Skip to content
Snippets Groups Projects
  1. Nov 14, 2017
    • Benjamin Bertrand's avatar
      Replace CSEntryError with ValidationError in models · 642a9b8c
      Benjamin Bertrand authored
      ValidationError is catched by default by flask-admin.
      It's easy to catch in the api/main.py to raise a CSEntryError.
      
      We actually don't need to catch ValidationError as it's based on
      ValueError that we already catch.
      642a9b8c
    • Benjamin Bertrand's avatar
      Handle CSEntry exceptions in admin views · e1ba3816
      Benjamin Bertrand authored
      Allow to use the same CSEntryError exceptions used for validation
      in the API and admin views.
      e1ba3816
    • Benjamin Bertrand's avatar
      Disable flask-admin unique validator · b4cf45ee
      Benjamin Bertrand authored
      Trying to insert an invalid IP or network address raises an exception.
      This is due to the unique validator from flask-admin that queries the
      database.
      
      The unique validator is automatically added for columns with
      unique=True. The only way to disable it is to monkey patch the Unique
      class.
      This allows the field validator to catch invalid format.
      
      IntegrityError are already catched anyway.
      b4cf45ee
    • Benjamin Bertrand's avatar
      Fix admin interface · 8dc4a249
      Benjamin Bertrand authored
      - replace TextAreaField by StringField for several Text columns
      - add filter to replace empty string by None on optional Text and INET
        fields
      8dc4a249
  2. Nov 13, 2017
  3. Sep 06, 2017
  4. Aug 22, 2017
  5. Jul 19, 2017
    • Benjamin Bertrand's avatar
      Fix hash computation in admin view · 74437b80
      Benjamin Bertrand authored
      The hash is supposed to be computed in the __init__ method of Item.
      But flask-admin never passes any parameter when creating the model class.
      The attributes are changed after creation.
      
      When creating an item in the admin view, we use the on_model_change
      method to update the hash.
      
      There might be a better way to avoid this code duplication.
      This works for now.
      74437b80
    • Benjamin Bertrand's avatar
      Fix admin view · aeaab0a7
      Benjamin Bertrand authored
      - restrict admin view to admin users only
      - the models shall only take optional parameters for flask-admin to work
      - the models shall implement the __str__ method to be displayed properly
        in the admin view
      aeaab0a7
Loading