Refactoring...

This commit is contained in:
tonio
2010-05-05 18:20:59 +02:00
parent d8ccbb736f
commit 846d298f44
25 changed files with 80 additions and 89 deletions
+5 -5
View File
@@ -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):
+2 -2
View File
@@ -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 = {}
@@ -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', {})
+2 -1
View File
@@ -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"}
]
+3 -3
View File
@@ -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", {})
-31
View File
@@ -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})
+8 -13
View File
@@ -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',
+1 -2
View File
@@ -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 {
+1
View File
@@ -0,0 +1 @@
<ul>{% include "common/menulist.html" %}</ul>
@@ -1,6 +1,5 @@
{% load i18n %}
<ul>
{% for entry in entries %}
{% for entry in entries %}
{% if entry.menu %}
<li class="dropdown {{ entry.class }}">
<img src="{{ entry.img }}" border="0" />
@@ -28,6 +27,5 @@
{{ entry.label }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% endfor %}
-5
View File
@@ -1,5 +0,0 @@
{% for entry in menu %}
<li><a href="{{ entry.url }}"><img src="{{ entry.img }}" border="0" />
{{ entry.name }}
</a></li>
{% endfor %}
+3 -6
View File
@@ -1,5 +1,5 @@
{% load i18n %}
{% load main_extras %}
{% load uprefs_extras %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -24,12 +24,9 @@
<div id="topmenubar" class="uibar menubar">
<div class="left" style="width: 50%">
<ul>
<li>
{% url main.views.index as index_url %}
<a href="{{ index_url }}">
<img src="/static/pics/user.png" border="0" />{% trans "Preferences" %}</a>
</li>
{% loadextmenu perms %}
{% uprefs_menu perms %}
{% if user.is_superuser or perms.admin.view_domains %}
<li class="dropdown topdropdown">
<img src="/static/pics/admin.png" border="0" />
@@ -7,7 +7,7 @@
<div class="title"><h1>{% trans "Change password" %}</h1></div>
{% if error %}<div class="error">{{ error }}</div>{% endif %}
{% url main.views.changepassword as action_url %}
{% url userprefs.views.changepassword as action_url %}
<form action="{{ action_url }}" method="post" name="chpwdform" id="chpwdform">
{% include "common/genericform.html" %}
@@ -1,8 +1,7 @@
{% extends "main/header.html" %}
{% extends "userprefs/header.html" %}
{% load i18n %}
{% block menu %}
{% load main_extras %}
{% menu "" perms %}
{% load uprefs_extras %}
{% endblock %}
{% block subcontent %}
<div class="info">
@@ -14,4 +13,4 @@
{% endif %}
</div>
{% endblock %}
{% endblock %}
+1 -1
View File
@@ -21,7 +21,7 @@ urlpatterns = patterns('',
# (r'^admin/(.*)', admin.site.root),
(r'^mailng/admin/', include('mailng.admin.urls')),
(r'^mailng/main/', include('mailng.main.urls')),
(r'^mailng/userprefs/', include('mailng.userprefs.urls')),
(r'^accounts/login/$', 'mailng.auth.views.dologin'),
(r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login'),
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog',
+1 -1
View File
@@ -1,5 +1,5 @@
from django import forms
from mailng.main.models import ARmessage
from models import ARmessage
from mailng.lib.authbackends import check_password
from django.utils.translation import ugettext as _
+38
View File
@@ -0,0 +1,38 @@
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 userprefs
from mailng.lib import events
register = template.Library()
@register.simple_tag
def uprefs_menu(perms):
entries = [
{"name" : "userprefs",
"img" : "/static/pics/user.png",
"label" : _("Preferences"),
"class" : "topdropdown",
"menu" : [
{"name" : "changepwd",
"url" : reverse(userprefs.views.changepassword),
"img" : "/static/pics/edit.png",
"label" : _("Change password"),
"class" : "boxed",
"rel" : "{handler:'iframe',size:{x:350,y:220}}"}
]
}
]
entries[0]["menu"] += [events.raiseQueryEvent("UserMenuDisplay",
target="user_menu_bar")]
return render_to_string('common/menulist.html',
{"entries" : entries, "perms" : perms})
@register.simple_tag
def loadextmenu(perms):
menu = events.raiseQueryEvent("UserMenuDisplay", target="user_menu_box",
perms=perms)
return render_to_string('common/menulist.html',
{"entries" : menu, "perms" : perms})
+1 -1
View File
@@ -1,6 +1,6 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('mailng.main.views',
urlpatterns = patterns('mailng.userprefs.views',
url(r'^$', 'index'),
url(r'^autoreply/$', 'autoreply'),
(r'^changepassword/$', 'changepassword'),
+5 -6
View File
@@ -8,7 +8,6 @@ from django.contrib.auth.decorators \
import login_required
from django.utils import simplejson
from django.utils.translation import ugettext as _
from mailng import main
from mailng.lib import _render, _ctx_ok, _ctx_ko
from mailng.lib.authbackends import crypt_password
from forms import ARmessageForm, ChangePasswordForm
@@ -22,7 +21,7 @@ def index(request):
arm = ARmessage.objects.filter(mbox=mb.id, enabled=True)
except ARmessage.DoesNotExist:
arm = None
return _render(request, "main/index.html", {"arm" : arm})
return _render(request, "userprefs/index.html", {"arm" : arm})
@login_required
def autoreply(request):
@@ -46,7 +45,7 @@ def autoreply(request):
)
form = ARmessageForm(instance=arm)
return _render(request, "main/autoreply.html", {
return _render(request, "userprefs/autoreply.html", {
"form" : form
})
@@ -62,19 +61,19 @@ def changepassword(request):
ctx = _ctx_ok("")
return HttpResponse(simplejson.dumps(ctx),
mimetype="application/json")
ctx = _ctx_ko("main/chpassword.html", {
ctx = _ctx_ko("userprefs/chpassword.html", {
"form" : form, "error" : error
})
return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
form = ChangePasswordForm(mb)
return render_to_response('main/chpassword.html', {
return render_to_response('userprefs/chpassword.html', {
"form" : form
})
@login_required
def confirm(request):
return render_to_response('main/confirm.html', {
return render_to_response('userprefs/confirm.html', {
"msg" : request.GET["question"]
})