From 77f1cb52ea9667e7de88bbedb704269defc33276 Mon Sep 17 00:00:00 2001 From: volpino Date: Wed, 8 Aug 2012 10:46:36 +0200 Subject: [PATCH] euscanwww: Improved forms UI, added preferences page and change password Signed-off-by: volpino --- euscanwww/djeuscan/forms.py | 8 ++++- .../templates/euscan/accounts/index.html | 13 +++++++- .../euscan/accounts/preferences.html | 32 +++++++++++++++++++ .../djeuscan/templates/euscan/world.html | 4 +-- .../templates/registration/login.html | 16 +++++++--- .../templates/registration/logout.html | 13 -------- .../registration/password_change_done.html | 6 ---- .../registration/password_change_form.html | 14 ++++++-- .../registration/password_reset_confirm.html | 10 ++++-- .../registration/password_reset_form.html | 10 ++++-- .../registration/registration_form.html | 6 +++- euscanwww/djeuscan/urls.py | 9 ++++++ euscanwww/djeuscan/views.py | 26 ++++++++++++++- euscanwww/euscanwww/urls.py | 4 +-- euscanwww/htdocs/css/style.css | 25 ++++++--------- 15 files changed, 140 insertions(+), 56 deletions(-) create mode 100644 euscanwww/djeuscan/templates/euscan/accounts/preferences.html delete mode 100644 euscanwww/djeuscan/templates/registration/logout.html delete mode 100644 euscanwww/djeuscan/templates/registration/password_change_done.html diff --git a/euscanwww/djeuscan/forms.py b/euscanwww/djeuscan/forms.py index 9db0f74..93fb0ad 100644 --- a/euscanwww/djeuscan/forms.py +++ b/euscanwww/djeuscan/forms.py @@ -1,6 +1,6 @@ from django import forms -from djeuscan.models import Package, Version, ProblemReport +from djeuscan.models import Version, ProblemReport class WorldForm(forms.Form): @@ -27,3 +27,9 @@ class ProblemReportForm(forms.ModelForm): class Meta: model = ProblemReport fields = ('version', 'subject', 'message') + + +class PreferencesForm(forms.Form): + first_name = forms.CharField(max_length=30, required=False) + last_name = forms.CharField(max_length=30, required=False) + email = forms.EmailField() diff --git a/euscanwww/djeuscan/templates/euscan/accounts/index.html b/euscanwww/djeuscan/templates/euscan/accounts/index.html index 6b11b1a..7db53f3 100644 --- a/euscanwww/djeuscan/templates/euscan/accounts/index.html +++ b/euscanwww/djeuscan/templates/euscan/accounts/index.html @@ -8,8 +8,19 @@ {% block content %} -

Welcome {{ user }}

+

+ Welcome {{ user }} + + + Change password + + + + Preferences + + +

Summary

diff --git a/euscanwww/djeuscan/templates/euscan/accounts/preferences.html b/euscanwww/djeuscan/templates/euscan/accounts/preferences.html new file mode 100644 index 0000000..05d8c0b --- /dev/null +++ b/euscanwww/djeuscan/templates/euscan/accounts/preferences.html @@ -0,0 +1,32 @@ +{% extends "_base.html" %} +{% load url from future %} + +{% block title %} + {{ block.super }} - Edit user preferences for {{ user }} +{% endblock %} + + +{% block content %} + {% if updated %} +
+ Saved! Your preferences has been saved +
+ {% endif %} + +

+ Edit user preferences +

+ +
+ {% csrf_token %} + + {{ form }} + + + + +
+ +
+
+{% endblock %} diff --git a/euscanwww/djeuscan/templates/euscan/world.html b/euscanwww/djeuscan/templates/euscan/world.html index c1fba03..6ba2791 100644 --- a/euscanwww/djeuscan/templates/euscan/world.html +++ b/euscanwww/djeuscan/templates/euscan/world.html @@ -15,7 +15,7 @@
{% csrf_token %} {{ world_form.as_p }} - +

@@ -24,7 +24,7 @@
{% csrf_token %} {{ packages_form.as_p }} - +
{% endblock %} diff --git a/euscanwww/djeuscan/templates/registration/login.html b/euscanwww/djeuscan/templates/registration/login.html index c198676..10ee384 100644 --- a/euscanwww/djeuscan/templates/registration/login.html +++ b/euscanwww/djeuscan/templates/registration/login.html @@ -5,12 +5,18 @@ {% block content %} {% if form.errors %} -

Your username and password didn't match. Please try again.

+
+ Error: Your username and password didn't match. Please try again. +
{% endif %} -
+

+ Login +

+ + {% csrf_token %} - +
@@ -27,10 +33,10 @@ + - + diff --git a/euscanwww/djeuscan/templates/registration/logout.html b/euscanwww/djeuscan/templates/registration/logout.html deleted file mode 100644 index 03746d0..0000000 --- a/euscanwww/djeuscan/templates/registration/logout.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "registration/_registration_base.html" %} -{% load i18n %} - -{% block content %} - -

You're logged out."

-

Redirect...

- - - -{% endblock %} diff --git a/euscanwww/djeuscan/templates/registration/password_change_done.html b/euscanwww/djeuscan/templates/registration/password_change_done.html deleted file mode 100644 index e223576..0000000 --- a/euscanwww/djeuscan/templates/registration/password_change_done.html +++ /dev/null @@ -1,6 +0,0 @@ -{% extends "registration/_registration_base.html" %} -{% block title %}Password changed{% endblock %} - -{% block content %} - Password successfully changed! -{% endblock %} diff --git a/euscanwww/djeuscan/templates/registration/password_change_form.html b/euscanwww/djeuscan/templates/registration/password_change_form.html index 3bb9bb8..c8ab089 100644 --- a/euscanwww/djeuscan/templates/registration/password_change_form.html +++ b/euscanwww/djeuscan/templates/registration/password_change_form.html @@ -1,14 +1,22 @@ {% extends "registration/_registration_base.html" %} + +{% load url from future %} + {% block title %}Change password{% endblock %} {% block content %} - {% csrf_token %} -
{{ form.username.label_tag }} {{ form.username }}
  
- Forgot password
+

+ Change password +

+ + + {% csrf_token %} +
{{ form }}
- +
diff --git a/euscanwww/djeuscan/templates/registration/password_reset_confirm.html b/euscanwww/djeuscan/templates/registration/password_reset_confirm.html index 653319b..43aefec 100644 --- a/euscanwww/djeuscan/templates/registration/password_reset_confirm.html +++ b/euscanwww/djeuscan/templates/registration/password_reset_confirm.html @@ -2,9 +2,15 @@ {% block title %}Confirm password reset{% endblock %} {% block content %} - Enter your new password below to reset your password: +

+ Reset password +

+ +

+ Enter your new password below to reset your password: +

{% csrf_token %} - +
{{ form.as_table }} diff --git a/euscanwww/djeuscan/templates/registration/password_reset_form.html b/euscanwww/djeuscan/templates/registration/password_reset_form.html index ae5c25b..7014401 100644 --- a/euscanwww/djeuscan/templates/registration/password_reset_form.html +++ b/euscanwww/djeuscan/templates/registration/password_reset_form.html @@ -3,15 +3,21 @@ {% block title %}Reset password{% endblock %} {% block content %} +

+ Reset password +

+ +

Forgot your password? Enter your email in the form below and we'll send you instructions for creating a new one. +

{% csrf_token %} -
+
{{ form }} - +
diff --git a/euscanwww/djeuscan/templates/registration/registration_form.html b/euscanwww/djeuscan/templates/registration/registration_form.html index 6fe2cd1..c7858f4 100644 --- a/euscanwww/djeuscan/templates/registration/registration_form.html +++ b/euscanwww/djeuscan/templates/registration/registration_form.html @@ -5,8 +5,12 @@ {% endblock %} {% block content %} +

+ Register +

+
{% csrf_token %} - +
{{ form }} diff --git a/euscanwww/djeuscan/urls.py b/euscanwww/djeuscan/urls.py index b1b1f88..c53b298 100644 --- a/euscanwww/djeuscan/urls.py +++ b/euscanwww/djeuscan/urls.py @@ -1,5 +1,7 @@ from django.conf.urls.defaults import url, patterns, include from django.contrib.auth.decorators import user_passes_test +from django.contrib.auth.views import logout +from django.views.generic import RedirectView from djcelery.views import apply as apply_task from djeuscan.views import registered_tasks @@ -83,12 +85,19 @@ tasks_patterns = patterns('djeuscan.views', accounts_patterns = patterns('djeuscan.views', url(r'^profile/$', 'accounts_index', name="accounts_index"), + url(r'^profile/preferences/$', 'accounts_preferences', + name="accounts_preferences"), url(r'^categories/$', 'accounts_categories', name="accounts_categories"), url(r'^herds/$', 'accounts_herds', name="accounts_herds"), url(r'^maintainers/$', 'accounts_maintainers', name="accounts_maintainers"), url(r'^packages/$', 'accounts_packages', name="accounts_packages"), url(r'^overlays/$', 'accounts_overlays', name="accounts_overlays"), + + url(r'^logout/$', logout, {'next_page': '/'}), + + url(r'^password/change/done/$', + RedirectView.as_view(url="../../../profile/")), ) diff --git a/euscanwww/djeuscan/views.py b/euscanwww/djeuscan/views.py index 817df77..f3a44c5 100644 --- a/euscanwww/djeuscan/views.py +++ b/euscanwww/djeuscan/views.py @@ -12,7 +12,8 @@ from djeuscan.helpers import version_key, packages_from_names, get_profile, \ get_account_categories, get_account_herds, get_account_maintainers from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \ VersionLog, RefreshPackageQuery, ProblemReport, Category, Overlay -from djeuscan.forms import WorldForm, PackagesForm, ProblemReportForm +from djeuscan.forms import WorldForm, PackagesForm, ProblemReportForm, \ + PreferencesForm from djeuscan.tasks import admin_tasks from djeuscan import charts @@ -415,6 +416,29 @@ def accounts_index(request): } +@login_required +@render_to('euscan/accounts/preferences.html') +def accounts_preferences(request): + user = request.user + updated = False + if request.method == "POST": + form = PreferencesForm(request.POST) + if form.is_valid(): + user.first_name = form.cleaned_data["first_name"] + user.last_name = form.cleaned_data["last_name"] + user.email = form.cleaned_data["email"] + user.save(force_update=True) + updated = True + else: + initial_data = { + "first_name": user.first_name, + "last_name": user.last_name, + "email": user.email + } + form = PreferencesForm(initial_data) + return {"form": form, "updated": updated} + + @login_required @render_to('euscan/accounts/categories.html') def accounts_categories(request): diff --git a/euscanwww/euscanwww/urls.py b/euscanwww/euscanwww/urls.py index 1aa3594..d6090b5 100644 --- a/euscanwww/euscanwww/urls.py +++ b/euscanwww/euscanwww/urls.py @@ -5,13 +5,11 @@ admin.autodiscover() urlpatterns = patterns('', - # Uncomment the admin/doc line below to enable admin documentation: - # (r'^admin/doc/', include('django.contrib.admindocs.urls')), + url(r'^', include('djeuscan.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^accounts/', include('captcha.backends.default.urls')), url(r'^accounts/', include('registration.backends.default.urls')), - url(r'^', include('djeuscan.urls')), ) diff --git a/euscanwww/htdocs/css/style.css b/euscanwww/htdocs/css/style.css index 44673f3..d5f89a3 100644 --- a/euscanwww/htdocs/css/style.css +++ b/euscanwww/htdocs/css/style.css @@ -125,25 +125,13 @@ hr { } -table { - max-width: 60em; - /* width: 50%; */ - border-collapse: collapse; - font-size: 1em; - margin-left: auto; - margin-right: auto; - background: #F5F5F5; - text-align: left; +.table { + width: 60% !important; + margin: auto; } td { - vertical-align: top; -} - -th { - font-size: 0.8em; - text-align: center; - border-bottom: 3px solid; + max-width: 350px; } #footer { @@ -245,3 +233,8 @@ th { textarea { width: inherit; } + +.errorlist > li { + color: red; + list-style: none; +}