class ImportOptionsForm(forms.Form): separator = forms.CharField(required=False) collections = forms.MultipleChoiceField( choices=( ( c.id, '%s%s' % ( '*' if c.id in writable_collection_ids else '', c.title ) ) for c in available_collections ), widget=forms.CheckboxSelectMultiple ) fieldset = FieldSetChoiceField(user=request.user, default_label='any') update = forms.BooleanField( label='Update existing records', initial=True, required=False) add = forms.BooleanField( label='Add new records', initial=True, required=False) test = forms.BooleanField( label='Test import only', initial=False, required=False) personal = forms.BooleanField( label='Personal records', initial=False, required=False) def clean(self): cleaned_data = self.cleaned_data if any(self.errors): return cleaned_data personal = cleaned_data['personal'] if not personal: for c in map(int, cleaned_data['collections']): if c not in writable_collection_ids: self._errors['collections'] = ErrorList( ["Can only add personal records to " "selected collections"]) del cleaned_data['collections'] return cleaned_data return cleaned_data
class FieldSetForm(forms.Form): fieldset = FieldSetChoiceField( user=request.user, default_label='Default' if not edit else None)