--- a/Allura/allura/templates/neighborhood_admin_permissions.html
+++ b/Allura/allura/model/types.py
@@ -1,81 +1,43 @@
-{% extends g.theme.master %}
+from ming.base import Object
+from ming import schema as S
-{% block extra_css %}
- <link rel="stylesheet" type="text/css" media="screen" href="{{g.forge_static('css/forge/accordion.css')}}" />
-{% endblock %}
+class ACE(S.Object):
+ '''ACE - access control entry'''
+ ALLOW, DENY = 'ALLOW', 'DENY'
+ def __init__(self, permissions, **kwargs):
+ if permissions is None:
+ permission=S.String()
+ else:
+ permission=S.OneOf('*', *permissions)
+ super(ACE, self).__init__(
+ fields=dict(
+ access=S.OneOf(self.ALLOW, self.DENY),
+ role_id=S.ObjectId(),
+ permission=permission),
+ **kwargs)
-{% block title %}{{neighborhood.name}} / Permissions{% endblock %}
+ @classmethod
+ def allow(cls, role_id, permission):
+ return Object(
+ access=cls.ALLOW,
+ role_id=role_id,
+ permission=permission)
-{% block header %}Permissions for {{neighborhood.name}}{% endblock %}
+ @classmethod
+ def deny(cls, role_id, permission):
+ return Object(
+ access=cls.DENY,
+ role_id=role_id,
+ permission=permission)
-{% block nav_menu %}
-{% include 'allura:templates/jinja_master/neigh_nav_menu.html' %}
-{% endblock %}
+ @classmethod
+ def match(cls, ace, role_id, permission):
+ return (
+ ace.role_id == role_id
+ and ace.permission in (permission, '*'))
-{% block top_nav %}
-{% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
-{% endblock %}
+class ACL(S.Array):
-{% block content %}
- <p>The ACL determines neighborhood-level permissions.</p>
- <div id="acl-admin">
- {% for permission, users in neighborhood.acl.iteritems() %}
- <h3><a href="#" id="permission_{{permission}}">Permission: {{permission}}</a></h3>
- <div>
- <form method="POST" action="update_acl">
- <input type="hidden" name="permission" value="{{permission}}"/>
- {% for uid in users %}
- <input type="hidden" name="user-{{loop.index0}}.id" value="{{uid}}"/>
- {% endfor %}
- <table>
- <thead>
- <tr><th>Username</th><th></th></tr>
- </thead>
- <tbody>
- {% for u in h.make_users(users) %}
- <tr>
- <td>{{u.username}}</td>
- <td><input type="submit" value="Remove" name="user-{{loop.index0}}.delete" /></td>
- </tr>
- {% endfor %}
- <tr>
- <td>
- <input name="new.username" type="text"/>
- </td>
- <td>
- <input type="submit" name="new.add" value="Add Permission"/>
- </td>
- </tr>
- </tbody>
- </table>
- </form>
- </div>
- {% endfor %}
- </div>
-{% endblock %}
-
-{% block extra_js %}
- <script type="text/javascript">
- $(function () {
- $("#acl-admin").accordion({
- autoHeight: false,
- navigation: true,
- change: function(event,ui) {
- var hid = ui.newHeader.children('a').attr('id');
- if (hid === undefined) {
- $.cookie('neighborhood-acl-admin', null);
- } else {
- $.cookie('neighborhood-acl-admin', hid, { path: '/', expires: 2 });
- }
- }
- });
- });
- $(document).ready(function () {
- if($.cookie('neighborhood-acl-admin')) {
- $('#acl-admin').accordion('option', 'animated', false)
- .accordion('activate', $('#' + $.cookie('neighborhood-acl-admin')).parent('h3'))
- .accordion('option', 'animated', 'slide');
- }
- });
-</script>
-{% endblock %}
+ def __init__(self, permissions=None, **kwargs):
+ super(ACL, self).__init__(
+ field_type=ACE(permissions), **kwargs)