0001-manager-provide-a-new-homepage-layout-66497.patch
src/authentic2/manager/static/authentic2/manager/css/style.scss | ||
---|---|---|
297 | 297 |
-webkit-column-width: 20em; |
298 | 298 |
column-width: 20em; |
299 | 299 |
} |
300 | ||
301 |
div.a2-manager-main { |
|
302 |
display: flex; |
|
303 |
justify-content: space-evenly; |
|
304 |
& > div { |
|
305 |
margin: 1em; |
|
306 |
text-align: center; |
|
307 |
} |
|
308 |
} |
|
309 | ||
310 |
div.a2-manager-id-tools_content { |
|
311 |
display: flex; |
|
312 |
flex-direction: column; |
|
313 |
& > a { |
|
314 |
margin: 1em; |
|
315 |
padding: .7em; |
|
316 |
} |
|
317 |
} |
|
318 | ||
319 |
div.a2-manager-id-objects ul.apps { |
|
320 |
padding: 1em; |
|
321 |
} |
src/authentic2/manager/templates/authentic2/manager/homepage.html | ||
---|---|---|
5 | 5 |
{% endblock %} |
6 | 6 | |
7 | 7 |
{% block appbar %} |
8 |
<h2>{% blocktrans %}Here you can manage objects related to organizational units, users, roles and applications.{% endblocktrans %}</h2>
|
|
8 |
<h2>{% blocktrans %}Identity management{% endblocktrans %}</h2>
|
|
9 | 9 |
{% if user.is_superuser or can_view_journal %} |
10 | 10 |
<span class="actions"> |
11 | 11 |
<a class="extra-actions-menu-opener"></a> |
... | ... | |
14 | 14 |
<li><a download href="{% url 'a2-manager-site-export' %}">{% trans 'Export Site' %}</a></li> |
15 | 15 |
<li><a href="{% url 'a2-manager-site-import' %}" rel="popup">{% trans 'Import Site' %}</a></li> |
16 | 16 |
{% endif %} |
17 |
{% if user.is_superuser or can_view_journal %} |
|
18 |
<li><a href="{% url 'a2-manager-journal' %}">{% trans 'Journal' %}</a></li> |
|
19 |
{% endif %} |
|
20 |
{% if user.is_superuser %} |
|
21 |
<li><a href="{% url 'a2-manager-tech-info' %}">{% trans 'Technical information' %}</a></li> |
|
22 |
{% endif %} |
|
23 |
<li><a href="{% url 'a2-manager-authenticators' %}">{% trans 'Authenticators' %}</a></li> |
|
24 | 17 |
</ul> |
25 | 18 |
</span> |
26 | 19 |
{% endif %} |
27 | 20 |
{% endblock %} |
28 | 21 | |
29 | 22 |
{% block content %} |
23 |
<div class="a2-manager-main"> |
|
24 |
<div class="a2-manager-id-objects"> |
|
25 |
<h3>{% blocktrans %}Objects related to organizational units, users, roles and applications{% endblocktrans %}</h3> |
|
30 | 26 |
<ul class="apps"> |
31 | 27 |
{% for entry in entries %} |
32 | 28 |
<li {% if entry.class %}class="{{ entry.class }}"{% endif %}> |
... | ... | |
34 | 30 |
</li> |
35 | 31 |
{% endfor %} |
36 | 32 |
</ul> |
33 |
</div> |
|
34 |
<div class="a2-manager-id-tools"> |
|
35 |
<h3>{% blocktrans %}Configuration & technical information{% endblocktrans %}</h3> |
|
36 |
<div class="a2-manager-id-tools_content"> |
|
37 |
<a id="authn" class="pk-button" href="{% url 'a2-manager-authenticators' %}">{% trans 'Authentication frontends management' %}</a> |
|
38 |
{% if user.is_superuser or can_view_journal %} |
|
39 |
<a id="journal" class="pk-button" href="{% url 'a2-manager-journal' %}">{% trans 'Global journal' %}</a> |
|
40 |
{% endif %} |
|
41 |
{% if display_tech_info %} |
|
42 |
<a id="tech-info" class="pk-button" href="{% url 'a2-manager-tech-info' %}">{% trans 'Directory servers’ technical information' %}</a> |
|
43 |
{% endif %} |
|
44 |
</div> |
|
45 |
</div> |
|
37 | 46 |
<br style="clear: both;"/> |
47 |
</div> |
|
38 | 48 |
{% endblock %} |
src/authentic2/manager/views.py | ||
---|---|---|
40 | 40 | |
41 | 41 |
from authentic2 import hooks |
42 | 42 |
from authentic2.a2_rbac.models import OrganizationalUnit |
43 |
from authentic2.backends import ldap_backend |
|
43 | 44 |
from authentic2.data_transfer import ImportContext, export_site, import_site |
44 | 45 |
from authentic2.decorators import json as json_view |
45 | 46 |
from authentic2.forms.profile import modelform_factory |
... | ... | |
595 | 596 |
'order': -1, |
596 | 597 |
'sub': False, |
597 | 598 |
'slug': 'identity-management', |
599 |
'skip_homepage': True, |
|
598 | 600 |
}, |
599 | 601 |
{ |
600 | 602 |
'class': 'icon-organizational-units', |
... | ... | |
660 | 662 |
return entries |
661 | 663 | |
662 | 664 |
def get_context_data(self, **kwargs): |
663 |
kwargs['entries'] = self.get_homepage_entries() |
|
665 |
kwargs['entries'] = [] |
|
666 |
for entry in self.get_homepage_entries(): |
|
667 |
if entry.get('skip_homepage', False): |
|
668 |
continue |
|
669 |
kwargs['entries'].append(entry) |
|
664 | 670 |
kwargs['can_view_journal'] = self.request.user.has_perms( |
665 | 671 |
['custom_user.view_user', 'a2_rbac.view_role'] |
666 | 672 |
) |
673 |
if list(ldap_backend.LDAPBackend.get_config()): |
|
674 |
kwargs['display_tech_info'] = True |
|
667 | 675 |
return super().get_context_data(**kwargs) |
668 | 676 | |
669 | 677 | |
... | ... | |
682 | 690 |
def get_context_data(self, **kwargs): |
683 | 691 |
import ldap |
684 | 692 | |
685 |
from authentic2.backends import ldap_backend |
|
686 | ||
687 | 693 |
backend = ldap_backend.LDAPBackend |
688 | 694 |
kwargs['ldap_list'] = [] |
689 | 695 |
for block in backend.get_config(): |
tests/test_manager.py | ||
---|---|---|
16 | 16 | |
17 | 17 | |
18 | 18 |
import json |
19 |
from unittest import mock |
|
19 | 20 |
from urllib.parse import urlparse |
20 | 21 | |
21 | 22 |
import pytest |
... | ... | |
58 | 59 |
path = reverse('a2-manager-%s' % section) |
59 | 60 |
assert manager_home_page.pyquery.remove_namespaces()('.apps a[href=\'%s\']' % path) |
60 | 61 | |
62 |
conf_entries = ['authn', 'journal'] |
|
63 |
assert len(manager_home_page.pyquery('div.a2-manager-id-tools_content').children()) == 2 |
|
64 |
for entry in conf_entries: |
|
65 |
assert manager_home_page.pyquery(f'a#{entry}') |
|
66 | ||
67 |
# mock ldap configuration |
|
68 |
mocked_config = [{'ldap_uri': 'ldaps://soundsfake.nowhere.null'}] |
|
69 |
with mock.patch('authentic2.backends.ldap_backend.LDAPBackend.get_config', return_value=mocked_config): |
|
70 |
# new tech info link appears |
|
71 |
manager_home_page = app.get(reverse('a2-manager-homepage')) |
|
72 |
assert len(manager_home_page.pyquery('div.a2-manager-id-tools_content').children()) == 3 |
|
73 |
assert manager_home_page.pyquery('a#tech-info') |
|
74 | ||
61 | 75 | |
62 | 76 |
def test_manager_create_ou(superuser_or_admin, app): |
63 | 77 |
ou_add = login(app, superuser_or_admin, path=reverse('a2-manager-ou-add')) |
tests/test_manager_authenticators.py | ||
---|---|---|
30 | 30 | |
31 | 31 |
logout(app) |
32 | 32 |
resp = login(app, superuser, path='/manage/') |
33 |
assert 'Authenticators' in resp.text
|
|
33 |
assert 'Authentication frontends management' in resp.text
|
|
34 | 34 | |
35 |
resp = resp.click('Authenticators')
|
|
35 |
resp = resp.click('Authentication frontends management')
|
|
36 | 36 |
assert 'Authenticators' in resp.text |
37 | 37 | |
38 | 38 |
tests/test_manager_journal.py | ||
---|---|---|
38 | 38 | |
39 | 39 |
logout(app) |
40 | 40 |
response = login(app, admin, path='/manage/') |
41 |
assert 'Journal' in response
|
|
41 |
assert 'Global journal' in response
|
|
42 | 42 |
app.get('/manage/journal/', status=200) |
43 | 43 | |
44 | 44 | |
... | ... | |
341 | 341 |
# remove event about admin login |
342 | 342 |
Event.objects.filter(user=superuser).delete() |
343 | 343 | |
344 |
response = response.click("Journal")
|
|
344 |
response = response.click("Global journal")
|
|
345 | 345 | |
346 | 346 |
content = extract_journal(response) |
347 | 347 | |
348 |
- |