1. 12 Feb, 2014 1 commit
    • Phil Schleihauf's avatar
      Update filename on werkzeug FileStorage for uploaded files · 96f5375c
      Phil Schleihauf authored
      This is an issue for fields whose name might be changed at any point, like any image ending in "jpeg" (which will be renamed to "jpg". That would cause the actual file to be saved to disk with ".jpeg", but be saved elsewhere as ".jpg".
      
      This example (mostly copied from the example in `examples/forms/simple.py`) shows it better than I can explain:
      
          import os
          from flask import Flask
          from flask.ext.admin import Admin, form
          from flask.ext.admin.contrib import sqla
          from flask.ext.sqlalchemy import SQLAlchemy
      
          app = Flask(__name__)
          app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///hello.db'
          db = SQLAlchemy(app)
      
          os.path.isdir('static') or os.mkdir('static')
      
          class Photo(db.Model):
              id = db.Column(db.Integer, primary_key=True)
              path = db.Column(db.Unicode(128))
      
          class PhotoView(sqla.ModelView):
              form_extra_fields = {'path': form.ImageUploadField('Photo', base_path='static')}
      
          admin = Admin(app, 'Photos are broken!')
          admin.add_view(PhotoView(Photo, db.session))
      
          db.create_all()
          app.run(debug=True)
      
      ... try uploading files with `.jpeg` vs `.jpg` extensions. It's pretty broken.
      96f5375c
  2. 03 Feb, 2014 3 commits
  3. 02 Feb, 2014 8 commits
  4. 28 Jan, 2014 3 commits
  5. 22 Jan, 2014 2 commits
  6. 21 Jan, 2014 2 commits
  7. 19 Jan, 2014 1 commit
  8. 16 Jan, 2014 1 commit
  9. 15 Jan, 2014 2 commits
  10. 09 Jan, 2014 2 commits
  11. 06 Jan, 2014 3 commits
  12. 02 Jan, 2014 1 commit
  13. 28 Dec, 2013 2 commits
  14. 26 Dec, 2013 2 commits
  15. 23 Dec, 2013 2 commits
  16. 20 Dec, 2013 2 commits
  17. 19 Dec, 2013 2 commits
    • John Rork's avatar
      Don't use column name for pk · a989bcf4
      John Rork authored
      Gets the attribute name of the model's pk column, rather than the
      column's name (which can differ).
      
      This probably needs to happen for inherited keys, too, but I have not
      tested.
      a989bcf4
    • Iuri de Silvio's avatar
      Use `send_file` instead of `send_from_directory` to serve files in FileAdmin · 2dc6d714
      Iuri de Silvio authored
      The path is already validated in `_normalize_path`. Also, `send_from_directory` abort paths with backslash, breaking FileAdmin subfolders in Windows.
      
      With `send_file`, we have a minor issue with the download URL, it has path with backslash, but `_normalize_path` fix this before download.
      2dc6d714
  18. 18 Dec, 2013 1 commit