diff --git a/passbook/admin/templates/administration/application/create.html b/passbook/admin/templates/administration/application/create.html deleted file mode 100644 index e23684b08..000000000 --- a/passbook/admin/templates/administration/application/create.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends "administration/base.html" %} - -{% block content %} -
- {{ form }} -
-{% endblock %} \ No newline at end of file diff --git a/passbook/admin/templates/administration/application/list.html b/passbook/admin/templates/administration/application/list.html index 7bd108b2d..517fe3b5e 100644 --- a/passbook/admin/templates/administration/application/list.html +++ b/passbook/admin/templates/administration/application/list.html @@ -1,647 +1,37 @@ {% extends "administration/base.html" %} -{% block content %} - -
-
-
-
- -
-
- - -
- -
-
-
- - - +{% load i18n %} +{% load utils %} -
-
-
- -
- -
- 1 of 3 - - - -
-
-
-
-
-
-
- -
-
- 0 of 0 selected -
-
-
-
- - - - - - - - - - - - - - -
Rendering EngineBrowserPlatform(s)Engine VersionCSS GradeActions
- -
-
- - per page -
-
- 1-15 of 75 - - - - of 5 - -
-
- - - +{% block title %} +{% title %} {% endblock %} -{% block scripts %} - - - +{% block content %} +
+ + {% trans 'Create...' %} + +
+ + + + + + + + + + + {% for application in object_list %} + + + + + + + {% endfor %} + +
{% trans 'Name' %}{% trans 'Provider' %}
{{ application.name }}{{ application.provider }}{% trans 'Edit' %}{% trans 'Delete' %}
+
{% endblock %} \ No newline at end of file diff --git a/passbook/admin/templates/generic/form.html b/passbook/admin/templates/generic/form.html index 977b9238b..541ab2466 100644 --- a/passbook/admin/templates/generic/form.html +++ b/passbook/admin/templates/generic/form.html @@ -7,10 +7,11 @@
{% block above_form %} {% endblock %} -
- {% csrf_token %} - {{ form|crispy }} - -
+
+
+ {% include 'blocks/form.html' with form=form %} + +
+
{% endblock %} \ No newline at end of file diff --git a/passbook/admin/urls.py b/passbook/admin/urls.py index d6a517c73..5d623bd2d 100644 --- a/passbook/admin/urls.py +++ b/passbook/admin/urls.py @@ -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//update/', + applications.ApplicationUpdateView.as_view(), name='application-update'), + path('applications//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//update/', sources.SourceUpdateView.as_view(), name='source-update'), diff --git a/passbook/admin/views/applications.py b/passbook/admin/views/applications.py index c097a1ff9..e2059dba5 100644 --- a/passbook/admin/views/applications.py +++ b/passbook/admin/views/applications.py @@ -1,21 +1,49 @@ -"""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(AdminRequiredMixin, CreateView): - """Create new application""" + +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 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')