mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
+7
-50
@@ -181,9 +181,8 @@ class User(DUser):
|
||||
|
||||
@property
|
||||
def tags(self):
|
||||
ret = '<span class="label">%s</span>' % _("account")
|
||||
ret += ' <span class="label label-info">%s</span>' % self.group
|
||||
return ret
|
||||
return [{"name" : "account", "label" : _("account"), "type" : "idt"},
|
||||
{"name" : self.group, "label" : self.group, "type" : "grp", "color" : "info"}]
|
||||
|
||||
@property
|
||||
def has_mailbox(self):
|
||||
@@ -265,7 +264,7 @@ class User(DUser):
|
||||
aliases = []
|
||||
if not idtfilter or ("alias" in idtfilter
|
||||
or "forward" in idtfilter
|
||||
or "distribution list" in idtfilter):
|
||||
or "dlist" in idtfilter):
|
||||
alct = get_content_type(Alias)
|
||||
ids = self.objectaccess_set.filter(content_type=alct) \
|
||||
.values_list('object_id', flat=True)
|
||||
@@ -772,51 +771,6 @@ class Mailbox(DatesAware):
|
||||
else:
|
||||
self.quota = value
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.create_dir():
|
||||
raise AdminError(_("Failed to initialise mailbox, check permissions"))
|
||||
try:
|
||||
user = getattr(self, "user")
|
||||
except User.DoesNotExist:
|
||||
user = User()
|
||||
user.email = "%s@%s" % (self.address, self.domain.name)
|
||||
if kwargs.has_key("username"):
|
||||
user.username = kwargs["username"]
|
||||
else:
|
||||
user.username = user.email
|
||||
if kwargs.has_key("enabled"):
|
||||
user.is_active = kwargs["enabled"]
|
||||
if kwargs.has_key("name"):
|
||||
try:
|
||||
fname, lname = kwargs["name"].split()
|
||||
except ValueError:
|
||||
fname = kwargs["name"]
|
||||
lname = ""
|
||||
user.first_name = fname
|
||||
user.last_name = lname
|
||||
if kwargs.has_key("password"):
|
||||
user.set_password(kwargs["password"])
|
||||
try:
|
||||
user.save()
|
||||
except IntegrityError, e:
|
||||
raise AdminError(_("Account '%s' already exists" % user.username))
|
||||
self.user = user
|
||||
|
||||
if user.groups.count() == 0:
|
||||
user.groups.add(Group.objects.get(name="SimpleUsers"))
|
||||
user.save()
|
||||
|
||||
self.set_ownership()
|
||||
if kwargs.has_key("quota"):
|
||||
self.set_quota(kwargs["quota"])
|
||||
|
||||
for kw in ["username", "name", "enabled", "password", "quota"]:
|
||||
try:
|
||||
del kwargs[kw]
|
||||
except KeyError:
|
||||
pass
|
||||
super(Mailbox, self).save(*args, **kwargs)
|
||||
|
||||
def save_from_user(self, localpart, domain, user, quota=None, owner=None):
|
||||
"""Simple save method called for automatic creations
|
||||
|
||||
@@ -901,12 +855,15 @@ class Alias(DatesAware):
|
||||
def tags(self):
|
||||
cpt = self.get_recipients_count()
|
||||
if cpt > 1:
|
||||
name = "dlist"
|
||||
label = _("distribution list")
|
||||
elif self.extmboxes != "":
|
||||
name = "forward"
|
||||
label = _("forward")
|
||||
else:
|
||||
name = "alias"
|
||||
label = _("alias")
|
||||
return '<span class="label">%s</span>' % label
|
||||
return [{"name" : name, "label" : label, "type" : "idt"}]
|
||||
|
||||
def save(self, int_rcpts, ext_rcpts, *args, **kwargs):
|
||||
if len(ext_rcpts):
|
||||
|
||||
@@ -159,6 +159,8 @@ Identities.prototype = {
|
||||
list_cb: function(data) {
|
||||
Admin.prototype.list_cb.call(this, data);
|
||||
|
||||
$("a.filter").click($.proxy(this.filter_by_tag, this));
|
||||
|
||||
$("a[name=delaccount]").confirm({
|
||||
question: gettext("Delete this account?"),
|
||||
checkboxes: {keepdir: gettext("Do not delete mailbox directory")},
|
||||
@@ -178,6 +180,22 @@ Identities.prototype = {
|
||||
});
|
||||
},
|
||||
|
||||
filter_by_tag: function(e) {
|
||||
var $link = $(e.target);
|
||||
e.preventDefault();
|
||||
|
||||
if ($link.hasClass("idt")) {
|
||||
this.navobj.setparam("idtfilter", $link.attr("name")).update();
|
||||
return;
|
||||
}
|
||||
if ($link.hasClass("grp")) {
|
||||
this.navobj
|
||||
.setparam("idtfilter", "account")
|
||||
.setparam("grpfilter", $link.attr("name"))
|
||||
.update();
|
||||
}
|
||||
},
|
||||
|
||||
simpleuser_mode: function() {
|
||||
$("#id_username").autocompleter({
|
||||
from_character: "@",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% load i18n admin_extras %}
|
||||
{% load i18n admin_extras libextras %}
|
||||
<table id="{{ tableid }}" class="table {{ styles }}">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -13,7 +13,7 @@
|
||||
<tr id="{{ ident.id }}" class="{% if not ident.enabled %}muted{% endif %}" name="{{ forloop.counter }}">
|
||||
<td name="identity">{% identity_modify_link ident %}</td>
|
||||
<td name="name_or_rcpt">{{ ident.name_or_rcpt }}</td>
|
||||
<td name="tags">{{ ident.tags|safe }}</td>
|
||||
<td name="tags">{% render_tags ident.tags %}</td>
|
||||
<td name="actions">{% identity_actions user ident %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -208,3 +208,13 @@ def connected_users(parser, token):
|
||||
except ValueError:
|
||||
raise template.TemplateSyntaxError('connected_users usage: {% connected_users as users %}')
|
||||
return ConnectedUsers(varname)
|
||||
|
||||
@register.simple_tag
|
||||
def render_tags(tags):
|
||||
t = Template("""{% for tag in tags %}
|
||||
<span class="label{% if tag.color %} label-{{ tag.color }}{% endif %}">
|
||||
<a href="#" class="filter {{ tag.type }}" name="{{ tag.name }}">{{ tag.label }}</a>
|
||||
</span>
|
||||
{% endfor %}
|
||||
""")
|
||||
return t.render(Context({"tags" : tags}))
|
||||
|
||||
@@ -91,4 +91,9 @@ body {
|
||||
.help-block {
|
||||
color: #999999;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.label a {
|
||||
color: #FFFFFF;
|
||||
text-decoration: none;
|
||||
}
|
||||
Reference in New Issue
Block a user