admin: update templates and stage views
This commit is contained in:
		| @ -59,9 +59,9 @@ | |||||||
|                     </a> |                     </a> | ||||||
|                 </li> |                 </li> | ||||||
|                 <li class="pf-c-nav__item"> |                 <li class="pf-c-nav__item"> | ||||||
|                     <a href="{% url 'passbook_admin:factors' %}" |                     <a href="{% url 'passbook_admin:stages' %}" | ||||||
|                         class="pf-c-nav__link {% is_active 'passbook_admin:factors' 'passbook_admin:factor-create' 'passbook_admin:factor-update' 'passbook_admin:factor-delete' %}"> |                         class="pf-c-nav__link {% is_active 'passbook_admin:stages' 'passbook_admin:stage-create' 'passbook_admin:stage-update' 'passbook_admin:stage-delete' %}"> | ||||||
|                         {% trans 'Factors' %} |                         {% trans 'Stages' %} | ||||||
|                     </a> |                     </a> | ||||||
|                 </li> |                 </li> | ||||||
|                 <li class="pf-c-nav__item"> |                 <li class="pf-c-nav__item"> | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ | |||||||
|                 <tr role="row"> |                 <tr role="row"> | ||||||
|                     <th role="columnheader" scope="col">{% trans 'Name' %}</th> |                     <th role="columnheader" scope="col">{% trans 'Name' %}</th> | ||||||
|                     <th role="columnheader" scope="col">{% trans 'Designation' %}</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="columnheader" scope="col">{% trans 'Policies' %}</th> | ||||||
|                     <th role="cell"></th> |                     <th role="cell"></th> | ||||||
|                 </tr> |                 </tr> | ||||||
| @ -47,7 +47,7 @@ | |||||||
|                     </td> |                     </td> | ||||||
|                     <td role="cell"> |                     <td role="cell"> | ||||||
|                         <span> |                         <span> | ||||||
|                             {{ flow.factors.all|length }} |                             {{ flow.stages.all|length }} | ||||||
|                         </span> |                         </span> | ||||||
|                     </td> |                     </td> | ||||||
|                     <td role="cell"> |                     <td role="cell"> | ||||||
|  | |||||||
| @ -48,16 +48,16 @@ | |||||||
|             </div> |             </div> | ||||||
|         </a> |         </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"> | ||||||
|                 <div class="pf-c-card__head-main"> |                 <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> |             </div> | ||||||
|             <div class="pf-c-card__body"> |             <div class="pf-c-card__body"> | ||||||
|                 {% if factor_count < 1 %} |                 {% if factor_count < 1 %} | ||||||
|                 <i class="pficon-error-circle-o"></i> {{ factor_count }} |                 <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 %} |                 {% else %} | ||||||
|                 <i class="pf-icon pf-icon-ok"></i> {{ factor_count }} |                 <i class="pf-icon pf-icon-ok"></i> {{ factor_count }} | ||||||
|                 {% endif %} |                 {% endif %} | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ | |||||||
|             <i class="pf-icon pf-icon-infrastructure"></i> |             <i class="pf-icon pf-icon-infrastructure"></i> | ||||||
|             {% trans 'Policies' %} |             {% trans 'Policies' %} | ||||||
|         </h1> |         </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> |     </div> | ||||||
| </section> | </section> | ||||||
| <section class="pf-c-page__main-section pf-m-no-padding-mobile"> | <section class="pf-c-page__main-section pf-m-no-padding-mobile"> | ||||||
|  | |||||||
| @ -9,9 +9,9 @@ | |||||||
|     <div class="pf-c-content"> |     <div class="pf-c-content"> | ||||||
|         <h1> |         <h1> | ||||||
|             <i class="pf-icon pf-icon-plugged"></i> |             <i class="pf-icon pf-icon-plugged"></i> | ||||||
|             {% trans 'Factors' %} |             {% trans 'Stages' %} | ||||||
|         </h1> |         </h1> | ||||||
|         <p>{% trans "Factors required for a user to successfully authenticate." %} |         <p>{% trans "Stages required for a user to successfully authenticate." %} | ||||||
|         </p> |         </p> | ||||||
|     </div> |     </div> | ||||||
| </section> | </section> | ||||||
| @ -27,7 +27,7 @@ | |||||||
|                     <ul class="pf-c-dropdown__menu" hidden> |                     <ul class="pf-c-dropdown__menu" hidden> | ||||||
|                         {% for type, name in types.items %} |                         {% for type, name in types.items %} | ||||||
|                         <li> |                         <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> |                         </li> | ||||||
|                         {% endfor %} |                         {% endfor %} | ||||||
|                     </ul> |                     </ul> | ||||||
| @ -39,34 +39,36 @@ | |||||||
|             <thead> |             <thead> | ||||||
|                 <tr role="row"> |                 <tr role="row"> | ||||||
|                     <th role="columnheader" scope="col">{% trans 'Name' %}</th> |                     <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="columnheader" scope="col">{% trans 'Enabled' %}</th> | ||||||
|                     <th role="cell"></th> |                     <th role="cell"></th> | ||||||
|                 </tr> |                 </tr> | ||||||
|             </thead> |             </thead> | ||||||
|             <tbody role="rowgroup"> |             <tbody role="rowgroup"> | ||||||
|                 {% for factor in object_list %} |                 {% for stage in object_list %} | ||||||
|                 <tr role="row"> |                 <tr role="row"> | ||||||
|                     <th role="columnheader"> |                     <th role="columnheader"> | ||||||
|                         <div> |                         <div> | ||||||
|                             <div>{{ factor.name }} ({{ factor.slug }})</div> |                             <div>{{ stage.name }}</div> | ||||||
|                             <small>{{ factor|verbose_name }}</small> |                             <small>{{ stage|verbose_name }}</small> | ||||||
|                         </div> |                         </div> | ||||||
|                     </th> |                     </th> | ||||||
|                     <td role="cell"> |                     <td role="cell"> | ||||||
|                         <span> |                         <ul> | ||||||
|                             {{ factor.order }} |                             {% for flow in stage.flow_set.all %} | ||||||
|                         </span> |                             <li><a href="{% url 'passbook_admin:flow-update' pk=flow.pk %}">{{ flow.slug }}</a></li> | ||||||
|  |                             {% endfor %} | ||||||
|  |                         </ul> | ||||||
|                     </td> |                     </td> | ||||||
|                     <td role="cell"> |                     <td role="cell"> | ||||||
|                         <span> |                         <span> | ||||||
|                             {{ factor.enabled }} |                             {{ stage.enabled }} | ||||||
|                         </span> |                         </span> | ||||||
|                     </td> |                     </td> | ||||||
|                     <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-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:factor-delete' pk=factor.pk %}?back={{ request.get_full_path }}">{% trans 'Delete' %}</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 factor as links %} |                         {% get_links stage as links %} | ||||||
|                         {% for name, href in links.items %} |                         {% for name, href in links.items %} | ||||||
|                         <a class="pf-c-button pf-m-tertiary" href="{{ href }}?back={{ request.get_full_path }}">{% trans name %}</a> |                         <a class="pf-c-button pf-m-tertiary" href="{{ href }}?back={{ request.get_full_path }}">{% trans name %}</a> | ||||||
|                         {% endfor %} |                         {% endfor %} | ||||||
| @ -24,12 +24,12 @@ def all_subclasses(cls): | |||||||
|  |  | ||||||
|  |  | ||||||
| class StageListView(LoginRequiredMixin, PermissionListMixin, ListView): | class StageListView(LoginRequiredMixin, PermissionListMixin, ListView): | ||||||
|     """Show list of all flows""" |     """Show list of all stages""" | ||||||
|  |  | ||||||
|     model = Stage |     model = Stage | ||||||
|     template_name = "administration/flow/list.html" |     template_name = "administration/stage/list.html" | ||||||
|     permission_required = "passbook_core.view_flow" |     permission_required = "passbook_flows.view_stage" | ||||||
|     ordering = "order" |     ordering = "name" | ||||||
|     paginate_by = 40 |     paginate_by = 40 | ||||||
|  |  | ||||||
|     def get_context_data(self, **kwargs): |     def get_context_data(self, **kwargs): | ||||||
| @ -52,21 +52,21 @@ class StageCreateView( | |||||||
|  |  | ||||||
|     model = Stage |     model = Stage | ||||||
|     template_name = "generic/create.html" |     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") |     success_message = _("Successfully created Stage") | ||||||
|  |  | ||||||
|     def get_context_data(self, **kwargs): |     def get_context_data(self, **kwargs): | ||||||
|         kwargs = super().get_context_data(**kwargs) |         kwargs = super().get_context_data(**kwargs) | ||||||
|         flow_type = self.request.GET.get("type") |         stage_type = self.request.GET.get("type") | ||||||
|         model = next(x for x in all_subclasses(Stage) if x.__name__ == flow_type) |         model = next(x for x in all_subclasses(Stage) if x.__name__ == stage_type) | ||||||
|         kwargs["type"] = model._meta.verbose_name |         kwargs["type"] = model._meta.verbose_name | ||||||
|         return kwargs |         return kwargs | ||||||
|  |  | ||||||
|     def get_form_class(self): |     def get_form_class(self): | ||||||
|         flow_type = self.request.GET.get("type") |         stage_type = self.request.GET.get("type") | ||||||
|         model = next(x for x in all_subclasses(Stage) if x.__name__ == flow_type) |         model = next(x for x in all_subclasses(Stage) if x.__name__ == stage_type) | ||||||
|         if not model: |         if not model: | ||||||
|             raise Http404 |             raise Http404 | ||||||
|         return path_to_class(model.form) |         return path_to_class(model.form) | ||||||
| @ -75,12 +75,12 @@ class StageCreateView( | |||||||
| class StageUpdateView( | class StageUpdateView( | ||||||
|     SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView |     SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView | ||||||
| ): | ): | ||||||
|     """Update flow""" |     """Update stage""" | ||||||
|  |  | ||||||
|     model = Stage |     model = Stage | ||||||
|     permission_required = "passbook_core.update_application" |     permission_required = "passbook_flows.update_application" | ||||||
|     template_name = "generic/update.html" |     template_name = "generic/update.html" | ||||||
|     success_url = reverse_lazy("passbook_admin:flows") |     success_url = reverse_lazy("passbook_admin:stages") | ||||||
|     success_message = _("Successfully updated Stage") |     success_message = _("Successfully updated Stage") | ||||||
|  |  | ||||||
|     def get_form_class(self): |     def get_form_class(self): | ||||||
| @ -97,12 +97,12 @@ class StageUpdateView( | |||||||
| class StageDeleteView( | class StageDeleteView( | ||||||
|     SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, DeleteView |     SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, DeleteView | ||||||
| ): | ): | ||||||
|     """Delete flow""" |     """Delete stage""" | ||||||
|  |  | ||||||
|     model = Stage |     model = Stage | ||||||
|     template_name = "generic/delete.html" |     template_name = "generic/delete.html" | ||||||
|     permission_required = "passbook_core.delete_flow" |     permission_required = "passbook_flows.delete_stage" | ||||||
|     success_url = reverse_lazy("passbook_admin:flows") |     success_url = reverse_lazy("passbook_admin:stages") | ||||||
|     success_message = _("Successfully deleted Stage") |     success_message = _("Successfully deleted Stage") | ||||||
|  |  | ||||||
|     def get_object(self, queryset=None): |     def get_object(self, queryset=None): | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ | |||||||
|             {% user_stages as user_stages_loc %} |             {% user_stages as user_stages_loc %} | ||||||
|             {% if user_stages_loc %} |             {% if user_stages_loc %} | ||||||
|             <section class="pf-c-nav__section"> |             <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"> |                 <ul class="pf-c-nav__list"> | ||||||
|                     {% for stage in user_stages_loc %} |                     {% for stage in user_stages_loc %} | ||||||
|                     <li class="pf-c-nav__item"> |                     <li class="pf-c-nav__item"> | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer