From 32f5e4802fac34d20044796ea8d65f7d9fbbde73 Mon Sep 17 00:00:00 2001 From: Chris Lawlor Date: Mon, 20 May 2013 09:06:28 -0400 Subject: [PATCH 1/5] Adds page title to model create page --- djadmin2/templates/admin2/bootstrap/model_add_form.html | 1 + djadmin2/views.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/djadmin2/templates/admin2/bootstrap/model_add_form.html b/djadmin2/templates/admin2/bootstrap/model_add_form.html index 2fac865..850f531 100644 --- a/djadmin2/templates/admin2/bootstrap/model_add_form.html +++ b/djadmin2/templates/admin2/bootstrap/model_add_form.html @@ -2,6 +2,7 @@ {% block content %} +

Add {{ model|capfirst }}

{% csrf_token %} {{ form.as_p }} diff --git a/djadmin2/views.py b/djadmin2/views.py index 5cf8c83..a56a58c 100644 --- a/djadmin2/views.py +++ b/djadmin2/views.py @@ -125,6 +125,11 @@ class ModelAddFormView(AdminModel2Mixin, generic.CreateView): default_template_name = "model_add_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 + return context + def get_success_url(self): view_name = 'admin2:{}_{}_detail'.format(self.app_label, self.model_name) return reverse(view_name, kwargs={'pk': self.object.pk}) From 3d2b347063b01c443e386c4602279b4965a2afd1 Mon Sep 17 00:00:00 2001 From: Chris Lawlor Date: Mon, 20 May 2013 10:34:35 -0400 Subject: [PATCH 2/5] Adds model name to AdminModel2Mixin template context. All views subclassing AdminModel2Mixin will need the model name in their template context, so moving it to the base class so child views don't all have to override get_context_data. --- djadmin2/views.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/djadmin2/views.py b/djadmin2/views.py index 5cf8c83..3c0d9aa 100644 --- a/djadmin2/views.py +++ b/djadmin2/views.py @@ -57,6 +57,8 @@ class AdminModel2Mixin(Admin2Mixin, AccessMixin): 'has_add_permission': self.model_admin.has_add_permission(self.request), 'has_edit_permission': self.model_admin.has_edit_permission(self.request), 'has_delete_permission': self.model_admin.has_delete_permission(self.request), + 'model': self.get_model()._meta.verbose_name, + 'model_pluralized': self.get_model()._meta.verbose_name_plural }) return context @@ -87,7 +89,6 @@ class IndexView(Admin2Mixin, generic.TemplateView): class ModelListView(Admin2Mixin, generic.ListView): - default_template_name = "model_list.html" permission_type = 'view' @@ -113,11 +114,6 @@ class ModelEditFormView(AdminModel2Mixin, generic.UpdateView): default_template_name = "model_edit_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 - return context - class ModelAddFormView(AdminModel2Mixin, generic.CreateView): form_class = None From ef8afcbb7e78c789c99ef28001e7e836140442d2 Mon Sep 17 00:00:00 2001 From: Daniel Greenfeld Date: Mon, 20 May 2013 20:40:16 +0300 Subject: [PATCH 3/5] Adding @chrislawlor to the list of authors. --- AUTHORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index 22d0df7..9b76611 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -15,3 +15,4 @@ Developers * Andrew Ingram (@AndrewIngram) * Gregor Müllegger (@gregmuellegger) * Rivo Laks (@rivol) +* Chris Lawlor (@chrislawlor) From f9a1540e09221607dd66dd6e661cbfe2ed3b54b1 Mon Sep 17 00:00:00 2001 From: Chris Lawlor Date: Mon, 20 May 2013 14:38:36 -0400 Subject: [PATCH 4/5] Add 'title' and 'page_title' template blocks. Makes template page title styling consistent across all templates. --- djadmin2/templates/admin2/bootstrap/base.html | 7 ++++++- djadmin2/templates/admin2/bootstrap/index.html | 1 - .../templates/admin2/bootstrap/model_add_form.html | 5 ++++- .../admin2/bootstrap/model_confirm_delete.html | 4 ++++ djadmin2/templates/admin2/bootstrap/model_detail.html | 4 ++++ .../templates/admin2/bootstrap/model_edit_form.html | 11 ++++------- djadmin2/templates/admin2/bootstrap/model_list.html | 10 ++++------ 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/djadmin2/templates/admin2/bootstrap/base.html b/djadmin2/templates/admin2/bootstrap/base.html index 4a8134a..445b587 100644 --- a/djadmin2/templates/admin2/bootstrap/base.html +++ b/djadmin2/templates/admin2/bootstrap/base.html @@ -3,7 +3,7 @@ - django-admin2 + {% block title %}Site administration{% endblock %} | django-admin2 @@ -46,6 +46,11 @@
+
+
+

{% block page_title %}Site administration{% endblock %}

