From ded84d38d30f06c76fa92fbe337ae16eb83cdcdc Mon Sep 17 00:00:00 2001 From: Ola Blissing Date: Fri, 20 Oct 2017 16:38:47 +0200 Subject: [PATCH 01/17] Add user gravatar and fix navbar margins --- assets/css/style.less | 5 ++ messages.pot | 67 +++++++++---------- xl_auth/public/views.py | 6 +- xl_auth/templates/nav.html | 17 +++-- .../translations/sv/LC_MESSAGES/messages.po | 67 +++++++++---------- xl_auth/utils.py | 10 +++ 6 files changed, 93 insertions(+), 79 deletions(-) diff --git a/assets/css/style.less b/assets/css/style.less index 1b2e5d79..0aa55e6e 100644 --- a/assets/css/style.less +++ b/assets/css/style.less @@ -39,6 +39,11 @@ textarea { .logotype { } } + .navbar-user-gravatar { + border-radius: 50%; + float: left; + margin: -.4em 0.5em; + } } .login-panel { diff --git a/messages.pot b/messages.pot index 1522933d..0fa15c42 100644 --- a/messages.pot +++ b/messages.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: xl_auth 0.4.0\n" +"Project-Id-Version: xl_auth 0.4.1\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2017-10-19 15:20+0200\n" +"POT-Creation-Date: 2017-10-20 16:26+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -19,16 +19,16 @@ msgstr "" #: tests/end2end/test_deleting_permission.py:24 tests/end2end/test_deleting_permission.py:51 #: tests/end2end/test_editing_permission.py:29 tests/end2end/test_editing_permission.py:63 -#: tests/end2end/test_editing_permission.py:91 tests/end2end/test_editing_user.py:181 +#: tests/end2end/test_editing_permission.py:91 tests/end2end/test_editing_user.py:184 #: tests/end2end/test_registering_permission.py:25 tests/end2end/test_registering_permission.py:58 #: tests/end2end/test_registering_permission.py:85 xl_auth/templates/nav.html:28 #: xl_auth/templates/permissions/home.html:4 xl_auth/templates/users/profile.html:34 msgid "Permissions" msgstr "" -#: tests/end2end/test_deleting_permission.py:26 tests/end2end/test_editing_collection.py:150 +#: tests/end2end/test_deleting_permission.py:26 tests/end2end/test_editing_collection.py:158 #: tests/end2end/test_editing_permission.py:31 tests/end2end/test_editing_permission.py:66 -#: tests/end2end/test_editing_user.py:187 tests/end2end/test_editing_user.py:213 +#: tests/end2end/test_editing_user.py:190 tests/end2end/test_editing_user.py:216 #: xl_auth/templates/permissions/home.html:37 msgid "Edit" msgstr "" @@ -42,59 +42,59 @@ msgstr "" msgid "Successfully deleted permissions for \"%(username)s\" on collection \"%(code)s\"." msgstr "" -#: tests/end2end/test_editing_collection.py:26 tests/end2end/test_editing_collection.py:147 -#: tests/end2end/test_registering_collection.py:30 tests/end2end/test_registering_collection.py:162 +#: tests/end2end/test_editing_collection.py:26 tests/end2end/test_editing_collection.py:155 +#: tests/end2end/test_registering_collection.py:29 tests/end2end/test_registering_collection.py:168 #: xl_auth/templates/collections/home.html:4 xl_auth/templates/nav.html:25 #: xl_auth/templates/users/home.html:20 msgid "Collections" msgstr "" -#: tests/end2end/test_editing_collection.py:47 tests/end2end/test_registering_collection.py:48 +#: tests/end2end/test_editing_collection.py:53 tests/end2end/test_registering_collection.py:52 msgid "category" msgstr "" -#: tests/end2end/test_editing_collection.py:49 tests/end2end/test_registering_collection.py:50 +#: tests/end2end/test_editing_collection.py:57 tests/end2end/test_registering_collection.py:56 #: xl_auth/collection/forms.py:21 xl_auth/templates/collections/home.html:37 #: xl_auth/templates/collections/home.html:79 msgid "No category" msgstr "" -#: tests/end2end/test_editing_collection.py:72 tests/end2end/test_registering_collection.py:73 +#: tests/end2end/test_editing_collection.py:80 tests/end2end/test_registering_collection.py:79 #: xl_auth/collection/forms.py:17 xl_auth/templates/collections/home.html:21 #: xl_auth/templates/collections/home.html:65 xl_auth/templates/users/profile.html:40 msgid "Code" msgstr "" -#: tests/end2end/test_editing_collection.py:72 tests/forms/test_collection.py:77 +#: tests/end2end/test_editing_collection.py:80 tests/forms/test_collection.py:77 #: xl_auth/collection/forms.py:63 msgid "Code cannot be modified" msgstr "" -#: tests/end2end/test_editing_collection.py:94 tests/end2end/test_registering_collection.py:96 +#: tests/end2end/test_editing_collection.py:102 tests/end2end/test_registering_collection.py:102 #: xl_auth/collection/forms.py:18 xl_auth/templates/users/home.html:19 msgid "Name" msgstr "" -#: tests/end2end/test_editing_collection.py:94 tests/end2end/test_editing_user.py:144 -#: tests/end2end/test_registering_collection.py:73 tests/end2end/test_registering_collection.py:96 +#: tests/end2end/test_editing_collection.py:102 tests/end2end/test_editing_user.py:147 +#: tests/end2end/test_registering_collection.py:79 tests/end2end/test_registering_collection.py:102 #: tests/forms/test_collection.py:21 tests/forms/test_collection.py:38 #: tests/forms/test_permission.py:31 tests/forms/test_permission.py:39 #: tests/forms/test_permission.py:47 tests/forms/test_permission.py:55 msgid "This field is required." msgstr "" -#: tests/end2end/test_editing_collection.py:116 tests/end2end/test_registering_collection.py:119 +#: tests/end2end/test_editing_collection.py:124 tests/end2end/test_registering_collection.py:125 #: xl_auth/collection/forms.py:19 xl_auth/templates/collections/home.html:23 #: xl_auth/templates/collections/home.html:68 msgid "Category" msgstr "" -#: tests/end2end/test_editing_collection.py:116 tests/end2end/test_registering_collection.py:119 +#: tests/end2end/test_editing_collection.py:124 tests/end2end/test_registering_collection.py:125 #: tests/forms/test_collection.py:104 tests/forms/test_collection.py:113 msgid "Not a valid choice" msgstr "" -#: tests/end2end/test_editing_collection.py:132 xl_auth/collection/views.py:58 +#: tests/end2end/test_editing_collection.py:140 xl_auth/collection/views.py:58 #, python-format msgid "Collection code \"%(code)s\" does not exist" msgstr "" @@ -111,7 +111,7 @@ msgstr "" msgid "Permissions for user \"%(username)s\" on collection \"%(code)s\" already registered" msgstr "" -#: tests/end2end/test_editing_user.py:23 tests/end2end/test_editing_user.py:60 +#: tests/end2end/test_editing_user.py:23 tests/end2end/test_editing_user.py:63 #: tests/end2end/test_registering_user.py:27 tests/end2end/test_registering_user.py:56 #: xl_auth/templates/collections/home.html:24 xl_auth/templates/collections/home.html:69 #: xl_auth/templates/nav.html:27 xl_auth/templates/users/home.html:4 @@ -123,52 +123,52 @@ msgstr "" msgid "Edit Details" msgstr "" -#: tests/end2end/test_editing_user.py:45 xl_auth/templates/permissions/home.html:30 +#: tests/end2end/test_editing_user.py:46 xl_auth/templates/permissions/home.html:30 #: xl_auth/templates/permissions/home.html:31 xl_auth/templates/permissions/home.html:32 #: xl_auth/templates/users/home.html:36 xl_auth/templates/users/profile.html:53 #: xl_auth/templates/users/profile.html:56 xl_auth/templates/users/profile.html:59 msgid "Yes" msgstr "" -#: tests/end2end/test_editing_user.py:45 xl_auth/templates/permissions/home.html:30 +#: tests/end2end/test_editing_user.py:46 xl_auth/templates/permissions/home.html:30 #: xl_auth/templates/permissions/home.html:31 xl_auth/templates/permissions/home.html:32 #: xl_auth/templates/users/home.html:36 xl_auth/templates/users/profile.html:53 #: xl_auth/templates/users/profile.html:56 xl_auth/templates/users/profile.html:59 msgid "No" msgstr "" -#: tests/end2end/test_editing_user.py:62 tests/end2end/test_editing_user.py:188 +#: tests/end2end/test_editing_user.py:65 tests/end2end/test_editing_user.py:191 #: xl_auth/templates/users/home.html:46 xl_auth/templates/users/profile.html:17 msgid "Change Password" msgstr "" -#: tests/end2end/test_editing_user.py:99 tests/end2end/test_editing_user.py:123 +#: tests/end2end/test_editing_user.py:102 tests/end2end/test_editing_user.py:126 #: xl_auth/templates/users/home.html:18 xl_auth/user/forms.py:13 msgid "Email" msgstr "" -#: tests/end2end/test_editing_user.py:99 tests/end2end/test_editing_user.py:123 +#: tests/end2end/test_editing_user.py:102 tests/end2end/test_editing_user.py:126 #: tests/forms/test_user.py:95 tests/forms/test_user.py:123 tests/forms/test_user.py:143 #: xl_auth/user/forms.py:67 msgid "Email cannot be modified" msgstr "" -#: tests/end2end/test_editing_user.py:144 xl_auth/user/forms.py:14 +#: tests/end2end/test_editing_user.py:147 xl_auth/user/forms.py:14 msgid "Full name" msgstr "" -#: tests/end2end/test_editing_user.py:160 tests/end2end/test_editing_user.py:165 +#: tests/end2end/test_editing_user.py:163 tests/end2end/test_editing_user.py:168 #: xl_auth/user/views.py:62 xl_auth/user/views.py:89 xl_auth/user/views.py:114 #, python-format msgid "User \"%(username)s\" does not exist" msgstr "" -#: tests/end2end/test_editing_user.py:209 tests/end2end/test_editing_user.py:221 -#: tests/end2end/test_editing_user.py:223 xl_auth/templates/users/profile.html:6 +#: tests/end2end/test_editing_user.py:212 tests/end2end/test_editing_user.py:224 +#: tests/end2end/test_editing_user.py:226 xl_auth/templates/users/profile.html:6 msgid "Welcome" msgstr "" -#: tests/end2end/test_logging_in.py:35 xl_auth/public/views.py:45 +#: tests/end2end/test_logging_in.py:35 xl_auth/public/views.py:47 msgid "You are logged out." msgstr "" @@ -180,12 +180,12 @@ msgstr "" msgid "Unknown username/email" msgstr "" -#: tests/end2end/test_registering_collection.py:32 tests/end2end/test_registering_collection.py:165 +#: tests/end2end/test_registering_collection.py:31 tests/end2end/test_registering_collection.py:171 #: xl_auth/templates/collections/home.html:15 msgid "New Collection" msgstr "" -#: tests/end2end/test_registering_collection.py:147 tests/forms/test_collection.py:47 +#: tests/end2end/test_registering_collection.py:153 tests/forms/test_collection.py:47 #: tests/forms/test_collection.py:59 xl_auth/collection/forms.py:46 #, python-format msgid "Code \"%(code)s\" already registered" @@ -330,7 +330,7 @@ msgstr "" msgid "Password" msgstr "" -#: xl_auth/public/views.py:32 +#: xl_auth/public/views.py:34 msgid "You are logged in." msgstr "" @@ -366,9 +366,8 @@ msgstr "" msgid "xl_auth" msgstr "" -#: xl_auth/templates/nav.html:35 -#, python-format -msgid "Logged in as %(user)s" +#: xl_auth/templates/nav.html:39 +msgid "Log out" msgstr "" #: xl_auth/templates/collections/edit.html:5 diff --git a/xl_auth/public/views.py b/xl_auth/public/views.py index 50292e99..894ea5f0 100644 --- a/xl_auth/public/views.py +++ b/xl_auth/public/views.py @@ -10,7 +10,7 @@ from ..extensions import login_manager from ..public.forms import LoginForm from ..user.models import User -from ..utils import flash_errors +from ..utils import flash_errors, get_gravatar_url blueprint = Blueprint('public', __name__, static_folder='../static') @@ -18,7 +18,9 @@ @login_manager.user_loader def load_user(user_id): """Load user by ID.""" - return User.get_by_id(int(user_id)) + user = User.get_by_id(int(user_id)) + user.gravatar = get_gravatar_url(user.email, 32) + return user @blueprint.route('/', methods=['GET', 'POST']) diff --git a/xl_auth/templates/nav.html b/xl_auth/templates/nav.html index 0750d894..d3131bbf 100644 --- a/xl_auth/templates/nav.html +++ b/xl_auth/templates/nav.html @@ -22,22 +22,21 @@