admin: add source admin
This commit is contained in:
		@ -8,14 +8,14 @@
 | 
			
		||||
  <li class="{% is_active 'passbook_admin:overview' %}">
 | 
			
		||||
    <a href="{% url 'passbook_admin:overview' %}">{% trans 'Overview' %}</a>
 | 
			
		||||
  </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>
 | 
			
		||||
  </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>
 | 
			
		||||
  </li>
 | 
			
		||||
  <li>
 | 
			
		||||
    <a href="#">{% trans 'Rules' %}</a>
 | 
			
		||||
  <li class="{% is_active 'passbook_admin:rules' 'passbook_admin:rule-create' 'passbook_admin:rule-update' 'passbook_admin:rule-delete' %}">
 | 
			
		||||
    <a href="{% url 'passbook_admin:rules' %}">{% trans 'Rules' %}</a>
 | 
			
		||||
  </li>
 | 
			
		||||
  <li>
 | 
			
		||||
    <a href="#">{% trans 'Users' %}</a>
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
<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">
 | 
			
		||||
      <h2 class="card-pf-title">
 | 
			
		||||
@ -51,4 +52,5 @@
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
{% 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,8 +1,10 @@
 | 
			
		||||
{% extends "generic/list.html" %}
 | 
			
		||||
{% extends "administration/base.html" %}
 | 
			
		||||
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
{% load utils %}
 | 
			
		||||
 | 
			
		||||
{% block above_table %}
 | 
			
		||||
{% block content %}
 | 
			
		||||
<div class="container">
 | 
			
		||||
  <div class="dropdown">
 | 
			
		||||
    <button class="btn btn-primary dropdown-toggle" type="button" id="createDropdown" data-toggle="dropdown">
 | 
			
		||||
      {% trans 'Create...' %}
 | 
			
		||||
@ -15,4 +17,25 @@
 | 
			
		||||
    </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>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
"""passbook URL Configuration"""
 | 
			
		||||
from django.urls import path
 | 
			
		||||
 | 
			
		||||
from passbook.admin.views import applications, overview, sources
 | 
			
		||||
from passbook.admin.views import applications, overview, rules, sources
 | 
			
		||||
 | 
			
		||||
urlpatterns = [
 | 
			
		||||
    path('', overview.AdministrationOverviewView.as_view(), name='overview'),
 | 
			
		||||
@ -14,6 +14,7 @@ urlpatterns = [
 | 
			
		||||
         applications.ApplicationUpdateView.as_view(), name='application-update'),
 | 
			
		||||
    path('applications/<uuid:pk>/delete/',
 | 
			
		||||
         applications.ApplicationDeleteView.as_view(), name='application-delete'),
 | 
			
		||||
    # Sources
 | 
			
		||||
    path('sources/', sources.SourceListView.as_view(), name='sources'),
 | 
			
		||||
    path('sources/create/', sources.SourceCreateView.as_view(), name='source-create'),
 | 
			
		||||
    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__()}
 | 
			
		||||
        return super().get_context_data(**kwargs)
 | 
			
		||||
 | 
			
		||||
    def get_queryset(self):
 | 
			
		||||
        return super().get_queryset().select_subclasses()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class SourceCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
 | 
			
		||||
    """Create new Source"""
 | 
			
		||||
 | 
			
		||||
    template_name = 'generic/create.html'
 | 
			
		||||
    template_name = 'administration/source/create.html'
 | 
			
		||||
    success_url = reverse_lazy('passbook_admin:sources')
 | 
			
		||||
    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
 | 
			
		||||
        fields = SOURCE_FORM_FIELDS + ['server_uri', 'bind_cn', 'bind_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):
 | 
			
		||||
#     """general settings form"""
 | 
			
		||||
 | 
			
		||||
@ -12,8 +12,8 @@ class LDAPSource(Source):
 | 
			
		||||
    TYPE_ACTIVE_DIRECTORY = 'ad'
 | 
			
		||||
    TYPE_GENERIC = 'generic'
 | 
			
		||||
    TYPES = (
 | 
			
		||||
        (TYPE_ACTIVE_DIRECTORY, TYPE_ACTIVE_DIRECTORY),
 | 
			
		||||
        (TYPE_GENERIC, TYPE_GENERIC),
 | 
			
		||||
        (TYPE_ACTIVE_DIRECTORY, _('Active Directory')),
 | 
			
		||||
        (TYPE_GENERIC, _('Generic')),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    server_uri = models.TextField()
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user