admin: add generic create and delete template

This commit is contained in:
Jens Langhammer 2018-11-26 22:30:14 +01:00
parent 5c5c865c0b
commit 755997a9c7
5 changed files with 38 additions and 8 deletions

View 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 %}

View File

@ -0,0 +1,20 @@
{% extends "administration/base.html" %}
{% load i18n %}
{% load utils %}
{% block content %}
<div class="container">
{% block above_form %}
<h1>{% trans 'Delete' %}</h1>
{% endblock %}
<div class="">
<form method="post" class="form-horizontal">
{% csrf_token %}
<p>Are you sure you want to delete "{{ object }}"?</p>
<a href="{% back %}" class="btn btn-default">{% trans 'Back' %}</a>
<input type="submit" class="btn btn-danger" value="{% trans 'Delete' %}" />
</form>
</div>
</div>
{% endblock %}

View File

@ -1,7 +1,7 @@
{% extends "administration/base.html" %}
{% load crispy_forms_tags %}
{% load i18n %}
{% load utils %}
{% block content %}
<div class="container">
@ -10,6 +10,7 @@
<div class="">
<form action="" method="post" class="form-horizontal">
{% include 'blocks/form.html' with form=form %}
<a class="btn btn-default" href="{% back %}">{% trans "Cancel" %}</a>
<input type="submit" class="btn btn-primary" value="{% trans 'Create' %}" />
</form>
</div>

View File

@ -28,7 +28,7 @@ class RuleListView(AdminRequiredMixin, ListView):
class RuleCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
"""Create new Rule"""
template_name = 'administration/rule/create.html'
template_name = 'generic/create_inheritance.html'
success_url = reverse_lazy('passbook_admin:rules')
success_message = _('Successfully created Rule')
@ -55,18 +55,16 @@ class RuleUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView):
return form_class
def get_object(self, queryset=None):
obj = Rule.objects.get(pk=self.kwargs.get('pk'))
return obj.cast()
return Rule.objects.filter(pk=self.kwargs.get('pk')).select_subclasses().first()
class RuleDeleteView(SuccessMessageMixin, AdminRequiredMixin, DeleteView):
"""Delete rule"""
model = Rule
template_name = 'generic/delete.html'
success_url = reverse_lazy('passbook_admin:rules')
success_message = _('Successfully updated Rule')
def get_object(self, queryset=None):
obj = Rule.objects.get(pk=self.kwargs.get('pk'))
return obj.cast()
return Rule.objects.filter(pk=self.kwargs.get('pk')).select_subclasses().first()

View File

@ -28,7 +28,7 @@ class SourceListView(AdminRequiredMixin, ListView):
class SourceCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
"""Create new Source"""
template_name = 'administration/source/create.html'
template_name = 'generic/create_inheritance.html'
success_url = reverse_lazy('passbook_admin:sources')
success_message = _('Successfully created Source')