This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make the stats report menu a bit more generic
- Loading branch information
Showing
5 changed files
with
63 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,29 @@ | ||
import jinja2 | ||
|
||
from jingo import register | ||
from jingo import env, register | ||
from tower import ugettext as _ | ||
from access import acl | ||
from addons.models import Addon | ||
from amo.urlresolvers import reverse | ||
|
||
|
||
@register.inclusion_tag('stats/report_menu.html') | ||
@register.function | ||
@jinja2.contextfunction | ||
def report_menu(context, request, addon, report): | ||
|
||
report_tree = [ | ||
{ | ||
'name': 'overview', | ||
'url': '', | ||
'title': _('Overview'), | ||
}, | ||
{ | ||
'name': 'downloads', | ||
'url': 'downloads/', | ||
'title': _('Downloads'), | ||
'children': [ | ||
{ | ||
'name': 'sources', | ||
'url': 'downloads/sources/', | ||
'title': _('by Source'), | ||
}, | ||
] | ||
}, | ||
{ | ||
'name': 'usage', | ||
'url': 'usage/', | ||
'title': _('Daily Users'), | ||
'children': [ | ||
{ | ||
'name': 'versions', | ||
'url': 'usage/versions/', | ||
'title': _('by Add-on Version') | ||
}, | ||
{ | ||
'name': 'apps', | ||
'url': 'usage/applications/', | ||
'title': _('by Application') | ||
}, | ||
{ | ||
'name': 'locales', | ||
'url': 'usage/languages/', | ||
'title': _('by Language') | ||
}, | ||
{ | ||
'name': 'os', | ||
'url': 'usage/os/', | ||
'title': _('by Platform') | ||
}, | ||
{ | ||
'name': 'statuses', | ||
'url': 'usage/status/', | ||
'title': _('by Add-on Status') | ||
}, | ||
] | ||
}, | ||
] | ||
|
||
if (request.user.is_authenticated() and ( | ||
acl.action_allowed(request, 'Stats', 'View') or | ||
addon.has_author(request.amo_user))): | ||
report_tree.append({ | ||
'name': 'contributions', | ||
'url': 'contributions/', | ||
'title': _('Contributions') | ||
}) | ||
|
||
base_url = reverse('stats.overview', args=[addon.slug]) | ||
|
||
def report_menu(context, request, report, obj=None): | ||
"""Reports Menu. navigation for the various statistic reports.""" | ||
c = {'report': report, | ||
'base_url': base_url, | ||
'report_tree': report_tree} | ||
return c | ||
if obj: | ||
if isinstance(obj, Addon): | ||
has_privs = False | ||
if (request.user.is_authenticated() and ( | ||
acl.action_allowed(request, 'Stats', 'View') or | ||
addon.has_author(request.amo_user))): | ||
has_privs = True | ||
t = env.get_template('stats/addon_report_menu.html') | ||
c = { | ||
'addon': obj, | ||
'has_privs': has_privs | ||
} | ||
return jinja2.Markup(t.render(c)) | ||
|
||
t = env.get_template('stats/global_report_menu.html') | ||
return jinja2.Markup(t.render()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<nav id="side-nav" class="report-menu"> | ||
<ul> | ||
<li data-report="overview" data-layout="overview"> | ||
<a href="{{ url('stats.overview', addon.slug) }}">{{ _('Overview') }}</a> | ||
</li> | ||
<li data-report="downloads"> | ||
<a href="{{ url('stats.downloads', addon.slug) }}">{{ _('Downloads') }}</a> | ||
</li> | ||
<ul> | ||
<li data-report="sources"> | ||
<a href="{{ url('stats.sources', addon.slug) }}/">{{ _('by Source') }}</a> | ||
</li> | ||
</ul> | ||
<li data-report="usage"> | ||
<a href="{{ url('stats.usage', addon.slug) }}">{{ _('Daily Users') }}</a> | ||
</li> | ||
<ul> | ||
<li data-report="versions"> | ||
<a href="{{ url('stats.versions', addon.slug) }}">{{ _('by Add-on Version') }}</a> | ||
</li> | ||
<li data-report="apps"> | ||
<a href="{{ url('stats.apps', addon.slug) }}">{{ _('by Application') }}</a> | ||
</li> | ||
<li data-report="locales"> | ||
<a href="{{ url('stats.locales', addon.slug) }}">{{ _('by Language') }}</a> | ||
</li> | ||
<li data-report="os"> | ||
<a href="{{ url('stats.os', addon.slug) }}">{{ _('by Platform') }}</a> | ||
</li> | ||
<li data-report="statuses"> | ||
<a href="{{ url('stats.statuses', addon.slug) }}">{{ _('by Add-on Status') }}</a> | ||
</li> | ||
</ul> | ||
{% if has_privs %} | ||
<li data-report="contributions"> | ||
<a href="{{ url('stats.contributions', addon.slug) }}">{{ _('Contributions') }}</a> | ||
</li> | ||
{% endif %} | ||
</ul> | ||
</nav> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters