diff options
-rw-r--r-- | fietsboek/routes.py | 3 | ||||
-rw-r--r-- | fietsboek/templates/layout.jinja2 | 2 | ||||
-rw-r--r-- | fietsboek/templates/user_data.jinja2 (renamed from fietsboek/templates/profile.jinja2) | 2 | ||||
-rw-r--r-- | fietsboek/views/user_data.py (renamed from fietsboek/views/profile.py) | 26 |
4 files changed, 16 insertions, 17 deletions
diff --git a/fietsboek/routes.py b/fietsboek/routes.py index 9e71686..cf6af82 100644 --- a/fietsboek/routes.py +++ b/fietsboek/routes.py @@ -53,8 +53,7 @@ def includeme(config): config.add_route("admin-badge-edit", "/admin/edit-badge") config.add_route("admin-badge-delete", "/admin/delete-badge") - config.add_route("profile", "/me") - config.add_route("change-profile", "/me/personal-data") + config.add_route("user-data", "/me") config.add_route("add-friend", "/me/send-friend-request") config.add_route("delete-friend", "/me/delete-friend") config.add_route("accept-friend", "/me/accept-friend") diff --git a/fietsboek/templates/layout.jinja2 b/fietsboek/templates/layout.jinja2 index d4e0a0d..8f322f6 100644 --- a/fietsboek/templates/layout.jinja2 +++ b/fietsboek/templates/layout.jinja2 @@ -73,7 +73,7 @@ const Legende = false; <a class="dropdown-item" href="{{ request.route_url('logout') }}">{{ _("page.navbar.logout") }}</a> </li> <li> - <a class="dropdown-item" href="{{ request.route_url('profile') }}">{{ _("page.navbar.profile") }}</a> + <a class="dropdown-item" href="{{ request.route_url('user-data') }}">{{ _("page.navbar.profile") }}</a> </li> {% if request.identity.is_admin %} <li> diff --git a/fietsboek/templates/profile.jinja2 b/fietsboek/templates/user_data.jinja2 index ef2ab5f..15588e8 100644 --- a/fietsboek/templates/profile.jinja2 +++ b/fietsboek/templates/user_data.jinja2 @@ -10,7 +10,7 @@ <h2>{{ _("page.my_profile.personal_data") }}</h2> - <form method="POST" action="{{ request.route_path('change-profile') }}" class="needs-validation" novalidate> + <form method="POST" action="{{ request.route_path('user-data') }}" class="needs-validation" novalidate> <div class="form-floating mb-3 col-lg-5"> <input type="text" class="form-control" id="inputName" name="name" value="{{ user.name }}" placeholder="x"> <label for="inputName">{{ _("page.my_profile.personal_data.name") }}</label> diff --git a/fietsboek/views/profile.py b/fietsboek/views/user_data.py index 6354465..a6ad11d 100644 --- a/fietsboek/views/profile.py +++ b/fietsboek/views/user_data.py @@ -10,13 +10,13 @@ from .. import models, util @view_config( - route_name="profile", - renderer="fietsboek:templates/profile.jinja2", + route_name="user-data", + renderer="fietsboek:templates/user_data.jinja2", permission="user", request_method="GET", ) -def profile(request): - """Provides the profile overview. +def user_data(request): + """Provides the user's data. :param request: The Pyramid request. :type request: pyramid.request.Request @@ -37,7 +37,7 @@ def profile(request): } -@view_config(route_name="change-profile", permission="user", request_method="POST") +@view_config(route_name="user-data", permission="user", request_method="POST") def do_change_profile(request): """Endpoint to change the personal data. @@ -52,13 +52,13 @@ def do_change_profile(request): util.check_password_constraints(password, request.params["repeat-password"]) except ValueError as exc: request.session.flash(request.localizer.translate(exc.args[0])) - return HTTPFound(request.route_url("profile")) + return HTTPFound(request.route_url("user-data")) request.identity.set_password(request.params["password"]) name = request.params["name"] if request.identity.name != name: request.identity.name = name request.session.flash(request.localizer.translate(_("flash.personal_data_updated"))) - return HTTPFound(request.route_url("profile")) + return HTTPFound(request.route_url("user-data")) @view_config(route_name="add-friend", permission="user", request_method="POST") @@ -76,13 +76,13 @@ def do_add_friend(request): candidate = request.dbsession.execute(models.User.query_by_email(email)).scalar_one_or_none() if candidate is None: request.session.flash(request.localizer.translate(_("flash.friend_not_found"))) - return HTTPFound(request.route_url("profile")) + return HTTPFound(request.route_url("user-data")) if candidate in request.identity.get_friends() or candidate in [ x.recipient for x in request.identity.outgoing_requests ]: request.session.flash(request.localizer.translate(_("flash.friend_already_exists"))) - return HTTPFound(request.route_url("profile")) + return HTTPFound(request.route_url("user-data")) for incoming in request.identity.incoming_requests: if incoming.sender == candidate: @@ -90,7 +90,7 @@ def do_add_friend(request): request.identity.add_friend(candidate) request.dbsession.delete(incoming) request.session.flash(request.localizer.translate(_("flash.friend_added"))) - return HTTPFound(request.route_url("profile")) + return HTTPFound(request.route_url("user-data")) # Nothing helped, so we send the friend request friend_req = models.FriendRequest( @@ -100,7 +100,7 @@ def do_add_friend(request): ) request.dbsession.add(friend_req) request.session.flash(request.localizer.translate(_("flash.friend_request_sent"))) - return HTTPFound(request.route_url("profile")) + return HTTPFound(request.route_url("user-data")) @view_config(route_name="delete-friend", permission="user", request_method="POST") @@ -119,7 +119,7 @@ def do_delete_friend(request): ).scalar_one_or_none() if friend: request.identity.remove_friend(friend) - return HTTPFound(request.route_url("profile")) + return HTTPFound(request.route_url("user-data")) @view_config(route_name="accept-friend", permission="user", request_method="POST") @@ -143,7 +143,7 @@ def do_accept_friend(request): friend_request.sender.add_friend(friend_request.recipient) request.dbsession.delete(friend_request) - return HTTPFound(request.route_url("profile")) + return HTTPFound(request.route_url("user-data")) @view_config(route_name="json-friends", renderer="json", permission="user") |