Added a new parameter to specify where the graphics can be found.

fixes #66
This commit is contained in:
Antoine Nguyen
2012-04-12 15:19:54 +02:00
parent c6dbb5f7a7
commit b376c6f55f
3 changed files with 7 additions and 5 deletions
+3
View File
@@ -31,6 +31,9 @@ def load():
parameters.register_admin("IMG_ROOTDIR", type="string",
deflt="/tmp/modoboa",
help=_("Path to directory where PNG files are stored"))
parameters.register_admin("GRAPHS_LOCATION", type="string",
deflt="graphs",
help=_("Graphics location (to build URLs)"))
def destroy():
events.unregister("AdminMenuDisplay", menu)
+1 -1
View File
@@ -4,6 +4,6 @@
{% endif %}
{% for elems in graphs %}
<h3>{% trans elems.label %}</h3>
<p><img src="{{ MEDIA_URL }}stats/{{ elems.name }}_{{ domain }}_AVERAGE_{% ifequal period 'custom' %}{{ period_name }}{% else %}{{ period }}{% endifequal %}.png"
<p><img src="{{ MEDIA_URL }}{{ graphs_loc }}/{{ elems.name }}_{{ domain }}_AVERAGE_{% ifequal period 'custom' %}{{ period_name }}{% else %}{{ period }}{% endifequal %}.png"
alt="{% trans 'No statistics available' %}" /></p>
{% endfor %}
+3 -4
View File
@@ -32,12 +32,10 @@ def index(request):
domains = request.user.get_domains()
return _render(request, 'stats/index.html', {
"domains" : domains,
"graphs" : graph_list,
"periods" : periods,
"period" : period,
"selection" : "stats",
"domid" : domid
"selection" : "stats"
})
@login_required
@@ -47,7 +45,8 @@ def graphs(request):
if not view:
raise ModoboaException(_("Invalid request"))
period = request.GET.get("period", "day")
tplvars = dict(graphs=graph_list, period=period)
tplvars = dict(graphs=graph_list, period=period,
graphs_loc=parameters.get_admin("GRAPHS_LOCATION"))
if view == "global":
if not request.user.is_superuser:
raise PermDeniedError(_("you're not allowed to see those statistics"))