From: Michael Tremer Date: Sun, 18 Nov 2012 21:37:51 +0000 (+0100) Subject: Redesign user profile edit page. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd870d0a81bb3c8ba0bfe1aec48196467bd03314;p=pbs.git Redesign user profile edit page. --- diff --git a/data/templates/modules/select/locale.html b/data/templates/modules/select/locale.html new file mode 100644 index 00000000..9281829b --- /dev/null +++ b/data/templates/modules/select/locale.html @@ -0,0 +1,9 @@ + diff --git a/data/templates/modules/select/timezone.html b/data/templates/modules/select/timezone.html new file mode 100644 index 00000000..4b865ba8 --- /dev/null +++ b/data/templates/modules/select/timezone.html @@ -0,0 +1,9 @@ + diff --git a/data/templates/user-profile-edit.html b/data/templates/user-profile-edit.html index 77e09fe1..abe39cb0 100644 --- a/data/templates/user-profile-edit.html +++ b/data/templates/user-profile-edit.html @@ -1,108 +1,154 @@ {% extends "base.html" %} +{% block title %}{{ _("Edit user profile: %s") % user.realname }}{% end block %} + {% block body %} -

{{ _("Edit user %s") % user.realname }}

+ + + -
+ {% raw xsrf_form_html() %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if current_user.is_admin() and not current_user == user %} -
{{ _("Username") }}:{{ user.name }}{{ _("Cannot be changed.") }}
{{ _("Email") }}: - - - {{ _("If the email address is changed, your account will be disabled until you reconfirm the new email address.") }} -
{{ _("Real name (optional)") }}: - - - {{ _("Your real name is used to identify you by others.") }} -
{{ _("Password") }}: - - - {{ _("The password is used to secure the login and must be at least 8 characters.") }} -
{{ _("Confirm") }}: - - - {{ _("Leave the password fields empty to keep the current password.") }} -
{{ _("Preferred language") }}: - + + + {{ _("This field is optional, but we appreciate it very much if you type in your real name.") }} + + + + +
+ +
+ + + + {{ _("If the email address is changed, your account will be disabled until you confirm the new email address.") }} + +
+
+ + + {% if current_user.is_admin() %} +
+ {{ _("Admin actions") }} + +
+ +
+ -
{{ _("Auto-detect will use the language transmitted by your browser.") }}
{{ _("Timezone") }}: - - {{ _("Auto-detect will use the language transmitted by your browser.") }}
- -

{{ _("Admin actions") }}

- - - - - - + + + + {{ _("Define the permissions of the user.") }} + + + + {% end %} - - - -
{{ _("State") }} - - - {{ _("Define the permissions of the user.") }} -
- -
+ +
+ {{ _("Account security settings") }} + +
+ +
+ + + + {{ _("The password is used to secure the login and must be at least 8 characters.") }} + +
+
+ +
+ +
+ + + + {{ _("Leave the password fields empty to keep the current password.") }} + +
+
+
+ +
+ {{ _("Locale & timezone settings") }} + +
+ +
+ {% module SelectLocale(name="locale", id="inputLocale", preselect=user.locale) %} + + + {{ _("Auto-detect will use the language transmitted by your browser.") }} + +
+
+ +
+ +
+ {% module SelectTimezone(name="timezone", id="inputTimezone", preselect=user.timezone.zone) %} + + + {{ _("Auto-detect will use the timezone transmitted by your browser.") }} + +
+
+
+ +
+ + {{ _("Cancel") }} +
{% end block %} diff --git a/web/__init__.py b/web/__init__.py index cefa3e3a..f298500d 100644 --- a/web/__init__.py +++ b/web/__init__.py @@ -65,6 +65,9 @@ class Application(tornado.web.Application): "UpdatesTable" : UpdatesTableModule, "UsersTable" : UsersTableModule, "WatchersSidebarTable" : WatchersSidebarTableModule, + + "SelectLocale" : SelectLocaleModule, + "SelectTimezone" : SelectTimezoneModule, }, xsrf_cookies = True, ) diff --git a/web/handlers_users.py b/web/handlers_users.py index f190b6df..c754938e 100644 --- a/web/handlers_users.py +++ b/web/handlers_users.py @@ -1,7 +1,6 @@ #!/usr/bin/python import datetime -import pytz import tornado.locale import tornado.web @@ -141,11 +140,6 @@ class UserPasswdHandler(UserActionHandler): class UserEditHandler(BaseHandler): - def prepare(self): - # Make list of all supported locales. - self.supported_locales = \ - [tornado.locale.get(l) for l in tornado.locale.get_supported_locales(None)] - @tornado.web.authenticated def get(self, name): user = self.pakfire.users.get_by_name(name) @@ -155,9 +149,7 @@ class UserEditHandler(BaseHandler): if not self.current_user == user and not self.current_user.is_admin(): raise tornado.web.HTTPError(403) - self.render("user-profile-edit.html", user=user, - supported_timezones=pytz.common_timezones, - supported_locales=self.supported_locales) + self.render("user-profile-edit.html", user=user) @tornado.web.authenticated def post(self, name): @@ -193,10 +185,6 @@ class UserEditHandler(BaseHandler): elif not pass1 == pass2: msgs.append(_("Passwords do not match.")) - # Check if locale is valid. - if locale and not locale in [l.code for l in self.supported_locales]: - msg.append(_("The choosen locale is invalid.")) - if msgs: self.render("user-profile-edit-fail.html", messages=msgs) return diff --git a/web/ui_modules.py b/web/ui_modules.py index 9e373855..6979fd82 100644 --- a/web/ui_modules.py +++ b/web/ui_modules.py @@ -1,5 +1,6 @@ #!/usr/bin/python +import pytz import re import string import textile @@ -332,3 +333,34 @@ class WatchersSidebarTableModule(UIModule): return self.render_string("modules/watchers-sidebar-table.html", build=build, watchers=watchers, limit=limit) + + +class SelectLocaleModule(UIModule): + LOCALE_NAMES = ( + # local code, English name, name + ("ca_ES", u"Catalan", "Catal\xc3\xa0"), + ("da_DK", u"Danish", u"Dansk"), + ("de_DE", u"German", u"Deutsch"), + ("en_GB", u"English (UK)", u"English (UK)"), + ("en_US", u"English (US)", u"English (US)"), + ("es_ES", u"Spanish (Spain)", u"Espa\xf1ol (Espa\xf1a)"), + ("es_LA", u"Spanish", u"Espa\xf1ol"), + ("fr_CA", u"French (Canada)", u"Fran\xe7ais (Canada)"), + ("fr_FR", u"French", u"Fran\xe7ais"), + ("it_IT", u"Italian", u"Italiano"), + ("km_KH", u"Khmer", u"\u1797\u17b6\u179f\u17b6\u1781\u17d2\u1798\u17c2\u179a"), + ("pt_BR", u"Portuguese (Brazil)", u"Portugu\xeas (Brasil)"), + ("pt_PT", u"Portuguese (Portugal)", u"Portugu\xeas (Portugal)"), + ("ru_RU", u"Russian", u"\u0440\u0443\u0441\u0441\u043a\u0438\u0439"), + ) + + def render(self, name=None, id=None, preselect=None): + return self.render_string("modules/select/locale.html", + name=name, id=id, preselect=preselect, supported_locales=self.LOCALE_NAMES) + + +class SelectTimezoneModule(UIModule): + def render(self, name=None, id=None, preselect=None): + return self.render_string("modules/select/timezone.html", + name=name, id=id, preselect=preselect, + supported_timezones=pytz.common_timezones)