changeset 2668:f649d7a3b3cd

Added Userwise ACL Report view Added userwise ACL report view for the admin to view ACL permissions any user has with respect to all the items in the wiki. There are links to modify view of the items from the report view itself in case the admin wishes to make any modifications.
author Ajitesh Gupta <ajgupta93@gmail.com>
date Sat, 19 Jul 2014 14:30:01 +0530
parents ccb13ba1308e
children 7798855349f6
files MoinMoin/apps/admin/templates/admin/user_acl_report.html MoinMoin/apps/admin/templates/admin/userbrowser.html MoinMoin/apps/admin/views.py MoinMoin/templates/base.html
diffstat 4 files changed, 93 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/apps/admin/templates/admin/user_acl_report.html	Sat Jul 19 14:30:01 2014 +0530
@@ -0,0 +1,30 @@
+{% extends theme("layout.html") %}
+{% import "utils.html" as utils %}
+{% block content %}
+    <h1>{{ _("User ACL Report") }}</h1>
+    <h2>{{ _("User Names") }}: {{ user_names|join(', ') }}</h2>
+    <table class="table table-hover tablesorter tablesorter-default moin-sortable" data-sortlist="[[0,0],[1,0]]">
+        <thead>
+            <tr>
+                <th>{{ _("Item Names") }}</th>
+                <th>{{ _("read") }}</th>
+                <th>{{ _("write") }}</th>
+                <th>{{ _("create") }}</th>
+                <th>{{ _("destroy") }}</th>
+                <th>{{ _("admin") }}</th>
+            </tr>
+        </thead>
+        <tbody>
+            {% for item in itemwise_acl %}
+                <tr>
+                    <td><a href="{{ url_for('frontend.modify_item', item_name=item['fqname']) }}">{% if item['name'] %}{{ item['name']|join(', ') }}{% else %}Item Id: {{ item['itemid'] }}{% endif %}</a></td>
+                    <td>{% if item['read'] %}{{ _("read") }}{% endif %}</td>
+                    <td>{% if item['write'] %}{{ _("write") }}{% endif %}</td>
+                    <td>{% if item['create'] %}{{ _("create") }}{% endif %}</td>
+                    <td>{% if item['destroy'] %}{{ _("destroy") }}{% endif %}</td>
+                    <td>{% if item['admin'] %}{{ _("admin") }}{% endif %}</td>
+                </tr>
+            {% endfor %}
+        </tbody>
+    </table>
+{% endblock %}
--- a/MoinMoin/apps/admin/templates/admin/userbrowser.html	Sat Jul 19 14:24:28 2014 +0530
+++ b/MoinMoin/apps/admin/templates/admin/userbrowser.html	Sat Jul 19 14:30:01 2014 +0530
@@ -1,35 +1,42 @@
 {% extends theme("layout.html") %}
 {% block content %}
     <h1>{{ _("Users") }}</h1>
-    <table class="zebra">
-    <tr>
-        <th>{{ _("User name") }}</th>
-        <th>{{ _("Member of Groups") }}</th>
-        <th>{{ _("Email address") }}</th>
-        <th>{{ _("Actions") }}</th>
-    </tr>
-    {% for u in user_accounts %}
-    <tr>
-        <td><a href="{{ url_for('frontend.show_item', item_name=u.fqname) }}">{{ u.name|join(',') }}</a>{{ u.disabled and " (%s)" % _("disabled") or ""}}</td>
-        <td>{{ u.groups|join(',') }}</td>
-        <td>
-            {% if u.email %}
-            <a href="mailto:{{ u.email|e }}" class="mailto">{{ u.email|e }}</a>
-            {% endif %}
-        </td>
-        <td>
-            <form action="{{ url_for('admin.userprofile', user_name=u.name[0]) }}" method="POST">
-                <input type="hidden" name="key" value="disabled" />
-                <input type="hidden" name="val" value="{{ u.disabled and "0" or "1" }}" />
-                <input type="submit" name="userprofile" value="{{ u.disabled and _("Enable user") or _("Disable user") }}" />
-            </form>
-            <form action="{{ url_for('admin.mail_recovery_token') }}" method="GET">
-                <input type="hidden" name="email" value="{{ u.email }}" />
-                <input type="hidden" name="account_sendmail" value="1" />
-                <input type="submit" name="recoverpass" value="{{ _("Mail account data") }}" />
-            </form>
-        </td>
-    </tr>
-    {% endfor %}
-</table>
+    <table class="table table-hover tablesorter tablesorter-default moin-sortable" data-sortlist="[[0,0],[1,0]]">
+        <tr>
+            <th>{{ _("User name") }}</th>
+            <th>{{ _("Member of Groups") }}</th>
+            <th>{{ _("Email address") }}</th>
+            <th colspan="3">{{ _("Actions") }}</th>
+        </tr>
+        {% for u in user_accounts %}
+            <tr>
+                <td><a href="{{ url_for('frontend.show_item', item_name=u.fqname) }}">{{ u.name|join(', ') }}</a>{{ u.disabled and " (%s)" % _("disabled") or ""}}</td>
+                <td>{{ u.groups|join(', ') }}</td>
+                <td>
+                    {% if u.email %}
+                        <a href="mailto:{{ u.email|e }}" class="mailto">{{ u.email|e }}</a>
+                    {% endif %}
+                </td>
+                <td>
+                    <form action="{{ url_for('admin.userprofile', user_name=u.name[0]) }}" method="POST">
+                        <input type="hidden" name="key" value="disabled" />
+                        <input type="hidden" name="val" value="{{ u.disabled and "0" or "1" }}" />
+                        <input type="submit" name="userprofile" value="{{ u.disabled and _("Enable user") or _("Disable user") }}" />
+                    </form>
+                </td>
+                <td>
+                    <form action="{{ url_for('admin.mail_recovery_token') }}" method="GET">
+                        <input type="hidden" name="email" value="{{ u.email }}" />
+                        <input type="hidden" name="account_sendmail" value="1" />
+                        <input type="submit" name="recoverpass" value="{{ _("Mail account data") }}" />
+                    </form>
+                </td>
+                <td>
+                    <form action="{{ url_for('admin.user_acl_report', uid=u.uid) }}" method="GET">
+                        <input type="submit" name="userwise_acl" value="{{ _("User ACL Info") }}" />
+                    </form>
+                </td>
+            </tr>
+        {% endfor %}
+    </table>
 {% endblock %}
--- a/MoinMoin/apps/admin/views.py	Sat Jul 19 14:24:28 2014 +0530
+++ b/MoinMoin/apps/admin/views.py	Sat Jul 19 14:30:01 2014 +0530
@@ -20,7 +20,7 @@
 from MoinMoin.themes import render_template, get_editor_info
 from MoinMoin.apps.admin import admin
 from MoinMoin import user
-from MoinMoin.constants.keys import NAME, ITEMID, SIZE, EMAIL, DISABLED, NAME_EXACT, WIKINAME, TRASH, NAMESPACE, NAME_OLD, REVID, MTIME, COMMENT, EMAIL_UNVALIDATED
+from MoinMoin.constants.keys import NAME, ITEMID, SIZE, EMAIL, DISABLED, NAME_EXACT, WIKINAME, TRASH, NAMESPACE, NAME_OLD, REVID, MTIME, COMMENT, LATEST_REVS, EMAIL_UNVALIDATED
 from MoinMoin.constants.namespaces import NAMESPACE_USERPROFILES, NAMESPACE_DEFAULT, NAMESPACE_ALL
 from MoinMoin.constants.rights import SUPERUSER
 from MoinMoin.security import require_permission
@@ -257,3 +257,26 @@
         meta = rev.meta
         results.append(trashedEntry(rev.fqname, meta[NAME_OLD], meta[REVID], meta[MTIME], meta[COMMENT], get_editor_info(meta)))
     return results
+
+
+@admin.route('/user_acl_report/<uid>', methods=['GET'])
+@require_permission(SUPERUSER)
+def user_acl_report(uid):
+    all_items = flaskg.storage.documents(wikiname=app.cfg.interwikiname)
+    groups = flaskg.groups
+    theuser = user.User(uid=uid)
+    itemwise_acl = []
+    for item in all_items:
+        fqname = CompositeName(item.meta.get(NAMESPACE), u'itemid', item.meta.get(ITEMID))
+        itemwise_acl.append({'name': item.meta.get(NAME),
+                             'itemid': item.meta.get(ITEMID),
+                             'fqname': fqname,
+                             'read': theuser.may.read(fqname),
+                             'write': theuser.may.write(fqname),
+                             'create': theuser.may.create(fqname),
+                             'admin': theuser.may.admin(fqname),
+                             'destroy': theuser.may.destroy(fqname)})
+    return render_template('admin/user_acl_report.html',
+                           title_name=_(u'User ACL Report'),
+                           user_names=theuser.name,
+                           itemwise_acl=itemwise_acl)
--- a/MoinMoin/templates/base.html	Sat Jul 19 14:24:28 2014 +0530
+++ b/MoinMoin/templates/base.html	Sat Jul 19 14:30:01 2014 +0530
@@ -81,6 +81,7 @@
     <script src="{{ url_for('frontend.template', filename='dictionary.js') }}"></script>
     <script src="{{ url_for('serve.files', name='bootstrap', filename='js/bootstrap.min.js') }}"></script>
     <script src="{{ url_for('serve.files', name='autosize', filename='jquery.autosize-min.js') }}"></script>
+    <script src="{{ url_for('serve.files', name='jquery_tablesorter', filename='jquery.tablesorter.js') }}"></script>
     <script src="{{ url_for('static', filename='js/common.js') }}"></script>
     {{ scripts }}
     <!--[if lt IE 9]>