From: jordan Date: Thu, 15 Dec 2011 19:46:30 +0000 (+0000) Subject: making the user edit url contain the user slug X-Git-Tag: live~105 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/afa2b5ca9e29a5f2f3dfa8f94a5be2f9e612d719?ds=sidebyside;hp=b86411ce4ba88589a32ce6c19a89ba5ae90e4a6e making the user edit url contain the user slug git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1212 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/registry.py b/forum/registry.py index 4c8df65..871f1e5 100644 --- a/forum/registry.py +++ b/forum/registry.py @@ -71,7 +71,10 @@ class SuperUserSwitchMenuItem(ui.UserMenuItem): ui.register(ui.USER_MENU, ui.UserMenuItem( label=_("edit profile"), - url=lambda u, c: reverse('edit_user', kwargs={'id': c['user'].id}), + url=lambda u, c: reverse('edit_user', kwargs={ + 'id': c['user'].id, + 'slug' : slugify(c['user'].username) + }), span_attrs={'class': 'user-edit'}, weight=0, name='EDIT_PROFILE' diff --git a/forum/skins/default/templates/users/edit.html b/forum/skins/default/templates/users/edit.html index 09292fe..ce54c77 100644 --- a/forum/skins/default/templates/users/edit.html +++ b/forum/skins/default/templates/users/edit.html @@ -33,7 +33,7 @@ {{ user.username }} - {% trans "edit profile" %}
-
+ {% csrf_token %}
{% if user.email %} diff --git a/forum/urls.py b/forum/urls.py index 3d202c7..fd82f7f 100644 --- a/forum/urls.py +++ b/forum/urls.py @@ -100,7 +100,7 @@ core_urls = ( url(r'^%s$' % _('users/'), app.users.users, name='users'), # url(r'^%s$' % _('online_users/'), app.users.online_users, name='online_users'), - url(r'^%s(?P\d+)/%s$' % (_('users/'), _('edit/')), app.users.edit_user, name='edit_user'), + url(r'^%s(?P\d+)/(?P.*)/%s$' % (_('users/'), _('edit/')), app.users.edit_user, name='edit_user'), url(r'^%s(?P\d+)/%s$' % (_('users/'), _('award/')), app.users.award_points, name='user_award_points'), url(r'^%s(?P\d+)/%s$' % (_('users/'), _('suspend/')), app.users.suspend, name='user_suspend'), url(r'^%s(?P\d+)/%s(?P[a-z]+)/(?P[a-z]+)/$' % (_('users/'), _('powers/')), app.users.user_powers, name='user_powers'), diff --git a/forum/views/users.py b/forum/views/users.py index bc0abc3..db65003 100644 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -131,7 +131,7 @@ def online_users(request): }) -def edit_user(request, id): +def edit_user(request, id, slug): user = get_object_or_404(User, id=id) if not (request.user.is_superuser or request.user == user): return HttpResponseUnauthorized(request)