mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 21:42:14 +00:00
Also apply better approach to generic detail pages
This commit is contained in:
@@ -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'
|
||||
|
||||
|
||||
@@ -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' %}
|
||||
@@ -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' %}
|
||||
@@ -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' %}
|
||||
@@ -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'
|
||||
|
||||
@@ -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='' %}
|
||||
@@ -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):
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
xml:lang="{% firstof LANGUAGE_CODE 'en' %}"
|
||||
lang="{% firstof LANGUAGE_CODE 'en' %}">
|
||||
<head>
|
||||
<title>{{page_title}}{% block title %}{% endblock %} | Rig Information Gathering System</title>
|
||||
<title>{% block title %}{{page_title}}{% endblock %} | Rig Information Gathering System</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
@@ -70,7 +70,7 @@
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% if page_title %}<h2>{{page_title}}</h2>{% endif %}
|
||||
{% if page_title and not request.is_ajax %}<h2>{{page_title}}</h2>{% endif %}
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{% block title %}{% endblock %}</h4>
|
||||
<h4 class="modal-title">{{page_title}}{% block title %}{% endblock %}</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
||||
{% extends override|default:"base_rigs.html" %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}{{ type }} | {{ object.name }}{% endblock %}
|
||||
{% load button from filters %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
{% if not request.is_ajax %}
|
||||
<div class="col-sm-12">
|
||||
<h1>{{ type }} | {{ object.name }}</h1>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col">
|
||||
<div class="card border-info">
|
||||
<div class="card-header">{{ type }} Details</div>
|
||||
@@ -52,11 +46,10 @@
|
||||
{% endif %}
|
||||
|
||||
{% if not request.is_ajax %}
|
||||
<div class="row">
|
||||
<div class="row py-2">
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group">
|
||||
<a href="{% url update_link object.pk %}" class="btn btn-warning"><span
|
||||
class="fas fa-edit"></span> Edit</a>
|
||||
{% button 'edit' update_link object.pk %}
|
||||
</div>
|
||||
{% include 'partials/last_edited.html' with target=history_link %}
|
||||
</div>
|
||||
@@ -65,13 +58,12 @@
|
||||
{% endblock %}
|
||||
{% if request.is_ajax %}
|
||||
{% block footer %}
|
||||
<div class="row">
|
||||
<div class="row py-2">
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url detail_link object.pk %}" class="btn btn-primary"><span
|
||||
class="fas fa-eye"></span> Open Page</a>
|
||||
<a href="{% url update_link object.pk %}" class="btn btn-warning"><span
|
||||
class="fas fa-edit"></span> Edit</a>
|
||||
{% button 'edit' update_link object.pk %}
|
||||
</div>
|
||||
{% include 'partials/last_edited.html' with target=history_link %}
|
||||
</div>
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col text-right">
|
||||
<form class="form-inline">
|
||||
<div class="col">
|
||||
<form class="form-inline justify-content-end">
|
||||
{% csrf_token %}
|
||||
<div class="input-group">
|
||||
<input type="search" name="q" placeholder="Search" value="{{ request.GET.q }}"
|
||||
|
||||
Reference in New Issue
Block a user