diff --git a/djadmin2/templates/admin2/bootstrap/model_add_form.html b/djadmin2/templates/admin2/bootstrap/model_add_form.html deleted file mode 100644 index ff42e50..0000000 --- a/djadmin2/templates/admin2/bootstrap/model_add_form.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "admin2/bootstrap/base.html" %} - -{% block title %}Add {{ model }}{% endblock %} - -{% block page_title %}Add {{ model }}{% endblock %} - -{% block content %} - -
- -{% endblock content %} diff --git a/djadmin2/templates/admin2/bootstrap/model_edit_form.html b/djadmin2/templates/admin2/bootstrap/model_update_form.html similarity index 76% rename from djadmin2/templates/admin2/bootstrap/model_edit_form.html rename to djadmin2/templates/admin2/bootstrap/model_update_form.html index abbdb52..1950414 100644 --- a/djadmin2/templates/admin2/bootstrap/model_edit_form.html +++ b/djadmin2/templates/admin2/bootstrap/model_update_form.html @@ -1,8 +1,8 @@ {% extends "admin2/bootstrap/base.html" %} -{% block title %}Change {{ model }}{% endblock %} +{% block title %}{{ action }} {{ model }}{% endblock %} -{% block page_title %}Change {{ model }}{% endblock %} +{% block page_title %}{{ action }} {{ model }}{% endblock %} {% block content %} @@ -12,8 +12,6 @@ {% csrf_token %} {{ form.as_p }} - {# TODO: combine/refactor this with model_add_form.html #} - diff --git a/djadmin2/views.py b/djadmin2/views.py index 50eecf1..249d31c 100644 --- a/djadmin2/views.py +++ b/djadmin2/views.py @@ -123,18 +123,25 @@ class ModelDetailView(AdminModel2Mixin, generic.DetailView): class ModelEditFormView(AdminModel2Mixin, Admin2ModelFormMixin, generic.UpdateView): form_class = None - default_template_name = "model_edit_form.html" + default_template_name = "model_update_form.html" permission_type = 'change' + def get_context_data(self, **kwargs): + context = super(ModelEditFormView, self).get_context_data(**kwargs) + context['model'] = self.get_model()._meta.verbose_name + context['action'] = "Change" + return context + class ModelAddFormView(AdminModel2Mixin, Admin2ModelFormMixin, generic.CreateView): form_class = None - default_template_name = "model_add_form.html" + default_template_name = "model_update_form.html" permission_type = 'add' def get_context_data(self, **kwargs): context = super(ModelAddFormView, self).get_context_data(**kwargs) context['model'] = self.get_model()._meta.verbose_name + context['action'] = "Add" return context