Skip to content

Commit 833bda0

Browse files
committed
Move the per user filter code in simple_form
This needs to be explicitly set after each instantiation of a form, not in a shared location below since some operations have already happened at that time.
1 parent cd4d9c1 commit 833bda0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pgweb/util/helpers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def simple_form(instancetype, itemid, request, formclass, formtemplate='base/for
5252

5353
# Process this form
5454
form = formclass(data=request.POST, instance=instance)
55+
if hasattr(form, 'filter_by_user'):
56+
form.filter_by_user(request.user)
5557
for fn in form.fields:
5658
if fn in getattr(instancetype, 'markdown_fields', []):
5759
form.fields[fn].validators.append(MarkdownValidator)
@@ -165,9 +167,8 @@ def simple_form(instancetype, itemid, request, formclass, formtemplate='base/for
165167
else:
166168
# Generate form
167169
form = formclass(instance=instance)
168-
169-
if hasattr(form, 'filter_by_user'):
170-
form.filter_by_user(request.user)
170+
if hasattr(form, 'filter_by_user'):
171+
form.filter_by_user(request.user)
171172

172173
for fn in form.fields:
173174
if fn in getattr(instancetype, 'markdown_fields', []):

0 commit comments

Comments
 (0)