From: Alex Sadleir Date: Mon, 21 Oct 2013 08:49:02 +0000 Subject: add user access list X-Git-Url: https://maxious.lambdacomplex.org/git/?p=ckanext-dga-stats.git&a=commitdiff&h=61a09cdc43b1c2673cf0471f92551fe4c469d7e3 --- add user access list --- --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,36 @@ -*.pyc +*.py[cod] +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + --- a/ckanext/dga_stats/controller.py +++ b/ckanext/dga_stats/controller.py @@ -17,6 +17,7 @@ c.summary_stats = stats.summary_stats() c.activity_counts = stats.activity_counts() c.by_org = stats.by_org() + c.user_access_list = stats.user_access_list() c.new_packages_by_week = rev_stats.get_by_week('new_packages') c.deleted_packages_by_week = rev_stats.get_by_week('deleted_packages') c.num_packages_by_week = rev_stats.get_num_packages_by_week() --- a/ckanext/dga_stats/stats.py +++ b/ckanext/dga_stats/stats.py @@ -122,7 +122,6 @@ @classmethod def summary_stats(cls): connection = model.Session.connection() -# select name,role from user_object_role inner join \"user\" on user_object_role.user_id = \"user\".id where name not in ('logged_in','visitor') group by name,role" res = connection.execute("SELECT 'Total Organisations', count(*) from \"group\" where type = 'organization' and state = 'active' union \ select 'Total Datasets', count(*) from package where state='active' or state='draft' or state='draft-complete' union \ @@ -134,6 +133,12 @@ def activity_counts(cls): connection = model.Session.connection() res = connection.execute("select to_char(timestamp, 'YYYY-MM') as month,activity_type, count(*) from activity group by month, activity_type order by month;").fetchall(); + return res + + @classmethod + def user_access_list(cls): + connection = model.Session.connection() + res = connection.execute("select name,sysadmin,role from user_object_role right outer join \"user\" on user_object_role.user_id = \"user\".id where name not in ('logged_in','visitor') group by name,sysadmin,role order by sysadmin desc, role asc;").fetchall(); return res --- a/ckanext/dga_stats/templates/ckanext/stats/index.html +++ b/ckanext/dga_stats/templates/ckanext/stats/index.html @@ -54,7 +54,33 @@

{{ _('No groups') }}

{% endif %} - +{% if h.check_access('sysadmin') %} +
+

{{ _('User Access List') }}

+ {% if c.user_access_list %} + + + + + + + + + + {% for username,sysadmin,role in c.user_access_list %} + + + + + + {% endfor %} + +
{{ _('Username') }}{{ _('Sysadmin') }}{{ _('Organisational Role') }}
{{ username }}{{ sysadmin }}{{ role }}
+ {% else %} +

{{ _('No groups') }}

+ {% endif %} +
+{% endif %}

{{ _('Total number of Datasets') }}

@@ -254,9 +280,12 @@

{{ _('Statistics Menu') }}