Also apply better approach to generic detail pages

This commit is contained in:
2020-10-08 23:15:55 +01:00
parent 3903481b3d
commit 5d56f4f7b0
11 changed files with 71 additions and 34 deletions

View File

@@ -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='' %}

View File

@@ -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):