mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-05 12:34:08 +01:00
Ticket #52
From now, users can store their own "preferences" inside MailNG.
This commit is contained in:
@@ -55,8 +55,8 @@ tpl = {'traffic':traffic_avg_template,
|
||||
|
||||
class Grapher(object):
|
||||
def __init__(self):
|
||||
self.rrd_rootdir = parameters.get("stats", "RRD_ROOTDIR")
|
||||
self.img_rootdir = parameters.get("stats", "IMG_ROOTDIR")
|
||||
self.rrd_rootdir = parameters.get_admin("stats", "RRD_ROOTDIR")
|
||||
self.img_rootdir = parameters.get_admin("stats", "IMG_ROOTDIR")
|
||||
|
||||
def process(self, target, suffix, start, end, tpl=traffic_avg_template):
|
||||
rrdfile = "%s/%s.rrd" % (self.rrd_rootdir, target)
|
||||
|
||||
@@ -276,8 +276,8 @@ class LogParser(object):
|
||||
G.make_defaults(dom, tpl=grapher.size_avg_template)
|
||||
|
||||
if __name__ == "__main__":
|
||||
log_file = parameters.get("stats", "LOGFILE")
|
||||
rrd_rootdir = parameters.get("stats", "RRD_ROOTDIR")
|
||||
log_file = parameters.get_admin("stats", "LOGFILE")
|
||||
rrd_rootdir = parameters.get_admin("stats", "RRD_ROOTDIR")
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-l","--logFile", default=log_file,
|
||||
|
||||
@@ -21,12 +21,15 @@ def infos():
|
||||
|
||||
def init():
|
||||
events.register("AdminMenuDisplay", menu)
|
||||
parameters.register("stats", "LOGFILE", "string", "/var/log/mail.log",
|
||||
help=_("Path to log file used to collect statistics"))
|
||||
parameters.register("stats", "RRD_ROOTDIR", "string", "/tmp/mailng",
|
||||
help=_("Path to directory where RRD files are stored"))
|
||||
parameters.register("stats", "IMG_ROOTDIR", "string", "/tmp/mailng",
|
||||
help=_("Path to directory where PNG files are stored"))
|
||||
parameters.register_admin("stats", "LOGFILE", type="string",
|
||||
deflt="/var/log/mail.log",
|
||||
help=_("Path to log file used to collect statistics"))
|
||||
parameters.register_admin("stats", "RRD_ROOTDIR", type="string",
|
||||
deflt="/tmp/mailng",
|
||||
help=_("Path to directory where RRD files are stored"))
|
||||
parameters.register_admin("stats", "IMG_ROOTDIR", type="string",
|
||||
deflt="/tmp/mailng",
|
||||
help=_("Path to directory where PNG files are stored"))
|
||||
|
||||
def destroy():
|
||||
events.unregister("AdminMenuDisplay", menu)
|
||||
|
||||
@@ -53,7 +53,7 @@ def graph_display(request,dom_id,graph_t=graph_types):
|
||||
"page" : "Domain statistics", "graph" : graph_nature,
|
||||
"domain": domain, "domains" : domains, "messages" : errors,
|
||||
"types" : graph_type, "tmp_path" : tmp_path,
|
||||
"img_rootdir" : parameters.get("stats", "IMG_ROOTDIR")})
|
||||
"img_rootdir" : parameters.get_admin("stats", "IMG_ROOTDIR")})
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
@@ -75,7 +75,7 @@ def adminindex(request):
|
||||
"graphs" : graph_list,
|
||||
"periods" : ["day", "week", "month", "year","Custom"],
|
||||
"period" : period, "cal" : CH_print,
|
||||
"img_rootdir" : parameters.get("stats", "IMG_ROOTDIR")})
|
||||
"img_rootdir" : parameters.get_admin("stats", "IMG_ROOTDIR")})
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
@@ -109,7 +109,7 @@ def custom_period(request):
|
||||
"start" : start_ref,
|
||||
"end" : end_ref,
|
||||
"messages" : ["Custom period not selected"],
|
||||
"img_rootdir" : parameters.get("stats", "IMG_ROOTDIR")})
|
||||
"img_rootdir" : parameters.get_admin("stats", "IMG_ROOTDIR")})
|
||||
|
||||
period_name = "%s_%s" %(start.replace('/',''),end.replace('/',''))
|
||||
G = Grapher()
|
||||
@@ -130,7 +130,7 @@ def custom_period(request):
|
||||
"start" : start_ref,
|
||||
"end" : end_ref,
|
||||
"messages" : None,
|
||||
"img_rootdir" : parameters.get("stats", "IMG_ROOTDIR")})
|
||||
"img_rootdir" : parameters.get_admin("stats", "IMG_ROOTDIR")})
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -147,4 +147,4 @@ def index(request, dom_id=None):
|
||||
"graphs" : graph_list,
|
||||
"periods" : ["day", "week", "month", "year","Custom"],
|
||||
"period" : period,
|
||||
"img_rootdir" : parameters.get("stats", "IMG_ROOTDIR")})
|
||||
"img_rootdir" : parameters.get_admin("stats", "IMG_ROOTDIR")})
|
||||
|
||||
Reference in New Issue
Block a user