manager: simplify data-url in tables (#60678)
This commit is contained in:
parent
20a8b32ee6
commit
a05c136ee5
|
@ -188,6 +188,9 @@ class OrganizationalUnit(OrganizationalUnitAbstractBase):
|
|||
def __str__(self):
|
||||
return str(self.name)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('a2-manager-ou-detail', kwargs={'pk': self.pk})
|
||||
|
||||
|
||||
OrganizationalUnit._meta.natural_key = [['uuid'], ['slug'], ['name']]
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
{% trans "This role is synchronised from LDAP, changing members is not allowed." %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% with row_link=1 url_name="a2-manager-user-detail" %}
|
||||
{% with row_link=1 %}
|
||||
{% render_table table "authentic2/manager/role_members_table.html" %}
|
||||
{% endwith %}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<div class="section">
|
||||
<h3>{% trans "Roles of users allowed on this service" %}</h3>
|
||||
<div id="authorized-roles">
|
||||
{% with row_link=1 url_name='a2-manager-role-members' %}
|
||||
{% with row_link=1 %}
|
||||
{% render_table table "authentic2/manager/service_roles_table.html" %}
|
||||
{% endwith %}
|
||||
<form method="post" class="manager-m2m-add-form">
|
||||
|
@ -51,7 +51,7 @@
|
|||
<div class="section">
|
||||
<h3>{% trans "Roles solely visible from this service" %}</h3>
|
||||
<div id="restricted-roles">
|
||||
{% with row_link=1 url_name='a2-manager-role-members' table=roles_table%}
|
||||
{% with row_link=1 table=roles_table %}
|
||||
{% render_table table "authentic2/manager/table.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
|
|
@ -25,11 +25,7 @@
|
|||
{% if popup_edit %}
|
||||
rel="popup"
|
||||
{% endif %}
|
||||
{% if table.context.url_name %}
|
||||
data-url="{% url table.context.url_name pk=row.record.pk %}"
|
||||
{% else %}
|
||||
data-url="{{ row.record.pk }}/"
|
||||
{% endif %}
|
||||
data-url="{{ row.record.get_absolute_url }}"
|
||||
{% endif %}>
|
||||
{% for column, cell in row.items %}
|
||||
<td {{ column.attrs.td.as_html }}>{% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %}</td>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% with row_link=1 url_name="a2-manager-role-members" %}
|
||||
{% with row_link=1 %}
|
||||
{% render_table table "authentic2/manager/user_roles_table.html" %}
|
||||
{% endwith %}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ from django.contrib.postgres.search import SearchVectorField
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.db import models, transaction
|
||||
from django.db.models.query import Q
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.http import urlquote
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
@ -447,6 +448,9 @@ class Service(models.Model):
|
|||
'roles': [role.to_json() for role in roles],
|
||||
}
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('a2-manager-service', kwargs={'service_pk': self.pk})
|
||||
|
||||
|
||||
Service._meta.natural_key = [['slug', 'ou']]
|
||||
|
||||
|
|
|
@ -806,7 +806,7 @@ def test_manager_ou(app, superuser_or_admin, ou1):
|
|||
ou2 = OU.objects.get(name='ou2')
|
||||
assert {e.text for e in ou_homepage.pyquery('td.name')} == {'OU1', 'Default organizational unit', 'ou2'}
|
||||
assert len(ou_homepage.pyquery('tr[data-pk="%s"] td.default span.true' % ou2.pk)) == 1
|
||||
assert len(ou_homepage.pyquery('tr[data-url="%s/"] td.default span.true' % ou2.pk)) == 1
|
||||
assert len(ou_homepage.pyquery('tr[data-url="%s"] td.default span.true' % ou2.get_absolute_url())) == 1
|
||||
|
||||
# FIXME: table lines are not clickable as they do not contain an anchor
|
||||
# default ou cannot be deleted
|
||||
|
|
Loading…
Reference in New Issue