summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-03-02 11:23:23 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-03-02 12:44:59 +0100
commitc3ac6de46a5ab6e35c0103456c47accc0f3cb3f9 (patch)
tree98dcb4e9c96101b01b4fd17bcddbd12a1c127377 /ishtar_common/forms.py
parent6676d09fbd11b26d014b46585db7e6997f4d2abc (diff)
downloadIshtar-c3ac6de46a5ab6e35c0103456c47accc0f3cb3f9.tar.bz2
Ishtar-c3ac6de46a5ab6e35c0103456c47accc0f3cb3f9.zip
Fix custom form -> use profile instead of person types
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r--ishtar_common/forms.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index 5b6501b13..27741c576 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -243,9 +243,7 @@ class CustomForm(BSForm):
alt_key, alt_field = new_fields.pop(k)
alt_field.order_number = k
fields[alt_key] = alt_field
-
self.fields = fields
-
self._post_init()
def are_available(self, keys):
@@ -317,12 +315,19 @@ class CustomForm(BSForm):
if not current_user:
return True, [], []
base_q = {"form": cls.form_slug, 'available': True}
- # order is important : try for user, user type then all
+ # order is important : try for user, profile type, user type then all
query_dicts = []
if current_user:
dct = base_q.copy()
dct.update({'users__pk': current_user.pk})
query_dicts = [dct]
+ if current_user.current_profile:
+ dct = base_q.copy()
+ pt = current_user.current_profile.profile_type.pk
+ dct.update(
+ {'profile_types__pk': pt})
+ query_dicts.append(dct)
+
for user_type in current_user.person.person_types.all():
dct = base_q.copy()
dct.update({'user_types__pk': user_type.pk}),