admin: add generic create and delete template
This commit is contained in:
parent
5c5c865c0b
commit
755997a9c7
11
passbook/admin/templates/generic/create_inheritance.html
Normal file
11
passbook/admin/templates/generic/create_inheritance.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 %}
|
20
passbook/admin/templates/generic/delete.html
Normal file
20
passbook/admin/templates/generic/delete.html
Normal 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 %}
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "administration/base.html" %}
|
{% extends "administration/base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_tags %}
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load utils %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
<div class="">
|
<div class="">
|
||||||
<form action="" method="post" class="form-horizontal">
|
<form action="" method="post" class="form-horizontal">
|
||||||
{% include 'blocks/form.html' with form=form %}
|
{% 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' %}" />
|
<input type="submit" class="btn btn-primary" value="{% trans 'Create' %}" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,7 +28,7 @@ class RuleListView(AdminRequiredMixin, ListView):
|
||||||
class RuleCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
|
class RuleCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
|
||||||
"""Create new Rule"""
|
"""Create new Rule"""
|
||||||
|
|
||||||
template_name = 'administration/rule/create.html'
|
template_name = 'generic/create_inheritance.html'
|
||||||
success_url = reverse_lazy('passbook_admin:rules')
|
success_url = reverse_lazy('passbook_admin:rules')
|
||||||
success_message = _('Successfully created Rule')
|
success_message = _('Successfully created Rule')
|
||||||
|
|
||||||
|
@ -55,18 +55,16 @@ class RuleUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView):
|
||||||
return form_class
|
return form_class
|
||||||
|
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
obj = Rule.objects.get(pk=self.kwargs.get('pk'))
|
return Rule.objects.filter(pk=self.kwargs.get('pk')).select_subclasses().first()
|
||||||
return obj.cast()
|
|
||||||
|
|
||||||
|
|
||||||
class RuleDeleteView(SuccessMessageMixin, AdminRequiredMixin, DeleteView):
|
class RuleDeleteView(SuccessMessageMixin, AdminRequiredMixin, DeleteView):
|
||||||
"""Delete rule"""
|
"""Delete rule"""
|
||||||
|
|
||||||
model = Rule
|
model = Rule
|
||||||
|
template_name = 'generic/delete.html'
|
||||||
success_url = reverse_lazy('passbook_admin:rules')
|
success_url = reverse_lazy('passbook_admin:rules')
|
||||||
success_message = _('Successfully updated Rule')
|
success_message = _('Successfully updated Rule')
|
||||||
|
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
obj = Rule.objects.get(pk=self.kwargs.get('pk'))
|
return Rule.objects.filter(pk=self.kwargs.get('pk')).select_subclasses().first()
|
||||||
return obj.cast()
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class SourceListView(AdminRequiredMixin, ListView):
|
||||||
class SourceCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
|
class SourceCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
|
||||||
"""Create new Source"""
|
"""Create new Source"""
|
||||||
|
|
||||||
template_name = 'administration/source/create.html'
|
template_name = 'generic/create_inheritance.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')
|
||||||
|
|
||||||
|
|
Reference in a new issue