Commit f0530049 by Bach Dániel

dashboard: rewrite AclUpdateView

parent 946970a3
...@@ -52,9 +52,11 @@ ...@@ -52,9 +52,11 @@
</a> </a>
</td> </td>
<td> <td>
<select class="form-control" name="perm-u-{{i.user.id}}"> <select class="form-control" name="perm-u-{{i.user.id}}"{% if i.level not in acl.allowed_levels %} disabled{% endif %}>
{% for id, name in acl.levels %} {% for id, name in acl.levels %}
<option{%if id = i.level%} selected="selected"{%endif%} value="{{id}}">{{name}}</option> <option{%if id = i.level%} selected="selected"{%endif%}
{% if id not in acl.allowed_levels %} disabled{% endif %}
value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</td> </td>
...@@ -72,9 +74,11 @@ ...@@ -72,9 +74,11 @@
</a> </a>
</td> </td>
<td> <td>
<select class="form-control" name="perm-g-{{i.group.id}}"> <select class="form-control" name="perm-g-{{i.group.id}}{% if i.level not in acl.allowed_levels %} disabled{% endif %}">
{% for id, name in acl.levels %} {% for id, name in acl.levels %}
<option{%if id = i.level%} selected="selected"{%endif%} value="{{id}}">{{name}}</option> <option{%if id = i.level%} selected="selected"{%endif%}
{% if id not in acl.allowed_levels %} disabled{% endif %}
value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</td> </td>
...@@ -87,7 +91,7 @@ ...@@ -87,7 +91,7 @@
<td><input type="text" class="form-control" name="perm-new-name" <td><input type="text" class="form-control" name="perm-new-name"
placeholder="{% trans "Name of group or user" %}"></td> placeholder="{% trans "Name of group or user" %}"></td>
<td><select class="form-control" name="perm-new"> <td><select class="form-control" name="perm-new">
{% for id, name in acl.levels %} {% for id, name in acl.allowed_levels %}
<option value="{{id}}">{{name}}</option> <option value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select></td><td></td> </select></td><td></td>
...@@ -95,7 +99,7 @@ ...@@ -95,7 +99,7 @@
</tbody> </tbody>
</table> </table>
<div class="form-actions"> <div class="form-actions">
<button type="submit" class="btn btn-success {% if not is_owner %}disabled{% endif %}">{% trans "Save" %}</button> <button type="submit" class="btn btn-success">{% trans "Save" %}</button>
</div> </div>
</form> </form>
</div> </div>
......
...@@ -1263,7 +1263,7 @@ class GroupDetailTest(LoginMixin, TestCase): ...@@ -1263,7 +1263,7 @@ class GroupDetailTest(LoginMixin, TestCase):
str(self.g1.pk) + '/acl/', str(self.g1.pk) + '/acl/',
{'perm-new-name': 'user3', 'perm-new': 'owner'}) {'perm-new-name': 'user3', 'perm-new': 'owner'})
self.assertEqual(acl_users, len(gp.get_users_with_level())) self.assertEqual(acl_users, len(gp.get_users_with_level()))
self.assertEqual(response.status_code, 403) self.assertEqual(response.status_code, 302)
def test_superuser_add_acluser_to_group(self): def test_superuser_add_acluser_to_group(self):
c = Client() c = Client()
...@@ -1306,7 +1306,7 @@ class GroupDetailTest(LoginMixin, TestCase): ...@@ -1306,7 +1306,7 @@ class GroupDetailTest(LoginMixin, TestCase):
str(self.g1.pk) + '/acl/', str(self.g1.pk) + '/acl/',
{'perm-new-name': 'group2', 'perm-new': 'owner'}) {'perm-new-name': 'group2', 'perm-new': 'owner'})
self.assertEqual(acl_groups, len(gp.get_groups_with_level())) self.assertEqual(acl_groups, len(gp.get_groups_with_level()))
self.assertEqual(response.status_code, 403) self.assertEqual(response.status_code, 302)
def test_superuser_add_aclgroup_to_group(self): def test_superuser_add_aclgroup_to_group(self):
c = Client() c = Client()
...@@ -1792,7 +1792,7 @@ class AclViewTest(LoginMixin, TestCase): ...@@ -1792,7 +1792,7 @@ class AclViewTest(LoginMixin, TestCase):
'perm-new': "", 'perm-new': "",
}) })
self.assertTrue((self.u1, "user") in inst.get_users_with_level()) self.assertTrue((self.u1, "user") in inst.get_users_with_level())
self.assertEqual(resp.status_code, 403) self.assertEqual(resp.status_code, 302)
def test_instance_original_owner_access_revoke(self): def test_instance_original_owner_access_revoke(self):
c = Client() c = Client()
...@@ -1836,7 +1836,7 @@ class AclViewTest(LoginMixin, TestCase): ...@@ -1836,7 +1836,7 @@ class AclViewTest(LoginMixin, TestCase):
'perm-new': "", 'perm-new': "",
}) })
self.assertTrue((self.u1, "user") in tmpl.get_users_with_level()) self.assertTrue((self.u1, "user") in tmpl.get_users_with_level())
self.assertEqual(resp.status_code, 403) self.assertEqual(resp.status_code, 302)
def test_template_original_owner_access_revoke(self): def test_template_original_owner_access_revoke(self):
c = Client() c = Client()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment