0001-manager-simplify-data-url-in-tables-60678.patch
src/authentic2/a2_rbac/models.py | ||
---|---|---|
188 | 188 |
def __str__(self): |
189 | 189 |
return str(self.name) |
190 | 190 | |
191 |
def get_absolute_url(self): |
|
192 |
return reverse('a2-manager-ou-detail', kwargs={'pk': self.pk}) |
|
193 | ||
191 | 194 | |
192 | 195 |
OrganizationalUnit._meta.natural_key = [['uuid'], ['slug'], ['name']] |
193 | 196 |
src/authentic2/manager/templates/authentic2/manager/role_members.html | ||
---|---|---|
61 | 61 |
{% trans "This role is synchronised from LDAP, changing members is not allowed." %} |
62 | 62 |
</div> |
63 | 63 |
{% endif %} |
64 |
{% with row_link=1 url_name="a2-manager-user-detail" %}
|
|
64 |
{% with row_link=1 %} |
|
65 | 65 |
{% render_table table "authentic2/manager/role_members_table.html" %} |
66 | 66 |
{% endwith %} |
67 | 67 |
src/authentic2/manager/templates/authentic2/manager/service.html | ||
---|---|---|
37 | 37 |
<div class="section"> |
38 | 38 |
<h3>{% trans "Roles of users allowed on this service" %}</h3> |
39 | 39 |
<div id="authorized-roles"> |
40 |
{% with row_link=1 url_name='a2-manager-role-members' %}
|
|
40 |
{% with row_link=1 %} |
|
41 | 41 |
{% render_table table "authentic2/manager/service_roles_table.html" %} |
42 | 42 |
{% endwith %} |
43 | 43 |
<form method="post" class="manager-m2m-add-form"> |
... | ... | |
51 | 51 |
<div class="section"> |
52 | 52 |
<h3>{% trans "Roles solely visible from this service" %}</h3> |
53 | 53 |
<div id="restricted-roles"> |
54 |
{% with row_link=1 url_name='a2-manager-role-members' table=roles_table%}
|
|
54 |
{% with row_link=1 table=roles_table %}
|
|
55 | 55 |
{% render_table table "authentic2/manager/table.html" %} |
56 | 56 |
{% endwith %} |
57 | 57 |
</div> |
src/authentic2/manager/templates/authentic2/manager/table.html | ||
---|---|---|
25 | 25 |
{% if popup_edit %} |
26 | 26 |
rel="popup" |
27 | 27 |
{% endif %} |
28 |
{% if table.context.url_name %} |
|
29 |
data-url="{% url table.context.url_name pk=row.record.pk %}" |
|
30 |
{% else %} |
|
31 |
data-url="{{ row.record.pk }}/" |
|
32 |
{% endif %} |
|
28 |
data-url="{{ row.record.get_absolute_url }}" |
|
33 | 29 |
{% endif %}> |
34 | 30 |
{% for column, cell in row.items %} |
35 | 31 |
<td {{ column.attrs.td.as_html }}>{% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %}</td> |
src/authentic2/manager/templates/authentic2/manager/user_roles.html | ||
---|---|---|
13 | 13 |
{% endblock %} |
14 | 14 | |
15 | 15 |
{% block main %} |
16 |
{% with row_link=1 url_name="a2-manager-role-members" %}
|
|
16 |
{% with row_link=1 %} |
|
17 | 17 |
{% render_table table "authentic2/manager/user_roles_table.html" %} |
18 | 18 |
{% endwith %} |
19 | 19 |
src/authentic2/models.py | ||
---|---|---|
29 | 29 |
from django.core.exceptions import ValidationError |
30 | 30 |
from django.db import models, transaction |
31 | 31 |
from django.db.models.query import Q |
32 |
from django.urls import reverse |
|
32 | 33 |
from django.utils import timezone |
33 | 34 |
from django.utils.http import urlquote |
34 | 35 |
from django.utils.translation import ugettext_lazy as _ |
... | ... | |
447 | 448 |
'roles': [role.to_json() for role in roles], |
448 | 449 |
} |
449 | 450 | |
451 |
def get_absolute_url(self): |
|
452 |
return reverse('a2-manager-service', kwargs={'service_pk': self.pk}) |
|
453 | ||
450 | 454 | |
451 | 455 |
Service._meta.natural_key = [['slug', 'ou']] |
452 | 456 |
tests/test_manager.py | ||
---|---|---|
806 | 806 |
ou2 = OU.objects.get(name='ou2') |
807 | 807 |
assert {e.text for e in ou_homepage.pyquery('td.name')} == {'OU1', 'Default organizational unit', 'ou2'} |
808 | 808 |
assert len(ou_homepage.pyquery('tr[data-pk="%s"] td.default span.true' % ou2.pk)) == 1 |
809 |
assert len(ou_homepage.pyquery('tr[data-url="%s/"] td.default span.true' % ou2.pk)) == 1
|
|
809 |
assert len(ou_homepage.pyquery('tr[data-url="%s"] td.default span.true' % ou2.get_absolute_url())) == 1
|
|
810 | 810 | |
811 | 811 |
# FIXME: table lines are not clickable as they do not contain an anchor |
812 | 812 |
# default ou cannot be deleted |
813 |
- |