Skip to content

Commit a7248d8

Browse files
authored
Add SSO conditionals back to organization templates (#249)
- Resolves #227
1 parent 7d16885 commit a7248d8

File tree

9 files changed

+161
-15
lines changed

9 files changed

+161
-15
lines changed

readthedocsext/theme/templates/organizations/member_list.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
{% load i18n %}
44
{% load gravatar %}
5+
56
{% load organizations %}
67

78
{% block title %}{{ organization.name }} - {% trans "Members" %}{% endblock %}
@@ -11,5 +12,10 @@
1112
{% endblock %}
1213

1314
{% block content %}
14-
{% include "organizations/partials/members_list.html" with objects=members %}
15+
{% if organization|has_sso_enabled:"allauth" %}
16+
{# We still have owners listed in this UI, which are included in the members union queryset #}
17+
{% include "organizations/partials/has_sso/members_list.html" with objects=members %}
18+
{% else %}
19+
{% include "organizations/partials/members_list.html" with objects=members %}
20+
{% endif %}
1521
{% endblock content %}

readthedocsext/theme/templates/organizations/organization_detail.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
{% load i18n %}
44
{% load gravatar %}
5+
56
{% load organizations %}
67

78
{% block title %}{{ organization.name }}{% endblock %}
@@ -11,5 +12,9 @@
1112
{% endblock %}
1213

1314
{% block content %}
14-
{% include "organizations/partials/project_list.html" with objects=projects %}
15+
{% if organization|has_sso_enabled:"allauth" %}
16+
{% include "organizations/partials/has_sso/project_list.html" with objects=projects show_create_button=True %}
17+
{% else %}
18+
{% include "organizations/partials/project_list.html" with objects=projects show_create_button=True %}
19+
{% endif %}
1520
{% endblock content %}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{% extends "organizations/partials/members_list.html" %}
2+
3+
{% load i18n %}
4+
{% load privacy_tags %}
5+
6+
{# Don't show filters, they aren't usable #}
7+
{% block top_menu %}
8+
<div class="ui info message">
9+
<i class="fas fa-exclamation-circle icon"></i>
10+
{% blocktrans trimmed %}
11+
This organization has single sign-on enabled.
12+
Only organization owners are listed below.
13+
{% endblocktrans %}
14+
</div>
15+
{% endblock top_menu %}
16+
17+
{% block top_left_menu_items %}
18+
<div class="item">
19+
<div class="content">
20+
<div class="ui sub header">
21+
Access
22+
</div>
23+
Owners
24+
</div>
25+
</div>
26+
{% endblock top_left_menu_items %}
27+
28+
{% block list_placeholder_header %}
29+
{% blocktrans trimmed %}
30+
Teams and members are disabled for this organization
31+
{% endblocktrans %}
32+
{% endblock list_placeholder_header %}
33+
{% block list_placeholder_text %}
34+
<p class="inline">
35+
{% blocktrans trimmed %}
36+
This organization has single sign-on enabled. Members are managed with your authentication provider.
37+
{% endblocktrans %}
38+
</p>
39+
{% endblock list_placeholder_text %}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{% extends "organizations/partials/project_list.html" %}
2+
3+
{% load i18n %}
4+
5+
{% load privacy_tags %}
6+
7+
{% block list_placeholder_icon_class %}{% endblock %}
8+
{% block list_placeholder_header %}
9+
{% trans "There are no projects configured yet, or no projects match your filter criteria" %}
10+
{% endblock list_placeholder_header %}
11+
{% block list_placeholder_text %}
12+
{% with is_owner=request.user|is_admin:organization %}
13+
{% if not is_owner %}
14+
<div class="inline">
15+
{% blocktrans trimmed %}
16+
Single sign-on is enabled for this organization.
17+
Contact an organization owner to add new projects.
18+
{% endblocktrans %}
19+
</div>
20+
{% else %}
21+
<a
22+
class="ui {% if not is_owner %} disabled {% else %} primary {% endif %} button"
23+
href="{% url "projects_import" %}">
24+
{% trans "Add a project" %}
25+
</a>
26+
{% endif %}
27+
{% endwith %}
28+
{% endblock list_placeholder_text %}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{% extends "organizations/partials/team_list.html" %}
2+
3+
{% load i18n %}
4+
5+
{% load organizations %}
6+
{% load privacy_tags %}
7+
8+
{# Don't show filters #}
9+
{% block top_left_menu_items %}
10+
{% endblock top_left_menu_items %}
11+
12+
{# Show create button as disabled #}
13+
{% block create_button %}
14+
<span data-content="{% trans "Teams are managed with your SSO provider" %}">
15+
<span class="ui disabled button">
16+
{% trans "Add team" %}
17+
</span>
18+
</span>
19+
{% endblock %}
20+
21+
{# Show more specific placeholder content #}
22+
{% block list_placeholder_icon_class %}fad fa-users icon{% endblock %}
23+
{% block list_placeholder_header %}
24+
{% blocktrans trimmed %}
25+
Teams are disabled for this organization
26+
{% endblocktrans %}
27+
{% endblock list_placeholder_header %}
28+
{% block list_placeholder_text %}
29+
<div class="inline">
30+
{% blocktrans trimmed %}
31+
This organization has single sign-on enabled. Teams are managed with your provider.
32+
{% endblocktrans %}
33+
</div>
34+
{% endblock list_placeholder_text %}
35+
36+
{# Disabled listing entirely #}
37+
{% block list %}
38+
{% endblock list %}

readthedocsext/theme/templates/organizations/partials/organization_list.html

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{% load humanize %}
55
{% load gravatar %}
66

7+
{% load organizations %}
78
{% load privacy_tags %}
89

910
{% block view_binding %}data-bind="with: OrganizationListView()"{% endblock view_binding %}
@@ -70,23 +71,33 @@
7071
{% block list_item_header %}
7172
<a href="{{ object.get_absolute_url }}">
7273
{{ object.name }}
74+
75+
{% if object|has_sso_enabled:"allauth" %}
76+
{% trans "SSO" context "Acronym for single sign-on" as text %}
77+
{% blocktrans trimmed with version=object.verbose_name asvar popup %}
78+
Single sign-on is enabled
79+
{% endblocktrans %}
80+
{% include "includes/components/config_label.html" with icon="fad fa-user-check" text=text popup=popup %}
81+
{% endif %}
7382
</a>
7483
<div class="sub header">
7584
</div>
7685
{% endblock list_item_header %}
7786

78-
{% block list_item_meta_items %}
87+
{% block list_item_meta %}
88+
{% endblock list_item_meta %}
89+
90+
{% block list_item_extra_items %}
7991
<a class="item" href="{{ object.get_absolute_url }}">
8092
{% blocktrans trimmed with project_count=object.projects.count %}
8193
{{ project_count }} projects
8294
{% endblocktrans %}
8395
</a>
84-
<a class="item" href="{% url "organization_team_list" slug=object.slug %}">
85-
{% blocktrans trimmed with team_count=object.teams.count %}
86-
{{ team_count }} teams
87-
{% endblocktrans %}
88-
</a>
89-
{% endblock list_item_meta_items %}
90-
91-
{% block list_item_extra %}
92-
{% endblock %}
96+
{% if not object|has_sso_enabled:"allauth" %}
97+
<a class="item" href="{% url "organization_team_list" slug=object.slug %}">
98+
{% blocktrans trimmed with team_count=object.teams.count %}
99+
{{ team_count }} teams
100+
{% endblocktrans %}
101+
</a>
102+
{% endif %}
103+
{% endblock list_item_extra_items %}
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
{% extends "projects/partials/project_list.html" %}
22

3+
{% comment "rst" %}
4+
This template uses an additional include argument, so that we can conditionally
5+
show some UI elements on main project listings, but not on subviews, like the
6+
team project listing.
7+
8+
``show_create_button``
9+
Boolean. Show the add button in the top menu.
10+
11+
{% endcomment %}
12+
13+
{% load privacy_tags %}
14+
315
{% block top_left_menu_items %}
416
{# This partial is used a few times and ``filter`` isn't used in some views #}
517
{% if filter %}
618
{% include "includes/filters/form.html" with fields=filter.form %}
719
{% endif %}
820
{% endblock top_left_menu_items %}
921

10-
{# Don't show the create button on any of the org/team UIs #}
1122
{% block create_button %}
23+
{% if show_create_button and request.user|is_admin:organization %}
24+
{{ block.super }}
25+
{% endif %}
1226
{% endblock create_button %}

readthedocsext/theme/templates/organizations/team_list.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% extends "organizations/base.html" %}
22

33
{% load i18n %}
4+
45
{% load organizations %}
56

67
{% block title %}{{ organization.name }} - {% trans "Teams" %}{% endblock %}
@@ -10,5 +11,9 @@
1011
{% endblock %}
1112

1213
{% block content %}
13-
{% include "organizations/partials/team_list.html" with objects=teams %}
14+
{% if organization|has_sso_enabled:"allauth" %}
15+
{% include "organizations/partials/has_sso/team_list.html" %}
16+
{% else %}
17+
{% include "organizations/partials/team_list.html" with objects=teams %}
18+
{% endif %}
1419
{% endblock content %}

readthedocsext/theme/templates/projects/partials/project_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
{% endblock top_left_menu_items %}
3333

3434
{% block create_button %}
35-
<a class="ui green button" href="{{ projects_import_url }}">
35+
<a class="ui green button" href="{% url "projects_import" %}">
3636
{% trans "Add project" %}
3737
</a>
3838
{% endblock %}

0 commit comments

Comments
 (0)