Commit 2aa12801 authored by Jens Langhammer's avatar Jens Langhammer

admin: add application admin

parent c507e310
{% extends "administration/base.html" %}
{% block content %}
<form action="">
{{ form }}
</form>
{% endblock %}
\ No newline at end of file
......@@ -7,10 +7,11 @@
<div class="container">
{% block above_form %}
{% endblock %}
<form action="" method="post">
{% csrf_token %}
{{ form|crispy }}
<input type="submit" class="btn btn-primary" value="{% trans 'Update' %}" />
</form>
<div class="">
<form action="" method="post" class="form-horizontal">
{% include 'blocks/form.html' with form=form %}
<input type="submit" class="btn btn-primary" value="{% trans 'Create' %}" />
</form>
</div>
</div>
{% endblock %}
\ No newline at end of file
......@@ -5,10 +5,15 @@ from passbook.admin.views import applications, overview, sources
urlpatterns = [
path('', overview.AdministrationOverviewView.as_view(), name='overview'),
# Applications
path('applications/', applications.ApplicationListView.as_view(),
name='applications'),
path('applications/create/', applications.ApplicationCreateView.as_view(),
name='application-create'),
path('applications/<uuid:pk>/update/',
applications.ApplicationUpdateView.as_view(), name='application-update'),
path('applications/<uuid:pk>/delete/',
applications.ApplicationDeleteView.as_view(), name='application-delete'),
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'),
......
"""passbook application administration"""
from django.views.generic import CreateView, ListView
"""passbook Application administration"""
from django.contrib.messages.views import SuccessMessageMixin
from django.urls import reverse_lazy
from django.utils.translation import ugettext as _
from django.views.generic import CreateView, DeleteView, ListView, UpdateView
from passbook.admin.mixins import AdminRequiredMixin
from passbook.core.forms.applications import ApplicationForm
from passbook.core.models import Application
class ApplicationListView(AdminRequiredMixin, ListView):
"""List all applications"""
"""Show list of all applications"""
model = Application
template_name = 'administration/application/list.html'
def get_queryset(self):
return super().get_queryset().select_subclasses()
class ApplicationCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
"""Create new Application"""
form_class = ApplicationForm
template_name = 'generic/create.html'
success_url = reverse_lazy('passbook_admin:applications')
success_message = _('Successfully created Application')
class ApplicationCreateView(AdminRequiredMixin, CreateView):
"""Create new application"""
class ApplicationUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView):
"""Update application"""
model = Application
template_name = 'administration/application/create.html'
fields = ['name', 'launch_url', 'icon_url']
form_class = ApplicationForm
template_name = 'generic/update.html'
success_url = reverse_lazy('passbook_admin:applications')
success_message = _('Successfully updated Application')
class ApplicationDeleteView(SuccessMessageMixin, AdminRequiredMixin, DeleteView):
"""Delete application"""
model = Application
success_url = reverse_lazy('passbook_admin:applications')
success_message = _('Successfully updated Application')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment