Commit 9fb9dfc6 by Őry Máté

dashboard: allow arbitrary GroupProfile.org_id values for admin

parent 240e00f7
...@@ -359,14 +359,17 @@ class GroupProfileUpdateForm(forms.ModelForm): ...@@ -359,14 +359,17 @@ class GroupProfileUpdateForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
new_groups = kwargs.pop('new_groups', None) new_groups = kwargs.pop('new_groups', None)
superuser = kwargs.pop('superuser', False)
super(GroupProfileUpdateForm, self).__init__(*args, **kwargs) super(GroupProfileUpdateForm, self).__init__(*args, **kwargs)
choices = [('', '--')] if not superuser:
if new_groups: choices = [('', '--')]
choices += [(g, g) for g in new_groups if len(g) <= 64] if new_groups:
self.fields['org_id'] = forms.ChoiceField( choices += [(g, g) for g in new_groups if len(g) <= 64]
choices=choices, required=False, label=_('Directory identifier')) self.fields['org_id'] = forms.ChoiceField(
if not new_groups: choices=choices, required=False,
self.fields['org_id'].widget = HiddenInput() label=_('Directory identifier'))
if not new_groups:
self.fields['org_id'].widget = HiddenInput()
self.fields['description'].widget = forms.Textarea(attrs={'rows': 3}) self.fields['description'].widget = forms.Textarea(attrs={'rows': 3})
@property @property
......
...@@ -1646,6 +1646,7 @@ class GroupProfileUpdate(GroupCodeMixin, LoginRequiredMixin, UpdateView): ...@@ -1646,6 +1646,7 @@ class GroupProfileUpdate(GroupCodeMixin, LoginRequiredMixin, UpdateView):
kwargs['instance'] = instance kwargs['instance'] = instance
kwargs['new_groups'] = cls.get_available_group_codes( kwargs['new_groups'] = cls.get_available_group_codes(
request, instance.org_id) request, instance.org_id)
kwargs['superuser'] = request.user.is_superuser
return cls.form_class(*args, **kwargs) return cls.form_class(*args, **kwargs)
def get(self, request, form=None, *args, **kwargs): def get(self, request, form=None, *args, **kwargs):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment