mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -36,7 +36,7 @@ How to upgrade
|
||||
|
||||
0.5 -> 0.6 : No modifications have been made to the core SQL schema so you
|
||||
just have to decompress the new tarball at the same location than your
|
||||
current installation. Once done, go to MailNG repository and run::
|
||||
current installation. Once done, go to MailNG directory and run::
|
||||
|
||||
python manage.py syncdb
|
||||
|
||||
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import MySQLdb
|
||||
|
||||
host = "localhost"
|
||||
dbname = "amavis"
|
||||
user = "root"
|
||||
password = "toto"
|
||||
|
||||
max_msg_days = "14"
|
||||
|
||||
if __name__ == "__main__":
|
||||
conn = MySQLdb.connect(host=host, db=dbname, user=user, passwd=password)
|
||||
cursor = conn.cursor()
|
||||
|
||||
print "Deleting messages older than %s days..." % max_msg_days
|
||||
cursor.execute("""
|
||||
DELETE FROM msgs WHERE time_num < UNIX_TIMESTAMP()-%s*24*3600;
|
||||
""" % max_msg_days)
|
||||
|
||||
conn.commit()
|
||||
|
||||
print "Deleting unreferenced e-mail addresses..."
|
||||
cursor.execute("""
|
||||
DELETE FROM maddr
|
||||
WHERE NOT EXISTS (SELECT 1 FROM msgs WHERE sid=id)
|
||||
AND NOT EXISTS (SELECT 1 FROM msgrcpt WHERE rid=id);
|
||||
""")
|
||||
conn.commit()
|
||||
|
||||
print "Optimizing tables..."
|
||||
cursor.execute("""
|
||||
OPTIMIZE TABLE msgs, msgrcpt, quarantine, maddr;
|
||||
""")
|
||||
conn.commit()
|
||||
|
||||
conn.close()
|
||||
|
||||
print "Done."
|
||||
@@ -48,13 +48,16 @@ def menu(**kwargs):
|
||||
"img" : "/static/pics/quarantine.png"}
|
||||
]
|
||||
|
||||
@login_required
|
||||
def index(request, message=None):
|
||||
if not request.user.is_superuser:
|
||||
mb = Mailbox.objects.get(user=request.user.id)
|
||||
filter = "AND maddr.email='%s'" % mb.full_address
|
||||
else:
|
||||
filter = ""
|
||||
def lookup(*args):
|
||||
filter = ""
|
||||
for a in args:
|
||||
if not a:
|
||||
continue
|
||||
if a[0] == "&":
|
||||
filter += " AND "
|
||||
else:
|
||||
filter += " OR "
|
||||
filter += a[1:]
|
||||
conn = db.getconnection("amavis_quarantine")
|
||||
status, cursor = db.execute(conn, """
|
||||
SELECT msgs.from_addr, maddr.email, msgs.subject, msgs.content, quarantine.mail_id,
|
||||
@@ -66,7 +69,10 @@ AND msgrcpt.mail_id=msgs.mail_id
|
||||
AND quarantine.chunk_ind=1
|
||||
%s
|
||||
ORDER BY msgs.time_num DESC
|
||||
""" % filter)
|
||||
""" % filter)
|
||||
return cursor
|
||||
|
||||
def render_listing(request, cursor):
|
||||
emails = []
|
||||
rows = cursor.fetchall()
|
||||
for row in rows:
|
||||
@@ -81,9 +87,23 @@ ORDER BY msgs.time_num DESC
|
||||
except ValueError:
|
||||
pagenum = 1
|
||||
page = paginator.page(pagenum)
|
||||
return render_to_string("amavis_quarantine/listing.html", {
|
||||
"count" : len(rows),
|
||||
"emails" : page, "current_page" : pagenum,
|
||||
"last_page" : paginator._get_num_pages()
|
||||
})
|
||||
|
||||
@login_required
|
||||
def index(request, message=None):
|
||||
if not request.user.is_superuser:
|
||||
mb = Mailbox.objects.get(user=request.user.id)
|
||||
filter = "&maddr.email='%s'" % mb.full_address
|
||||
else:
|
||||
filter = None
|
||||
cursor = lookup(filter)
|
||||
|
||||
return _render(request, 'amavis_quarantine/index.html', {
|
||||
"count" : len(rows), "emails" : page,
|
||||
"current_page" : pagenum, "last_page" : paginator._get_num_pages()
|
||||
"content" : render_listing(request, cursor)
|
||||
})
|
||||
|
||||
@login_required
|
||||
@@ -269,3 +289,13 @@ def process(request):
|
||||
ctx = _ctx_ok(reverse(index) + "?page=%s" % pagenum)
|
||||
return HttpResponse(simplejson.dumps(ctx),
|
||||
mimetype="application/json")
|
||||
|
||||
@login_required
|
||||
def search(request):
|
||||
if not request.GET.has_key("pattern"):
|
||||
return
|
||||
filter = "&msgs.from_addr LIKE '%%%s%%'" % request.GET["pattern"]
|
||||
cursor = lookup(filter)
|
||||
ctx = {"status" : "ok", "content" : render_listing(request, cursor)}
|
||||
return HttpResponse(simplejson.dumps(ctx),
|
||||
mimetype="application/json")
|
||||
|
||||
@@ -40,6 +40,11 @@ td {
|
||||
font-size: smaller;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
#searchbox {
|
||||
float: right;
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -96,6 +101,23 @@ window.addEvent("domready", function() {
|
||||
toggleSelection(false);
|
||||
}
|
||||
});
|
||||
|
||||
{% url extensions.amavis_quarantine.main.search as s_url %}
|
||||
$("searchfield").addEvent("change", function(event) {
|
||||
new Request.JSON({url: "{{ s_url }}", onSuccess: function(resp) {
|
||||
$("listing").set("html", resp.content);
|
||||
}}).get({"pattern" : $("searchfield").value});
|
||||
});
|
||||
|
||||
$("searchfield").addEvent("click", function(event) {
|
||||
$("searchfield").select();
|
||||
});
|
||||
|
||||
$("searchfield").addEvent("blur", function(event) {
|
||||
if ($("searchfield").value == "") {
|
||||
$("searchfield").set("value", "{% trans "Search..." %}");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -110,6 +132,9 @@ window.addEvent("domready", function() {
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div id="searchbox">
|
||||
<input type="text" name="searchfield" id="searchfield" value="{% trans "Search..." %}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menubar" class="menu2">
|
||||
@@ -121,50 +146,7 @@ window.addEvent("domready", function() {
|
||||
<input type="hidden" name="pagenum" id="pagenum" value="{{ current_page }}" />
|
||||
|
||||
<div id="listing">
|
||||
<div id="listheader">
|
||||
<div id="counter">
|
||||
Messages {{ emails.start_index }} à {{ emails.end_index }} sur {{ count }}
|
||||
</div>
|
||||
<div id="navbar">
|
||||
{% if emails.has_previous %}
|
||||
<a href="?page=1">
|
||||
<img src="/static/pics/first.png" border="0" title="{% trans "First" %}" />
|
||||
</a>
|
||||
<a href="?page={{ emails.previous_page_number }}">
|
||||
<img src="/static/pics/back.png" border="0" title="{% trans "Previous" %}" />
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if emails.has_next %}
|
||||
<a href="?page={{ emails.next_page_number }}">
|
||||
<img src="/static/pics/next.png" border="0" title="{% trans "Next" %}" />
|
||||
</a>
|
||||
<a href="?page={{ last_page }}">
|
||||
<img src="/static/pics/last.png" border="0" title="{% trans "Last" %}" />
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th><input type="checkbox" name="selectall" id="selectall" /></th>
|
||||
<th>{% trans "Type" %}</th>
|
||||
<th width="150px">{% trans "From" %}</th>
|
||||
<th>{% trans "Subject" %}</th>
|
||||
<th width="100px">{% trans "Date" %}</th>
|
||||
</tr>
|
||||
{% for m in emails.object_list %}
|
||||
<tr class="{% cycle 'odd' 'even' %}">
|
||||
<td><input type="checkbox" name="selection" id="selection"
|
||||
value="{{ m.mailid }}" /></td>
|
||||
<td>{{ m.type }}</td>
|
||||
<td>{{ m.from }}</td>
|
||||
{% url extensions.amavis_quarantine.main.viewmail m.mailid as view_url %}
|
||||
<td><a href="{{ view_url }}?page={{ current_page }}">{{ m.subject }}</a></td>
|
||||
<td>{{ m.time }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{{ content }}
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,46 @@
|
||||
{% load i18n %}
|
||||
|
||||
<div id="listheader">
|
||||
<div id="counter">
|
||||
Messages {{ emails.start_index }} à {{ emails.end_index }} sur {{ count }}
|
||||
</div>
|
||||
<div id="navbar">
|
||||
{% if emails.has_previous %}
|
||||
<a href="?page=1">
|
||||
<img src="/static/pics/first.png" border="0" title="{% trans "First" %}" />
|
||||
</a>
|
||||
<a href="?page={{ emails.previous_page_number }}">
|
||||
<img src="/static/pics/back.png" border="0" title="{% trans "Previous" %}" />
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if emails.has_next %}
|
||||
<a href="?page={{ emails.next_page_number }}">
|
||||
<img src="/static/pics/next.png" border="0" title="{% trans "Next" %}" />
|
||||
</a>
|
||||
<a href="?page={{ last_page }}">
|
||||
<img src="/static/pics/last.png" border="0" title="{% trans "Last" %}" />
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th><input type="checkbox" name="selectall" id="selectall" /></th>
|
||||
<th>{% trans "Type" %}</th>
|
||||
<th width="150px">{% trans "From" %}</th>
|
||||
<th>{% trans "Subject" %}</th>
|
||||
<th width="100px">{% trans "Date" %}</th>
|
||||
</tr>
|
||||
{% for m in emails.object_list %}
|
||||
<tr class="{% cycle 'odd' 'even' %}">
|
||||
<td><input type="checkbox" name="selection" id="selection"
|
||||
value="{{ m.mailid }}" /></td>
|
||||
<td>{{ m.type }}</td>
|
||||
<td>{{ m.from }}</td>
|
||||
{% url extensions.amavis_quarantine.main.viewmail m.mailid as view_url %}
|
||||
<td><a href="{{ view_url }}?page={{ current_page }}">{{ m.subject }}</a></td>
|
||||
<td>{{ m.time }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
@@ -8,4 +8,5 @@ urlpatterns = patterns('mailng.extensions.amavis_quarantine.main',
|
||||
(r'^process/$', 'process'),
|
||||
(r'^delete/(?P<mail_id>[\w\-\+]+)/$', 'delete'),
|
||||
(r'^release/(?P<mail_id>[\w\-\+]+)/$', 'release'),
|
||||
(r'^search/', 'search'),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user