admin: add source admin
This commit is contained in:
		| @ -8,14 +8,14 @@ | |||||||
|   <li class="{% is_active 'passbook_admin:overview' %}"> |   <li class="{% is_active 'passbook_admin:overview' %}"> | ||||||
|     <a href="{% url 'passbook_admin:overview' %}">{% trans 'Overview' %}</a> |     <a href="{% url 'passbook_admin:overview' %}">{% trans 'Overview' %}</a> | ||||||
|   </li> |   </li> | ||||||
|   <li class="{% is_active 'passbook_admin:applications' %}"> |   <li class="{% is_active 'passbook_admin:applications' 'passbook_admin:application-create' 'passbook_admin:application-update' 'passbook_admin:application-delete' %}"> | ||||||
|     <a href="{% url 'passbook_admin:applications' %}">{% trans 'Applications' %}</a> |     <a href="{% url 'passbook_admin:applications' %}">{% trans 'Applications' %}</a> | ||||||
|   </li> |   </li> | ||||||
|   <li class="{% is_active 'passbook_admin:sources' %}"> |   <li class="{% is_active 'passbook_admin:sources' 'passbook_admin:source-create' 'passbook_admin:source-update' 'passbook_admin:source-delete' %}"> | ||||||
|     <a href="{% url 'passbook_admin:sources' %}">{% trans 'Sources' %}</a> |     <a href="{% url 'passbook_admin:sources' %}">{% trans 'Sources' %}</a> | ||||||
|   </li> |   </li> | ||||||
|   <li> |   <li class="{% is_active 'passbook_admin:rules' 'passbook_admin:rule-create' 'passbook_admin:rule-update' 'passbook_admin:rule-delete' %}"> | ||||||
|     <a href="#">{% trans 'Rules' %}</a> |     <a href="{% url 'passbook_admin:rules' %}">{% trans 'Rules' %}</a> | ||||||
|   </li> |   </li> | ||||||
|   <li> |   <li> | ||||||
|     <a href="#">{% trans 'Users' %}</a> |     <a href="#">{% trans 'Users' %}</a> | ||||||
|  | |||||||
| @ -3,7 +3,8 @@ | |||||||
| {% load i18n %} | {% load i18n %} | ||||||
|  |  | ||||||
| {% block content %} | {% block content %} | ||||||
| <div class="col-xs-6 col-sm-2 col-md-2"> | <div class="container"> | ||||||
|  |   <div class="col-xs-6 col-sm-2 col-md-2"> | ||||||
|     <div class="card-pf card-pf-accented card-pf-aggregate-status"> |     <div class="card-pf card-pf-accented card-pf-aggregate-status"> | ||||||
|       <h2 class="card-pf-title"> |       <h2 class="card-pf-title"> | ||||||
|         <a href="#"><span class="fa fa-shield"></span><span class="card-pf-aggregate-status-count"></span> {% trans 'Applications' %}</a> |         <a href="#"><span class="fa fa-shield"></span><span class="card-pf-aggregate-status-count"></span> {% trans 'Applications' %}</a> | ||||||
| @ -14,8 +15,8 @@ | |||||||
|         </p> |         </p> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
| </div> |   </div> | ||||||
| <div class="col-xs-6 col-sm-2 col-md-2"> |   <div class="col-xs-6 col-sm-2 col-md-2"> | ||||||
|     <div class="card-pf card-pf-accented card-pf-aggregate-status"> |     <div class="card-pf card-pf-accented card-pf-aggregate-status"> | ||||||
|       <h2 class="card-pf-title"> |       <h2 class="card-pf-title"> | ||||||
|         <a href="#"><span class="fa fa-shield"></span><span class="card-pf-aggregate-status-count"></span> {% trans 'Providers' %}</a> |         <a href="#"><span class="fa fa-shield"></span><span class="card-pf-aggregate-status-count"></span> {% trans 'Providers' %}</a> | ||||||
| @ -26,8 +27,8 @@ | |||||||
|         </p> |         </p> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
| </div> |   </div> | ||||||
| <div class="col-xs-6 col-sm-2 col-md-2"> |   <div class="col-xs-6 col-sm-2 col-md-2"> | ||||||
|     <div class="card-pf card-pf-accented card-pf-aggregate-status"> |     <div class="card-pf card-pf-accented card-pf-aggregate-status"> | ||||||
|       <h2 class="card-pf-title"> |       <h2 class="card-pf-title"> | ||||||
|         <a href="#"><span class="fa fa-shield"></span><span class="card-pf-aggregate-status-count"></span> {% trans 'Rules' %}</a> |         <a href="#"><span class="fa fa-shield"></span><span class="card-pf-aggregate-status-count"></span> {% trans 'Rules' %}</a> | ||||||
| @ -38,8 +39,8 @@ | |||||||
|         </p> |         </p> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
| </div> |   </div> | ||||||
| <div class="col-xs-6 col-sm-2 col-md-2"> |   <div class="col-xs-6 col-sm-2 col-md-2"> | ||||||
|     <div class="card-pf card-pf-accented card-pf-aggregate-status"> |     <div class="card-pf card-pf-accented card-pf-aggregate-status"> | ||||||
|       <h2 class="card-pf-title"> |       <h2 class="card-pf-title"> | ||||||
|         <a href="#"><span class="fa fa-shield"></span><span class="card-pf-aggregate-status-count"></span> {% trans 'Users' %}</a> |         <a href="#"><span class="fa fa-shield"></span><span class="card-pf-aggregate-status-count"></span> {% trans 'Users' %}</a> | ||||||
| @ -50,5 +51,6 @@ | |||||||
|         </p> |         </p> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|  |   </div> | ||||||
| </div> | </div> | ||||||
| {% endblock %} | {% endblock %} | ||||||
							
								
								
									
										11
									
								
								passbook/admin/templates/administration/source/create.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								passbook/admin/templates/administration/source/create.html
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | {% extends "generic/create.html" %} | ||||||
|  |  | ||||||
|  | {% load i18n %} | ||||||
|  |  | ||||||
|  | {% block title %} | ||||||
|  | {% blocktrans with type=request.GET.type %}Create {{ type }}{% endblocktrans %} | ||||||
|  | {% endblock %} | ||||||
|  |  | ||||||
|  | {% block above_form %} | ||||||
|  | <h1>{% blocktrans with type=request.GET.type %}Create {{ type }}{% endblocktrans %}</h1> | ||||||
|  | {% endblock %} | ||||||
| @ -1,9 +1,11 @@ | |||||||
| {% extends "generic/list.html" %} | {% extends "administration/base.html" %} | ||||||
|  |  | ||||||
| {% load i18n %} | {% load i18n %} | ||||||
|  | {% load utils %} | ||||||
|  |  | ||||||
| {% block above_table %} | {% block content %} | ||||||
| <div class="dropdown"> | <div class="container"> | ||||||
|  |   <div class="dropdown"> | ||||||
|     <button class="btn btn-primary dropdown-toggle" type="button" id="createDropdown" data-toggle="dropdown"> |     <button class="btn btn-primary dropdown-toggle" type="button" id="createDropdown" data-toggle="dropdown"> | ||||||
|       {% trans 'Create...' %} |       {% trans 'Create...' %} | ||||||
|       <span class="caret"></span> |       <span class="caret"></span> | ||||||
| @ -13,6 +15,27 @@ | |||||||
|       <li role="presentation"><a role="menuitem" tabindex="-1" href="{% url 'passbook_admin:source-create' %}?type={{ type }}">{{ name }}</a></li> |       <li role="presentation"><a role="menuitem" tabindex="-1" href="{% url 'passbook_admin:source-create' %}?type={{ type }}">{{ name }}</a></li> | ||||||
|       {% endfor %} |       {% endfor %} | ||||||
|     </ul> |     </ul> | ||||||
|  |   </div> | ||||||
|  |   <hr> | ||||||
|  |   <table class="table table-striped table-bordered"> | ||||||
|  |     <thead> | ||||||
|  |       <tr> | ||||||
|  |         <th>{% trans 'Name' %}</th> | ||||||
|  |         <th>{% trans 'Class' %}</th> | ||||||
|  |         <th></th> | ||||||
|  |         <th></th> | ||||||
|  |       </tr> | ||||||
|  |     </thead> | ||||||
|  |     <tbody> | ||||||
|  |       {% for source in object_list %} | ||||||
|  |         <tr> | ||||||
|  |           <td>{{ source.name }}</td> | ||||||
|  |           <td>{{ source.cast|fieldtype }}</td> | ||||||
|  |           <td><a href="{% url 'passbook_admin:source-update' pk=source.uuid %}">{% trans 'Edit' %}</a></td> | ||||||
|  |           <td><a href="{% url 'passbook_admin:source-delete' pk=source.uuid %}">{% trans 'Delete' %}</a></td> | ||||||
|  |         </tr> | ||||||
|  |       {% endfor %} | ||||||
|  |     </tbody> | ||||||
|  |   </table> | ||||||
| </div> | </div> | ||||||
| <hr> |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
| @ -1,7 +1,7 @@ | |||||||
| """passbook URL Configuration""" | """passbook URL Configuration""" | ||||||
| from django.urls import path | from django.urls import path | ||||||
|  |  | ||||||
| from passbook.admin.views import applications, overview, sources | from passbook.admin.views import applications, overview, rules, sources | ||||||
|  |  | ||||||
| urlpatterns = [ | urlpatterns = [ | ||||||
|     path('', overview.AdministrationOverviewView.as_view(), name='overview'), |     path('', overview.AdministrationOverviewView.as_view(), name='overview'), | ||||||
| @ -14,6 +14,7 @@ urlpatterns = [ | |||||||
|          applications.ApplicationUpdateView.as_view(), name='application-update'), |          applications.ApplicationUpdateView.as_view(), name='application-update'), | ||||||
|     path('applications/<uuid:pk>/delete/', |     path('applications/<uuid:pk>/delete/', | ||||||
|          applications.ApplicationDeleteView.as_view(), name='application-delete'), |          applications.ApplicationDeleteView.as_view(), name='application-delete'), | ||||||
|  |     # Sources | ||||||
|     path('sources/', sources.SourceListView.as_view(), name='sources'), |     path('sources/', sources.SourceListView.as_view(), name='sources'), | ||||||
|     path('sources/create/', sources.SourceCreateView.as_view(), name='source-create'), |     path('sources/create/', sources.SourceCreateView.as_view(), name='source-create'), | ||||||
|     path('sources/<uuid:pk>/update/', sources.SourceUpdateView.as_view(), name='source-update'), |     path('sources/<uuid:pk>/update/', sources.SourceUpdateView.as_view(), name='source-update'), | ||||||
|  | |||||||
| @ -21,11 +21,14 @@ class SourceListView(AdminRequiredMixin, ListView): | |||||||
|             x.__name__: x._meta.verbose_name for x in Source.__subclasses__()} |             x.__name__: x._meta.verbose_name for x in Source.__subclasses__()} | ||||||
|         return super().get_context_data(**kwargs) |         return super().get_context_data(**kwargs) | ||||||
|  |  | ||||||
|  |     def get_queryset(self): | ||||||
|  |         return super().get_queryset().select_subclasses() | ||||||
|  |  | ||||||
|  |  | ||||||
| class SourceCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView): | class SourceCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView): | ||||||
|     """Create new Source""" |     """Create new Source""" | ||||||
|  |  | ||||||
|     template_name = 'generic/create.html' |     template_name = 'administration/source/create.html' | ||||||
|     success_url = reverse_lazy('passbook_admin:sources') |     success_url = reverse_lazy('passbook_admin:sources') | ||||||
|     success_message = _('Successfully created Source') |     success_message = _('Successfully created Source') | ||||||
|  |  | ||||||
|  | |||||||
							
								
								
									
										18
									
								
								passbook/core/forms/applications.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								passbook/core/forms/applications.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | |||||||
