Files
modoboa/extensions/stats/main.py
T
tonio c01d6de7d8 fix: return receipts are now displayed correctly.
new: parameters module refactored. The API is more simple now, there is no need to provide a module name anymore, this last is automatically guessed. Also, a new 'label' field can be provide when declaring a new parameter. It will be used instead of the name.

new: email parsing refactored. My first attempt was really ugly. I did not really studied the various RFC describing how messages are formatted or what IMAP fetch queries can do. Now, I hope this new code will face better unknown types. At least, It will be simpler to update.
2010-09-17 09:23:35 +02:00

58 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
"""
Graphical statistics about emails traffic using RRDtool
This module provides support to retrieve statistics from postfix log :
sent, received, bounced, rejected
"""
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
from django.conf.urls.defaults import *
from modoboa.lib import events, parameters, static_url
def infos():
return {
"name" : "Statistics",
"version" : "1.0",
"description" : _("Graphical statistics about emails traffic using RRDtool")
}
def init():
events.register("AdminMenuDisplay", menu)
parameters.register_admin("LOGFILE", type="string",
deflt="/var/log/mail.log",
help=_("Path to log file used to collect statistics"))
parameters.register_admin("RRD_ROOTDIR", type="string",
deflt="/tmp/modoboa",
help=_("Path to directory where RRD files are stored"))
parameters.register_admin("IMG_ROOTDIR", type="string",
deflt="/tmp/modoboa",
help=_("Path to directory where PNG files are stored"))
def destroy():
events.unregister("AdminMenuDisplay", menu)
def urls():
return (r'^modoboa/stats/',
include('modoboa.extensions.stats.urls'))
def menu(**kwargs):
if kwargs["target"] == "admin_menu_bar":
domain_id = kwargs['domain']
return [
{"label" : _("Statistics"),
"name" : "stats",
"url" : reverse('domindex', args=[domain_id]),
"img" : static_url("pics/graph.png")}
]
if kwargs["target"] == "admin_menu_box":
return [
{"name" : "stats",
"label" : _("Statistics"),
"url" : reverse('fullindex'),
"img" : static_url("pics/graph.png")}
]
return []