Files
modoboa/extensions/stats/__init__.py
T
Antoine Nguyen 86f855220a Refactored extension API
* Modoboa extensions must now declare themselves
* Now using django 1.3 *staticfiles* module
* Better distinction between *static* content and *media* content

see #197
2012-05-22 11:40:50 +02:00

50 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 _, ugettext_lazy
from django.conf.urls.defaults import *
from modoboa.lib import events, parameters
from modoboa.extensions import ModoExtension, exts_pool
class Stats(ModoExtension):
name = "stats"
label = "Statistics"
version = "1.0"
description = ugettext_lazy("Graphical statistics about emails traffic using RRDtool")
def load(self):
parameters.register_admin("LOGFILE", type="string",
deflt="/var/log/mail.log",
help=ugettext_lazy("Path to log file used to collect statistics"))
parameters.register_admin("RRD_ROOTDIR", type="string",
deflt="/tmp/modoboa",
help=ugettext_lazy("Path to directory where RRD files are stored"))
parameters.register_admin("IMG_ROOTDIR", type="string",
deflt="/tmp/modoboa",
help=ugettext_lazy("Path to directory where PNG files are stored"))
parameters.register_admin("GRAPHS_LOCATION", type="string",
deflt="graphs",
help=ugettext_lazy("Graphics location (to build URLs)"))
def destroy(self):
events.unregister("AdminMenuDisplay", menu)
exts_pool.register_extension(Stats)
@events.observe("UserMenuDisplay")
def menu(target, user):
if target != "top_menu" or user.group == "SimpleUsers":
return []
return [
{"name" : "stats",
"label" : _("Statistics"),
"url" : reverse('fullindex')}
]