admin: update templates and stage views

This commit is contained in:
Jens Langhammer 2020-05-10 18:44:58 +02:00
parent 8de87d9acb
commit 2ffa2fc6b8
7 changed files with 42 additions and 40 deletions

View file

@ -59,9 +59,9 @@
</a>
</li>
<li class="pf-c-nav__item">
<a href="{% url 'passbook_admin:factors' %}"
class="pf-c-nav__link {% is_active 'passbook_admin:factors' 'passbook_admin:factor-create' 'passbook_admin:factor-update' 'passbook_admin:factor-delete' %}">
{% trans 'Factors' %}
<a href="{% url 'passbook_admin:stages' %}"
class="pf-c-nav__link {% is_active 'passbook_admin:stages' 'passbook_admin:stage-create' 'passbook_admin:stage-update' 'passbook_admin:stage-delete' %}">
{% trans 'Stages' %}
</a>
</li>
<li class="pf-c-nav__item">

View file

@ -26,7 +26,7 @@
<tr role="row">
<th role="columnheader" scope="col">{% trans 'Name' %}</th>
<th role="columnheader" scope="col">{% trans 'Designation' %}</th>
<th role="columnheader" scope="col">{% trans 'Factors' %}</th>
<th role="columnheader" scope="col">{% trans 'Stages' %}</th>
<th role="columnheader" scope="col">{% trans 'Policies' %}</th>
<th role="cell"></th>
</tr>
@ -47,7 +47,7 @@
</td>
<td role="cell">
<span>
{{ flow.factors.all|length }}
{{ flow.stages.all|length }}
</span>
</td>
<td role="cell">

View file

@ -48,16 +48,16 @@
</div>
</a>
<a href="{% url 'passbook_admin:factors' %}" class="pf-c-card pf-m-hoverable pf-m-compact">
<a href="{% url 'passbook_admin:stages' %}" class="pf-c-card pf-m-hoverable pf-m-compact">
<div class="pf-c-card__head">
<div class="pf-c-card__head-main">
<i class="pf-icon pf-icon-plugged"></i> {% trans 'Factors' %}
<i class="pf-icon pf-icon-plugged"></i> {% trans 'Stages' %}
</div>
</div>
<div class="pf-c-card__body">
{% if factor_count < 1 %}
<i class="pficon-error-circle-o"></i> {{ factor_count }}
<p>{% trans 'No Factors configured. No Users will be able to login.' %}"></p>
<p>{% trans 'No Stages configured. No Users will be able to login.' %}"></p>
{% else %}
<i class="pf-icon pf-icon-ok"></i> {{ factor_count }}
{% endif %}

View file

@ -10,7 +10,7 @@
<i class="pf-icon pf-icon-infrastructure"></i>
{% trans 'Policies' %}
</h1>
<p>{% trans "Allow users to use Applications based on properties, enforce Password Criteria and selectively apply Factors." %}</p>
<p>{% trans "Allow users to use Applications based on properties, enforce Password Criteria and selectively apply Stages." %}</p>
</div>
</section>
<section class="pf-c-page__main-section pf-m-no-padding-mobile">

View file

