From 846d298f440009e86a68706897240c6716c75f46 Mon Sep 17 00:00:00 2001 From: tonio Date: Wed, 5 May 2010 18:20:59 +0200 Subject: [PATCH] Refactoring... --- admin/templatetags/admin_extras.py | 10 ++--- admin/views.py | 4 +- .../templatetags/amextras.py | 4 +- extensions/webmail/main.py | 3 +- extensions/webmail/templatetags/webextras.py | 6 +-- main/templatetags/main_extras.py | 31 --------------- static/js/common.js | 21 ++++------ static/stylesheets/default.css | 3 +- templates/common/menu.html | 1 + .../{main/menu.html => common/menulist.html} | 8 ++-- templates/main/menulist.html | 5 --- templates/nlayout.html | 9 ++--- templates/{main => userprefs}/autoreply.html | 0 templates/{main => userprefs}/chpassword.html | 2 +- templates/{main => userprefs}/confirm.html | 0 templates/{main => userprefs}/header.html | 0 templates/{main => userprefs}/index.html | 7 ++-- urls.py | 2 +- {main => userprefs}/__init__.py | 0 {main => userprefs}/forms.py | 2 +- {main => userprefs}/models.py | 0 {main => userprefs}/templatetags/__init__.py | 0 userprefs/templatetags/uprefs_extras.py | 38 +++++++++++++++++++ {main => userprefs}/urls.py | 2 +- {main => userprefs}/views.py | 11 +++--- 25 files changed, 80 insertions(+), 89 deletions(-) delete mode 100644 main/templatetags/main_extras.py create mode 100644 templates/common/menu.html rename templates/{main/menu.html => common/menulist.html} (93%) delete mode 100644 templates/main/menulist.html rename templates/{main => userprefs}/autoreply.html (100%) rename templates/{main => userprefs}/chpassword.html (91%) rename templates/{main => userprefs}/confirm.html (100%) rename templates/{main => userprefs}/header.html (100%) rename templates/{main => userprefs}/index.html (77%) rename {main => userprefs}/__init__.py (100%) rename {main => userprefs}/forms.py (97%) rename {main => userprefs}/models.py (100%) rename {main => userprefs}/templatetags/__init__.py (100%) create mode 100644 userprefs/templatetags/uprefs_extras.py rename {main => userprefs}/urls.py (85%) rename {main => userprefs}/views.py (89%) diff --git a/admin/templatetags/admin_extras.py b/admin/templatetags/admin_extras.py index 65bc8a969..4fff9c50d 100644 --- a/admin/templatetags/admin_extras.py +++ b/admin/templatetags/admin_extras.py @@ -41,7 +41,7 @@ def domain_menu(domain_id, selection, perms): ] entries += events.raiseQueryEvent("AdminMenuDisplay", target="admin_menu_bar", perms=perms, domain=domain_id) - return render_to_string('main/menu.html', + return render_to_string('common/menu.html', {"selection" : selection, "entries" : entries, "perms" : perms}) @@ -66,7 +66,7 @@ def settings_menu(selection, perms): "url" : reverse(admin.views.viewextensions), "label" : _("Extensions")}, ] - return render_to_string('main/menu.html', + return render_to_string('common/menu.html', {"selection" : selection, "entries" : entries, "perms" : perms}) @@ -86,7 +86,7 @@ def domains_menu(selection, perms): ] entries += events.raiseQueryEvent("AdminMenuDisplay", target="admin_menu_box", perms=perms) - return render_to_string('main/menu.html', + return render_to_string('common/menu.html', {"entries" : entries, "selection" : selection, "perms" : perms}) @@ -94,8 +94,8 @@ def domains_menu(selection, perms): def loadadminextmenu(perms): menu = events.raiseQueryEvent("AdminMenuDisplay", target="admin_menu_box", perms=perms) - return render_to_string('main/menulist.html', - {"menu" : menu, "perms" : perms}) + return render_to_string('common/menulist.html', + {"entries" : menu, "perms" : perms}) @register.simple_tag def param(app, definition): diff --git a/admin/views.py b/admin/views.py index e5b5e23ec..c4b93c134 100644 --- a/admin/views.py +++ b/admin/views.py @@ -11,7 +11,7 @@ from django.core.urlresolvers import reverse from django.contrib.auth.decorators \ import login_required, permission_required, user_passes_test from django.contrib.auth.models import User, Group -from mailng import admin, main +from mailng import admin, userprefs from mailng.admin.models import Domain, Mailbox, Alias, Extension from forms import MailboxForm, DomainForm, AliasForm, PermissionForm from mailng.lib.authbackends import crypt_password @@ -51,7 +51,7 @@ def domains(request): mb = Mailbox.objects.get(user=request.user.id) return mailboxes(request, dom_id=mb.domain.id) - return HttpResponseRedirect(reverse(main.views.index)) + return HttpResponseRedirect(reverse(userprefs.views.index)) domains = Domain.objects.all() counters = {} diff --git a/extensions/amavis_quarantine/templatetags/amextras.py b/extensions/amavis_quarantine/templatetags/amextras.py index 03e1d31a0..b8aaccb08 100644 --- a/extensions/amavis_quarantine/templatetags/amextras.py +++ b/extensions/amavis_quarantine/templatetags/amextras.py @@ -48,7 +48,7 @@ def viewm_menu(selection, backurl, mail_id, perms): "menu" : options_menu} ] - return render_to_string('main/menu.html', + return render_to_string('common/menu.html', {"selection" : selection, "entries" : entries, "perms" : perms}) @@ -82,7 +82,7 @@ def quar_menu(selection, perms): } ] - menu = render_to_string('main/menu.html', + menu = render_to_string('common/menu.html', {"selection" : selection, "entries" : entries, "perms" : perms}) searchbar = render_to_string('common/email_searchbar.html', {}) diff --git a/extensions/webmail/main.py b/extensions/webmail/main.py index 74d57c8ba..3cad08f5b 100644 --- a/extensions/webmail/main.py +++ b/extensions/webmail/main.py @@ -54,7 +54,8 @@ def menu(**kwargs): if kwargs["target"] != "user_menu_box": return [] return [ - {"name" : _("Webmail"), + {"name" : "webmail", + "label" : _("Webmail"), "url" : reverse(index), "img" : "/static/pics/webmail.png"} ] diff --git a/extensions/webmail/templatetags/webextras.py b/extensions/webmail/templatetags/webextras.py index da6fc0f75..cf8eb8b99 100644 --- a/extensions/webmail/templatetags/webextras.py +++ b/extensions/webmail/templatetags/webextras.py @@ -32,7 +32,7 @@ def viewm_menu(selection, backurl, folder, mail_id, perms): "label" : _("Delete")}, ] - return render_to_string('main/menu.html', + return render_to_string('common/menu.html', {"selection" : selection, "entries" : entries, "perms" : perms}) @@ -48,7 +48,7 @@ def compose_menu(selection, backurl, perms): "img" : "/static/pics/send-receive.png", "label" : _("Send")}, ] - return render_to_string('main/menu.html', + return render_to_string('common/menu.html', {"selection" : selection, "entries" : entries, "perms" : perms}) @@ -90,7 +90,7 @@ def listing_menu(selection, folder, perms): ] } ] - menu = render_to_string("main/menu.html", + menu = render_to_string("common/menu.html", {"selection" : selection, "entries" : entries, "perms" : perms}) searchbar = render_to_string("common/email_searchbar.html", {}) diff --git a/main/templatetags/main_extras.py b/main/templatetags/main_extras.py deleted file mode 100644 index 774ac99b5..000000000 --- a/main/templatetags/main_extras.py +++ /dev/null @@ -1,31 +0,0 @@ -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 main -from mailng.lib import events - -register = template.Library() - -@register.simple_tag -def menu(selection, perms): - entries = [ - {"name" : "changepwd", - "url" : reverse(main.views.changepassword), - "img" : "/static/pics/edit.png", - "label" : _("Change password"), - "class" : "boxed", - "rel" : "{handler:'iframe',size:{x:350,y:220}}"} - ] - entries += events.raiseQueryEvent("UserMenuDisplay", target="user_menu_bar") - - return render_to_string('main/menu.html', - {"selection" : selection, "entries" : entries, - "perms" : perms}) - -@register.simple_tag -def loadextmenu(perms): - menu = events.raiseQueryEvent("UserMenuDisplay", target="user_menu_box", - perms=perms) - return render_to_string('main/menulist.html', - {"menu" : menu, "perms" : perms}) diff --git a/static/js/common.js b/static/js/common.js index 7164fa5da..d4969ef77 100644 --- a/static/js/common.js +++ b/static/js/common.js @@ -176,33 +176,28 @@ function HashWrapper(deflocation) { parse_menubar = function(id) { if ($(id)) { - //var first = true; - $(id).getElements('li.dropdown').each(function(elem){ var list = elem.getElement('ul.links'); var myFx = new Fx.Slide(list, { duration: 200 - }).hide(); - - myFx.addEvent("start", function() { - this.wrapper.setStyle("clear", "both"); }); + + myFx.wrapper.setStyles({ + /*"clear" : "both",*/ + "position" : "absolute" + }); + myFx.hide(); elem.addEvents({ - 'mouseenter' : function(){ + 'mouseenter' : function(evt) { myFx.cancel(); myFx.slideIn(); }, - 'mouseleave' : function(){ + 'mouseleave' : function() { myFx.cancel(); myFx.slideOut(); } }); - /*if (!first) { - elem.setStyle("margin-left", "10em"); - } else { - first = false; - }*/ }); SqueezeBox.assign($$('a.boxed'), { parse: 'rel', diff --git a/static/stylesheets/default.css b/static/stylesheets/default.css index 56a4b68f0..9bee80dfd 100644 --- a/static/stylesheets/default.css +++ b/static/stylesheets/default.css @@ -194,14 +194,12 @@ div.right { .dropdown { /*position: absolute;*/ position: relative; - /*clear: both;*/ z-index: 2; /*width: 250px;*/ } .dropdown li { padding: 5px; - width: 170px; cursor: pointer; } @@ -215,6 +213,7 @@ div.right { border-right: 5px solid #333; border-left: 5px solid #333; width: 150px; + float: left; } .dropdown ul li { diff --git a/templates/common/menu.html b/templates/common/menu.html new file mode 100644 index 000000000..b664754a9 --- /dev/null +++ b/templates/common/menu.html @@ -0,0 +1 @@ + diff --git a/templates/main/menu.html b/templates/common/menulist.html similarity index 93% rename from templates/main/menu.html rename to templates/common/menulist.html index 9bd651828..50f30ca9c 100644 --- a/templates/main/menu.html +++ b/templates/common/menulist.html @@ -1,6 +1,5 @@ {% load i18n %} - + {% endif %} +{% endfor %} diff --git a/templates/main/menulist.html b/templates/main/menulist.html deleted file mode 100644 index 063fc2ccc..000000000 --- a/templates/main/menulist.html +++ /dev/null @@ -1,5 +0,0 @@ -{% for entry in menu %} -
  • - {{ entry.name }} -
  • -{% endfor %} \ No newline at end of file diff --git a/templates/nlayout.html b/templates/nlayout.html index 5a75f72e4..349218492 100644 --- a/templates/nlayout.html +++ b/templates/nlayout.html @@ -1,5 +1,5 @@ {% load i18n %} -{% load main_extras %} +{% load uprefs_extras %} @@ -24,12 +24,9 @@