Mercurial > personas_backend
view personasbackend/personas/forms.py @ 149:98257bc9841e
We no longer require users to manually click the 'agree to terms' button after they've initially created their persona.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 04 Apr 2008 12:01:44 -0700 |
parents | 9bcc77e37c19 |
children | 052bf8a07b76 |
line wrap: on
line source
import django.newforms as forms from personasbackend.personas import models class BasePersonaForm( forms.ModelForm ): """ Form given to normal users who don't have the permission to publish Personas. """ class Meta: model = models.Persona exclude = ["owner", "date_published", "popularity", "status"] def _color_cleaner( self, field ): models.ensure_color_is_valid( self.cleaned_data[field], error_class = forms.ValidationError ) return self.cleaned_data[field] def clean_text_color( self ): return self._color_cleaner( "text_color" ) def clean_accent_color( self ): return self._color_cleaner( "accent_color" ) class EditPersonaForm( BasePersonaForm ): pass class NewPersonaForm( BasePersonaForm ): agree_to_terms = forms.BooleanField( label = "I agree to the terms of use.", # TODO: setting required to True doesn't seem to have any effect, # but the Django docs say it should ensure that the checkbox # is filled out. required = True, help_text = ("Terms of use: I agree that Mozilla is providing " "a service by hosting the " "content I am submitting, and that they are in no " "way responsible for any damages that occur as " "a result of hosting said content.") ) def clean( self ): if not self.cleaned_data["agree_to_terms"]: raise forms.ValidationError( "You must agree to the terms of service to " "submit your Persona." ) return self.cleaned_data