|  | """passbook Core Application forms""" | ||||||
|  | from django import forms | ||||||
|  |  | ||||||
|  | from passbook.core.models import Application | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class ApplicationForm(forms.ModelForm): | ||||||
|  |     """Application Form""" | ||||||
|  |  | ||||||
|  |     class Meta: | ||||||
|  |  | ||||||
|  |         model = Application | ||||||
|  |         fields = ['name', 'launch_url', 'icon_url', 'rules', 'provider', 'skip_authorization'] | ||||||
|  |         widgets = { | ||||||
|  |             'name': forms.TextInput(), | ||||||
|  |             'launch_url': forms.TextInput(), | ||||||
|  |             'icon_url': forms.TextInput(), | ||||||
|  |         } | ||||||
| @ -14,6 +14,14 @@ class LDAPSourceForm(forms.ModelForm): | |||||||
|         model = LDAPSource |         model = LDAPSource | ||||||
|         fields = SOURCE_FORM_FIELDS + ['server_uri', 'bind_cn', 'bind_password', |         fields = SOURCE_FORM_FIELDS + ['server_uri', 'bind_cn', 'bind_password', | ||||||
|                                        'type', 'domain', 'base_dn', 'create_user', 'reset_password'] |                                        'type', 'domain', 'base_dn', 'create_user', 'reset_password'] | ||||||
|  |         widgets = { | ||||||
|  |             'name': forms.TextInput(), | ||||||
|  |             'server_uri': forms.TextInput(), | ||||||
|  |             'bind_cn': forms.TextInput(), | ||||||
|  |             'bind_password': forms.TextInput(), | ||||||
|  |             'domain': forms.TextInput(), | ||||||
|  |             'base_dn': forms.TextInput(), | ||||||
|  |         } | ||||||
|  |  | ||||||
| # class GeneralSettingsForm(SettingsForm): | # class GeneralSettingsForm(SettingsForm): | ||||||
| #     """general settings form""" | #     """general settings form""" | ||||||
|  | |||||||
| @ -12,8 +12,8 @@ class LDAPSource(Source): | |||||||
|     TYPE_ACTIVE_DIRECTORY = 'ad' |     TYPE_ACTIVE_DIRECTORY = 'ad' | ||||||
|     TYPE_GENERIC = 'generic' |     TYPE_GENERIC = 'generic' | ||||||
|     TYPES = ( |     TYPES = ( | ||||||
|         (TYPE_ACTIVE_DIRECTORY, TYPE_ACTIVE_DIRECTORY), |         (TYPE_ACTIVE_DIRECTORY, _('Active Directory')), | ||||||
|         (TYPE_GENERIC, TYPE_GENERIC), |         (TYPE_GENERIC, _('Generic')), | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|     server_uri = models.TextField() |     server_uri = models.TextField() | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer