changeset 2729:63267bfa9099

Added capability to edit acl string in item acl report view itself
author Ajitesh Gupta <ajgupta93@gmail.com>
date Fri, 15 Aug 2014 22:09:25 +0530
parents 3cf58438633e
children cadd7e64a7e0
files MoinMoin/apps/admin/templates/admin/item_acl_report.html MoinMoin/apps/admin/views.py MoinMoin/static/css/common.css
diffstat 3 files changed, 52 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/admin/templates/admin/item_acl_report.html	Fri Aug 15 22:02:02 2014 +0530
+++ b/MoinMoin/apps/admin/templates/admin/item_acl_report.html	Fri Aug 15 22:09:25 2014 +0530
@@ -12,8 +12,28 @@
         <tbody>
             {% for item in items_acls %}
                 <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>{{ item['acl'] }}</td>
+                    <td>
+                        <a href="{{ url_for('frontend.show_item', item_name=item['fqname']) }}">
+                            {% if item['name'] %}
+                                {{ item['name'] | join(', ') }}
+                            {% else %}
+                                {{ _("Item Id") }}: {{ item['itemid'] }}
+                            {% endif %}
+                        </a>
+                    </td>
+                    <td>
+                        {% if user.may.admin(item['fqname']) %}
+                            <form id="moin-acl-form" action="{{ url_for('admin.modify_acl', item_name=item['fqname']) }}" method="POST">
+                                <input type="text" class="moin-acl-string" name="{{ item['itemid'] }}" value="{{ item['acl'] }}"/>
+                                <input type="submit" value="{{ _("Modify ACL") }}"/>
+                            </form>
+                        {% else %}
+                            {{ item['acl'] }}
+                        {% endif %}
+                        {% if item['acl_default'] %}
+                            {{ _(" (Default) ") }}
+                        {% endif %}
+                    </td>
                 </tr>
             {% endfor %}
         </tbody>
--- a/MoinMoin/apps/admin/views.py	Fri Aug 15 22:02:02 2014 +0530
+++ b/MoinMoin/apps/admin/views.py	Fri Aug 15 22:09:25 2014 +0530
@@ -27,6 +27,8 @@
 from MoinMoin.util.interwiki import CompositeName
 from MoinMoin.datastruct.backends.wiki_groups import WikiGroup
 from MoinMoin.datastruct.backends import GroupDoesNotExistError
+from MoinMoin.items import Item
+from MoinMoin.util.interwiki import split_fqname
 
 
 @admin.route('/superuser')
@@ -321,15 +323,17 @@
         item_id = item.meta.get(ITEMID)
         item_name = item.meta.get(NAME)
         item_acl = item.meta.get(ACL)
+        acl_default = item_acl is None
         fqname = CompositeName(item_namespace, u'itemid', item_id)
-        if item_acl is None:
+        if acl_default:
             for namespace, acl_config in app.cfg.acl_mapping:
-                if item_namespace == namespace or item_namespace == 'userprofiles' and namespace == 'userprofiles/':
-                    item_acl = 'Default ({0})'.format(acl_config['default'])
+                if item_namespace == namespace[:-1]:
+                    item_acl = acl_config['default']
         items_acls.append({'name': item_name,
                            'itemid': item_id,
                            'fqname': fqname,
-                           'acl': item_acl})
+                           'acl': item_acl,
+                           'acl_default': acl_default})
     return render_template('admin/item_acl_report.html',
                            title_name=_('Item ACL Report'),
                            items_acls=items_acls)
@@ -367,3 +371,16 @@
                            title_name=_(u'Group ACL Report'),
                            group_items=group_items,
                            group_name=group_name)
+
+
+@admin.route('/modify_acl/<itemname:item_name>', methods=['POST'])
+@require_permission(SUPERUSER)
+def modify_acl(item_name):
+    fqname = split_fqname(item_name)
+    item = Item.create(item_name)
+    meta = dict(item.meta)
+    new_acl = request.form.get(fqname.value)
+    meta[ACL] = new_acl
+    item._save(meta=meta)
+    flash("Changes successfully applied", "info")
+    return redirect(url_for('.item_acl_report'))
--- a/MoinMoin/static/css/common.css	Fri Aug 15 22:02:02 2014 +0530
+++ b/MoinMoin/static/css/common.css	Fri Aug 15 22:09:25 2014 +0530
@@ -76,3 +76,12 @@
 .four-col li{
   width: 25%;
 }
+input[type="text"], .moin-acl-string {
+  width: 70%;
+}
+.tablesorter {
+  width: 100%;
+}
+#moin-acl-form {
+  display: inline;
+}