diff --git a/PyRIGS/views.py b/PyRIGS/views.py index 3899daf2..ae8ccba1 100644 --- a/PyRIGS/views.py +++ b/PyRIGS/views.py @@ -155,7 +155,7 @@ class GenericListView(generic.ListView): paginate_by = 20 def get_context_data(self, **kwargs): - context = super(generic.ListView, self).get_context_data(**kwargs) + context = super(GenericListView, self).get_context_data(**kwargs) context['page_title'] = self.model.__name__ + "s" if self.request.is_ajax(): context['override'] = "base_ajax.html" @@ -183,6 +183,17 @@ class GenericListView(generic.ListView): return object_list +class GenericDetailView(generic.DetailView): + template_name = "generic_detail.html" + + def get_context_data(self, **kwargs): + context = super(GenericDetailView, self).get_context_data(**kwargs) + context['page_title'] = "{} | {}".format(self.model.__name__, self.object.name) + if self.request.is_ajax(): + context['override'] = "base_ajax.html" + return context + + class SearchHelp(generic.TemplateView): template_name = 'search_help.html' diff --git a/RIGS/templates/organisation_detail.html b/RIGS/templates/organisation_detail.html deleted file mode 100644 index 6d6733c0..00000000 --- a/RIGS/templates/organisation_detail.html +++ /dev/null @@ -1 +0,0 @@ -{% include 'generic_detail.html' with type='Organisation' history_link='organisation_history' detail_link='organisation_detail' update_link='organisation_update' associated='partials/associated_people.html' associated2='partials/associated_events.html' %} diff --git a/RIGS/templates/person_detail.html b/RIGS/templates/person_detail.html deleted file mode 100644 index 4f4288fc..00000000 --- a/RIGS/templates/person_detail.html +++ /dev/null @@ -1 +0,0 @@ -{% include 'generic_detail.html' with type='Person' history_link='person_history' detail_link='person_detail' update_link='person_update' associated='partials/associated_organisations.html' associated2='partials/associated_events.html' %} diff --git a/RIGS/templates/venue_detail.html b/RIGS/templates/venue_detail.html deleted file mode 100644 index 50971b7b..00000000 --- a/RIGS/templates/venue_detail.html +++ /dev/null @@ -1 +0,0 @@ -{% include 'generic_detail.html' with type='Venue' history_link='venue_history' detail_link='venue_detail' update_link='venue_update' associated2='partials/associated_events.html' %} diff --git a/RIGS/views.py b/RIGS/views.py index 4cb21cc5..8825ddfe 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -20,7 +20,7 @@ from RIGS import models, forms from assets import models as asset_models from functools import reduce -from PyRIGS.views import GenericListView +from PyRIGS.views import GenericListView,GenericDetailView class PersonList(GenericListView): @@ -35,10 +35,18 @@ class PersonList(GenericListView): return context -class PersonDetail(generic.DetailView): - template_name = 'person_detail.html' +class PersonDetail(GenericDetailView): model = models.Person + def get_context_data(self, **kwargs): + context = super(PersonDetail, self).get_context_data(**kwargs) + context['history_link'] = 'person_history' + context['detail_link'] = 'person_detail' + context['update_link'] = 'person_update' + context['associated'] ='partials/associated_organisations.html' + context['associated2'] ='partials/associated_events.html' + return context + class PersonCreate(generic.CreateView): template_name = 'person_form.html' @@ -87,10 +95,17 @@ class OrganisationList(GenericListView): context['union_account'] = True return context -class OrganisationDetail(generic.DetailView): - template_name = 'organisation_detail.html' +class OrganisationDetail(GenericDetailView): model = models.Organisation + def get_context_data(self, **kwargs): + context = super(OrganisationDetail, self).get_context_data(**kwargs) + context['history_link'] = 'organisation_history' + context['detail_link'] = 'organisation_detail' + context['update_link'] = 'organisation_update' + context['associated'] ='partials/associated_people.html' + context['associated2'] ='partials/associated_events.html' + return context class OrganisationCreate(generic.CreateView): template_name = 'organisation_form.html' @@ -139,10 +154,17 @@ class VenueList(GenericListView): return context -class VenueDetail(generic.DetailView): - template_name = 'venue_detail.html' +class VenueDetail(GenericDetailView): model = models.Venue + def get_context_data(self, **kwargs): + context = super(VenueDetail, self).get_context_data(**kwargs) + context['history_link'] = 'venue_history' + context['detail_link'] = 'venue_detail' + context['update_link'] = 'venue_update' + context['associated2'] = 'partials/associated_events.html' + return context + class VenueCreate(generic.CreateView): template_name = 'venue_form.html' diff --git a/assets/templates/supplier_detail.html b/assets/templates/supplier_detail.html deleted file mode 100644 index 678bb4a5..00000000 --- a/assets/templates/supplier_detail.html +++ /dev/null @@ -1 +0,0 @@ -{% include 'generic_detail.html' with type='Supplier' history_link='supplier_history' detail_link='supplier_detail' update_link='supplier_update' associated='partials/associated_assets.html' associated2='' %} diff --git a/assets/views.py b/assets/views.py index f3d39d96..1874e073 100644 --- a/assets/views.py +++ b/assets/views.py @@ -14,7 +14,7 @@ from django.utils.decorators import method_decorator from django.views import generic from django.views.decorators.csrf import csrf_exempt from versioning import versioning -from PyRIGS.views import GenericListView +from PyRIGS.views import GenericListView, GenericDetailView @method_decorator(csrf_exempt, name='dispatch') @@ -214,6 +214,10 @@ class SupplierList(GenericListView): context['create'] = 'supplier_create' context['edit'] = 'supplier_update' context['detail'] = 'supplier_detail' + if self.request.is_ajax(): + context['override'] = "base_ajax.html" + else: + context['override'] = 'base_assets.html' return context @@ -228,9 +232,21 @@ class SupplierSearch(SupplierList): return JsonResponse(result, safe=False) -class SupplierDetail(generic.DetailView): +class SupplierDetail(GenericDetailView): model = models.Supplier - template_name = 'supplier_detail.html' + + def get_context_data(self, **kwargs): + context = super(SupplierDetail, self).get_context_data(**kwargs) + context['history_link'] = 'supplier_history' + context['update_link'] = 'supplier_update' + context['detail_link'] = 'supplier_detail' + context['associated'] = 'partials/associated_assets.html' + context['associated2'] = '' + if self.request.is_ajax(): + context['override'] = "base_ajax.html" + else: + context['override'] = 'base_assets.html' + return context class SupplierCreate(generic.CreateView): diff --git a/templates/base.html b/templates/base.html index e32c67fd..132dae8a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,7 +7,7 @@ xml:lang="{% firstof LANGUAGE_CODE 'en' %}" lang="{% firstof LANGUAGE_CODE 'en' %}">
-