From: Radek Czajka Date: Mon, 17 Oct 2011 13:40:05 +0000 (+0200) Subject: show my page link to unlogged, hide admin links, X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/f73ecfb6b870b18ed88303ff71a06da55001274b show my page link to unlogged, hide admin links, properly redirect on logout from protected pages --- diff --git a/apps/catalogue/templatetags/catalogue.py b/apps/catalogue/templatetags/catalogue.py index bfb900bf..2ce4add9 100644 --- a/apps/catalogue/templatetags/catalogue.py +++ b/apps/catalogue/templatetags/catalogue.py @@ -24,14 +24,15 @@ def main_tabs(context): tabs = [] user = context['user'] - if user.is_authenticated(): - tabs.append(Tab('my', _('My page'), reverse("catalogue_user"))) + tabs.append(Tab('my', _('My page'), reverse("catalogue_user"))) tabs.append(Tab('activity', _('Activity'), reverse("catalogue_activity"))) tabs.append(Tab('all', _('All'), reverse("catalogue_document_list"))) tabs.append(Tab('users', _('Users'), reverse("catalogue_users"))) - tabs.append(Tab('create', _('Add'), reverse("catalogue_create_missing"))) - tabs.append(Tab('upload', _('Upload'), reverse("catalogue_upload"))) + + if user.has_perm('catalogue.add_book'): + tabs.append(Tab('create', _('Add'), reverse("catalogue_create_missing"))) + tabs.append(Tab('upload', _('Upload'), reverse("catalogue_upload"))) if user.is_staff: tabs.append(Tab('admin', _('Admin'), reverse("admin:index"))) diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index fad8a692..72cf63d3 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -56,6 +56,8 @@ def my(request): return render(request, 'catalogue/my_page.html', { 'last_books': sorted(request.session.get("wiki_last_books", {}).items(), key=lambda x: x[1]['time'], reverse=True), + + "logout_to": '/', }) @@ -110,6 +112,8 @@ def create_missing(request, slug=None): return direct_to_template(request, "catalogue/document_create_missing.html", extra_context={ "slug": slug, "form": form, + + "logout_to": '/', }) @@ -165,12 +169,16 @@ def upload(request): "ok_list": ok_list, "skipped_list": skipped_list, "error_list": error_list, + + "logout_to": '/', }) else: form = forms.DocumentsUploadForm() return direct_to_template(request, "catalogue/document_upload.html", extra_context={ "form": form, + + "logout_to": '/', }) @@ -326,6 +334,8 @@ def book_append(request, slug): return direct_to_template(request, "catalogue/book_append_to.html", extra_context={ "book": book, "form": form, + + "logout_to": '/', }) diff --git a/redakcja/templates/registration/head_login.html b/redakcja/templates/registration/head_login.html index f051213a..64bd3e7e 100644 --- a/redakcja/templates/registration/head_login.html +++ b/redakcja/templates/registration/head_login.html @@ -2,7 +2,7 @@ {% if user.is_authenticated %} {{ user.username }} | -{% trans "Log Out" %} +{% trans "Log Out" %} {% else %} {% url login as login_url %} {% ifnotequal login_url request.path %}