diff options
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}), |