changeset 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 6fadd6ce1429
children 59949d9a2281
files personasbackend/personas/forms.py personasbackend/personas/views.py
diffstat 2 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/personasbackend/personas/forms.py	Fri Apr 04 11:46:40 2008 -0700
+++ b/personasbackend/personas/forms.py	Fri Apr 04 12:01:44 2008 -0700
@@ -1,7 +1,7 @@
 import django.newforms as forms
 from personasbackend.personas import models
 
-class PersonaForm( forms.ModelForm ):
+class BasePersonaForm( forms.ModelForm ):
     """
     Form given to normal users who don't have the permission to
     publish Personas.
@@ -11,19 +11,6 @@
         model = models.Persona
         exclude = ["owner", "date_published", "popularity", "status"]
 
-    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 _color_cleaner( self, field ):
         models.ensure_color_is_valid(
             self.cleaned_data[field],
@@ -37,6 +24,23 @@
     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(
--- a/personasbackend/personas/views.py	Fri Apr 04 11:46:40 2008 -0700
+++ b/personasbackend/personas/views.py	Fri Apr 04 12:01:44 2008 -0700
@@ -105,6 +105,7 @@
     if persona_id is None:
         persona = None
         pageTitle = "Create a new Persona"
+        formClass = forms.NewPersonaForm
     else:
         persona = get_object_or_404( models.Persona, id=persona_id )
         if not persona.can_user_edit( request.user ):
@@ -112,11 +113,12 @@
                 "<h1>You do not have permission to edit "
                 "this Persona.</h1>"
                 )
-        pageTitle = "Edit Persona"
+        pageTitle = "Edit Persona \"%s\"" % persona.name
+        formClass = forms.EditPersonaForm
 
     if request.method == "POST":
-        form = forms.PersonaForm( request.POST, request.FILES,
-                                  instance=persona )
+        form = formClass( request.POST, request.FILES,
+                          instance=persona )
         if form.is_valid():
             newPersona = form.save( commit=False )
 
@@ -143,7 +145,7 @@
             url = reverse("edit-persona", args=[newPersona.id])
             return HttpResponseRedirect( url )
     else:
-        form = forms.PersonaForm( instance=persona )
+        form = formClass( instance=persona )
 
     return render_to_response(
         "personas/edit.html",