+
+
{% block content %}{% endblock %}
diff --git a/djadmin2/templates/admin2/bootstrap/index.html b/djadmin2/templates/admin2/bootstrap/index.html index 1ab2836..fdbbe58 100644 --- a/djadmin2/templates/admin2/bootstrap/index.html +++ b/djadmin2/templates/admin2/bootstrap/index.html @@ -2,7 +2,6 @@ {% load admin2_urls %} {% block content %} -

Site administration

diff --git a/djadmin2/templates/admin2/bootstrap/model_add_form.html b/djadmin2/templates/admin2/bootstrap/model_add_form.html index 850f531..f18b91a 100644 --- a/djadmin2/templates/admin2/bootstrap/model_add_form.html +++ b/djadmin2/templates/admin2/bootstrap/model_add_form.html @@ -1,8 +1,11 @@ {% extends "admin2/bootstrap/base.html" %} +{% block title %}Add {{ model }}{% endblock %} + +{% block page_title %}Add {{ model }}{% endblock %} + {% block content %} -

Add {{ model|capfirst }}

{% csrf_token %} {{ form.as_p }} diff --git a/djadmin2/templates/admin2/bootstrap/model_confirm_delete.html b/djadmin2/templates/admin2/bootstrap/model_confirm_delete.html index 7c7b742..a8d90a8 100644 --- a/djadmin2/templates/admin2/bootstrap/model_confirm_delete.html +++ b/djadmin2/templates/admin2/bootstrap/model_confirm_delete.html @@ -1,5 +1,9 @@ {% extends "admin2/bootstrap/base.html" %} +{% block title %}Delete {{ model }}{% endblock %} + +{% block page_title %}Delete {{ model }}{% endblock %} + {% block content %} diff --git a/djadmin2/templates/admin2/bootstrap/model_detail.html b/djadmin2/templates/admin2/bootstrap/model_detail.html index 0b7b55c..fe098a5 100644 --- a/djadmin2/templates/admin2/bootstrap/model_detail.html +++ b/djadmin2/templates/admin2/bootstrap/model_detail.html @@ -1,5 +1,9 @@ {% extends "admin2/bootstrap/base.html" %} +{% block title %}{{ object }}{% endblock %} + +{% block page_title %}{{ object }}{% endblock %} + {% block content %} {{ object }} diff --git a/djadmin2/templates/admin2/bootstrap/model_edit_form.html b/djadmin2/templates/admin2/bootstrap/model_edit_form.html index 76f8a45..a130e31 100644 --- a/djadmin2/templates/admin2/bootstrap/model_edit_form.html +++ b/djadmin2/templates/admin2/bootstrap/model_edit_form.html @@ -1,14 +1,11 @@ {% extends "admin2/bootstrap/base.html" %} +{% block title %}Change {{ model }}{% endblock %} + +{% block page_title %}Change {{ model }}{% endblock %} + {% block content %} -
-
-

Change {{ model }}

-
-
- -
diff --git a/djadmin2/templates/admin2/bootstrap/model_list.html b/djadmin2/templates/admin2/bootstrap/model_list.html index 9259edd..47975d8 100644 --- a/djadmin2/templates/admin2/bootstrap/model_list.html +++ b/djadmin2/templates/admin2/bootstrap/model_list.html @@ -1,13 +1,11 @@ {% extends "admin2/bootstrap/base.html" %} {% load admin2_urls %} -{% block content %} -
-
-

Select {{ model }} to change

-
-
+{% block title %}Select {{ model }} to change{% endblock %} +{% block page_title %}Select {{ model }} to change{% endblock %} + +{% block content %}
From 55168a0ea098e61be95a03b5e88e33cff7fe6498 Mon Sep 17 00:00:00 2001 From: Audrey Roy Date: Mon, 20 May 2013 23:33:37 +0200 Subject: [PATCH 5/5] Fix delete text to match original admin. --- .../templates/admin2/bootstrap/model_confirm_delete.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/djadmin2/templates/admin2/bootstrap/model_confirm_delete.html b/djadmin2/templates/admin2/bootstrap/model_confirm_delete.html index a8d90a8..6025b9a 100644 --- a/djadmin2/templates/admin2/bootstrap/model_confirm_delete.html +++ b/djadmin2/templates/admin2/bootstrap/model_confirm_delete.html @@ -1,14 +1,16 @@ {% extends "admin2/bootstrap/base.html" %} -{% block title %}Delete {{ model }}{% endblock %} +{% block title %}Are you sure?{% endblock %} -{% block page_title %}Delete {{ model }}{% endblock %} +{% block page_title %}Are you sure?{% endblock %} {% block content %} +

Are you sure you want to delete the {{ model }} "{{ object }}"? All of the following related items will be deleted:

+ +TODO {% csrf_token %} - delete {{ object }} {{ form.as_p }}