diff --git a/modoboa/core/templatetags/core_tags.py b/modoboa/core/templatetags/core_tags.py index 3e1bee986..f8820e6ca 100644 --- a/modoboa/core/templatetags/core_tags.py +++ b/modoboa/core/templatetags/core_tags.py @@ -79,11 +79,11 @@ def admin_menu(selection, user): @register.simple_tag -def user_menu(user, selection): +def user_menu(request, selection): entries = [ {"name": "user", "img": "fa fa-user", - "label": user.fullname, + "label": request.user.fullname, "menu": [ {"name": "settings", "img": "fa fa-list", @@ -93,17 +93,21 @@ def user_menu(user, selection): ] extra_entries = signals.extra_user_menu_entries.send( - sender="user_menu", location="options_menu", user=user) + sender="user_menu", location="options_menu", user=request.user) extra_entries = reduce( lambda a, b: a + b, [entry[1] for entry in extra_entries]) entries[0]["menu"] += ( - extra_entries + [{"name": "logout", - "url": reverse("core:logout"), - "label": _("Logout"), - "img": "fa fa-sign-out"}] + extra_entries + [{ + "name": "logout", + "url": reverse("core:logout"), + "label": _("Logout"), + "img": "fa fa-sign-out", + "method": "post" + }] ) return render_to_string("common/menulist.html", { - "selection": selection, "entries": entries, "user": user + "request": request, "selection": selection, + "entries": entries, "user": request.user }) diff --git a/modoboa/core/views/auth.py b/modoboa/core/views/auth.py index 3057eb50d..3cd254d1d 100644 --- a/modoboa/core/views/auth.py +++ b/modoboa/core/views/auth.py @@ -16,6 +16,7 @@ from django.utils.http import urlsafe_base64_encode from django.utils.translation import gettext as _ from django.views import generic from django.views.decorators.cache import never_cache +from django.views.decorators.http import require_http_methods from django.contrib.auth import ( authenticate, login, logout, views as auth_views @@ -126,6 +127,7 @@ def dologin(request): dologin = never_cache(dologin) +@require_http_methods(["POST"]) def dologout(request): """Logout current user.""" if not request.user.is_anonymous: diff --git a/modoboa/lib/templatetags/lib_tags.py b/modoboa/lib/templatetags/lib_tags.py index 2f72b088a..2ca57dcbe 100644 --- a/modoboa/lib/templatetags/lib_tags.py +++ b/modoboa/lib/templatetags/lib_tags.py @@ -3,7 +3,7 @@ from datetime import datetime from django import template -from django.template import Context, Template +from django.template import Context, RequestContext, Template from django.utils.safestring import mark_safe from django.utils.translation import gettext as _ @@ -51,6 +51,15 @@ class="{{ mdclass }}{% if link.class %} {{ link.class }}{% endif %}" return t.render(Context({"link": linkdef, "mdclass": mdclass})) +@register.simple_tag +def render_post_link(linkdef, request): + t = Template("""
+{% csrf_token %} +{% if link.img %}{% endif %}{{ link.label }} +
""") + return t.render(RequestContext(request, {"link": linkdef})) + + @register.simple_tag def progress_color(value): value = int(value) diff --git a/modoboa/static/css/custom.css b/modoboa/static/css/custom.css index 1db572383..89a4e2a14 100644 --- a/modoboa/static/css/custom.css +++ b/modoboa/static/css/custom.css @@ -1,6 +1,6 @@ /* ------- Media ------- */ -.sidebar { +.sidebar { display: none; } @@ -67,7 +67,7 @@ /* --------- general --------- */ -.container-fluid { +.container-fluid { padding-left: 0; padding-right: 0; } @@ -101,7 +101,7 @@ /* Global */ -body { +body { padding-top: 50px; padding-bottom: 50px; } @@ -168,7 +168,15 @@ label { table-layout: fixed; } - +.menu-link { + display: block; + padding: 3px 20px; + clear: both; + font-weight: 400; + line-height: 1.42857143; + color: #333; + white-space: nowrap; +} /* --------- main page --------- */ @@ -202,7 +210,7 @@ html body div.navbar div.container-fluid div#navigate-navbar-collapse.collapse u padding-left: 20px;*/ } -.nav-sidebar > li > a:hover { +.nav-sidebar > li > a:hover { background-color: #eee; } @@ -230,7 +238,7 @@ html body div.navbar div.container-fluid div#navigate-navbar-collapse.collapse u margin-bottom: 4px; } -.main { +.main { padding: 20px 15px; } @@ -280,7 +288,7 @@ table td[name="actions"] { /* modals */ -.modal-body .nav-pills { +.modal-body .nav-pills { margin-bottom: 15px; } diff --git a/modoboa/templates/common/menulist.html b/modoboa/templates/common/menulist.html index 3b5177746..030051049 100644 --- a/modoboa/templates/common/menulist.html +++ b/modoboa/templates/common/menulist.html @@ -4,19 +4,23 @@
  •  
  • {% else %} {% if entry.menu %} - {% else %}
  • - {% render_link entry %} + {% if entry.method == "post" %} + {% render_post_link entry request %} + {% else %} + {% render_link entry %} + {% endif %}
  • {% endif %} {% endif %} diff --git a/modoboa/templates/nlayout.html b/modoboa/templates/nlayout.html index 0d851d75d..427a9603b 100644 --- a/modoboa/templates/nlayout.html +++ b/modoboa/templates/nlayout.html @@ -60,7 +60,7 @@ {% endif %} {% include "common/top_notifications.html" %}