* Added domain aliases delete,
 * Permissions are not implemented yet.

see #103

 * New generic create and remove buttons,
 * New javascript confirmation module,
 * Fixed a lot of problems about objects relations removal,
 * Simpler interface (no more dropdown menus),
 * Multiple removal support.
This commit is contained in:
tonio
2010-12-13 23:45:37 +01:00
parent 308702ec10
commit 9d95107bbd
22 changed files with 353 additions and 339 deletions
@@ -19,7 +19,7 @@ class Migration(SchemaMigration):
'Meta': {'object_name': 'Alias'},
'address': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'full_address': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '150'}),
'full_address': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '254'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'mboxes': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['admin.Mailbox']", 'symmetrical': 'False'})
},
+29 -1
View File
@@ -51,6 +51,20 @@ class Domain(models.Model):
% (parameters.get_admin("STORAGE_PATH"),
self.name))
def delete(self, *args, **kwargs):
keepdir = False
if kwargs.has_key("keepdir"):
keepdir = kwargs["keepdir"]
del kwargs["keepdir"]
# Not very optimized but currently, this is the simple way
# I've found to delete all related objects (mailboxes, users
# and aliases)!
for mb in self.mailbox_set.all():
mb.delete(keepdir=keepdir)
super(Domain, self).delete(*args, **kwargs)
if not keepdir:
self.delete_dir()
def __str__(self):
return self.name
@@ -74,7 +88,7 @@ class Mailbox(models.Model):
gid = models.IntegerField()
path = models.CharField(max_length=200)
domain = models.ForeignKey(Domain)
user = models.ForeignKey(User)
user = models.OneToOneField(User)
path = models.CharField(max_length=255)
class Meta:
@@ -164,6 +178,20 @@ class Mailbox(models.Model):
pass
super(Mailbox, self).save(*args, **kwargs)
def delete(self, *args, **kwargs):
keepdir = False
if kwargs.has_key("keepdir"):
keepdir = kwargs["keepdir"]
del kwargs["keepdir"]
for alias in self.alias_set.all():
alias.mboxes.remove(self)
if len(alias.mboxes.all()) == 0:
alias.delete()
self.user.delete()
super(Mailbox, self).delete(*args, **kwargs)
if not keepdir:
self.delete_dir()
def tohash(self):
return {
"id" : self.id,
+10 -56
View File
@@ -58,40 +58,6 @@ def admin_menu(user):
return render_to_string("common/menulist.html",
{"entries" : entries, "user" : user})
@register.simple_tag
def domain_menu(domain_id, selection, user):
entries = [
{"name" : "",
"url" : reverse(admin.views.newmailbox),
"label" : _("New mailbox"),
"img" : static_url("pics/add.png"),
"class" : "boxed",
"rel" : "{handler:'iframe',size:{x:300,y:280}}"},
{"name" : "mailboxes",
"url" : reverse(admin.views.mailboxes),
"img" : static_url("pics/mailbox.png"),
"label" : _("Mailboxes")},
{"name" : "aliases",
"url" : reverse("full-aliases"),
"img" : static_url("/pics/alias.png"),
"label" : _("Aliases")},
]
if user.has_perm("admin.change_domain"):
entries += [
{"name" : "",
"url" : reverse(admin.views.editdomain, args=[domain_id]),
"label" : _("Properties"),
"img" : static_url("pics/edit.png"),
"class" : "boxed",
"rel" : "{handler:'iframe',size:{x:300,y:180}}"}
]
entries += events.raiseQueryEvent("AdminMenuDisplay", target="admin_menu_bar",
user=user, domain=domain_id)
return render_to_string('common/menu.html',
{"selection" : selection, "entries" : entries,
"user" : user})
@register.simple_tag
def settings_menu(selection, user):
entries = [
@@ -114,13 +80,6 @@ def dommenu_entry(name, label, img, listurl, newurl):
"img" : img,
"url" : listurl,
"class" : "menubardropdown",
"menu" : [{"name" : "%s_new" % name,
"url" : newurl,
"label" : _("New"),
"img" : static_url("pics/add.png"),
"class" : "boxed",
"rel" : "{handler:'iframe',size:{x:300,y:200}}"}
]
}
return result
@@ -128,6 +87,15 @@ def dommenu_entry(name, label, img, listurl, newurl):
def domains_menu(selection, user, domid):
args = domid != "" and ("?domid=%s" % domid) or ""
entries = []
entries += [{"name" : "new",
"label" : _("New"),
"img" : static_url("pics/add.png")},
{"name" : "remove",
"label" : _("Remove"),
"img" : static_url("pics/remove.png")
}]
entries += [{"separator" : True}]
if user.has_perm("admin.view_domains"):
entries += dommenu_entry("domains", _("Domains"),
static_url("pics/domains.png"),
@@ -188,11 +156,6 @@ def domain_actions(user, domid):
"title" : _("Edit domain"),
"class" : "boxed",
"rel" : "{handler:'iframe',size:{x:300,y:180}}"},
{"name" : "deldomain",
"url" : reverse(admin.views.deldomain, args=[domid]),
"img" : static_url("pics/remove.png"),
"title" : _("Delete domain"),
"confirm" : _("Delete this domain?")},
{"name" : "domaliases",
"url" : reverse(admin.views.domaliases) + "?domid=%s" % domid,
"img" : static_url("pics/alias.png"),
@@ -221,10 +184,6 @@ def mailbox_actions(user, mbox):
"title" : _("Edit mailbox"),
"class" : "boxed",
"rel" : "{handler:'iframe',size:{x:300,y:280}}"},
{"name" : "deleteMb",
"url" : reverse(admin.views.delmailbox, args=[mbox.id]),
"img" : static_url("pics/remove.png"),
"title" : _("Delete mailbox")},
{"name" : "aliases",
"url" : reverse(admin.views.mbaliases) + "?mbid=%d" % mbox.id,
"img" : static_url("pics/alias.png"),
@@ -240,12 +199,7 @@ def mbalias_actions(user, alias):
"img" : static_url("pics/edit.png"),
"title" : _("Edit mailbox alias"),
"class" : "boxed",
"rel" : "{handler:'iframe',size:{x:300,y:250}}"},
{"name" : "dembalias",
"url" : reverse(admin.views.delmbalias, args=[alias.id]),
"img" : static_url("pics/remove.png"),
"title" : _("Delete mailbox alias"),
"confirm" : _("Delete this alias?")},
"rel" : "{handler:'iframe',size:{x:300,y:250}}"}
]
return render_actions(actions)
+4 -3
View File
@@ -5,21 +5,22 @@ urlpatterns = patterns('modoboa.admin.views',
url(r'^domains/$', 'domains', name="domains"),
(r'^domains/new/', 'newdomain'),
(r'^domains/(?P<dom_id>\d+)/edit/$', 'editdomain'),
(r'^domains/(?P<dom_id>\d+)/delete/$', 'deldomain'),
(r'^domains/delete/$', 'deldomain'),
(r'^domaliases/$', "domaliases"),
(r'^domaliases/new/', 'newdomalias'),
(r'^domaliases/edit/(?P<alias_id>\d+)/', 'editdomalias'),
(r'^domaliases/delete/$', 'deldomalias'),
(r'^mailboxes/$', 'mailboxes'),
(r'^mailboxes/new/$', 'newmailbox'),
(r'^mailboxes/edit/(?P<mbox_id>\d+)/$', 'editmailbox'),
(r'^mailboxes/delete/(?P<mbox_id>\d+)/$', 'delmailbox'),
(r'^mailboxes/delete/$', 'delmailbox'),
(r'^mbaliases/$', 'mbaliases'),
(r'^mbaliases/new/$', 'newmbalias'),
(r'^mbaliases/edit/(?P<alias_id>\d+)/$', 'editmbalias'),
(r'^mbaliases/delete/(?P<alias_id>\d+)/$', 'delmbalias'),
(r'^mbaliases/delete/$', 'delmbalias'),
(r'^domains/(?P<dom_id>\d+)/raw/$', 'mailboxes_raw'),
#url(r'^domains/(?P<dom_id>\d+)/aliases/$', "aliases", name="full-aliases"),
+58 -24
View File
@@ -63,8 +63,10 @@ def domains(request):
counters = {}
for dom in domains:
dom.mboxcounter = len(dom.mailbox_set.all())
deloptions = {"keepdir" : _("Do not delete domain directory")}
return render_domains_page(request, "domains",
domains=domains, counter=counters)
domains=domains, counter=counters,
deloptions=deloptions)
@login_required
def domaliases(request):
@@ -137,6 +139,15 @@ def editdomalias(request, alias_id):
"form" : form, "domalias" : domalias
})
@login_required
@permission_required("admin.delete_domalias")
def deldomalias(request):
selection = request.GET["selection"].split(",")
DomainAlias.objects.filter(id__in=selection).delete()
messages.info(request, _("Domain alias(es) deleted"), fail_silently=True)
return HttpResponse(simplejson.dumps(_ctx_ok("")),
mimetype="application/json")
@login_required
@permission_required("admin.add_domain")
def newdomain(request):
@@ -200,13 +211,26 @@ def editdomain(request, dom_id):
@login_required
@permission_required("admin.delete_domain")
def deldomain(request, dom_id):
domain = Domain.objects.get(pk=dom_id)
events.raiseEvent("DeleteDomain", dom=domain)
domain.delete_dir()
domain.delete()
messages.info(request, _("Domain deleted"), fail_silently=True)
return HttpResponseRedirect(reverse(admin.views.domains))
def deldomain(request):
selection = request.GET["selection"].split(",")
error = None
if request.user.id != 1:
mb = Mailbox.objects.get(user__id=request.user.id)
if dom.id in selection:
error = _("You can't delete your own domain")
if error is None:
if request.GET.has_key("keepdir") and request.GET["keepdir"] == "true":
keepdir = True
else:
keepdir = False
for dom in Domain.objects.filter(id__in=selection):
events.raiseEvent("DeleteDomain", dom=dom)
dom.delete(keepdir=keepdir)
messages.info(request, _("Domain deleted"), fail_silently=True)
ctx = _ctx_ok("")
else:
ctx = getctx("ko", error=error)
return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
@login_required
@good_domain
@@ -214,12 +238,13 @@ def deldomain(request, dom_id):
def mailboxes(request):
if request.GET.has_key("domid"):
domain = Domain.objects.get(pk=request.GET["domid"])
mailboxes = Mailbox.objects.filter(domain=domain.id)
mboxes = Mailbox.objects.filter(domain=domain.id)
else:
mailboxes = Mailbox.objects.all()
mboxes = Mailbox.objects.all()
domain = None
deloptions = {"keepdir" : _("Do not delete mailbox directory")}
return render_domains_page(request, "mailboxes",
mailboxes=mailboxes, domain=domain)
mailboxes=mboxes, domain=domain, deloptions=deloptions)
@login_required
@good_domain
@@ -306,18 +331,26 @@ def editmailbox(request, mbox_id=None):
@login_required
@good_domain
@permission_required("admin.delete_mailbox")
def delmailbox(request, mbox_id=None):
mb = Mailbox.objects.get(pk=mbox_id)
if mb.user.id != request.user.id:
events.raiseEvent("DeleteMailbox", mbox=mb)
if not request.GET.has_key("keepdir") or request.GET["keepdir"] != "true":
mb.delete_dir()
mb.user.delete()
mb.delete()
def delmailbox(request):
selection = request.GET["selection"].split(",")
error = None
if not request.user.is_superuser:
mb = Mailbox.objects.get(user__id=request.user.id)
if mb.id in selection:
error = _("You can't delete your own mailbox")
if error is None:
if request.GET.has_key("keepdir") and request.GET["keepdir"] == "true":
keepdir = True
else:
keepdir = False
for mb in Mailbox.objects.filter(id__in=selection):
events.raiseEvent("DeleteMailbox", mbox=mb)
mb.delete()#keepdir=keepdir)
messages.info(request, _("Mailbox deleted"), fail_silently=True)
ctx = _ctx_ok("")
else:
ctx = getctx("ko", error=_("You can't delete your own mailbox"))
ctx = getctx("ko", error=error)
return HttpResponse(simplejson.dumps(ctx),
mimetype="application/json")
@@ -398,11 +431,12 @@ def editmbalias(request, alias_id):
@login_required
@good_domain
@permission_required("admin.delete_alias")
def delmbalias(request, alias_id):
alias = Alias.objects.get(pk=alias_id)
alias.delete()
def delmbalias(request):
selection = request.GET["selection"].split(",")
Alias.objects.filter(id__in=selection).delete()
messages.info(request, _("Alias deleted"), fail_silently=True)
return HttpResponseRedirect(reverse(admin.views.mbaliases))
return HttpResponse(simplejson.dumps(_ctx_ok("")),
mimetype="application/json")
@login_required
@permission_required("auth.view_permissions")
-25
View File
@@ -104,31 +104,6 @@ td.even {
width: 120px;
}
/* Dialog box */
#dlg-buttons {
clear: both;
width: 100%;
text-align: center;
padding-top: 20px;
}
#dlg-iconbox {
float: left;
margin-top: 20px;
width: 32px;
}
#dlg-textbox {
float: left;
margin-left: 20px;
margin-top: 10px;
width: 80%;
}
#dlg-buttons input {
width: 90px;
}
/* Mootools tooltips */
.tip {
color: #fff;
+54 -1
View File
@@ -290,15 +290,22 @@ th.right {
text-align: right;
}
th.center, td.center {
text-align: center;
}
td {
border-bottom: 1px solid #C8D6E8;
/*padding: 5px;*/
}
tr.table-tr-selected {
background: #ffffcc;
}
input {
border: 1px solid #cccccc;
color: inherit;
/*background-color: #e9e9e9;*/
background-color: #eee;
padding: 2px;
}
@@ -389,3 +396,49 @@ div.row label {
display: inline;
color: red;
}
.separator {
padding-left: 5px;
padding-right: 5px;
}
/* Custom confirmation box */
#dlg-buttons {
clear: both;
width: 100%;
text-align: center;
padding-top: 20px;
}
#dlg-iconbox {
float: left;
margin-top: 20px;
width: 32px;
}
#dlg-textbox {
float: left;
margin-left: 20px;
margin-top: 10px;
width: 80%;
}
#dlg-textbox input {
float: left;
padding: 0;
margin: 0;
}
#dlg-textbox label {
margin-left: 5px;
}
#dlg-buttons {
position: absolute;
bottom: 15px;
}
#dlg-buttons input {
width: 90px;
margin: 2px;
}
+1 -39
View File
@@ -193,7 +193,6 @@ parse_menubar = function(id) {
});
myFx.wrapper.setStyles({
/*"clear" : "both",*/
"position" : "absolute"
});
myFx.hide();
@@ -235,43 +234,6 @@ get_iframe_body = function(id) {
return (data);
};
confirmation = function(question, action, callback) {
SqueezeBox.initialize({
size: {x: 350, y: 140},
handler: 'iframe',
onClose: function(content) {
var ibody = get_iframe_body(this.asset);
var elt = ibody.getElement("input[name=result]");
if (elt.get("value") == "ok") {
var params = "";
if (typeof callback != "undefined") {
params = callback(ibody);
}
new Request.JSON({
method: "get",
url: action.get("href"),
onSuccess: function(res) {
if (res.status == "ok") {
window.location.reload();
} else {
infobox.error(res.error);
infobox.hide(2);
}
}
}).send(params);
}
}
});
/* FIXME: avoid using a hard coded address like this, maybe it
could be fixed by creating a new class for "confirmation" and
create one instance for each section/page using it (I mean
directly inside the html template) */
SqueezeBox.open("/modoboa/userprefs/confirm/?question=" + question);
};
setDivHeight = function(id, extrah, modulo) {
var contentsize = $(document.body).getSize().y
- $("topmenubar").getSize().y
@@ -286,7 +248,7 @@ setDivHeight = function(id, extrah, modulo) {
};
bindRows = function(rooturl, page) {
$$("tr").addEvent("click", function(event) {
$$("tr").addEvent("dblclick", function(event) {
if (event.target.parentNode.id) {
var url = rooturl + "?domid=" + event.target.parentNode.id;
if (page != "") {
+91
View File
@@ -0,0 +1,91 @@
var Confirmation = new Class({
Implements: [Options, Events],
options: {
checkboxes: []
},
build_checkboxes: function() {
var result = "";
var cbhash = new Hash(this.options.checkboxes);
cbhash.each(function(value, key, hash) {
result += "<input type='checkbox' name='" + key + "' value='' />";
result += "<label>" + value + "</label>";
});
return result;
},
initialize: function(url, urlparams, question, options) {
this.setOptions(options);
Confirmation.url = url;
Confirmation.urlparams = urlparams;
var content = new Element("div", {id: "confirmbox"});
var icondiv = new Element("div", {
id: "dlg-iconbox",
html: "<img src='/static/pics/dialog-warning.png' alt='Warning' />"
}).inject(content);
this.textdiv = new Element("div", {
id: "dlg-textbox",
html: "<b>" + question + "</b>"
+ "<p>" + this.build_checkboxes() + "</p>"
}).inject(content);
var buttonsdiv = new Element("div", {
id: "dlg-buttons"
}).inject(content);
new Element("input", {type: "button", name: "ok", id: "ok", value: "Ok"})
.addEvent("click", this.ok_handler)
.inject(buttonsdiv);
new Element("input", {type: "button", name: "cancel", value: "Cancel"})
.addEvent("click", this.cancel_handler)
.inject(buttonsdiv);
new Element("input", {type: "hidden", name: "result", id: "result", value: "cancel"})
.inject(content);
SqueezeBox.initialize({
size: {x: 350, y: 140},
handler: "adopt",
onClose: this.close_handler
});
SqueezeBox.open(content);
},
close_handler: function(content) {
var result = $("confirmbox").getElement("input[name=result]");
if (result.get("value") != "ok") {
return;
}
var params = Confirmation.urlparams;
$$("input[type=checkbox]:checked").each(function(item) {
if (params != "") {
params += "&";
}
params += item.get("name") + "=true";
});
new Request.JSON({
method: "get",
url: Confirmation.url,
onSuccess: function(res) {
if (res.status == "ok") {
window.location.reload();
} else {
infobox.error(res.error);
infobox.hide(2);
}
}
}).send(params);
},
ok_handler: function(evt) {
$("result").value = "ok";
parent.SqueezeBox.close();
},
cancel_handler: function(evt) {
parent.SqueezeBox.close();
}
});
+4 -27
View File
@@ -1,4 +1,3 @@
window.addEvent('domready', function() {
var handlers = new Array();
@@ -19,28 +18,12 @@ window.addEvent('domready', function() {
event.stop();
});
if ($$("a[name=deleteMb]"))
$$("a[name=deleteMb]").addEvent('click', function(event) {
event.stop();
confirmation(gettext("Delete this mailbox?"), this, function(body) {
var result = "";
body.getElements("input[type=checkbox]:checked").each(function(obj) {
if (result != "") {
result += "&";
}
result += obj.name + "=true";
});
return result;
});
});
if ($$("a[name=deleteAlias]"))
$$("a[name=deleteAlias]").addEvent('click', function(event) {
if (!confirm(gettext("Delete this alias?")))
event.stop();
});
$(document.body).addEvent('click', function(event) {
var target = event.target;
if (target.get('tag') == 'a') {
@@ -68,18 +51,12 @@ window.addEvent('domready', function() {
}
});
setDivHeight("content", 20, 0);
objtable = new HtmlTable($("objects_table"), {
selectable: true
});
});
newdom = function() {
form = $("form[name=newdom]");
var params = obj.toQueryString();
form.set('send', {
onSuccess: function(response) {
SqueezeBox.loadModal(obj.action + '?' + params);
}
}).send();
};
loadPage = function(url, destination, callback) {
destination = (destination == null) ? "page" : destination;
-42
View File
@@ -1,42 +0,0 @@
{% extends "admin/domain_header.html" %}
{% block menu %}
{% load admin_extras %}
{% domain_menu domain.id "aliases" user %}
{% endblock %}
{% block domcontent %}
{% load i18n %}
{% if not aliases %}
<p>{% trans "No alias defined." %}</p>
{% else %}
<table>
<tr>
<th width="50px">{% trans "Actions" %}</th>
<th width="150px">{% trans "Address" %}</th>
<th width="200px">{% trans "Mailbox" %}</th>
<th width="75px">{% trans "Enabled" %}</th>
</tr>
{% for alias in aliases %}
<tr>
<td>
{% url admin.views.editalias domain.id alias.id as edit_url %}
<a href="{{ edit_url }}" class="boxed"
rel="{handler:'iframe',size:{x:300,y:250}}">
<img src="{{ MEDIA_URL }}pics/edit.png" border="0" title="{% trans 'Edit alias' %}"/>
</a>
{% url admin.views.delalias domain.id alias.id as del_url %}
<a href="{{ del_url }}" name="deleteAlias">
<img src="{{ MEDIA_URL }}pics/remove.png" border="0" title="{% trans 'Delete alias' %}" />
</a>
</td>
<td>{{ alias.full_address }}</td>
<td>
{% for mb in alias.mboxes.all %}
{{ mb.full_address }}<br/>
{% endfor %}
</td>
<td>{{ alias.enabled|yesno }}</td
</tr>
{% endfor %}
</table>
{% endif %}
{% endblock %}
-14
View File
@@ -1,14 +0,0 @@
{% extends "nlayout.html" %}
{% load i18n libextras %}
{% block html_head %}
<script src="{{ MEDIA_URL }}js/domains.js" type="text/javascript"></script>
{% endblock %}
{% block middletitle %}{% trans "Domain" %} {{ domain.name }}{% endblock %}
{% block content %}
{% if messages %}
{% display_messages messages %}
{% endif %}
<div id="subcontent">
{% block domcontent %}{% endblock %}
</div>
{% endblock %}
+5 -3
View File
@@ -11,11 +11,12 @@
{% endblock %}
{% block middletitle %}{% trans "Available domains" %}{% endblock %}
{% block subcontent %}
<div id="objects" name="domains" rel="300 190">
{% if not domains %}<div class="info">{% trans "No domain defined." %}</div>
{% else %}
<table>
<table id="objects_table">
<tr>
<th width="100px">{% trans "Actions" %}</th>
<th width="70px" class="center">{% trans "Actions" %}</th>
<th>{% trans "Name" %}</th>
<th width="150px">{% trans "Mailboxes" %}</th>
<th width="50px">{% trans "Quota" %}</th>
@@ -23,7 +24,7 @@
</tr>
{% for dom in domains %}
<tr class="{% cycle 'odd' 'even' %}" id="{{ dom.id }}">
<td>{% domain_actions user dom.id %}</td>
<td class="center">{% domain_actions user dom.id %}</td>
<td>{{ dom.name }}</td>
<td>{{ dom.mboxcounter }}</td>
<td>{{ dom.quota }} {% trans "MB" %}</td>
@@ -32,4 +33,5 @@
{% endfor %}
</table>
{% endif %}
</div>
{% endblock %}
+38
View File
@@ -2,6 +2,44 @@
{% load i18n admin_extras libextras %}
{% block html_head %}
<script src="{{ MEDIA_URL }}js/domains.js" type="text/javascript"></script>
<script src="{{ MEDIA_URL }}js/confirmation.js" type="text/javascript"></script>
<script type="text/javascript">
window.addEvent("domready", function() {
var rooturl = "{% url index %}";
$$("a[name=new]").addEvent("click", function(evt) {
var type = $("objects").get("name");
var sizes = $("objects").get("rel").split(" ");
evt.stop();
SqueezeBox.initialize({
size: {x: sizes[0], y: sizes[1]},
handler: 'iframe'
});
SqueezeBox.open(rooturl + type + "/new/");
});
$$("a[name=remove]").addEvent("click", function(evt) {
evt.stop();
if (objtable.selectedRows.length == 0) {
return;
}
var type = $("objects").get("name");
var selection = "";
objtable.selectedRows.each(function(item) {
if (selection != "") {
selection += ",";
}
selection += item.get("id");
});
new Confirmation(rooturl + type + "/delete/", "selection=" + selection,
gettext("Remove this selection?"), {
{% if deloptions %}checkboxes: { {% join deloptions %} }{% endif %}
});
});
});
</script>
{% endblock %}
{% block middletitle %}
{% block pagetitle %}{% endblock %}{% if domain %} ({% trans "for" %} {{ domain.name }}){% endif %}
+4 -2
View File
@@ -2,10 +2,11 @@
{% load i18n admin_extras libextras %}
{% block pagetitle %}{% trans "Domain aliases" %}{% endblock %}
{% block subcontent %}
<div id="objects" name="domaliases" rel="300 190">
{% if not domaliases %}
<div class="info">{% trans "No domain alias defined." %}</div>
{% else %}
<table>
<table id="objects_table">
<tr>
<th width="50px">{% trans "Actions" %}</th>
<th width="150px">{% trans "Name" %}</th>
@@ -13,7 +14,7 @@
<th width="75px">{% trans "Enabled" %}</th>
</tr>
{% for domalias in domaliases %}
<tr class="{% cycle 'odd' 'even' %}">
<tr class="{% cycle 'odd' 'even' %}" id="{{ domalias.id }}">
<td>{% domalias_actions user domalias.id %}</td>
<td>{{ domalias.name }}</td>
<td>{{ domalias.target.name }}</td>
@@ -22,4 +23,5 @@
{% endfor %}
</table>
{% endif %}
</div>
{% endblock %}
-9
View File
@@ -1,9 +0,0 @@
{% extends "nlayout.html" %}
{% block content %}
{% load i18n %}
<div id="body">
<div id="content">
{%block mainframe %}{% endblock %}
</div>
</div>
{% endblock %}
+24 -22
View File
@@ -2,26 +2,28 @@
{% load i18n admin_extras %}
{% block pagetitle %}{% trans "Available mailboxes" %}{% endblock %}
{% block subcontent %}
{% if not mailboxes %}
<div class="info">{% trans "No mailbox defined." %}</div>
{% else %}
<table>
<tr>
<th width="80px">{% trans "Actions" %}</th>
<th width="130px">{% trans "Name" %}</th>
<th width="170px">{% trans "Address" %}</th>
<th width="60px">{% trans "Quota" %}</th>
<th width="50px">{{ "Enabled"|gender:"f" }}</th>
</tr>
{% for mb in mailboxes %}
<tr class="{% cycle 'odd' 'even' %}">
<td>{% mailbox_actions user mb %}</td>
<td>{{ mb.name }}</td>
<td>{{ mb.address }}@{{ mb.domain.name }}</td>
<td>{{ mb.quota }} {% trans "MB" %}</td>
<td>{{ mb.user.is_active|yesno:_("yes,no") }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
<div id="objects" name="mailboxes" rel="300 320">
{% if not mailboxes %}
<div class="info">{% trans "No mailbox defined." %}</div>
{% else %}
<table id="objects_table">
<tr>
<th width="80px">{% trans "Actions" %}</th>
<th width="130px">{% trans "Name" %}</th>
<th width="170px">{% trans "Address" %}</th>
<th width="60px">{% trans "Quota" %}</th>
<th width="50px">{{ "Enabled"|gender:"f" }}</th>
</tr>
{% for mb in mailboxes %}
<tr class="{% cycle 'odd' 'even' %}" id="{{ mb.id }}">
<td>{% mailbox_actions user mb %}</td>
<td>{{ mb.name }}</td>
<td>{{ mb.address }}@{{ mb.domain.name }}</td>
<td>{{ mb.quota }} {% trans "MB" %}</td>
<td>{{ mb.user.is_active|yesno:_("yes,no") }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
</div>
{% endblock %}
+26 -24
View File
@@ -2,28 +2,30 @@
{% load i18n admin_extras %}
{% block pagetitle %}{% trans "Mailbox aliases" %}{% endblock %}
{% block subcontent %}
{% if not aliases %}
<div class="info">{% trans "No mailbox alias defined." %}</div>
{% else %}
<table>
<tr>
<th width="50px">{% trans "Actions" %}</th>
<th width="150px">{% trans "Address" %}</th>
<th width="200px">{% trans "Mailbox" %}</th>
<th width="75px">{% trans "Enabled" %}</th>
</tr>
{% for alias in aliases %}
<tr>
<td>{% mbalias_actions user alias %}
<td>{{ alias.full_address }}</td>
<td>
{% for mb in alias.mboxes.all %}
{{ mb.full_address }}<br/>
{% endfor %}
</td>
<td>{{ alias.enabled|yesno }}</td
</tr>
{% endfor %}
</table>
{% endif %}
<div id="objects" name="mbaliases" rel="300 260">
{% if not aliases %}
<div class="info">{% trans "No mailbox alias defined." %}</div>
{% else %}
<table id="objects_table">
<tr>
<th width="50px">{% trans "Actions" %}</th>
<th width="150px">{% trans "Address" %}</th>
<th width="200px">{% trans "Mailbox" %}</th>
<th width="75px">{% trans "Enabled" %}</th>
</tr>
{% for alias in aliases %}
<tr class="{% cycle 'odd' 'even' %}" id="{{ alias.id }}">
<td>{% mbalias_actions user alias %}
<td>{{ alias.full_address }}</td>
<td>
{% for mb in alias.mboxes.all %}
{{ mb.full_address }}<br/>
{% endfor %}
</td>
<td>{{ alias.enabled|yesno }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
</div>
{% endblock %}
+4
View File
@@ -1,5 +1,8 @@
{% load i18n %}
{% for entry in entries %}
{% if entry.separator %}
<li class="separator">&nbsp;</li>
{% else %}
{% if entry.menu %}
<li class="dropdown {{ entry.class }}{% if selection == entry.name %} selected{% endif %}">
<img src="{{ entry.img }}" border="0" />
@@ -32,5 +35,6 @@
{{ entry.label }}
</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
-35
View File
@@ -1,35 +0,0 @@
{% extends "layout_simple.html" %}
{% block html_head %}
<script type="text/javascript">
window.addEvent('domready', function(){
$("ok").addEvent("click", function(event) {
$("result").value = "ok";
parent.SqueezeBox.close();
});
$("cancel").addEvent("click", function(event) {
parent.SqueezeBox.close();
});
});
</script>
{% endblock %}
{% block content %}
{% load i18n %}
<div id="dlg-iconbox">
<img src="{{ MEDIA_URL }}pics/dialog-warning.png" alt="Warning" />
</div>
<div id="dlg-textbox">
<b>{{ msg }}</b><br/>
<p>
<input type="checkbox" name="keepdir" value="" />{% trans "Do not delete mailbox directory" %}
</p>
</div>
<div id="dlg-buttons">
<input type="button" name="ok" id="ok" value="Ok" />
<input type="button" id="cancel" value="Cancel" />
</div>
<input type="hidden" name="result" id="result" value="cancel" />
{% endblock %}
-1
View File
@@ -5,5 +5,4 @@ urlpatterns = patterns('modoboa.userprefs.views',
(r'^preferences/$', 'preferences'),
(r'^preferences/save/$', 'savepreferences'),
(r'^changepassword/$', 'changepassword'),
(r'^confirm/$', 'confirm'),
)
-10
View File
@@ -1,10 +1,6 @@
import copy
from django.shortcuts import get_object_or_404, render_to_response
from django.template.loader import render_to_string
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth.decorators \
import login_required
from django.utils import simplejson
@@ -77,9 +73,3 @@ def savepreferences(request):
ctx = getctx("ok")
return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
@login_required
def confirm(request):
return _render(request, 'userprefs/confirm.html', {
"msg" : request.GET["question"]
})