diff --git a/admin/templatetags/admin_extras.py b/admin/templatetags/admin_extras.py index 02b117e98..fe9a5f067 100644 --- a/admin/templatetags/admin_extras.py +++ b/admin/templatetags/admin_extras.py @@ -1,6 +1,9 @@ from django import template from django.template.loader import render_to_string from django.utils.translation import ugettext as _ +from django.core.urlresolvers import reverse +from mailng import admin +from mailng.lib import events register = template.Library() @@ -10,9 +13,35 @@ genders = { @register.simple_tag def domain_menu(domain_id, selection, perms): - return render_to_string('admin/domain_menu.html', - {"selection" : selection, - "domain_id" : domain_id, + entries = [ + {"name" : "", + "url" : reverse(admin.views.newmailbox, args=[domain_id]), + "label" : _("New mailbox"), + "img" : "/static/pics/add.png", + "class" : "boxed", + "rel" : "{handler:'iframe',size:{x:300,y:280}}"}, + {"name" : "mailboxes", + "url" : reverse(admin.views.mailboxes, args=[domain_id]), + "img" : "/static/pics/mailbox.png", + "label" : _("Mailboxes")}, + {"name" : "aliases", + "url" : reverse("full-aliases", args=[domain_id]), + "img" : "/static/pics/alias.png", + "label" : _("Aliases")}, + ] + + if perms.user.has_perm("admin.change_domain"): + entries += [ + {"name" : "", + "url" : reverse(admin.views.editdomain, args=[domain_id]), + "label" : _("Properties"), + "img" : "/static/pics/edit.png", + "class" : "boxed", + "rel" : "{handler:'iframe',size:{x:300,y:180}}"} + ] + entries += events.raiseQueryEvent("AdminMenuDisplay", target="admin_menu_bar") + return render_to_string('main/menu.html', + {"selection" : selection, "entries" : entries, "perms" : perms}) @register.simple_tag diff --git a/lib/events.py b/lib/events.py index 62d67262d..9e04a9900 100644 --- a/lib/events.py +++ b/lib/events.py @@ -12,7 +12,8 @@ events = ["CreateDomain", "DeleteMailbox", "ModifyMailbox", - "UserMenuDisplay"] + "UserMenuDisplay", + "AdminMenuDisplay"] callbacks = {} diff --git a/templates/admin/domain_menu.html b/templates/admin/domain_menu.html deleted file mode 100644 index 85c92c440..000000000 --- a/templates/admin/domain_menu.html +++ /dev/null @@ -1,30 +0,0 @@ -{% load i18n %} -{% url admin.views.editdomain domain_id as edit_url %} -{% url admin.views.newmailbox domain_id as new_url %} -{% url admin.views.mailboxes domain_id as mboxes_url %} -{% url full-aliases domain_id as aliases_url %} -
- {% trans "New mailbox" %}
-
-
- {% trans "Mailboxes" %}
- {% trans "Aliases" %}
- {% trans "Properties" %}