@ -9,9 +9,9 @@
<div class="pf-c-content">
<h1>
<i class="pf-icon pf-icon-plugged"></i>
{% trans 'Factors' %}
{% trans 'Stages' %}
</h1>
<p>{% trans "Factors required for a user to successfully authenticate." %}
<p>{% trans "Stages required for a user to successfully authenticate." %}
</p>
</div>
</section>
@ -27,7 +27,7 @@
<ul class="pf-c-dropdown__menu" hidden>
{% for type, name in types.items %}
<li>
<a class="pf-c-dropdown__menu-item" href="{% url 'passbook_admin:factor-create' %}?type={{ type }}&back={{ request.get_full_path }}">{{ name }}</a>
<a class="pf-c-dropdown__menu-item" href="{% url 'passbook_admin:stage-create' %}?type={{ type }}&back={{ request.get_full_path }}">{{ name }}</a>
</li>
{% endfor %}
</ul>
@ -39,34 +39,36 @@
<thead>
<tr role="row">
<th role="columnheader" scope="col">{% trans 'Name' %}</th>
<th role="columnheader" scope="col">{% trans 'Order' %}</th>
<th role="columnheader" scope="col">{% trans 'Flows' %}</th>
<th role="columnheader" scope="col">{% trans 'Enabled' %}</th>
<th role="cell"></th>
</tr>
</thead>
<tbody role="rowgroup">
{% for factor in object_list %}
{% for stage in object_list %}
<tr role="row">
<th role="columnheader">
<div>
<div>{{ factor.name }} ({{ factor.slug }})</div>
<small>{{ factor|verbose_name }}</small>
<div>{{ stage.name }}</div>
<small>{{ stage|verbose_name }}</small>
</div>
</th>
<td role="cell">
<span>
{{ factor.order }}
</span>
<ul>
{% for flow in stage.flow_set.all %}
<li><a href="{% url 'passbook_admin:flow-update' pk=flow.pk %}">{{ flow.slug }}</a></li>
{% endfor %}
</ul>
</td>
<td role="cell">
<span>
{{ factor.enabled }}
{{ stage.enabled }}
</span>
</td>
<td>
<a class="pf-c-button pf-m-secondary" href="{% url 'passbook_admin:factor-update' pk=factor.pk %}?back={{ request.get_full_path }}">{% trans 'Edit' %}</a>
<a class="pf-c-button pf-m-danger" href="{% url 'passbook_admin:factor-delete' pk=factor.pk %}?back={{ request.get_full_path }}">{% trans 'Delete' %}</a>
{% get_links factor as links %}
<a class="pf-c-button pf-m-secondary" href="{% url 'passbook_admin:stage-update' pk=stage.pk %}?back={{ request.get_full_path }}">{% trans 'Edit' %}</a>
<a class="pf-c-button pf-m-danger" href="{% url 'passbook_admin:stage-delete' pk=stage.pk %}?back={{ request.get_full_path }}">{% trans 'Delete' %}</a>
{% get_links stage as links %}
{% for name, href in links.items %}
<a class="pf-c-button pf-m-tertiary" href="{{ href }}?back={{ request.get_full_path }}">{% trans name %}</a>
{% endfor %}

View file

@ -24,12 +24,12 @@ def all_subclasses(cls):
class StageListView(LoginRequiredMixin, PermissionListMixin, ListView):
"""Show list of all flows"""
"""Show list of all stages"""
model = Stage
template_name = "administration/flow/list.html"
permission_required = "passbook_core.view_flow"
ordering = "order"
template_name = "administration/stage/list.html"
permission_required = "passbook_flows.view_stage"
ordering = "name"
paginate_by = 40
def get_context_data(self, **kwargs):
@ -52,21 +52,21 @@ class StageCreateView(
model = Stage
template_name = "generic/create.html"
permission_required = "passbook_core.add_flow"
permission_required = "passbook_flows.add_stage"
success_url = reverse_lazy("passbook_admin:flows")
success_url = reverse_lazy("passbook_admin:stages")
success_message = _("Successfully created Stage")
def get_context_data(self, **kwargs):
kwargs = super().get_context_data(**kwargs)
flow_type = self.request.GET.get("type")
model = next(x for x in all_subclasses(Stage) if x.__name__ == flow_type)
stage_type = self.request.GET.get("type")
model = next(x for x in all_subclasses(Stage) if x.__name__ == stage_type)
kwargs["type"] = model._meta.verbose_name
return kwargs
def get_form_class(self):
flow_type = self.request.GET.get("type")
model = next(x for x in all_subclasses(Stage) if x.__name__ == flow_type)
stage_type = self.request.GET.get("type")
model = next(x for x in all_subclasses(Stage) if x.__name__ == stage_type)
if not model:
raise Http404
return path_to_class(model.form)
@ -75,12 +75,12 @@ class StageCreateView(
class StageUpdateView(
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
):
"""Update flow"""
"""Update stage"""
model = Stage
permission_required = "passbook_core.update_application"
permission_required = "passbook_flows.update_application"
template_name = "generic/update.html"
success_url = reverse_lazy("passbook_admin:flows")
success_url = reverse_lazy("passbook_admin:stages")
success_message = _("Successfully updated Stage")
def get_form_class(self):
@ -97,12 +97,12 @@ class StageUpdateView(
class StageDeleteView(
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, DeleteView
):
"""Delete flow"""
"""Delete stage"""
model = Stage
template_name = "generic/delete.html"
permission_required = "passbook_core.delete_flow"
success_url = reverse_lazy("passbook_admin:flows")
permission_required = "passbook_flows.delete_stage"
success_url = reverse_lazy("passbook_admin:stages")
success_message = _("Successfully deleted Stage")
def get_object(self, queryset=None):

View file

@ -21,7 +21,7 @@
{% user_stages as user_stages_loc %}
{% if user_stages_loc %}
<section class="pf-c-nav__section">
<h2 class="pf-c-nav__section-title">{% trans 'Factors' %}</h2>
<h2 class="pf-c-nav__section-title">{% trans 'Stages' %}</h2>
<ul class="pf-c-nav__list">
{% for stage in user_stages_loc %}
<li class="pf-c-nav__item">