Example #1
0
 def clean(self):
     domain = self.cleaned_data.get('domain')
     if self.cleaned_data.get('linked'):
         if not LINKED_APPS.enabled(domain):
             raise forms.ValidationError(
                 "The target project space does not have linked apps enabled."
             )
Example #2
0
    def __init__(self, from_domain, app, *args, **kwargs):
        export_zipped_apps_enabled = kwargs.pop('export_zipped_apps_enabled', False)
        super(CopyApplicationForm, self).__init__(*args, **kwargs)
        fields = ['domain', 'name', 'toggles']
        if app:
            self.fields['name'].initial = app.name
        if export_zipped_apps_enabled:
            self.fields['gzip'] = forms.FileField(required=False)
            fields.append('gzip')
        if LINKED_APPS.enabled(from_domain):
            fields.append(PrependedText('linked', ''))

        self.helper = FormHelper()
        self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2'
        self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'
        self.helper.layout = Layout(
            Fieldset(
                _('Copy Application'),
                *fields
            ),
            Hidden('app', app.get_id),
            hqcrispy.FormActions(
                StrictButton(_('Copy'), type='button', css_class='btn-primary')
            )
        )