Commit 9fb9dfc6 by Őry Máté

dashboard: allow arbitrary GroupProfile.org_id values for admin

parent 240e00f7
...@@ -359,12 +359,15 @@ class GroupProfileUpdateForm(forms.ModelForm): ...@@ -359,12 +359,15 @@ 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)
if not superuser:
choices = [('', '--')] choices = [('', '--')]
if new_groups: if new_groups:
choices += [(g, g) for g in new_groups if len(g) <= 64] choices += [(g, g) for g in new_groups if len(g) <= 64]
self.fields['org_id'] = forms.ChoiceField( self.fields['org_id'] = forms.ChoiceField(
choices=choices, required=False, label=_('Directory identifier')) choices=choices, required=False,
label=_('Directory identifier'))
if not new_groups: if not new_groups:
self.fields['org_id'].widget = HiddenInput() self.fields['org_id'].widget = HiddenInput()
self.fields['description'].widget = forms.Textarea(attrs={'rows': 3}) self.fields['description'].widget = forms.Textarea(attrs={'rows': 3})
......
...@@ -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