mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Initial work on productions dashboard
This commit is contained in:
@@ -261,15 +261,15 @@ class EventManager(models.Manager):
|
|||||||
'venue', 'mic')
|
'venue', 'mic')
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
def active_dry_hires(self):
|
||||||
|
return self.filter(dry_hire=True, start_date__gte=timezone.now(), is_rig=True)
|
||||||
|
|
||||||
def rig_count(self):
|
def rig_count(self):
|
||||||
event_count = self.filter(
|
event_count = self.exclude(status=BaseEvent.CANCELLED).filter(
|
||||||
(models.Q(start_date__gte=timezone.now(), end_date__isnull=True, dry_hire=False,
|
(models.Q(start_date__gte=timezone.now(), end_date__isnull=True, dry_hire=False,
|
||||||
is_rig=True) & ~models.Q(
|
is_rig=True)) | # Starts after with no end
|
||||||
status=Event.CANCELLED)) | # Starts after with no end
|
(models.Q(end_date__gte=timezone.now(), dry_hire=False, is_rig=True)) | # Ends after
|
||||||
(models.Q(end_date__gte=timezone.now(), dry_hire=False, is_rig=True) & ~models.Q(
|
(models.Q(dry_hire=True, start_date__gte=timezone.now(), is_rig=True)) # Active dry hire
|
||||||
status=Event.CANCELLED)) | # Ends after
|
|
||||||
(models.Q(dry_hire=True, start_date__gte=timezone.now(), is_rig=True) & ~models.Q(
|
|
||||||
status=Event.CANCELLED)) # Active dry hire
|
|
||||||
).count()
|
).count()
|
||||||
return event_count
|
return event_count
|
||||||
|
|
||||||
@@ -602,15 +602,20 @@ class EventAuthorisation(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
class SubhireManager(models.Manager):
|
class SubhireManager(models.Manager):
|
||||||
def current_events(self):
|
def current_events(self):
|
||||||
events = self.filter(
|
events = self.exclude(status=BaseEvent.CANCELLED).filter(
|
||||||
(models.Q(start_date__gte=timezone.now(), end_date__isnull=True) & ~models.Q(
|
(models.Q(start_date__gte=timezone.now(), end_date__isnull=True)) | # Starts after with no end
|
||||||
status=Event.CANCELLED)) | # Starts after with no end
|
(models.Q(end_date__gte=timezone.now().date())) # Ends after
|
||||||
(models.Q(end_date__gte=timezone.now().date()) & ~models.Q(
|
|
||||||
status=Event.CANCELLED)) # Ends after
|
|
||||||
).order_by('start_date', 'end_date', 'start_time', 'end_time').select_related('person', 'organisation')
|
).order_by('start_date', 'end_date', 'start_time', 'end_time').select_related('person', 'organisation')
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
def event_count(self):
|
||||||
|
event_count = self.exclude(status=BaseEvent.CANCELLED).filter(
|
||||||
|
(models.Q(start_date__gte=timezone.now(), end_date__isnull=True)) | # Starts after with no end
|
||||||
|
(models.Q(end_date__gte=timezone.now()))
|
||||||
|
).count()
|
||||||
|
return event_count
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
class Subhire(BaseEvent):
|
class Subhire(BaseEvent):
|
||||||
|
|||||||
29
RIGS/templates/dashboards/productions.html
Normal file
29
RIGS/templates/dashboards/productions.html
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{% extends 'base_rigs.html' %}
|
||||||
|
|
||||||
|
{% load button from filters %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Upcoming Events</div>
|
||||||
|
<div class="card-body">{{ rig_count }}</div>
|
||||||
|
<div class="card-footer"><a href={% url 'rigboard' %}>View</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Upcoming Subhire</div>
|
||||||
|
<div class="card-body">{{ subhire_count }}</div>
|
||||||
|
<div class="card-footer"><a href={% url 'subhire_list' %}>View</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Active Dry Hires</div>
|
||||||
|
<div class="card-body">{{ hire_count }}</div>
|
||||||
|
<div class="card-footer"><a href={% url 'rigboard' %}>View</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -77,6 +77,10 @@ urlpatterns = [
|
|||||||
path('subhire/upcoming', views.SubhireList.as_view(),
|
path('subhire/upcoming', views.SubhireList.as_view(),
|
||||||
name='subhire_list'),
|
name='subhire_list'),
|
||||||
|
|
||||||
|
# Dashboards
|
||||||
|
path('dashboard/productions/', views.ProductionsDashboard.as_view(),
|
||||||
|
name='productions_dashboard'),
|
||||||
|
|
||||||
|
|
||||||
# Event H&S
|
# Event H&S
|
||||||
path('event/hs/', permission_required_with_403('RIGS.view_riskassessment')(views.HSList.as_view()), name='hs_list'),
|
path('event/hs/', permission_required_with_403('RIGS.view_riskassessment')(views.HSList.as_view()), name='hs_list'),
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ from .hs import *
|
|||||||
from .ical import *
|
from .ical import *
|
||||||
from .rigboard import *
|
from .rigboard import *
|
||||||
from .subhire import *
|
from .subhire import *
|
||||||
|
from .dashboards import *
|
||||||
14
RIGS/views/dashboards.py
Normal file
14
RIGS/views/dashboards.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from django.views import generic
|
||||||
|
from RIGS import models
|
||||||
|
|
||||||
|
|
||||||
|
class ProductionsDashboard(generic.TemplateView):
|
||||||
|
template_name = 'dashboards/productions.html'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['page_title'] = "Productions Dashboard"
|
||||||
|
context['rig_count'] = models.Event.objects.rig_count()
|
||||||
|
context['subhire_count'] = models.Subhire.objects.event_count()
|
||||||
|
context['hire_count'] = models.Event.objects.active_dry_hires().count()
|
||||||
|
return context
|
||||||
Reference in New Issue
Block a user