Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added agreement checkbox to signup; fix bug 730440

  • Loading branch information...
commit d7df29f9db455f2db3e72c9b0b2ffa124b2cf62d 1 parent 1ef0299
@ednapiranha ednapiranha authored
View
23 flicks/users/forms.py
@@ -1,10 +1,27 @@
-from happyforms import ModelForm
+from django import forms
+
+import jinja2
+from happyforms import Form, ModelForm
+from tower import ugettext as _, ugettext_lazy as _lazy
from flicks.users.models import UserProfile
-class UserProfileForm(ModelForm):
- """Video upload form."""
+class UserProfileEditForm(ModelForm):
+ """User edit form."""
class Meta:
model = UserProfile
exclude = ('user',)
+
+
+class UserProfileCreateForm(UserProfileEditForm):
+ """User create form."""
+ agreement = forms.BooleanField(required=True)
+
+ def __init__(self, *args, **kwargs):
+ super(UserProfileCreateForm, self).__init__(*args, **kwargs)
+
+ self.fields['agreement'].label = jinja2.Markup(_(
+ u"I'm okay with Mozilla handling this info as you explain in your "
+ "<a href='{url}' target='_blank'>privacy policy</a>.")).format(
+ url='http://www.mozilla.org/en-US/privacy-policy.html')
View
12 flicks/users/templates/users/edit_profile.html
@@ -61,6 +61,18 @@
{{ form_section(f, edit_form) }}
{% endfor %}
+ {% if not profile %}
+ <p id="signup-public-message">
+ {% trans %}
+ Your name will be displayed publicly with your video.
+ {% endtrans %}
+ </p>
+ <div class="agreement field">
+ {{ edit_form['agreement'] }}
+ {{ edit_form['agreement'].label_tag() }}
+ </div>
+ {% endif %}
+
<button type="submit">{{ _('Save') }}</button>
</form>
</div>
View
4 flicks/users/tests/test_views.py
@@ -64,7 +64,7 @@ def test_no_profile(self):
user = self.build_user(salt='no.profile', login=True, profile=False)
eq_(UserProfile.objects.filter(pk=user.pk).exists(), False)
- self._post(bio='asdf', full_name='bob')
+ self._post(bio='asdf', full_name='bob', agreement='on')
eq_(UserProfile.objects.filter(pk=user.pk).exists(), True)
def test_has_profile(self):
@@ -77,6 +77,6 @@ def test_has_profile(self):
profile = UserProfile.objects.get(pk=user.pk)
eq_(profile.bio, 'asdf')
- self._post(bio='1234', full_name='bob')
+ self._post(bio='1234', full_name='bob', agreement='on')
profile = UserProfile.objects.get(pk=user.pk)
eq_(profile.bio, '1234')
View
12 flicks/users/views.py
@@ -9,7 +9,7 @@
from django_browserid.forms import BrowserIDForm
from flicks.base.util import get_object_or_none, redirect
-from flicks.users.forms import UserProfileForm
+from flicks.users.forms import UserProfileCreateForm, UserProfileEditForm
from flicks.users.models import UserProfile
from flicks.videos.forms import SearchForm
from flicks.videos.models import User, Video
@@ -87,14 +87,20 @@ def edit_profile(request):
"""Create and/or edit a user profile."""
profile = get_object_or_none(UserProfile, pk=request.user.pk)
if request.method == 'POST':
- form = UserProfileForm(request.POST, instance=profile)
+ if profile:
+ form = UserProfileEditForm(request.POST, instance=profile)
+ else:
+ form = UserProfileCreateForm(request.POST, instance=profile)
if form.is_valid():
profile = form.save(commit=False)
profile.user = request.user
profile.save()
return redirect('flicks.users.my_profile')
else:
- form = UserProfileForm(instance=profile)
+ if profile:
+ form = UserProfileEditForm(instance=profile)
+ else:
+ form = UserProfileCreateForm(instance=profile)
d = dict(profile=profile,
edit_form=form,
View
5 media/css/main.css
@@ -1232,3 +1232,8 @@ img.judge {
margin: 5px 15px 10px 0px;
width: 139px;
}
+
+#signup-public-message {
+ font-size: 14px;
+ margin-top: 20px;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.