diff options
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 |
commit | 4d49208aef1e0a0babae8c2ffd231f397f19d513 (patch) | |
tree | 98dcb4e9c96101b01b4fd17bcddbd12a1c127377 /ishtar_common/forms.py | |
parent | f8d43731beb03c1407f4f8991c0764d980494ef4 (diff) | |
download | Ishtar-4d49208aef1e0a0babae8c2ffd231f397f19d513.tar.bz2 Ishtar-4d49208aef1e0a0babae8c2ffd231f397f19d513.zip |
Fix custom form -> use profile instead of person types
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r-- | ishtar_common/forms.py | 11 |
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}), |