Anonymous committed 15c6db4

fixed photo validator to deny the insert of missing-file photos

  • Participants
  • Parent commits 034c859

Comments (0)

Files changed (1)

File photos/controllers/

 def _get_current_user():
     return getattr(request.identity['user'], primary_key(app_model.User).key)
+class FileValidatorRequired(FileValidator):
  1. Alessandro Molina

    This won't work as in case TW1 is used (line 25 of this file) the variable is not named required but instead not_empty. Instead of sublcassing FileValidator the proper solution is probably to set require_fields in form_options so that the field ends up being required.

+    def __init__(self, **kw):
+        FileValidator.__init__(self, **kw)
+        self.required = True
 class PhotosController(EasyCrudRestController):
     allow_only = predicates.in_group('photos')
     title = "Manage Photos"
     __form_options__ = {
         '__hide_fields__' : ['uid', 'author', 'gallery'],
         '__field_widget_types__' : {'image':FileField},
-        '__field_validator_types__' : {'image':FileValidator},
+        '__field_validators__' : {'image':FileValidatorRequired},
         '__field_widget_args__' : {'author':{'default':_get_current_user,