Make filter_by_user apply to forms when they are edited as well, not just
authorMagnus Hagander <magnus@hagander.net>
Fri, 26 Feb 2010 11:30:28 +0000 (12:30 +0100)
committerMagnus Hagander <magnus@hagander.net>
Fri, 26 Feb 2010 11:30:28 +0000 (12:30 +0100)
when they are created. This is to make sure the organisation list, for example,
doesn't list all non-avaiable organisations when there was a missing field
somewhere else in the form.

pgweb/util/helpers.py

index 8a4e731507534807fbb042a98551b74cfcb0ebdc..07e70f85847d9d0aeef69f65354ebbab8de0295d 100644 (file)
@@ -32,8 +32,9 @@ def simple_form(instancetype, itemid, request, formclass, formtemplate='base/for
        else:
                # Generate form
                form = formclass(instance=instance)
-               if hasattr(form, 'filter_by_user'):
-                       form.filter_by_user(request.user)
+
+       if hasattr(form, 'filter_by_user'):
+               form.filter_by_user(request.user)
 
        if hasattr(instancetype, 'markdown_fields'):
                markdownfields = instancetype.markdown_fields