Hide privacy layout
@@ -40,28 +40,34 @@ class VersionForm(HideProtectedLevelMixin, forms.ModelForm):
self.fields['hidden'].widget = forms.CheckboxInput()
self.fields['hidden'].empty_value = False
- self.helper = FormHelper()
- self.helper.layout = Layout(
+
+ field_sets = [
Fieldset(
_('States'),
HTML(render_to_string('projects/project_version_states_help_text.html')),
*self.Meta.states_fields,
),
+ ]
+
+ if settings.ALLOW_PRIVATE_REPOS:
+ field_sets.append(
Fieldset(
_('Privacy'),
*self.Meta.privacy_fields,
- ),
+ )
+ )
+ else:
+ self.fields.pop('privacy_level')
+
+ field_sets.append(
HTML(render_to_string(
'projects/project_version_submit.html',
context={'version': self.instance},
- )),
+ ))
)
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
-
- if not settings.ALLOW_PRIVATE_REPOS:
- self.fields.pop('privacy_level')
+ self.helper = FormHelper()
+ self.helper.layout = Layout(*field_sets)
def clean_active(self):
active = self.cleaned_data['active']
