From 4d49208aef1e0a0babae8c2ffd231f397f19d513 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 2 Mar 2021 11:23:23 +0100 Subject: Fix custom form -> use profile instead of person types --- ishtar_common/forms.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ishtar_common/forms.py') 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}), -- cgit v1.2.3