Compare commits
86 Commits
imgbot
...
948a41f43a
| Author | SHA1 | Date | |
|---|---|---|---|
| 948a41f43a | |||
|
4449efcced
|
|||
|
8b0cd13159
|
|||
|
e7e760de2e
|
|||
| 9091197639 | |||
|
4f4baa62c1
|
|||
|
b9f8621e1a
|
|||
|
4b1dc37a7f
|
|||
|
|
9273ca35cf | ||
|
|
4a4b7fa30d | ||
| a44a532c7d | |||
| 3a2e5c943b | |||
| 426a9088cc | |||
|
|
1369a2f978 | ||
|
38eafbced3
|
|||
|
900002bf71
|
|||
|
2869c9fcc3
|
|||
|
00eb4e0e27
|
|||
|
23e17b0e34
|
|||
|
bf268a4566
|
|||
|
dedb8d81fe
|
|||
|
7d785f4f1b
|
|||
|
5eb113156b
|
|||
|
ab03ad081a
|
|||
| cd5889f60e | |||
| f18bf3b077 | |||
|
3d36d986a4
|
|||
|
41f5a23ef0
|
|||
|
09f48f740d
|
|||
|
805d77af20
|
|||
|
fabab87e23
|
|||
|
a95779e04e
|
|||
|
24e6ba540d
|
|||
|
14d3522b81
|
|||
|
e4cfaba57d
|
|||
|
d9664422c5
|
|||
|
27bb3f1d8e
|
|||
|
151ac8b3bd
|
|||
|
c2dcd86d5d
|
|||
|
6c14b30c13
|
|||
|
5215af349a
|
|||
|
a5e888fef5
|
|||
|
|
2ae4e4142c | ||
|
8799f822bb
|
|||
|
2dd3d306b4
|
|||
|
042004e1ae
|
|||
|
733ea69cc5
|
|||
|
bbea47e8ec
|
|||
|
c4aafbd7e5
|
|||
|
ccdc13df93
|
|||
|
aa19ceaf18
|
|||
|
05d280172d
|
|||
|
2f51b7b1d3
|
|||
|
8d1edb54ea
|
|||
| 54c90a7be4 | |||
|
3e1e0079d8
|
|||
|
b6952aeb52
|
|||
|
d33a4231fb
|
|||
|
8dea6aeab0
|
|||
|
34c03e379d
|
|||
|
988fb78b45
|
|||
|
eda314c092
|
|||
|
8ef520619a
|
|||
|
95931f86b4
|
|||
|
cc2cb5c4d1
|
|||
|
3ae507b469
|
|||
|
33754eed60
|
|||
|
15ab626593
|
|||
|
7bc47b446c
|
|||
|
83b287a418
|
|||
|
3b9848d457
|
|||
|
308d0c697e
|
|||
|
f243a589fa
|
|||
|
79c90ac92c
|
|||
|
8244287a64
|
|||
|
da4d62729b
|
|||
|
f8a48798de
|
|||
|
fc817fa9b5
|
|||
|
b04a168f01
|
|||
|
cc6992976e
|
|||
|
a556b17d2d
|
|||
|
f9e38338dc
|
|||
|
ce83ae6dd1
|
|||
|
9e1d54dc02
|
|||
| 375b0af2fd | |||
|
|
0354662864 |
14
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: Manual Deploy
|
||||||
|
|
||||||
|
on: workflow_dispatch
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
|
||||||
|
with:
|
||||||
|
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
|
||||||
|
heroku_app_name: "pyrigs" #Must be unique in Heroku
|
||||||
|
heroku_email: "aj@aronajones.com"
|
||||||
12
Dockerfile
@@ -1,12 +0,0 @@
|
|||||||
FROM python:3.6
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
ADD . /app
|
|
||||||
|
|
||||||
RUN pip install -r requirements.txt && \
|
|
||||||
python manage.py collectstatic --noinput
|
|
||||||
|
|
||||||
EXPOSE 8000
|
|
||||||
|
|
||||||
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
|
||||||
25
Pipfile
@@ -11,7 +11,7 @@ asgiref = "~=3.3.1"
|
|||||||
beautifulsoup4 = "~=4.9.3"
|
beautifulsoup4 = "~=4.9.3"
|
||||||
Brotli = "~=1.0.9"
|
Brotli = "~=1.0.9"
|
||||||
cachetools = "~=4.2.1"
|
cachetools = "~=4.2.1"
|
||||||
certifi = "~=2020.12.5"
|
certifi = "*"
|
||||||
chardet = "~=4.0.0"
|
chardet = "~=4.0.0"
|
||||||
configparser = "~=5.0.1"
|
configparser = "~=5.0.1"
|
||||||
contextlib2 = "~=0.6.0.post1"
|
contextlib2 = "~=0.6.0.post1"
|
||||||
@@ -33,7 +33,7 @@ envparse = "~=0.2.0"
|
|||||||
gunicorn = "~=20.0.4"
|
gunicorn = "~=20.0.4"
|
||||||
icalendar = "~=4.0.7"
|
icalendar = "~=4.0.7"
|
||||||
idna = "~=2.10"
|
idna = "~=2.10"
|
||||||
lxml = "~=4.7.1"
|
lxml = "*"
|
||||||
Markdown = "~=3.3.3"
|
Markdown = "~=3.3.3"
|
||||||
msgpack = "~=1.0.2"
|
msgpack = "~=1.0.2"
|
||||||
pep517 = "~=0.9.1"
|
pep517 = "~=0.9.1"
|
||||||
@@ -44,12 +44,11 @@ psutil = "~=5.8.0"
|
|||||||
psycopg2 = "~=2.8.6"
|
psycopg2 = "~=2.8.6"
|
||||||
Pygments = "~=2.7.4"
|
Pygments = "~=2.7.4"
|
||||||
pyparsing = "~=2.4.7"
|
pyparsing = "~=2.4.7"
|
||||||
PyPDF2 = "~=1.26.0"
|
PyPDF2 = "~=1.27.5"
|
||||||
PyPOM = "~=2.2.0"
|
|
||||||
python-dateutil = "~=2.8.1"
|
python-dateutil = "~=2.8.1"
|
||||||
pytoml = "~=0.1.21"
|
pytoml = "~=0.1.21"
|
||||||
pytz = "~=2020.5"
|
pytz = "~=2020.5"
|
||||||
reportlab = "~=3.5.59"
|
reportlab = "*"
|
||||||
requests = "~=2.25.1"
|
requests = "~=2.25.1"
|
||||||
retrying = "~=1.3.3"
|
retrying = "~=1.3.3"
|
||||||
simplejson = "~=3.17.2"
|
simplejson = "~=3.17.2"
|
||||||
@@ -63,7 +62,6 @@ tornado = "~=6.1"
|
|||||||
urllib3 = "~=1.26.5"
|
urllib3 = "~=1.26.5"
|
||||||
whitenoise = "~=5.2.0"
|
whitenoise = "~=5.2.0"
|
||||||
yolk = "~=0.4.3"
|
yolk = "~=0.4.3"
|
||||||
"z3c.rml" = "~=4.1.2"
|
|
||||||
zipp = "~=3.4.0"
|
zipp = "~=3.4.0"
|
||||||
"zope.component" = "~=4.6.2"
|
"zope.component" = "~=4.6.2"
|
||||||
"zope.deferredimport" = "~=4.3.1"
|
"zope.deferredimport" = "~=4.3.1"
|
||||||
@@ -79,6 +77,10 @@ python-barcode = "*"
|
|||||||
django-hCaptcha = "*"
|
django-hCaptcha = "*"
|
||||||
importlib-metadata = "*"
|
importlib-metadata = "*"
|
||||||
django-hcaptcha = "*"
|
django-hcaptcha = "*"
|
||||||
|
"z3c.rml" = "*"
|
||||||
|
pikepdf = "*"
|
||||||
|
django-queryable-properties = "*"
|
||||||
|
django-mass-edit = "*"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
selenium = "~=3.141.0"
|
selenium = "~=3.141.0"
|
||||||
@@ -91,14 +93,11 @@ pluggy = "*"
|
|||||||
pytest-splinter = "*"
|
pytest-splinter = "*"
|
||||||
pytest = "*"
|
pytest = "*"
|
||||||
pytest-reverse = "*"
|
pytest-reverse = "*"
|
||||||
|
pytest-xdist = {extras = [ "psutil",], version = "*"}
|
||||||
|
PyPOM = {extras = [ "splinter",], version = "*"}
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.9"
|
python_version = "3.9"
|
||||||
|
|
||||||
[dev-packages.pytest-xdist]
|
[pipenv]
|
||||||
extras = [ "psutil",]
|
allow_prereleases = true
|
||||||
version = "*"
|
|
||||||
|
|
||||||
[dev-packages.PyPOM]
|
|
||||||
extras = [ "splinter",]
|
|
||||||
version = "*"
|
|
||||||
|
|||||||
983
Pipfile.lock
generated
@@ -9,9 +9,8 @@ from RIGS import models
|
|||||||
|
|
||||||
def get_oembed(login_url, request, oembed_view, kwargs):
|
def get_oembed(login_url, request, oembed_view, kwargs):
|
||||||
context = {}
|
context = {}
|
||||||
context['oembed_url'] = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'],
|
context['oembed_url'] = f"{request.scheme}://{request.META['HTTP_HOST']}{reverse(oembed_view, kwargs=kwargs)}"
|
||||||
reverse(oembed_view, kwargs=kwargs))
|
context['login_url'] = f"{login_url}?{REDIRECT_FIELD_NAME}={request.get_full_path()}"
|
||||||
context['login_url'] = "{0}?{1}={2}".format(login_url, REDIRECT_FIELD_NAME, request.get_full_path())
|
|
||||||
resp = render(request, 'login_redirect.html', context=context)
|
resp = render(request, 'login_redirect.html', context=context)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ def has_oembed(oembed_view, login_url=settings.LOGIN_URL):
|
|||||||
if oembed_view is not None:
|
if oembed_view is not None:
|
||||||
return get_oembed(login_url, request, oembed_view, kwargs)
|
return get_oembed(login_url, request, oembed_view, kwargs)
|
||||||
else:
|
else:
|
||||||
return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, request.get_full_path()))
|
return HttpResponseRedirect(f'{login_url}?{REDIRECT_FIELD_NAME}={request.get_full_path()}')
|
||||||
|
|
||||||
_checklogin.__doc__ = view_func.__doc__
|
_checklogin.__doc__ = view_func.__doc__
|
||||||
_checklogin.__dict__ = view_func.__dict__
|
_checklogin.__dict__ = view_func.__dict__
|
||||||
@@ -55,7 +54,7 @@ def user_passes_test_with_403(test_func, login_url=None, oembed_view=None):
|
|||||||
if oembed_view is not None:
|
if oembed_view is not None:
|
||||||
return get_oembed(login_url, request, oembed_view, kwargs)
|
return get_oembed(login_url, request, oembed_view, kwargs)
|
||||||
else:
|
else:
|
||||||
return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, request.get_full_path()))
|
return HttpResponseRedirect(f'{login_url}?{REDIRECT_FIELD_NAME}={request.get_full_path()}')
|
||||||
else:
|
else:
|
||||||
resp = render(request, '403.html')
|
resp = render(request, '403.html')
|
||||||
resp.status_code = 403
|
resp.status_code = 403
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ INSTALLED_APPS = (
|
|||||||
'reversion',
|
'reversion',
|
||||||
'widget_tweaks',
|
'widget_tweaks',
|
||||||
'hcaptcha',
|
'hcaptcha',
|
||||||
|
'massadmin',
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE = (
|
MIDDLEWARE = (
|
||||||
|
|||||||
@@ -120,10 +120,10 @@ class TextBox(Region):
|
|||||||
class SimpleMDETextArea(Region):
|
class SimpleMDETextArea(Region):
|
||||||
@property
|
@property
|
||||||
def value(self):
|
def value(self):
|
||||||
return self.driver.execute_script("return document.querySelector('#' + arguments[0]).nextSibling.nextSibling.CodeMirror.getDoc().getValue();", self.root.get_attribute("id"))
|
return self.driver.execute_script("return document.querySelector('#' + arguments[0]).nextSibling.children[1].CodeMirror.getDoc().getValue();", self.root.get_attribute("id"))
|
||||||
|
|
||||||
def set_value(self, value):
|
def set_value(self, value):
|
||||||
self.driver.execute_script("document.querySelector('#' + arguments[0]).nextSibling.nextSibling.CodeMirror.getDoc().setValue(arguments[1]);", self.root.get_attribute("id"), value)
|
self.driver.execute_script("document.querySelector('#' + arguments[0]).nextSibling.children[1].CodeMirror.getDoc().setValue(arguments[1]);", self.root.get_attribute("id"), value)
|
||||||
|
|
||||||
|
|
||||||
class CheckBox(Region):
|
class CheckBox(Region):
|
||||||
@@ -145,7 +145,7 @@ class RadioSelect(Region): # Currently only works for yes/no radio selects
|
|||||||
value = "0"
|
value = "0"
|
||||||
else:
|
else:
|
||||||
value = "1"
|
value = "1"
|
||||||
self.find_element(By.XPATH, "//label[@for='{}_{}']".format(self.root.get_attribute("id"), value)).click()
|
self.find_element(By.XPATH, f"//label[@for='{self.root.get_attribute('id')}_{value}']").click()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self):
|
def value(self):
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from pytest_django.asserts import assertTemplateUsed, assertInHTML
|
|||||||
from PyRIGS import urls
|
from PyRIGS import urls
|
||||||
from RIGS.models import Event, Profile
|
from RIGS.models import Event, Profile
|
||||||
from assets.models import Asset
|
from assets.models import Asset
|
||||||
|
from training.tests.test_unit import get_response
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.template.defaultfilters import striptags
|
from django.template.defaultfilters import striptags
|
||||||
from django.urls.exceptions import NoReverseMatch
|
from django.urls.exceptions import NoReverseMatch
|
||||||
@@ -135,3 +136,11 @@ def test_keyholder_access(client):
|
|||||||
assertContains(response, 'View Revision History')
|
assertContains(response, 'View Revision History')
|
||||||
client.logout()
|
client.logout()
|
||||||
call_command('deleteSampleData')
|
call_command('deleteSampleData')
|
||||||
|
|
||||||
|
|
||||||
|
def test_search(admin_client, admin_user):
|
||||||
|
url = reverse('search')
|
||||||
|
response = admin_client.get(url, {'q': "Definetelynothingfoundifwesearchthis"})
|
||||||
|
assertContains(response, "No results found")
|
||||||
|
response = admin_client.get(url, {'q': admin_user.first_name})
|
||||||
|
assertContains(response, admin_user.first_name)
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ urlpatterns = [
|
|||||||
name="api_secure"),
|
name="api_secure"),
|
||||||
|
|
||||||
path('closemodal/', views.CloseModal.as_view(), name='closemodal'),
|
path('closemodal/', views.CloseModal.as_view(), name='closemodal'),
|
||||||
|
path('search/', login_required(views.Search.as_view()), name='search'),
|
||||||
path('search_help/', login_required(views.SearchHelp.as_view()), name='search_help'),
|
path('search_help/', login_required(views.SearchHelp.as_view()), name='search_help'),
|
||||||
|
|
||||||
path('', include('users.urls')),
|
path('', include('users.urls')),
|
||||||
|
|
||||||
|
path('admin/', include('massadmin.urls')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path("robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
|
path("robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
|
||||||
]
|
]
|
||||||
|
|||||||
166
PyRIGS/views.py
@@ -1,18 +1,30 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import operator
|
import operator
|
||||||
from functools import reduce
|
import re
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
import simplejson
|
from functools import reduce
|
||||||
|
from itertools import chain
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
from PyPDF2 import PdfFileMerger, PdfFileReader
|
||||||
|
from z3c.rml import rml2pdf
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.urls import reverse_lazy, reverse, NoReverseMatch
|
from django.urls import reverse_lazy, reverse, NoReverseMatch
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
from django.views.decorators.clickjacking import xframe_options_exempt
|
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||||
|
from django.template.loader import get_template
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
from assets import models as asset_models
|
from assets import models as asset_models
|
||||||
@@ -23,11 +35,18 @@ def is_ajax(request):
|
|||||||
return request.headers.get('x-requested-with') == 'XMLHttpRequest'
|
return request.headers.get('x-requested-with') == 'XMLHttpRequest'
|
||||||
|
|
||||||
|
|
||||||
|
def get_related(form, context): # Get some other objects to include in the form. Used when there are errors but also nice and quick.
|
||||||
|
for field, model in form.related_models.items():
|
||||||
|
value = form[field].value()
|
||||||
|
if value is not None and value != '':
|
||||||
|
context[field] = model.objects.get(pk=value)
|
||||||
|
|
||||||
|
|
||||||
class Index(generic.TemplateView): # Displays the current rig count along with a few other bits and pieces
|
class Index(generic.TemplateView): # Displays the current rig count along with a few other bits and pieces
|
||||||
template_name = 'index.html'
|
template_name = 'index.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(Index, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['rig_count'] = models.Event.objects.rig_count()
|
context['rig_count'] = models.Event.objects.rig_count()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -39,6 +58,7 @@ class SecureAPIRequest(generic.View):
|
|||||||
'organisation': models.Organisation,
|
'organisation': models.Organisation,
|
||||||
'profile': models.Profile,
|
'profile': models.Profile,
|
||||||
'event': models.Event,
|
'event': models.Event,
|
||||||
|
'asset': asset_models.Asset,
|
||||||
'supplier': asset_models.Supplier,
|
'supplier': asset_models.Supplier,
|
||||||
'training_item': training_models.TrainingItem,
|
'training_item': training_models.TrainingItem,
|
||||||
}
|
}
|
||||||
@@ -49,8 +69,9 @@ class SecureAPIRequest(generic.View):
|
|||||||
'organisation': 'RIGS.view_organisation',
|
'organisation': 'RIGS.view_organisation',
|
||||||
'profile': 'RIGS.view_profile',
|
'profile': 'RIGS.view_profile',
|
||||||
'event': None,
|
'event': None,
|
||||||
|
'asset': None,
|
||||||
'supplier': None,
|
'supplier': None,
|
||||||
'training_item': None, # TODO
|
'training_item': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@@ -119,14 +140,13 @@ class SecureAPIRequest(generic.View):
|
|||||||
'text': o.name,
|
'text': o.name,
|
||||||
}
|
}
|
||||||
try: # See if there is a valid update URL
|
try: # See if there is a valid update URL
|
||||||
data['update'] = reverse("%s_update" % model, kwargs={'pk': o.pk})
|
data['update'] = reverse(f"{model}_update", kwargs={'pk': o.pk})
|
||||||
except NoReverseMatch:
|
except NoReverseMatch:
|
||||||
pass
|
pass
|
||||||
results.append(data)
|
results.append(data)
|
||||||
|
|
||||||
# return a data response
|
# return a data response
|
||||||
json = simplejson.dumps(results)
|
return JsonResponse(results, safe=False)
|
||||||
return HttpResponse(json, content_type="application/json") # Always json
|
|
||||||
|
|
||||||
start = request.GET.get('start', None)
|
start = request.GET.get('start', None)
|
||||||
end = request.GET.get('end', None)
|
end = request.GET.get('end', None)
|
||||||
@@ -151,8 +171,7 @@ class SecureAPIRequest(generic.View):
|
|||||||
}
|
}
|
||||||
|
|
||||||
results.append(data)
|
results.append(data)
|
||||||
json = simplejson.dumps(results)
|
return JsonResponse(results, safe=False)
|
||||||
return HttpResponse(json, content_type="application/json") # Always json
|
|
||||||
|
|
||||||
return HttpResponse(model)
|
return HttpResponse(model)
|
||||||
|
|
||||||
@@ -176,27 +195,14 @@ class GenericListView(generic.ListView):
|
|||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GenericListView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['page_title'] = self.model.__name__ + "s"
|
context['page_title'] = self.model.__name__ + "s"
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
q = self.request.GET.get('q', "")
|
object_list = self.model.objects.search(query=self.request.GET.get('q', ""))
|
||||||
|
|
||||||
filter = Q(name__icontains=q) | Q(email__icontains=q) | Q(address__icontains=q) | Q(notes__icontains=q) | Q(
|
|
||||||
phone__startswith=q) | Q(phone__endswith=q)
|
|
||||||
|
|
||||||
# try and parse an int
|
|
||||||
try:
|
|
||||||
val = int(q)
|
|
||||||
filter = filter | Q(pk=val)
|
|
||||||
except: # noqa
|
|
||||||
# not an integer
|
|
||||||
pass
|
|
||||||
|
|
||||||
object_list = self.model.objects.filter(filter)
|
|
||||||
|
|
||||||
orderBy = self.request.GET.get('orderBy', "name")
|
orderBy = self.request.GET.get('orderBy', "name")
|
||||||
if orderBy != "":
|
if orderBy != "":
|
||||||
@@ -208,8 +214,8 @@ class GenericDetailView(generic.DetailView):
|
|||||||
template_name = "generic_detail.html"
|
template_name = "generic_detail.html"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GenericDetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['page_title'] = "{} | {}".format(self.model.__name__, self.object.name)
|
context['page_title'] = f"{self.model.__name__} | {self.object.name}"
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
return context
|
return context
|
||||||
@@ -219,8 +225,8 @@ class GenericUpdateView(generic.UpdateView):
|
|||||||
template_name = "generic_form.html"
|
template_name = "generic_form.html"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GenericUpdateView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['page_title'] = "Edit {}".format(self.model.__name__)
|
context['page_title'] = f"Edit {self.model.__name__}"
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
return context
|
return context
|
||||||
@@ -230,13 +236,60 @@ class GenericCreateView(generic.CreateView):
|
|||||||
template_name = "generic_form.html"
|
template_name = "generic_form.html"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GenericCreateView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['page_title'] = "Create {}".format(self.model.__name__)
|
context['page_title'] = f"Create {self.model.__name__}"
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class Search(generic.ListView):
|
||||||
|
template_name = 'search_results.html'
|
||||||
|
paginate_by = 20
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
def get_context_data(self, *args, **kwargs):
|
||||||
|
context = super().get_context_data(*args, **kwargs)
|
||||||
|
context['count'] = self.count or 0
|
||||||
|
context['query'] = self.request.GET.get('q')
|
||||||
|
context['page_title'] = f"{context['count']} search results for <b>{context['query']}</b>"
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
request = self.request
|
||||||
|
query = request.GET.get('q', None)
|
||||||
|
|
||||||
|
if query is not None:
|
||||||
|
event_results = models.Event.objects.search(query)
|
||||||
|
person_results = models.Person.objects.search(query)
|
||||||
|
organisation_results = models.Organisation.objects.search(query)
|
||||||
|
venue_results = models.Venue.objects.search(query)
|
||||||
|
invoice_results = models.Invoice.objects.search(query)
|
||||||
|
asset_results = asset_models.Asset.objects.search(query)
|
||||||
|
supplier_results = asset_models.Supplier.objects.search(query)
|
||||||
|
trainee_results = training_models.Trainee.objects.search(query)
|
||||||
|
training_item_results = training_models.TrainingItem.objects.search(query)
|
||||||
|
|
||||||
|
# combine querysets
|
||||||
|
queryset_chain = chain(
|
||||||
|
event_results,
|
||||||
|
person_results,
|
||||||
|
organisation_results,
|
||||||
|
venue_results,
|
||||||
|
invoice_results,
|
||||||
|
asset_results,
|
||||||
|
supplier_results,
|
||||||
|
trainee_results,
|
||||||
|
training_item_results,
|
||||||
|
)
|
||||||
|
qs = sorted(queryset_chain,
|
||||||
|
key=lambda instance: instance.pk,
|
||||||
|
reverse=True)
|
||||||
|
self.count = len(qs) # since qs is actually a list
|
||||||
|
return qs
|
||||||
|
return models.Event.objects.none() # just an empty queryset as default
|
||||||
|
|
||||||
|
|
||||||
class SearchHelp(generic.TemplateView):
|
class SearchHelp(generic.TemplateView):
|
||||||
template_name = 'search_help.html'
|
template_name = 'search_help.html'
|
||||||
|
|
||||||
@@ -256,14 +309,57 @@ class CloseModal(generic.TemplateView):
|
|||||||
class OEmbedView(generic.View):
|
class OEmbedView(generic.View):
|
||||||
def get(self, request, pk=None):
|
def get(self, request, pk=None):
|
||||||
embed_url = reverse(self.url_name, args=[pk])
|
embed_url = reverse(self.url_name, args=[pk])
|
||||||
full_url = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'], embed_url)
|
full_url = f"{request.scheme}://{request.META['HTTP_HOST']}{embed_url}"
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'html': '<iframe src="{0}" frameborder="0" width="100%" height="250"></iframe>'.format(full_url),
|
'html': f'<iframe src="{full_url}" frameborder="0" width="100%" height="250"></iframe>',
|
||||||
'version': '1.0',
|
'version': '1.0',
|
||||||
'type': 'rich',
|
'type': 'rich',
|
||||||
'height': '250'
|
'height': '250'
|
||||||
}
|
}
|
||||||
|
|
||||||
json = simplejson.JSONEncoderForHTML().encode(data)
|
return JsonResponse(data)
|
||||||
return HttpResponse(json, content_type="application/json")
|
|
||||||
|
|
||||||
|
class PrintView(generic.View):
|
||||||
|
append_terms = False
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
obj = get_object_or_404(self.model, pk=self.kwargs['pk'])
|
||||||
|
user_str = f"by {self.request.user.name} " if self.request.user is not None else ""
|
||||||
|
time = timezone.now().strftime('%d/%m/%Y %H:%I')
|
||||||
|
object_name = re.sub(r'[^a-zA-Z0-9 \n\.]', '', obj.name)
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'object': obj,
|
||||||
|
'current_user': self.request.user,
|
||||||
|
'object_name': object_name,
|
||||||
|
'info_string': f"[Paperwork generated {user_str}on {time} - {obj.current_version_id}]",
|
||||||
|
}
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get(self, request, pk):
|
||||||
|
template = get_template(self.template_name)
|
||||||
|
|
||||||
|
merger = PdfFileMerger()
|
||||||
|
|
||||||
|
context = self.get_context_data()
|
||||||
|
|
||||||
|
rml = template.render(context)
|
||||||
|
buffer = rml2pdf.parseString(rml)
|
||||||
|
merger.append(PdfFileReader(buffer))
|
||||||
|
buffer.close()
|
||||||
|
|
||||||
|
if self.append_terms:
|
||||||
|
terms = urllib.request.urlopen(settings.TERMS_OF_HIRE_URL)
|
||||||
|
merger.append(BytesIO(terms.read()))
|
||||||
|
|
||||||
|
merged = BytesIO()
|
||||||
|
merger.write(merged)
|
||||||
|
|
||||||
|
response = HttpResponse(content_type='application/pdf')
|
||||||
|
f = context['filename']
|
||||||
|
response['Content-Disposition'] = f'filename="{f}"'
|
||||||
|
response.write(merged.getvalue())
|
||||||
|
return response
|
||||||
|
|||||||
193
RIGS/admin.py
@@ -8,6 +8,7 @@ from django.db.models import Count
|
|||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.db import IntegrityError
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from reversion.admin import VersionAdmin
|
from reversion.admin import VersionAdmin
|
||||||
|
|
||||||
@@ -21,17 +22,139 @@ admin.site.register(models.EventItem, VersionAdmin)
|
|||||||
admin.site.register(models.Invoice, VersionAdmin)
|
admin.site.register(models.Invoice, VersionAdmin)
|
||||||
|
|
||||||
|
|
||||||
def approve_user(modeladmin, request, queryset):
|
@transaction.atomic() # Copied from django-extensions. GenericForeignKey support removed as unnecessary.
|
||||||
queryset.update(is_approved=True)
|
def merge_model_instances(primary_object, alias_objects):
|
||||||
|
"""
|
||||||
|
Merge several model instances into one, the `primary_object`.
|
||||||
|
Use this function to merge model objects and migrate all of the related
|
||||||
|
fields from the alias objects the primary object.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# get related fields
|
||||||
|
related_fields = list(filter(
|
||||||
|
lambda x: x.is_relation is True,
|
||||||
|
primary_object._meta.get_fields()))
|
||||||
|
|
||||||
|
many_to_many_fields = list(filter(
|
||||||
|
lambda x: x.many_to_many is True, related_fields))
|
||||||
|
|
||||||
|
related_fields = list(filter(
|
||||||
|
lambda x: x.many_to_many is False, related_fields))
|
||||||
|
|
||||||
|
# Loop through all alias objects and migrate their references to the
|
||||||
|
# primary object
|
||||||
|
deleted_objects = []
|
||||||
|
deleted_objects_count = 0
|
||||||
|
for alias_object in alias_objects:
|
||||||
|
# Migrate all foreign key references from alias object to primary
|
||||||
|
# object.
|
||||||
|
for many_to_many_field in many_to_many_fields:
|
||||||
|
alias_varname = many_to_many_field.name
|
||||||
|
related_objects = getattr(alias_object, alias_varname)
|
||||||
|
for obj in related_objects.all():
|
||||||
|
try:
|
||||||
|
# Handle regular M2M relationships.
|
||||||
|
getattr(alias_object, alias_varname).remove(obj)
|
||||||
|
getattr(primary_object, alias_varname).add(obj)
|
||||||
|
except AttributeError:
|
||||||
|
# Handle M2M relationships with a 'through' model.
|
||||||
|
# This does not delete the 'through model.
|
||||||
|
# TODO: Allow the user to delete a duplicate 'through' model.
|
||||||
|
through_model = getattr(alias_object, alias_varname).through
|
||||||
|
kwargs = {
|
||||||
|
many_to_many_field.m2m_reverse_field_name(): obj,
|
||||||
|
many_to_many_field.m2m_field_name(): alias_object,
|
||||||
|
}
|
||||||
|
through_model_instances = through_model.objects.filter(**kwargs)
|
||||||
|
for instance in through_model_instances:
|
||||||
|
# Re-attach the through model to the primary_object
|
||||||
|
setattr(
|
||||||
|
instance,
|
||||||
|
many_to_many_field.m2m_field_name(),
|
||||||
|
primary_object)
|
||||||
|
instance.save()
|
||||||
|
# TODO: Here, try to delete duplicate instances that are
|
||||||
|
# disallowed by a unique_together constraint
|
||||||
|
|
||||||
|
for related_field in related_fields:
|
||||||
|
if related_field.one_to_many:
|
||||||
|
with transaction.atomic():
|
||||||
|
try:
|
||||||
|
alias_varname = related_field.get_accessor_name()
|
||||||
|
related_objects = getattr(alias_object, alias_varname)
|
||||||
|
for obj in related_objects.all():
|
||||||
|
field_name = related_field.field.name
|
||||||
|
setattr(obj, field_name, primary_object)
|
||||||
|
obj.save()
|
||||||
|
except IntegrityError:
|
||||||
|
pass # Skip to avoid integrity error from unique_together
|
||||||
|
elif related_field.one_to_one or related_field.many_to_one:
|
||||||
|
alias_varname = related_field.name
|
||||||
|
if hasattr(alias_object, alias_varname):
|
||||||
|
related_object = getattr(alias_object, alias_varname)
|
||||||
|
primary_related_object = getattr(primary_object, alias_varname)
|
||||||
|
if primary_related_object is None:
|
||||||
|
setattr(primary_object, alias_varname, related_object)
|
||||||
|
primary_object.save()
|
||||||
|
elif related_field.one_to_one:
|
||||||
|
related_object.delete()
|
||||||
|
|
||||||
|
if alias_object.id:
|
||||||
|
deleted_objects += [alias_object]
|
||||||
|
alias_object.delete()
|
||||||
|
deleted_objects_count += 1
|
||||||
|
|
||||||
|
return primary_object, deleted_objects, deleted_objects_count
|
||||||
|
|
||||||
|
|
||||||
approve_user.short_description = "Approve selected users"
|
class AssociateAdmin(VersionAdmin):
|
||||||
|
search_fields = ['id', 'name']
|
||||||
|
list_display_links = ['id', 'name']
|
||||||
|
actions = ['merge']
|
||||||
|
|
||||||
|
def get_queryset(self, request):
|
||||||
|
return super().get_queryset(request).annotate(event_count=Count('event'))
|
||||||
|
|
||||||
|
def number_of_events(self, obj):
|
||||||
|
return obj.latest_events.count()
|
||||||
|
|
||||||
|
number_of_events.admin_order_field = 'event_count'
|
||||||
|
|
||||||
|
def merge(self, request, queryset):
|
||||||
|
if request.POST.get('post'): # Has the user confirmed which is the master record?
|
||||||
|
try:
|
||||||
|
master_object_pk = request.POST.get('master')
|
||||||
|
master_object = queryset.get(pk=master_object_pk)
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
self.message_user(request, "An error occured. Did you select a 'master' record?", level=messages.ERROR)
|
||||||
|
return
|
||||||
|
|
||||||
|
primary_object, deleted_objects, deleted_objects_count = merge_model_instances(master_object, queryset.exclude(pk=master_object_pk).all())
|
||||||
|
reversion.set_comment('Merging Objects')
|
||||||
|
self.message_user(request, f"Objects successfully merged. {deleted_objects_count} old objects deleted.")
|
||||||
|
else: # Present the confirmation screen
|
||||||
|
class TempForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = queryset.model
|
||||||
|
fields = self.merge_fields
|
||||||
|
|
||||||
|
forms = []
|
||||||
|
for obj in queryset:
|
||||||
|
forms.append(TempForm(instance=obj))
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'title': _("Are you sure?"),
|
||||||
|
'queryset': queryset,
|
||||||
|
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
|
||||||
|
'forms': forms
|
||||||
|
}
|
||||||
|
return TemplateResponse(request, 'admin_associate_merge.html', context)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(models.Profile)
|
@admin.register(models.Profile)
|
||||||
class ProfileAdmin(UserAdmin):
|
class ProfileAdmin(UserAdmin, AssociateAdmin):
|
||||||
# Don't know how to add 'is_approved' whilst preserving the default list...
|
list_display = ('username', 'name', 'is_approved', 'is_staff', 'is_superuser', 'is_supervisor', 'number_of_events')
|
||||||
list_filter = ('is_approved', 'is_active', 'is_staff', 'is_superuser', 'groups')
|
list_display_links = ['username']
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, {'fields': ('username', 'password')}),
|
(None, {'fields': ('username', 'password')}),
|
||||||
(_('Personal info'), {
|
(_('Personal info'), {
|
||||||
@@ -49,62 +172,12 @@ class ProfileAdmin(UserAdmin):
|
|||||||
)
|
)
|
||||||
form = user_forms.ProfileChangeForm
|
form = user_forms.ProfileChangeForm
|
||||||
add_form = user_forms.ProfileCreationForm
|
add_form = user_forms.ProfileCreationForm
|
||||||
actions = [approve_user]
|
actions = ['approve_user', 'merge']
|
||||||
|
|
||||||
|
merge_fields = ['username', 'first_name', 'last_name', 'initials', 'email', 'phone', 'is_supervisor']
|
||||||
|
|
||||||
class AssociateAdmin(VersionAdmin):
|
def approve_user(modeladmin, request, queryset):
|
||||||
list_display = ('id', 'name', 'number_of_events')
|
queryset.update(is_approved=True)
|
||||||
search_fields = ['id', 'name']
|
|
||||||
list_display_links = ['id', 'name']
|
|
||||||
actions = ['merge']
|
|
||||||
|
|
||||||
merge_fields = ['name']
|
|
||||||
|
|
||||||
def get_queryset(self, request):
|
|
||||||
return super(AssociateAdmin, self).get_queryset(request).annotate(event_count=Count('event'))
|
|
||||||
|
|
||||||
def number_of_events(self, obj):
|
|
||||||
return obj.latest_events.count()
|
|
||||||
|
|
||||||
number_of_events.admin_order_field = 'event_count'
|
|
||||||
|
|
||||||
def merge(self, request, queryset):
|
|
||||||
if request.POST.get('post'): # Has the user confirmed which is the master record?
|
|
||||||
try:
|
|
||||||
masterObjectPk = request.POST.get('master')
|
|
||||||
masterObject = queryset.get(pk=masterObjectPk)
|
|
||||||
except ObjectDoesNotExist:
|
|
||||||
self.message_user(request, "An error occured. Did you select a 'master' record?", level=messages.ERROR)
|
|
||||||
return
|
|
||||||
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
for obj in queryset.exclude(pk=masterObjectPk):
|
|
||||||
events = obj.event_set.all()
|
|
||||||
for event in events:
|
|
||||||
masterObject.event_set.add(event)
|
|
||||||
obj.delete()
|
|
||||||
reversion.set_comment('Merging Objects')
|
|
||||||
|
|
||||||
self.message_user(request, "Objects successfully merged.")
|
|
||||||
return
|
|
||||||
else: # Present the confirmation screen
|
|
||||||
|
|
||||||
class TempForm(ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = queryset.model
|
|
||||||
fields = self.merge_fields
|
|
||||||
|
|
||||||
forms = []
|
|
||||||
for obj in queryset:
|
|
||||||
forms.append(TempForm(instance=obj))
|
|
||||||
|
|
||||||
context = {
|
|
||||||
'title': _("Are you sure?"),
|
|
||||||
'queryset': queryset,
|
|
||||||
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
|
|
||||||
'forms': forms
|
|
||||||
}
|
|
||||||
return TemplateResponse(request, 'admin_associate_merge.html', context)
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(models.Person)
|
@admin.register(models.Person)
|
||||||
|
|||||||
@@ -124,6 +124,22 @@ class EventForm(forms.ModelForm):
|
|||||||
'purchase_order', 'collector']
|
'purchase_order', 'collector']
|
||||||
|
|
||||||
|
|
||||||
|
class SubhireForm(forms.ModelForm):
|
||||||
|
related_models = {
|
||||||
|
'person': models.Person,
|
||||||
|
'organisation': models.Organisation,
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['start_date'].widget.format = '%Y-%m-%d'
|
||||||
|
self.fields['end_date'].widget.format = '%Y-%m-%d'
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.Subhire
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class BaseClientEventAuthorisationForm(forms.ModelForm):
|
class BaseClientEventAuthorisationForm(forms.ModelForm):
|
||||||
tos = forms.BooleanField(required=True, label="Terms of hire")
|
tos = forms.BooleanField(required=True, label="Terms of hire")
|
||||||
name = forms.CharField(label="Your Name")
|
name = forms.CharField(label="Your Name")
|
||||||
@@ -153,6 +169,10 @@ class EventAuthorisationRequestForm(forms.Form):
|
|||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentForm(forms.ModelForm):
|
class EventRiskAssessmentForm(forms.ModelForm):
|
||||||
|
related_models = {
|
||||||
|
'power_mic': models.Profile,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
for name, field in self.fields.items():
|
for name, field in self.fields.items():
|
||||||
@@ -172,9 +192,9 @@ class EventRiskAssessmentForm(forms.ModelForm):
|
|||||||
unexpected_values = []
|
unexpected_values = []
|
||||||
for field, value in models.RiskAssessment.expected_values.items():
|
for field, value in models.RiskAssessment.expected_values.items():
|
||||||
if self.cleaned_data.get(field) != value:
|
if self.cleaned_data.get(field) != value:
|
||||||
unexpected_values.append("<li>{}</li>".format(self._meta.model._meta.get_field(field).help_text))
|
unexpected_values.append(f"<li>{self._meta.model._meta.get_field(field).help_text}</li>")
|
||||||
if len(unexpected_values) > 0 and not self.cleaned_data.get('supervisor_consulted'):
|
if len(unexpected_values) > 0 and not self.cleaned_data.get('supervisor_consulted'):
|
||||||
raise forms.ValidationError("Your answers to these questions: <ul>{}</ul> require consulting with a supervisor.".format(''.join([str(elem) for elem in unexpected_values])), code='unusual_answers')
|
raise forms.ValidationError(f"Your answers to these questions: <ul>{''.join([str(elem) for elem in unexpected_values])}</ul> require consulting with a supervisor.", code='unusual_answers')
|
||||||
return super(EventRiskAssessmentForm, self).clean()
|
return super(EventRiskAssessmentForm, self).clean()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -235,9 +255,9 @@ class EventChecklistForm(forms.ModelForm):
|
|||||||
pk = int(key.split('_')[1])
|
pk = int(key.split('_')[1])
|
||||||
|
|
||||||
for field in other_fields:
|
for field in other_fields:
|
||||||
value = self.data['{}_{}'.format(field, pk)]
|
value = self.data[f'{field}_{pk}']
|
||||||
if value == '':
|
if value == '':
|
||||||
raise forms.ValidationError('Add a {} to crewmember {}'.format(field, pk), code='{}_mismatch'.format(field))
|
raise forms.ValidationError(f'Add a {field} to crewmember {pk}', code=f'{field}_mismatch')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
item = models.EventChecklistCrew.objects.get(pk=pk)
|
item = models.EventChecklistCrew.objects.get(pk=pk)
|
||||||
|
|||||||
36
RIGS/migrations/0045_subhire.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Generated by Django 3.2.12 on 2022-10-15 19:36
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import versioning.versioning
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0044_profile_is_supervisor'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Subhire',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=255)),
|
||||||
|
('description', models.TextField(blank=True, default='')),
|
||||||
|
('status', models.IntegerField(choices=[(0, 'Provisional'), (1, 'Confirmed'), (2, 'Booked'), (3, 'Cancelled')], default=0)),
|
||||||
|
('start_date', models.DateField()),
|
||||||
|
('start_time', models.TimeField(blank=True, null=True)),
|
||||||
|
('end_date', models.DateField(blank=True, null=True)),
|
||||||
|
('end_time', models.TimeField(blank=True, null=True)),
|
||||||
|
('purchase_order', models.CharField(blank=True, default='', max_length=255, verbose_name='PO')),
|
||||||
|
('insurance_value', models.DecimalField(decimal_places=2, max_digits=10)),
|
||||||
|
('organisation', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='RIGS.organisation')),
|
||||||
|
('person', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='RIGS.person')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
RIGS/migrations/0046_subhire_events.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.16 on 2022-10-20 11:56
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0045_subhire'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='subhire',
|
||||||
|
name='events',
|
||||||
|
field=models.ManyToManyField(to='RIGS.Event'),
|
||||||
|
),
|
||||||
|
]
|
||||||
311
RIGS/models.py
@@ -8,6 +8,7 @@ from urllib.parse import urlparse
|
|||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.db.models import Q, F
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import AbstractUser
|
from django.contrib.auth.models import AbstractUser
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
@@ -17,6 +18,18 @@ from django.utils import timezone
|
|||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from reversion.models import Version
|
from reversion.models import Version
|
||||||
|
from versioning.versioning import RevisionMixin
|
||||||
|
|
||||||
|
|
||||||
|
def filter_by_pk(filt, query):
|
||||||
|
# try and parse an int
|
||||||
|
try:
|
||||||
|
val = int(query)
|
||||||
|
filt = filt | Q(pk=val)
|
||||||
|
except: # noqa
|
||||||
|
# not an integer
|
||||||
|
pass
|
||||||
|
return filt
|
||||||
|
|
||||||
|
|
||||||
class Profile(AbstractUser):
|
class Profile(AbstractUser):
|
||||||
@@ -50,7 +63,7 @@ class Profile(AbstractUser):
|
|||||||
def name(self):
|
def name(self):
|
||||||
name = self.get_full_name()
|
name = self.get_full_name()
|
||||||
if self.initials:
|
if self.initials:
|
||||||
name += ' "{}"'.format(self.initials)
|
name += f' "{self.initials}"'
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -69,48 +82,28 @@ class Profile(AbstractUser):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class RevisionMixin:
|
class ContactableManager(models.Manager):
|
||||||
@property
|
def search(self, query=None):
|
||||||
def is_first_version(self):
|
qs = self.get_queryset()
|
||||||
versions = Version.objects.get_for_object(self)
|
if query is not None:
|
||||||
return len(versions) == 1
|
or_lookup = Q(name__icontains=query) | Q(email__icontains=query) | Q(address__icontains=query) | Q(notes__icontains=query) | Q(
|
||||||
|
phone__startswith=query) | Q(phone__endswith=query)
|
||||||
|
|
||||||
@property
|
or_lookup = filter_by_pk(or_lookup, query)
|
||||||
def current_version(self):
|
|
||||||
version = Version.objects.get_for_object(self).select_related('revision').first()
|
|
||||||
return version
|
|
||||||
|
|
||||||
@property
|
qs = qs.filter(or_lookup).distinct() # distinct() is often necessary with Q lookups
|
||||||
def last_edited_at(self):
|
return qs
|
||||||
version = self.current_version
|
|
||||||
if version is None:
|
|
||||||
return None
|
|
||||||
return version.revision.date_created
|
|
||||||
|
|
||||||
@property
|
|
||||||
def last_edited_by(self):
|
|
||||||
version = self.current_version
|
|
||||||
if version is None:
|
|
||||||
return None
|
|
||||||
return version.revision.user
|
|
||||||
|
|
||||||
@property
|
|
||||||
def current_version_id(self):
|
|
||||||
version = self.current_version
|
|
||||||
if version is None:
|
|
||||||
return None
|
|
||||||
return f"V{version.pk} | R{version.revision.pk}"
|
|
||||||
|
|
||||||
|
|
||||||
class Person(models.Model, RevisionMixin):
|
class Person(models.Model, RevisionMixin):
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
phone = models.CharField(max_length=15, blank=True, default='')
|
phone = models.CharField(max_length=15, blank=True, default='')
|
||||||
email = models.EmailField(blank=True, default='')
|
email = models.EmailField(blank=True, default='')
|
||||||
|
|
||||||
address = models.TextField(blank=True, default='')
|
address = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
notes = models.TextField(blank=True, default='')
|
notes = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
|
objects = ContactableManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
if self.notes is not None:
|
if self.notes is not None:
|
||||||
@@ -142,12 +135,12 @@ class Organisation(models.Model, RevisionMixin):
|
|||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
phone = models.CharField(max_length=15, blank=True, default='')
|
phone = models.CharField(max_length=15, blank=True, default='')
|
||||||
email = models.EmailField(blank=True, default='')
|
email = models.EmailField(blank=True, default='')
|
||||||
|
|
||||||
address = models.TextField(blank=True, default='')
|
address = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
notes = models.TextField(blank=True, default='')
|
notes = models.TextField(blank=True, default='')
|
||||||
union_account = models.BooleanField(default=False)
|
union_account = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
objects = ContactableManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
if self.notes is not None:
|
if self.notes is not None:
|
||||||
@@ -216,9 +209,10 @@ class Venue(models.Model, RevisionMixin):
|
|||||||
email = models.EmailField(blank=True, default='')
|
email = models.EmailField(blank=True, default='')
|
||||||
three_phase_available = models.BooleanField(default=False)
|
three_phase_available = models.BooleanField(default=False)
|
||||||
notes = models.TextField(blank=True, default='')
|
notes = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
address = models.TextField(blank=True, default='')
|
address = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
|
objects = ContactableManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
if self.notes and len(self.notes) > 0:
|
if self.notes and len(self.notes) > 0:
|
||||||
@@ -292,9 +286,47 @@ class EventManager(models.Manager):
|
|||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
def search(self, query=None):
|
||||||
|
qs = self.get_queryset()
|
||||||
|
if query is not None:
|
||||||
|
or_lookup = Q(name__icontains=query) | Q(description__icontains=query) | Q(notes__icontains=query)
|
||||||
|
|
||||||
@reversion.register(follow=['items'])
|
or_lookup = filter_by_pk(or_lookup, query)
|
||||||
class Event(models.Model, RevisionMixin):
|
|
||||||
|
try:
|
||||||
|
if query[0] == "N":
|
||||||
|
val = int(query[1:])
|
||||||
|
or_lookup = Q(pk=val) # If string is N###### then do a simple PK filter
|
||||||
|
except: # noqa
|
||||||
|
pass
|
||||||
|
|
||||||
|
qs = qs.filter(or_lookup).distinct() # distinct() is often necessary with Q lookups
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
def find_earliest_event_time(event, datetime_list):
|
||||||
|
# If there is no start time defined, pretend it's midnight
|
||||||
|
startTimeFaked = False
|
||||||
|
if event.has_start_time:
|
||||||
|
startDateTime = datetime.datetime.combine(event.start_date, event.start_time)
|
||||||
|
else:
|
||||||
|
startDateTime = datetime.datetime.combine(event.start_date, datetime.time(00, 00))
|
||||||
|
startTimeFaked = True
|
||||||
|
|
||||||
|
# timezoneIssues - apply the default timezone to the naiive datetime
|
||||||
|
tz = pytz.timezone(settings.TIME_ZONE)
|
||||||
|
startDateTime = tz.localize(startDateTime)
|
||||||
|
datetime_list.append(startDateTime) # then add it to the list
|
||||||
|
|
||||||
|
earliest = min(datetime_list).astimezone(tz) # find the earliest datetime in the list
|
||||||
|
|
||||||
|
# if we faked it & it's the earliest, better own up
|
||||||
|
if startTimeFaked and earliest == startDateTime:
|
||||||
|
return event.start_date
|
||||||
|
return earliest
|
||||||
|
|
||||||
|
|
||||||
|
class BaseEvent(models.Model, RevisionMixin):
|
||||||
# Done to make it much nicer on the database
|
# Done to make it much nicer on the database
|
||||||
PROVISIONAL = 0
|
PROVISIONAL = 0
|
||||||
CONFIRMED = 1
|
CONFIRMED = 1
|
||||||
@@ -310,31 +342,85 @@ class Event(models.Model, RevisionMixin):
|
|||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
person = models.ForeignKey('Person', null=True, blank=True, on_delete=models.CASCADE)
|
person = models.ForeignKey('Person', null=True, blank=True, on_delete=models.CASCADE)
|
||||||
organisation = models.ForeignKey('Organisation', blank=True, null=True, on_delete=models.CASCADE)
|
organisation = models.ForeignKey('Organisation', blank=True, null=True, on_delete=models.CASCADE)
|
||||||
venue = models.ForeignKey('Venue', blank=True, null=True, on_delete=models.CASCADE)
|
|
||||||
description = models.TextField(blank=True, default='')
|
description = models.TextField(blank=True, default='')
|
||||||
notes = models.TextField(blank=True, default='')
|
|
||||||
status = models.IntegerField(choices=EVENT_STATUS_CHOICES, default=PROVISIONAL)
|
status = models.IntegerField(choices=EVENT_STATUS_CHOICES, default=PROVISIONAL)
|
||||||
dry_hire = models.BooleanField(default=False)
|
|
||||||
is_rig = models.BooleanField(default=True)
|
|
||||||
based_on = models.ForeignKey('Event', on_delete=models.SET_NULL, related_name='future_events', blank=True,
|
|
||||||
null=True)
|
|
||||||
|
|
||||||
# Timing
|
# Timing
|
||||||
start_date = models.DateField()
|
start_date = models.DateField()
|
||||||
start_time = models.TimeField(blank=True, null=True)
|
start_time = models.TimeField(blank=True, null=True)
|
||||||
end_date = models.DateField(blank=True, null=True)
|
end_date = models.DateField(blank=True, null=True)
|
||||||
end_time = models.TimeField(blank=True, null=True)
|
end_time = models.TimeField(blank=True, null=True)
|
||||||
|
|
||||||
|
purchase_order = models.CharField(max_length=255, blank=True, default='', verbose_name='PO')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cancelled(self):
|
||||||
|
return (self.status == self.CANCELLED)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def confirmed(self):
|
||||||
|
return (self.status == self.BOOKED or self.status == self.CONFIRMED)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_start_time(self):
|
||||||
|
return self.start_time is not None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_end_time(self):
|
||||||
|
return self.end_time is not None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def latest_time(self):
|
||||||
|
"""Returns the end of the event - this function could return either a tzaware datetime, or a naiive date object"""
|
||||||
|
tz = pytz.timezone(settings.TIME_ZONE)
|
||||||
|
endDate = self.end_date
|
||||||
|
if endDate is None:
|
||||||
|
endDate = self.start_date
|
||||||
|
|
||||||
|
if self.has_end_time:
|
||||||
|
endDateTime = datetime.datetime.combine(endDate, self.end_time)
|
||||||
|
tz = pytz.timezone(settings.TIME_ZONE)
|
||||||
|
endDateTime = tz.localize(endDateTime)
|
||||||
|
|
||||||
|
return endDateTime
|
||||||
|
|
||||||
|
else:
|
||||||
|
return endDate
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
errdict = {}
|
||||||
|
if self.end_date and self.start_date > self.end_date:
|
||||||
|
errdict['end_date'] = ['Unless you\'ve invented time travel, the event can\'t finish before it has started.']
|
||||||
|
|
||||||
|
startEndSameDay = not self.end_date or self.end_date == self.start_date
|
||||||
|
hasStartAndEnd = self.has_start_time and self.has_end_time
|
||||||
|
if startEndSameDay and hasStartAndEnd and self.start_time > self.end_time:
|
||||||
|
errdict['end_time'] = ['Unless you\'ve invented time travel, the event can\'t finish before it has started.']
|
||||||
|
return errdict
|
||||||
|
|
||||||
|
|
||||||
|
@reversion.register(follow=['items'])
|
||||||
|
class Event(BaseEvent):
|
||||||
|
mic = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='event_mic', blank=True, null=True,
|
||||||
|
verbose_name="MIC", on_delete=models.CASCADE)
|
||||||
|
venue = models.ForeignKey('Venue', blank=True, null=True, on_delete=models.CASCADE)
|
||||||
|
notes = models.TextField(blank=True, default='')
|
||||||
|
dry_hire = models.BooleanField(default=False)
|
||||||
|
is_rig = models.BooleanField(default=True)
|
||||||
|
based_on = models.ForeignKey('Event', on_delete=models.SET_NULL, related_name='future_events', blank=True,
|
||||||
|
null=True)
|
||||||
|
|
||||||
access_at = models.DateTimeField(blank=True, null=True)
|
access_at = models.DateTimeField(blank=True, null=True)
|
||||||
meet_at = models.DateTimeField(blank=True, null=True)
|
meet_at = models.DateTimeField(blank=True, null=True)
|
||||||
|
|
||||||
# Crew management
|
# Dry-hire only
|
||||||
checked_in_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='event_checked_in', blank=True, null=True,
|
checked_in_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='event_checked_in', blank=True, null=True,
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
mic = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='event_mic', blank=True, null=True,
|
|
||||||
verbose_name="MIC", on_delete=models.CASCADE)
|
|
||||||
|
|
||||||
# Monies
|
# Monies
|
||||||
purchase_order = models.CharField(max_length=255, blank=True, default='', verbose_name='PO')
|
|
||||||
collector = models.CharField(max_length=255, blank=True, default='', verbose_name='collected by')
|
collector = models.CharField(max_length=255, blank=True, default='', verbose_name='collected by')
|
||||||
|
|
||||||
# Authorisation request details
|
# Authorisation request details
|
||||||
@@ -346,10 +432,8 @@ class Event(models.Model, RevisionMixin):
|
|||||||
def display_id(self):
|
def display_id(self):
|
||||||
if self.pk:
|
if self.pk:
|
||||||
if self.is_rig:
|
if self.is_rig:
|
||||||
return str("N%05d" % self.pk)
|
return f"N{self.pk:05d}"
|
||||||
|
|
||||||
return self.pk
|
return self.pk
|
||||||
|
|
||||||
return "????"
|
return "????"
|
||||||
|
|
||||||
# Calculated values
|
# Calculated values
|
||||||
@@ -386,26 +470,10 @@ class Event(models.Model, RevisionMixin):
|
|||||||
def total(self):
|
def total(self):
|
||||||
return Decimal(self.sum_total + self.vat).quantize(Decimal('.01'))
|
return Decimal(self.sum_total + self.vat).quantize(Decimal('.01'))
|
||||||
|
|
||||||
@property
|
|
||||||
def cancelled(self):
|
|
||||||
return (self.status == self.CANCELLED)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def confirmed(self):
|
|
||||||
return (self.status == self.BOOKED or self.status == self.CONFIRMED)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hs_done(self):
|
def hs_done(self):
|
||||||
return self.riskassessment is not None and len(self.checklists.all()) > 0
|
return self.riskassessment is not None and len(self.checklists.all()) > 0
|
||||||
|
|
||||||
@property
|
|
||||||
def has_start_time(self):
|
|
||||||
return self.start_time is not None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def has_end_time(self):
|
|
||||||
return self.end_time is not None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def earliest_time(self):
|
def earliest_time(self):
|
||||||
"""Finds the earliest time defined in the event - this function could return either a tzaware datetime, or a naiive date object"""
|
"""Finds the earliest time defined in the event - this function could return either a tzaware datetime, or a naiive date object"""
|
||||||
@@ -419,45 +487,10 @@ class Event(models.Model, RevisionMixin):
|
|||||||
if self.meet_at:
|
if self.meet_at:
|
||||||
datetime_list.append(self.meet_at)
|
datetime_list.append(self.meet_at)
|
||||||
|
|
||||||
# If there is no start time defined, pretend it's midnight
|
earliest = find_earliest_event_time(self, datetime_list)
|
||||||
startTimeFaked = False
|
|
||||||
if self.has_start_time:
|
|
||||||
startDateTime = datetime.datetime.combine(self.start_date, self.start_time)
|
|
||||||
else:
|
|
||||||
startDateTime = datetime.datetime.combine(self.start_date, datetime.time(00, 00))
|
|
||||||
startTimeFaked = True
|
|
||||||
|
|
||||||
# timezoneIssues - apply the default timezone to the naiive datetime
|
|
||||||
tz = pytz.timezone(settings.TIME_ZONE)
|
|
||||||
startDateTime = tz.localize(startDateTime)
|
|
||||||
datetime_list.append(startDateTime) # then add it to the list
|
|
||||||
|
|
||||||
earliest = min(datetime_list).astimezone(tz) # find the earliest datetime in the list
|
|
||||||
|
|
||||||
# if we faked it & it's the earliest, better own up
|
|
||||||
if startTimeFaked and earliest == startDateTime:
|
|
||||||
return self.start_date
|
|
||||||
|
|
||||||
return earliest
|
return earliest
|
||||||
|
|
||||||
@property
|
|
||||||
def latest_time(self):
|
|
||||||
"""Returns the end of the event - this function could return either a tzaware datetime, or a naiive date object"""
|
|
||||||
tz = pytz.timezone(settings.TIME_ZONE)
|
|
||||||
endDate = self.end_date
|
|
||||||
if endDate is None:
|
|
||||||
endDate = self.start_date
|
|
||||||
|
|
||||||
if self.has_end_time:
|
|
||||||
endDateTime = datetime.datetime.combine(endDate, self.end_time)
|
|
||||||
tz = pytz.timezone(settings.TIME_ZONE)
|
|
||||||
endDateTime = tz.localize(endDateTime)
|
|
||||||
|
|
||||||
return endDateTime
|
|
||||||
|
|
||||||
else:
|
|
||||||
return endDate
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def internal(self):
|
def internal(self):
|
||||||
return bool(self.organisation and self.organisation.union_account)
|
return bool(self.organisation and self.organisation.union_account)
|
||||||
@@ -478,14 +511,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
return f"{self.display_id}: {self.name}"
|
return f"{self.display_id}: {self.name}"
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
errdict = {}
|
errdict = super.clean()
|
||||||
if self.end_date and self.start_date > self.end_date:
|
|
||||||
errdict['end_date'] = ['Unless you\'ve invented time travel, the event can\'t finish before it has started.']
|
|
||||||
|
|
||||||
startEndSameDay = not self.end_date or self.end_date == self.start_date
|
|
||||||
hasStartAndEnd = self.has_start_time and self.has_end_time
|
|
||||||
if startEndSameDay and hasStartAndEnd and self.start_time > self.end_time:
|
|
||||||
errdict['end_time'] = ['Unless you\'ve invented time travel, the event can\'t finish before it has started.']
|
|
||||||
|
|
||||||
if self.access_at is not None:
|
if self.access_at is not None:
|
||||||
if self.access_at.date() > self.start_date:
|
if self.access_at.date() > self.start_date:
|
||||||
@@ -546,6 +572,16 @@ class EventAuthorisation(models.Model, RevisionMixin):
|
|||||||
return f"{self.event.display_id} (requested by {self.sent_by.initials})"
|
return f"{self.event.display_id} (requested by {self.sent_by.initials})"
|
||||||
|
|
||||||
|
|
||||||
|
@reversion.register
|
||||||
|
class Subhire(BaseEvent):
|
||||||
|
insurance_value = models.DecimalField(max_digits=10, decimal_places=2) # TODO Validate if this is over notifiable threshold
|
||||||
|
events = models.ManyToManyField(Event)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def display_id(self):
|
||||||
|
return f"S{self.pk:05d}"
|
||||||
|
|
||||||
|
|
||||||
class InvoiceManager(models.Manager):
|
class InvoiceManager(models.Manager):
|
||||||
def outstanding_invoices(self):
|
def outstanding_invoices(self):
|
||||||
# Manual query is the only way I have found to do this efficiently. Not ideal but needs must
|
# Manual query is the only way I have found to do this efficiently. Not ideal but needs must
|
||||||
@@ -562,6 +598,34 @@ class InvoiceManager(models.Manager):
|
|||||||
query = self.raw(sql)
|
query = self.raw(sql)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
def search(self, query=None):
|
||||||
|
qs = self.get_queryset()
|
||||||
|
if query is not None:
|
||||||
|
or_lookup = Q(event__name__icontains=query)
|
||||||
|
|
||||||
|
or_lookup = filter_by_pk(or_lookup, query)
|
||||||
|
|
||||||
|
# try and parse an int
|
||||||
|
try:
|
||||||
|
val = int(query)
|
||||||
|
or_lookup = or_lookup | Q(event__pk=val)
|
||||||
|
except: # noqa
|
||||||
|
# not an integer
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
if query[0] == "N":
|
||||||
|
val = int(query[1:])
|
||||||
|
or_lookup = Q(event__pk=val) # If string is Nxxxxx then filter by event number
|
||||||
|
elif query[0] == "#":
|
||||||
|
val = int(query[1:])
|
||||||
|
or_lookup = Q(pk=val) # If string is #xxxxx then filter by invoice number
|
||||||
|
except: # noqa
|
||||||
|
pass
|
||||||
|
|
||||||
|
qs = qs.filter(or_lookup).distinct() # distinct() is often necessary with Q lookups
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(follow=['payment_set'])
|
@reversion.register(follow=['payment_set'])
|
||||||
class Invoice(models.Model, RevisionMixin):
|
class Invoice(models.Model, RevisionMixin):
|
||||||
@@ -601,14 +665,14 @@ class Invoice(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return "#{} for Event {}".format(self.display_id, self.event.display_id)
|
return f"{self.display_id} for Event {self.event.display_id}"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%i: %s (%.2f)" % (self.pk, self.event, self.balance)
|
return f"{self.display_id}: {self.event} (£{self.balance:.2f})"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def display_id(self):
|
def display_id(self):
|
||||||
return "{:05d}".format(self.pk)
|
return f"#{self.pk:05d}"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-invoice_date']
|
ordering = ['-invoice_date']
|
||||||
@@ -637,11 +701,11 @@ class Payment(models.Model, RevisionMixin):
|
|||||||
reversion_hide = True
|
reversion_hide = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s: %d" % (self.get_method_display(), self.amount)
|
return f"{self.get_method_display()}: {self.amount}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return str("payment of £{}".format(self.amount))
|
return f"payment of £{self.amount}"
|
||||||
|
|
||||||
|
|
||||||
def validate_url(value):
|
def validate_url(value):
|
||||||
@@ -713,7 +777,7 @@ class RiskAssessment(models.Model, RevisionMixin):
|
|||||||
'contractors': False,
|
'contractors': False,
|
||||||
'other_companies': False,
|
'other_companies': False,
|
||||||
'crew_fatigue': False,
|
'crew_fatigue': False,
|
||||||
'big_power': False,
|
# 'big_power': False Doesn't require checking with a super either way
|
||||||
'generators': False,
|
'generators': False,
|
||||||
'other_companies_power': False,
|
'other_companies_power': False,
|
||||||
'nonstandard_equipment_power': False,
|
'nonstandard_equipment_power': False,
|
||||||
@@ -755,15 +819,22 @@ class RiskAssessment(models.Model, RevisionMixin):
|
|||||||
else:
|
else:
|
||||||
return self.SMALL[0]
|
return self.SMALL[0]
|
||||||
|
|
||||||
|
def get_event_size_display(self):
|
||||||
|
return self.SIZES[self.event_size][1] + " Event"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return str(self.event)
|
return str(self.event)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return str(self)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('ra_detail', kwargs={'pk': self.pk})
|
return reverse('ra_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%i - %s" % (self.pk, self.event)
|
return f"{self.pk} | {self.event}"
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(follow=['vehicles', 'crew'])
|
@reversion.register(follow=['vehicles', 'crew'])
|
||||||
@@ -845,7 +916,7 @@ class EventChecklist(models.Model, RevisionMixin):
|
|||||||
return reverse('ec_detail', kwargs={'pk': self.pk})
|
return reverse('ec_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%i - %s" % (self.pk, self.event)
|
return f"{self.pk} - {self.event}"
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
@@ -857,7 +928,7 @@ class EventChecklistVehicle(models.Model, RevisionMixin):
|
|||||||
reversion_hide = True
|
reversion_hide = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} driven by {}".format(self.vehicle, str(self.driver))
|
return f"{self.vehicle} driven by {self.driver}"
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
@@ -875,4 +946,4 @@ class EventChecklistCrew(models.Model, RevisionMixin):
|
|||||||
raise ValidationError('Unless you\'ve invented time travel, crew can\'t finish before they have started.')
|
raise ValidationError('Unless you\'ve invented time travel, crew can\'t finish before they have started.')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} ({})".format(str(self.crewmember), self.role)
|
return f"{self.crewmember} ({self.role})"
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ def send_eventauthorisation_success_email(instance):
|
|||||||
elif instance.event.organisation is not None and instance.email == instance.event.organisation.email:
|
elif instance.event.organisation is not None and instance.email == instance.event.organisation.email:
|
||||||
context['to_name'] = instance.event.organisation.name
|
context['to_name'] = instance.event.organisation.name
|
||||||
|
|
||||||
subject = "N%05d | %s - Event Authorised" % (instance.event.pk, instance.event.name)
|
subject = f"{instance.event.display_id} | {instance.event.name} - Event Authorised"
|
||||||
|
|
||||||
client_email = EmailMultiAlternatives(
|
client_email = EmailMultiAlternatives(
|
||||||
subject,
|
subject,
|
||||||
@@ -70,7 +70,7 @@ def send_eventauthorisation_success_email(instance):
|
|||||||
|
|
||||||
escapedEventName = re.sub(r'[^a-zA-Z0-9 \n\.]', '', instance.event.name)
|
escapedEventName = re.sub(r'[^a-zA-Z0-9 \n\.]', '', instance.event.name)
|
||||||
|
|
||||||
client_email.attach('N%05d - %s - CONFIRMATION.pdf' % (instance.event.pk, escapedEventName),
|
client_email.attach(f'{instance.event.display_id} - {escapedEventName} - CONFIRMATION.pdf',
|
||||||
merged.getvalue(),
|
merged.getvalue(),
|
||||||
'application/pdf'
|
'application/pdf'
|
||||||
)
|
)
|
||||||
@@ -116,7 +116,7 @@ def send_admin_awaiting_approval_email(user, request, **kwargs):
|
|||||||
}
|
}
|
||||||
|
|
||||||
email = EmailMultiAlternatives(
|
email = EmailMultiAlternatives(
|
||||||
"%s new users awaiting approval on RIGS" % (context['number_of_users']),
|
f"{context['number_of_users']} new users awaiting approval on RIGS",
|
||||||
get_template("admin_awaiting_approval.txt").render(context),
|
get_template("admin_awaiting_approval.txt").render(context),
|
||||||
to=[admin.email],
|
to=[admin.email],
|
||||||
reply_to=[user.email],
|
reply_to=[user.email],
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 278 KiB After Width: | Height: | Size: 278 KiB |
|
Before Width: | Height: | Size: 6.3 MiB After Width: | Height: | Size: 5.4 MiB |
|
Before Width: | Height: | Size: 852 KiB After Width: | Height: | Size: 852 KiB |
139
RIGS/templates/base_print.xml
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE document SYSTEM "rml.dtd">
|
||||||
|
<document filename="{{filename}}">
|
||||||
|
<docinit>
|
||||||
|
<registerTTFont faceName="OpenSans" fileName="static/fonts/OpenSans-Regular.tff"/>
|
||||||
|
<registerTTFont faceName="OpenSans-Bold" fileName="static/fonts/OpenSans-Bold.tff"/>
|
||||||
|
<registerFontFamily name="OpenSans" bold="OpenSans-Bold" boldItalic="OpenSans-Bold"/>
|
||||||
|
</docinit>
|
||||||
|
|
||||||
|
<stylesheet>
|
||||||
|
<initialize>
|
||||||
|
<color id="LightGray" RGB="#D3D3D3"/>
|
||||||
|
<color id="DarkGray" RGB="#707070"/>
|
||||||
|
</initialize>
|
||||||
|
|
||||||
|
<paraStyle name="style.para" fontName="OpenSans" />
|
||||||
|
<paraStyle name="blockPara" spaceAfter="5" spaceBefore="5"/>
|
||||||
|
<paraStyle name="style.Heading1" fontName="OpenSans" fontSize="16" leading="18" spaceAfter="0"/>
|
||||||
|
<paraStyle name="style.Heading2" fontName="OpenSans-Bold" fontSize="10" spaceAfter="2"/>
|
||||||
|
<paraStyle name="style.Heading3" fontName="OpenSans" fontSize="10" spaceAfter="0"/>
|
||||||
|
<paraStyle name="center" alignment="center"/>
|
||||||
|
<paraStyle name="page-head" alignment="center" fontName="OpenSans-Bold" fontSize="16" leading="18" spaceAfter="0"/>
|
||||||
|
|
||||||
|
<paraStyle name="style.event_description" fontName="OpenSans" textColor="DarkGray" />
|
||||||
|
<paraStyle name="style.item_description" fontName="OpenSans" textColor="DarkGray" leftIndent="10" />
|
||||||
|
<paraStyle name="style.specific_description" fontName="OpenSans" textColor="DarkGray" fontSize="10" />
|
||||||
|
<paraStyle name="style.times" fontName="OpenSans" fontSize="10" />
|
||||||
|
<paraStyle name="style.head_titles" fontName="OpenSans-Bold" fontSize="10" />
|
||||||
|
<paraStyle name="style.head_numbers" fontName="OpenSans" fontSize="10" />
|
||||||
|
|
||||||
|
<blockTableStyle id="eventSpecifics">
|
||||||
|
<blockValign value="top"/>
|
||||||
|
<lineStyle kind="LINEAFTER" colorName="LightGrey" start="0,0" stop="1,0" thickness="1"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="headLayout">
|
||||||
|
<blockValign value="top"/>
|
||||||
|
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="eventDetails">
|
||||||
|
<blockValign value="top"/>
|
||||||
|
<blockTopPadding start="0,0" stop="-1,0" length="0"/>
|
||||||
|
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="itemTable">
|
||||||
|
<blockValign value="top"/>
|
||||||
|
<lineStyle kind="LINEBELOW" colorName="LightGrey" start="0,0" stop="-1,-1" thickness="1"/>
|
||||||
|
{#<lineStyle kind="box" colorName="black" thickness="1" start="0,0" stop="-1,-1"/>#}
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="totalTable">
|
||||||
|
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
||||||
|
<lineStyle kind="LINEBELOW" colorName="LightGrey" start="-2,0" stop="-1,-1" thickness="1"/>
|
||||||
|
{# <lineStyle cap="default" kind="grid" colorName="black" thickness="1" start="1,0" stop="-1,-1"/> #}
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="infoTable" keepWithNext="true">
|
||||||
|
<blockLeftPadding start="0,0" stop="-1,-1" length="0"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="paymentTable">
|
||||||
|
<blockBackground colorName="LightGray" start="0,1" stop="3,1"/>
|
||||||
|
<blockFont name="OpenSans-Bold" start="0,1" stop="0,1"/>
|
||||||
|
<blockFont name="OpenSans-Bold" start="2,1" stop="2,1"/>
|
||||||
|
<lineStyle kind="outline" colorName="black" thickness="1" start="0,1" stop="3,1"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="signatureTable">
|
||||||
|
<blockTopPadding length="20" />
|
||||||
|
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
||||||
|
<lineStyle kind="linebelow" start="1,0" stop="1,0" colorName="black"/>
|
||||||
|
<lineStyle kind="linebelow" start="3,0" stop="3,0" colorName="black"/>
|
||||||
|
<lineStyle kind="linebelow" start="5,0" stop="5,0" colorName="black"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<listStyle name="ol"
|
||||||
|
bulletFormat="%s."
|
||||||
|
bulletFontSize="10" />
|
||||||
|
|
||||||
|
<listStyle name="ul"
|
||||||
|
start="bulletchar"
|
||||||
|
bulletFontSize="10"/>
|
||||||
|
</stylesheet>
|
||||||
|
|
||||||
|
<template > {# Note: page is 595x842 points (1 point=1/72in) #}
|
||||||
|
<pageTemplate id="Headed" >
|
||||||
|
<pageGraphics>
|
||||||
|
<image file="static/imgs/paperwork/corner-tr-su.jpg" x="395" y="642" height="200" width="200"/>
|
||||||
|
<image file="static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
||||||
|
|
||||||
|
{# logo positioned 42 from left, 33 from top #}
|
||||||
|
<image file="static/imgs/paperwork/tec-logo.jpg" x="42" y="719" height="90" width="84"/>
|
||||||
|
|
||||||
|
<setFont name="OpenSans-Bold" size="22.5" leading="10"/>
|
||||||
|
<drawString x="137" y="780">TEC PA & Lighting</drawString>
|
||||||
|
|
||||||
|
<setFont name="OpenSans" size="9"/>
|
||||||
|
<drawString x="137" y="760">Portland Building, University Park, Nottingham, NG7 2RD</drawString>
|
||||||
|
<drawString x="137" y="746">www.nottinghamtec.co.uk</drawString>
|
||||||
|
<drawString x="265" y="746">info@nottinghamtec.co.uk</drawString>
|
||||||
|
<drawString x="137" y="732">Phone: (0115) 846 8720</drawString>
|
||||||
|
|
||||||
|
<setFont name="OpenSans" size="10" />
|
||||||
|
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
||||||
|
<setFont name="OpenSans" size="7" />
|
||||||
|
<drawCenteredString x="302.5" y="26">
|
||||||
|
{{info_string}}
|
||||||
|
</drawCenteredString>
|
||||||
|
</pageGraphics>
|
||||||
|
|
||||||
|
<frame id="main" x1="50" y1="65" width="495" height="645"/>
|
||||||
|
</pageTemplate>
|
||||||
|
|
||||||
|
<pageTemplate id="Main">
|
||||||
|
<pageGraphics>
|
||||||
|
<image file="static/imgs/paperwork/corner-tr.jpg" x="395" y="642" height="200" width="200"/>
|
||||||
|
<image file="static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
||||||
|
|
||||||
|
<setFont name="OpenSans" size="10"/>
|
||||||
|
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
||||||
|
<setFont name="OpenSans" size="7" />
|
||||||
|
<drawCenteredString x="302.5" y="26">
|
||||||
|
{{info_string}}
|
||||||
|
</drawCenteredString>
|
||||||
|
</pageGraphics>
|
||||||
|
<frame id="main" x1="50" y1="65" width="495" height="727"/>
|
||||||
|
</pageTemplate>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<story firstPageTemplate="Headed">
|
||||||
|
<setNextFrame name="main"/>
|
||||||
|
<nextFrame/>
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
</story>
|
||||||
|
|
||||||
|
</document>
|
||||||
@@ -30,6 +30,8 @@
|
|||||||
{% if perms.RIGS.add_event %}
|
{% if perms.RIGS.add_event %}
|
||||||
<a class="dropdown-item" href="{% url 'event_create' %}"><span class="fas fa-plus"></span>
|
<a class="dropdown-item" href="{% url 'event_create' %}"><span class="fas fa-plus"></span>
|
||||||
New Event</a>
|
New Event</a>
|
||||||
|
<a class="dropdown-item" href="{% url 'subhire_create' %}"><span class="fas fa-truck"></span>
|
||||||
|
New Subhire</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -27,15 +27,12 @@
|
|||||||
|
|
||||||
calendar = new FullCalendar.Calendar(calendarEl, {
|
calendar = new FullCalendar.Calendar(calendarEl, {
|
||||||
themeSystem: 'bootstrap',
|
themeSystem: 'bootstrap',
|
||||||
//defaultView: 'dayGridMonth', This is now default
|
|
||||||
aspectRatio: 1.5,
|
aspectRatio: 1.5,
|
||||||
eventTimeFormat: {
|
eventTimeFormat: {
|
||||||
'hour': '2-digit',
|
'hour': '2-digit',
|
||||||
'minute': '2-digit',
|
'minute': '2-digit',
|
||||||
'hour12': false
|
'hour12': false
|
||||||
},
|
},
|
||||||
//nowIndicator: true,
|
|
||||||
//firstDay: 1,
|
|
||||||
headerToolbar: false,
|
headerToolbar: false,
|
||||||
editable: false,
|
editable: false,
|
||||||
dayMaxEventRows: true, // allow "more" link when too many events
|
dayMaxEventRows: true, // allow "more" link when too many events
|
||||||
@@ -58,8 +55,10 @@
|
|||||||
};
|
};
|
||||||
$(doc).each(function() {
|
$(doc).each(function() {
|
||||||
end = $(this).attr('latest')
|
end = $(this).attr('latest')
|
||||||
|
allDay = false
|
||||||
if(end.indexOf("T") < 0){ //If latest does not contain a time
|
if(end.indexOf("T") < 0){ //If latest does not contain a time
|
||||||
end = moment(end).add(1, 'days') //End date is non-inclusive, so add a day
|
end = moment(end + " 23:59").format("YYYY-MM-DD[T]HH:mm:ss")
|
||||||
|
allDay = true
|
||||||
}
|
}
|
||||||
|
|
||||||
thisEvent = {
|
thisEvent = {
|
||||||
@@ -67,7 +66,8 @@
|
|||||||
'end': end,
|
'end': end,
|
||||||
'className': 'modal-href',
|
'className': 'modal-href',
|
||||||
'title': $(this).attr('title'),
|
'title': $(this).attr('title'),
|
||||||
'url': $(this).attr('url')
|
'url': $(this).attr('url'),
|
||||||
|
'allDay': allDay
|
||||||
}
|
}
|
||||||
|
|
||||||
if($(this).attr('is_rig')===true || $(this).attr('status') === "Cancelled"){
|
if($(this).attr('is_rig')===true || $(this).attr('status') === "Cancelled"){
|
||||||
|
|||||||
@@ -25,12 +25,10 @@
|
|||||||
{% include 'partials/hs_details.html' %}
|
{% include 'partials/hs_details.html' %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if event.is_rig %}
|
{% if event.is_rig and event.internal and perms.RIGS.view_event %}
|
||||||
{% if event.is_rig and event.internal and perms.RIGS.view_event %}
|
<div class="col-md-8 py-3">
|
||||||
<div class="col-md-8 py-3">
|
{% include 'partials/auth_details.html' %}
|
||||||
{% include 'partials/auth_details.html' %}
|
</div>
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not request.is_ajax and perms.RIGS.view_event %}
|
{% if not request.is_ajax and perms.RIGS.view_event %}
|
||||||
<div class="col-sm-12 text-right">
|
<div class="col-sm-12 text-right">
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
{% block css %}
|
{% block css %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'css/selects.css' %}"/>
|
<link rel="stylesheet" type="text/css" href="{% static 'css/selects.css' %}"/>
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'css/simplemde.min.css' %}">
|
<link rel="stylesheet" type="text/css" href="{% static 'css/easymde.min.css' %}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block preload_js %}
|
{% block preload_js %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script src="{% static 'js/selects.js' %}"></script>
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
<script src="{% static 'js/simplemde.min.js' %}"></script>
|
<script src="{% static 'js/easymde.min.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
@@ -23,8 +23,6 @@
|
|||||||
<script src="{% static 'js/interaction.js' %}"></script>
|
<script src="{% static 'js/interaction.js' %}"></script>
|
||||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
|
||||||
{% include 'partials/datetime-fix.html' %}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const matches = window.matchMedia("(prefers-reduced-motion: reduce)").matches || window.matchMedia("(update: slow)").matches;
|
const matches = window.matchMedia("(prefers-reduced-motion: reduce)").matches || window.matchMedia("(update: slow)").matches;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
@@ -124,7 +122,7 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-9 col-md-7 col-lg-8">
|
<div class="col-sm-9 col-md-7 col-lg-8">
|
||||||
<select id="{{ form.person.id_for_label }}" name="{{ form.person.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='person' %}">
|
<select id="{{ form.person.id_for_label }}" name="{{ form.person.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='person' %}">
|
||||||
{% if person %}
|
{% if person %}
|
||||||
<option value="{{form.person.value}}" selected="selected" data-update_url="{% url 'person_update' form.person.value %}">{{ person }}</option>
|
<option value="{{form.person.value}}" selected="selected" data-update_url="{% url 'person_update' form.person.value %}">{{ person }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -151,7 +149,7 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-9 col-md-7 col-lg-8">
|
<div class="col-sm-9 col-md-7 col-lg-8">
|
||||||
<select id="{{ form.organisation.id_for_label }}" name="{{ form.organisation.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='organisation' %}" >
|
<select id="{{ form.organisation.id_for_label }}" name="{{ form.organisation.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='organisation' %}" >
|
||||||
{% if organisation %}
|
{% if organisation %}
|
||||||
<option value="{{form.organisation.value}}" selected="selected" data-update_url="{% url 'organisation_update' form.organisation.value %}">{{ organisation }}</option>
|
<option value="{{form.organisation.value}}" selected="selected" data-update_url="{% url 'organisation_update' form.organisation.value %}">{{ organisation }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -209,7 +207,7 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-9 col-md-7 col-lg-8">
|
<div class="col-sm-9 col-md-7 col-lg-8">
|
||||||
<select id="{{ form.venue.id_for_label }}" name="{{ form.venue.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='venue' %}">
|
<select id="{{ form.venue.id_for_label }}" name="{{ form.venue.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='venue' %}">
|
||||||
{% if venue %}
|
{% if venue %}
|
||||||
<option value="{{form.venue.value}}" selected="selected" data-update_url="{% url 'venue_update' form.venue.value %}">{{ venue }}</option>
|
<option value="{{form.venue.value}}" selected="selected" data-update_url="{% url 'venue_update' form.venue.value %}">{{ venue }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -279,10 +277,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-4 col-sm-8">
|
<div class="col-sm-offset-4 col-sm-8">
|
||||||
<div class="checkbox">
|
|
||||||
<label data-toggle="tooltip" title="Mark this event as a dry-hire, so it needs to be checked in at the end">
|
<label data-toggle="tooltip" title="Mark this event as a dry-hire, so it needs to be checked in at the end">
|
||||||
{% render_field form.dry_hire %}{{ form.dry_hire.label }}
|
{{ form.dry_hire.label }} {% render_field form.dry_hire %}
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -304,7 +300,7 @@
|
|||||||
class="col-sm-4 col-form-label">{{ form.mic.label }}</label>
|
class="col-sm-4 col-form-label">{{ form.mic.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select id="{{ form.mic.id_for_label }}" name="{{ form.mic.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
<select id="{{ form.mic.id_for_label }}" name="{{ form.mic.name }}" class="px-0 selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
{% if mic %}
|
{% if mic %}
|
||||||
<option value="{{form.mic.value}}" selected="selected" >{{ mic.name }}</option>
|
<option value="{{form.mic.value}}" selected="selected" >{{ mic.name }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -318,7 +314,7 @@
|
|||||||
class="col-sm-4 col-form-label">{{ form.checked_in_by.label }}</label>
|
class="col-sm-4 col-form-label">{{ form.checked_in_by.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select id="{{ form.checked_in_by.id_for_label }}" name="{{ form.checked_in_by.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
<select id="{{ form.checked_in_by.id_for_label }}" name="{{ form.checked_in_by.name }}" class="px-0 selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
{% if checked_in_by %}
|
{% if checked_in_by %}
|
||||||
<option value="{{form.checked_in_by.value}}" selected="selected" >{{ checked_in_by.name }}</option>
|
<option value="{{form.checked_in_by.value}}" selected="selected" >{{ checked_in_by.name }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -1,136 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
{% extends 'base_print.xml' %}
|
||||||
<!DOCTYPE document SYSTEM "rml.dtd">
|
|
||||||
<document filename="{{filename}}">
|
|
||||||
<docinit>
|
|
||||||
<registerTTFont faceName="OpenSans" fileName="static/fonts/OpenSans-Regular.tff"/>
|
|
||||||
<registerTTFont faceName="OpenSans-Bold" fileName="static/fonts/OpenSans-Bold.tff"/>
|
|
||||||
<registerFontFamily name="OpenSans" bold="OpenSans-Bold" boldItalic="OpenSans-Bold"/>
|
|
||||||
</docinit>
|
|
||||||
|
|
||||||
<stylesheet>
|
{% block content %}
|
||||||
<initialize>
|
{% include "event_print_page.xml" %}
|
||||||
<color id="LightGray" RGB="#D3D3D3"/>
|
{% endblock %}
|
||||||
<color id="DarkGray" RGB="#707070"/>
|
|
||||||
</initialize>
|
|
||||||
|
|
||||||
<paraStyle name="style.para" fontName="OpenSans" />
|
|
||||||
<paraStyle name="blockPara" spaceAfter="5" spaceBefore="5"/>
|
|
||||||
<paraStyle name="style.Heading1" fontName="OpenSans" fontSize="16" leading="18" spaceAfter="0"/>
|
|
||||||
<paraStyle name="style.Heading2" fontName="OpenSans-Bold" fontSize="10" spaceAfter="2"/>
|
|
||||||
<paraStyle name="style.Heading3" fontName="OpenSans" fontSize="10" spaceAfter="0"/>
|
|
||||||
<paraStyle name="center" alignment="center"/>
|
|
||||||
<paraStyle name="page-head" alignment="center" fontName="OpenSans-Bold" fontSize="16" leading="18" spaceAfter="0"/>
|
|
||||||
|
|
||||||
<paraStyle name="style.event_description" fontName="OpenSans" textColor="DarkGray" />
|
|
||||||
<paraStyle name="style.item_description" fontName="OpenSans" textColor="DarkGray" leftIndent="10" />
|
|
||||||
<paraStyle name="style.specific_description" fontName="OpenSans" textColor="DarkGray" fontSize="10" />
|
|
||||||
<paraStyle name="style.times" fontName="OpenSans" fontSize="10" />
|
|
||||||
<paraStyle name="style.head_titles" fontName="OpenSans-Bold" fontSize="10" />
|
|
||||||
<paraStyle name="style.head_numbers" fontName="OpenSans" fontSize="10" />
|
|
||||||
|
|
||||||
<blockTableStyle id="eventSpecifics">
|
|
||||||
<blockValign value="top"/>
|
|
||||||
<lineStyle kind="LINEAFTER" colorName="LightGrey" start="0,0" stop="1,0" thickness="1"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="headLayout">
|
|
||||||
<blockValign value="top"/>
|
|
||||||
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="eventDetails">
|
|
||||||
<blockValign value="top"/>
|
|
||||||
<blockTopPadding start="0,0" stop="-1,0" length="0"/>
|
|
||||||
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="itemTable">
|
|
||||||
<blockValign value="top"/>
|
|
||||||
<lineStyle kind="LINEBELOW" colorName="LightGrey" start="0,0" stop="-1,-1" thickness="1"/>
|
|
||||||
{#<lineStyle kind="box" colorName="black" thickness="1" start="0,0" stop="-1,-1"/>#}
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="totalTable">
|
|
||||||
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
|
||||||
<lineStyle kind="LINEBELOW" colorName="LightGrey" start="-2,0" stop="-1,-1" thickness="1"/>
|
|
||||||
{# <lineStyle cap="default" kind="grid" colorName="black" thickness="1" start="1,0" stop="-1,-1"/> #}
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="infoTable" keepWithNext="true">
|
|
||||||
<blockLeftPadding start="0,0" stop="-1,-1" length="0"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="paymentTable">
|
|
||||||
<blockBackground colorName="LightGray" start="0,1" stop="3,1"/>
|
|
||||||
<blockFont name="OpenSans-Bold" start="0,1" stop="0,1"/>
|
|
||||||
<blockFont name="OpenSans-Bold" start="2,1" stop="2,1"/>
|
|
||||||
<lineStyle kind="outline" colorName="black" thickness="1" start="0,1" stop="3,1"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="signatureTable">
|
|
||||||
<blockTopPadding length="20" />
|
|
||||||
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
|
||||||
<lineStyle kind="linebelow" start="1,0" stop="1,0" colorName="black"/>
|
|
||||||
<lineStyle kind="linebelow" start="3,0" stop="3,0" colorName="black"/>
|
|
||||||
<lineStyle kind="linebelow" start="5,0" stop="5,0" colorName="black"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<listStyle name="ol"
|
|
||||||
bulletFormat="%s."
|
|
||||||
bulletFontSize="10" />
|
|
||||||
|
|
||||||
<listStyle name="ul"
|
|
||||||
start="bulletchar"
|
|
||||||
bulletFontSize="10"/>
|
|
||||||
</stylesheet>
|
|
||||||
|
|
||||||
<template > {# Note: page is 595x842 points (1 point=1/72in) #}
|
|
||||||
<pageTemplate id="Headed" >
|
|
||||||
<pageGraphics>
|
|
||||||
<image file="static/imgs/paperwork/corner-tr-su.jpg" x="395" y="642" height="200" width="200"/>
|
|
||||||
<image file="static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
|
||||||
|
|
||||||
{# logo positioned 42 from left, 33 from top #}
|
|
||||||
<image file="static/imgs/paperwork/tec-logo.jpg" x="42" y="719" height="90" width="84"/>
|
|
||||||
|
|
||||||
<setFont name="OpenSans-Bold" size="22.5" leading="10"/>
|
|
||||||
<drawString x="137" y="780">TEC PA & Lighting</drawString>
|
|
||||||
|
|
||||||
<setFont name="OpenSans" size="9"/>
|
|
||||||
<drawString x="137" y="760">Portland Building, University Park, Nottingham, NG7 2RD</drawString>
|
|
||||||
<drawString x="137" y="746">www.nottinghamtec.co.uk</drawString>
|
|
||||||
<drawString x="265" y="746">info@nottinghamtec.co.uk</drawString>
|
|
||||||
<drawString x="137" y="732">Phone: (0115) 846 8720</drawString>
|
|
||||||
|
|
||||||
<setFont name="OpenSans" size="10" />
|
|
||||||
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
|
||||||
<setFont name="OpenSans" size="7" />
|
|
||||||
<drawCenteredString x="302.5" y="26">
|
|
||||||
[Paperwork generated{% if current_user %} by {{current_user.name}} |{% endif %} {% now "d/m/Y H:i" %} | {{object.current_version_id}}]
|
|
||||||
</drawCenteredString>
|
|
||||||
</pageGraphics>
|
|
||||||
|
|
||||||
<frame id="main" x1="50" y1="65" width="495" height="645"/>
|
|
||||||
</pageTemplate>
|
|
||||||
|
|
||||||
<pageTemplate id="Main">
|
|
||||||
<pageGraphics>
|
|
||||||
<image file="static/imgs/paperwork/corner-tr.jpg" x="395" y="642" height="200" width="200"/>
|
|
||||||
<image file="static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
|
||||||
|
|
||||||
<setFont name="OpenSans" size="10"/>
|
|
||||||
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
|
||||||
<setFont name="OpenSans" size="7" />
|
|
||||||
<drawCenteredString x="302.5" y="26">
|
|
||||||
[Paperwork generated{% if current_user %} by {{current_user.name}} |{% endif %} {% now "d/m/Y H:i" %} | {{object.current_version_id}}]
|
|
||||||
</drawCenteredString>
|
|
||||||
</pageGraphics>
|
|
||||||
<frame id="main" x1="50" y1="65" width="495" height="727"/>
|
|
||||||
</pageTemplate>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<story firstPageTemplate="Headed">
|
|
||||||
{% include "event_print_page.xml" %}
|
|
||||||
</story>
|
|
||||||
|
|
||||||
</document>
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
{% load markdown_tags %}
|
{% load markdown_tags %}
|
||||||
{% load filters %}
|
{% load filters %}
|
||||||
|
|
||||||
<setNextFrame name="main"/>
|
|
||||||
<nextFrame/>
|
|
||||||
<blockTable style="headLayout" colWidths="330,165">
|
<blockTable style="headLayout" colWidths="330,165">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h1><b>N{{ object.pk|stringformat:"05d" }}:</b> '{{ object.name }}'<small></small></h1>
|
<h1><b>N{{ object.pk|stringformat:"05d" }}:</b> '{{ object.name }}'</h1>
|
||||||
|
|
||||||
<para style="style.event_description">
|
<para style="style.event_description">
|
||||||
<b>{{object.start_date|date:"D jS N Y"}}</b>
|
<b>{{object.start_date|date:"D jS N Y"}}</b>
|
||||||
@@ -180,15 +178,10 @@
|
|||||||
{% for item in object.items.all %}
|
{% for item in object.items.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<para>{{ item.name }}
|
<para><b>{{ item.name }}</b></para>
|
||||||
{% if item.description %}
|
{% if item.description %}
|
||||||
</para>
|
{{ item.description|markdown:"rml" }}
|
||||||
<para style="item_description">
|
{% endif %}
|
||||||
{{ item.description|markdown:"rml" }}
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
{% endif %}
|
|
||||||
</para>
|
|
||||||
</td>
|
</td>
|
||||||
<td>£{{ item.cost|floatformat:2 }}</td>
|
<td>£{{ item.cost|floatformat:2 }}</td>
|
||||||
<td>{{ item.quantity }}</td>
|
<td>{{ item.quantity }}</td>
|
||||||
@@ -208,9 +201,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if quote %}
|
{% if quote %}
|
||||||
<para>
|
<para>This quote is valid for 30 days unless otherwise arranged.</para>
|
||||||
This quote is valid for 30 days unless otherwise arranged.
|
|
||||||
</para>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if object.vat > 0 %}
|
{% if object.vat > 0 %}
|
||||||
|
|||||||
@@ -5,21 +5,6 @@
|
|||||||
|
|
||||||
{% block title %}Request Authorisation{% endblock %}
|
{% block title %}Request Authorisation{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
|
||||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
|
||||||
<script src="{% static 'js/popover.js' %}"></script>
|
|
||||||
<script src="{% static 'js/clipboard.min.js' %}"></script>
|
|
||||||
<script>
|
|
||||||
var clipboard = new ClipboardJS('.btn');
|
|
||||||
|
|
||||||
clipboard.on('success', function(e) {
|
|
||||||
$(e.trigger).popover('show');
|
|
||||||
window.setTimeout(function () {$(e.trigger).popover('hide')}, 3000);
|
|
||||||
e.clearSelection();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
@@ -33,11 +18,11 @@
|
|||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
{% if object.person.email %}
|
{% if object.person.email %}
|
||||||
<dt>Person Email</dt>
|
<dt>Person Email</dt>
|
||||||
<dd><span id="person-email">{{ object.person.email }}</span>{% button 'copy' id='#person-email' %}</dd>
|
<dd><span id="person-email" class="pr-1">{{ object.person.email }}</span> {% button 'copy' id='#person-email' %}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if object.organisation.email %}
|
{% if object.organisation.email %}
|
||||||
<dt>Organisation Email</dt>
|
<dt>Organisation Email</dt>
|
||||||
<dd><span id="org-email">{{ object.organisation.email }}</span>{% button 'copy' id='#org-email' %}</dd>
|
<dd><span id="org-email" class="pr-1">{{ object.organisation.email }}</span> {% button 'copy' id='#org-email' %}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
{% else %}
|
{% else %}
|
||||||
@@ -57,11 +42,20 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
<script src="{% static 'js/popover.js' %}"></script>
|
||||||
|
<script src="{% static 'js/clipboard.min.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
$('#auth-request-form').on('submit', function () {
|
$('#auth-request-form').on('submit', function () {
|
||||||
$('#auth-request-form button').attr('disabled', true);
|
$('#auth-request-form button').attr('disabled', true);
|
||||||
});
|
});
|
||||||
|
var clipboard = new ClipboardJS('.btn');
|
||||||
|
|
||||||
|
clipboard.on('success', function(e) {
|
||||||
|
$(e.trigger).popover('show');
|
||||||
|
window.setTimeout(function () {$(e.trigger).popover('hide')}, 3000);
|
||||||
|
e.clearSelection();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,6 @@
|
|||||||
<script src="{% static 'js/autocompleter.js' %}"></script>
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
|
||||||
{% include 'partials/datetime-fix.html' %}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('button[data-action=add]').on('click', function (event) {
|
$('button[data-action=add]').on('click', function (event) {
|
||||||
135
RIGS/templates/hs/ra_print.xml
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
{% extends 'base_print.xml' %}
|
||||||
|
{% load filters %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<spacer length="15"/>
|
||||||
|
<h1>Event Specific Risk Assessment for <strong>{{ object.event }}</strong></h1>
|
||||||
|
<spacer length="15"/>
|
||||||
|
<h2>Client: {{ object.event.person|default:object.event.organisation }} | Venue: {{ object.event.venue }} | MIC: {{ object.event.mic }}</h2>
|
||||||
|
<spacer length="15"/>
|
||||||
|
<hr/>
|
||||||
|
<blockTable colWidths="425,100" spaceAfter="15">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>General</strong></h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'nonstandard_equipment'|striptags }}</para></td>
|
||||||
|
<td>{{ object.nonstandard_equipment|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'nonstandard_use'|striptags }}</para></td>
|
||||||
|
<td>{{ object.nonstandard_use|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'contractors'|striptags }}</para></td>
|
||||||
|
<td>{{ object.contractors|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'other_companies'|striptags }}</para></td>
|
||||||
|
<td>{{ object.other_companies|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'crew_fatigue'|striptags }}</para></td>
|
||||||
|
<td>{{ object.crew_fatigue|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'general_notes'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.general_notes|default:'No' }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>Power</strong></h3><spacer length="4"/><para textColor="white" backColor={% if object.event_size == 0 %}"green"{% elif object.event_size == 1 %}"yellow"{% else %}"red"{% endif %} borderPadding="3">{{ object.get_event_size_display }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'big_power'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.big_power|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'power_mic'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.power_mic|default:object.event.mic }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'outside'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.outside|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'generators'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.generators|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'other_companies_power'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.other_companies_power|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'nonstandard_equipment_power'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.nonstandard_equipment_power|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'multiple_electrical_environments'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.multiple_electrical_environments|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'power_notes'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.power_notes|default:'No' }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>Sound</strong></h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'noise_monitoring'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.noise_monitoring|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'sound_notes'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.sound_notes|default:'No' }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>Site Details</strong></h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'known_venue'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.known_venue|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'safe_loading'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.safe_loading|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'safe_storage'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.safe_storage|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'area_outside_of_control'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.area_outside_of_control|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'barrier_required'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.barrier_required|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'nonstandard_emergency_procedure'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.nonstandard_emergency_procedure|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>Structures</strong></h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'special_structures'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.special_structures|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'suspended_structures'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.suspended_structures|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'persons_responsible_structures'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.persons_responsible_structures|default:'N/A' }}</para></td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
<spacer length="15"/>\
|
||||||
|
<hr/>
|
||||||
|
<spacer length="15"/>
|
||||||
|
<para><em>Assessment completed by {{ object.last_edited_by }} on {{ object.last_edited_at }}</em></para>
|
||||||
|
{% if object.reviewed_by %}
|
||||||
|
<para><em>Reviewed by {{ object.reviewed_by }} on {{ object.reviewed.at }}</em></para>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
||||||
{% load help_text from filters %}
|
{% load filters %}
|
||||||
{% load yesnoi from filters %}
|
|
||||||
{% load linkornone from filters %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row py-3">
|
<div class="row py-3">
|
||||||
@@ -47,7 +45,7 @@
|
|||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-6">{{ object|help_text:'power_mic'|safe }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'power_mic'|safe }}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
{{ object.power_mic.name|default:'None' }}
|
{{ object.power_mic.name|default:object.event.mic }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-6">{{ object|help_text:'outside' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'outside' }}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
@@ -144,7 +142,7 @@
|
|||||||
</dd>
|
</dd>
|
||||||
<dt class="col-12">{{ object|help_text:'persons_responsible_structures' }}</dt>
|
<dt class="col-12">{{ object|help_text:'persons_responsible_structures' }}</dt>
|
||||||
<dd class="col-12">
|
<dd class="col-12">
|
||||||
{{ object.persons_responsible_structures.name|default:'N/A'|linebreaks }}
|
{{ object.persons_responsible_structures|default:'N/A'|linebreaks }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-12">{{ object|help_text:'rigging_plan'|safe }}</dt>
|
<dt class="col-12">{{ object|help_text:'rigging_plan'|safe }}</dt>
|
||||||
<dd class="col-12">
|
<dd class="col-12">
|
||||||
@@ -157,6 +155,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 text-right">
|
<div class="col-12 text-right">
|
||||||
|
{% button 'print' 'ra_print' object.pk %}
|
||||||
<a href="{% url 'ra_edit' object.pk %}" class="btn btn-warning my-3"><span class="fas fa-edit"></span> <span
|
<a href="{% url 'ra_edit' object.pk %}" class="btn btn-warning my-3"><span class="fas fa-edit"></span> <span
|
||||||
class="d-none d-sm-inline">Edit</span></a>
|
class="d-none d-sm-inline">Edit</span></a>
|
||||||
<a href="{% url 'event_detail' object.event.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> View Event</a>
|
<a href="{% url 'event_detail' object.event.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> View Event</a>
|
||||||
@@ -98,9 +98,9 @@
|
|||||||
<label for="{{ form.power_mic.id_for_label }}"
|
<label for="{{ form.power_mic.id_for_label }}"
|
||||||
class="col col-form-label">{{ form.power_mic.help_text|safe }}</label>
|
class="col col-form-label">{{ form.power_mic.help_text|safe }}</label>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<select id="{{ form.power_mic.id_for_label }}" name="{{ form.power_mic.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
<select id="{{ form.power_mic.id_for_label }}" name="{{ form.power_mic.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
{% if object.power_mic %}
|
{% if power_mic %}
|
||||||
<option value="{{object.power_mic.pk}}" selected="selected">{{ object.power_mic.name }}</option>
|
<option value="{{form.power_mic.value}}" selected="selected">{{ power_mic }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
<dt class="col-sm-6">Phone Number</dt>
|
<dt class="col-sm-6">Phone Number</dt>
|
||||||
<dd class="col-sm-6">{{ object.organisation.phone|linkornone:'tel' }}</dd>
|
<dd class="col-sm-6">{{ object.organisation.phone|linkornone:'tel' }}</dd>
|
||||||
<dt class="col-sm-6">Has SU Account</dt>
|
<dt class="col-sm-6">Has SU Account</dt>
|
||||||
<dd class="col-sm-6">{{ event.organisation.union_account|yesno|capfirst }}</dd>
|
<dd class="col-sm-6">{{ object.organisation.union_account|yesno|capfirst }}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{% if event.internal %}
|
{% if event.internal %}
|
||||||
<a class="btn item-add modal-href event-authorise-request
|
<a class="btn item-add modal-href event-authorise-request
|
||||||
{% if event.authorised %}
|
{% if event.authorised %}
|
||||||
btn-success active
|
btn-success active disabled
|
||||||
{% elif event.authorisation and event.authorisation.amount != event.total and event.authorisation.last_edited_at > event.auth_request_at %}
|
{% elif event.authorisation and event.authorisation.amount != event.total and event.authorisation.last_edited_at > event.auth_request_at %}
|
||||||
btn-warning
|
btn-warning
|
||||||
{% elif event.auth_request_to %}
|
{% elif event.auth_request_to %}
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
btn-secondary
|
btn-secondary
|
||||||
{% endif %}
|
{% endif %}
|
||||||
"
|
"
|
||||||
href="{% url 'event_authorise_request' object.pk %}">
|
{% if event.authorised %}aria-disabled="true"{% else %}href="{% url 'event_authorise_request' object.pk %}"{% endif %}>
|
||||||
<span class="fas fa-paper-plane"></span>
|
<span class="fas fa-paper-plane"></span>
|
||||||
<span class="d-none d-sm-inline">
|
<span class="d-none d-sm-inline">
|
||||||
{% if event.authorised %}
|
{% if event.authorised %}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{% if object.venue %}
|
{% if object.venue %}
|
||||||
<dt class="col-sm-6">Venue Notes</dt>
|
<dt class="col-sm-6">Venue Notes</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
{{ object.venue.notes }}{% if object.venue.three_phase_available %}<br>(Three phase available){%endif%}
|
{{ object.venue.notes|markdown }}{% if object.venue.three_phase_available %}<br>(Three phase available){%endif%}
|
||||||
</dd>
|
</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not event.dry_hire %}
|
{% if not event.dry_hire %}
|
||||||
{% if event.riskassessment %}
|
{% if event.riskassessment %}
|
||||||
<span class="badge badge-success">RA: <span class="fas fa-check"></span>{%if event.riskassessment.reviewed_by%}<span class="fas fa-check"></span>{%endif%}</span>
|
<a href="{{ event.riskassessment.get_absolute_url }}"><span class="badge badge-success">RA: <span class="fas fa-check{% if event.riskassessment.reviewed_by %}-double{%endif%}"></span></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="badge badge-danger">RA: <span class="fas fa-times"></span></span>
|
<span class="badge badge-danger">RA: <span class="fas fa-times"></span></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{% load namewithnotes from filters %}
|
{% load namewithnotes from filters %}
|
||||||
|
{% load markdown_tags %}
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table mb-0" id="event_table">
|
<table class="table mb-0" id="event_table">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -29,7 +30,15 @@
|
|||||||
<!---Number-->
|
<!---Number-->
|
||||||
<th scope="row" id="event_number">{{ event.display_id }}</th>
|
<th scope="row" id="event_number">{{ event.display_id }}</th>
|
||||||
<!--Dates & Times-->
|
<!--Dates & Times-->
|
||||||
<td id="event_dates">
|
<td id="event_dates" style="text-align: justify;">
|
||||||
|
{% if not event.cancelled %}
|
||||||
|
{% if event.meet_at %}
|
||||||
|
<span class="text-nowrap">Meet: <strong>{{ event.meet_at|date:"D d/m/Y H:i" }}</strong></span>
|
||||||
|
{% endif %}
|
||||||
|
{% if event.access_at %}
|
||||||
|
<br><span class="text-nowrap">Access: <strong>{{ event.access_at|date:"D d/m/Y H:i" }}</strong></span>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
<span class="text-nowrap">Start: <strong>{{ event.start_date|date:"D d/m/Y" }}
|
<span class="text-nowrap">Start: <strong>{{ event.start_date|date:"D d/m/Y" }}
|
||||||
{% if event.has_start_time %}
|
{% if event.has_start_time %}
|
||||||
{{ event.start_time|date:"H:i" }}
|
{{ event.start_time|date:"H:i" }}
|
||||||
@@ -43,14 +52,6 @@
|
|||||||
{% endif %}</strong>
|
{% endif %}</strong>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not event.cancelled %}
|
|
||||||
{% if event.meet_at %}
|
|
||||||
<br><span class="text-nowrap">Meet: <strong>{{ event.meet_at|date:"D d/m/Y H:i" }}</strong></span>
|
|
||||||
{% endif %}
|
|
||||||
{% if event.access_at %}
|
|
||||||
<br><span class="text-nowrap">Access: <strong>{{ event.access_at|date:" D d/m/Y H:i" }}</strong></span>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
</td>
|
||||||
<!---Details-->
|
<!---Details-->
|
||||||
<td id="event_details" class="w-100">
|
<td id="event_details" class="w-100">
|
||||||
@@ -74,7 +75,7 @@
|
|||||||
</h5>
|
</h5>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not event.cancelled and event.description %}
|
{% if not event.cancelled and event.description %}
|
||||||
<p>{{ event.description|linebreaksbr }}</p>
|
<p>{{ event.description|markdown }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include 'partials/event_status.html' %}
|
{% include 'partials/event_status.html' %}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
27
RIGS/templates/subhire_detail.html
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
||||||
|
|
||||||
|
{% load markdown_tags %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row my-3 py-3">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{% include 'partials/contact_details.html' %}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{% include 'partials/event_details.html' %}
|
||||||
|
</div>
|
||||||
|
{% if not request.is_ajax and perms.RIGS.view_event %}
|
||||||
|
<div class="col-sm-12 text-right">
|
||||||
|
{% include 'partials/last_edited.html' with target="event_history" %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% if request.is_ajax %}
|
||||||
|
{% block footer %}
|
||||||
|
{% if perms.RIGS.view_event %}
|
||||||
|
{% include 'partials/last_edited.html' with target="event_history" %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
{% endif %}
|
||||||
188
RIGS/templates/subhire_form.html
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
{% extends 'base_rigs.html' %}
|
||||||
|
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
{% load static %}
|
||||||
|
{% load multiply from filters %}
|
||||||
|
{% load button from filters %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'css/selects.css' %}"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'css/easymde.min.css' %}">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block preload_js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
|
<script src="{% static 'js/easymde.min.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
|
<script src="{% static 'js/interaction.js' %}"></script>
|
||||||
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
setupMDE('#id_description');
|
||||||
|
});
|
||||||
|
$(function () {
|
||||||
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<form class="row" role="form" method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="col-12">
|
||||||
|
{% include 'form_errors.html' %}
|
||||||
|
</div>
|
||||||
|
{# Contact details #}
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Contact Details</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-group" data-toggle="tooltip">
|
||||||
|
<label for="{{ form.person.id_for_label }}">Primary Contact</label>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-9">
|
||||||
|
<select id="{{ form.person.id_for_label }}" name="{{ form.person.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='person' %}">
|
||||||
|
{% if person %}
|
||||||
|
<option value="{{form.person.value}}" selected="selected" data-update_url="{% url 'person_update' form.person.value %}">{{ person }}</option>
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-3 align-right">
|
||||||
|
<div class="btn-group">
|
||||||
|
<a href="{% url 'person_create' %}" class="btn btn-success modal-href"
|
||||||
|
data-target="#{{ form.person.id_for_label }}">
|
||||||
|
<span class="fas fa-plus"></span>
|
||||||
|
</a>
|
||||||
|
<a {% if form.person.value %}href="{% url 'person_update' form.person.value %}"{% endif %} class="btn btn-warning modal-href" id="{{ form.person.id_for_label }}-update" data-target="#{{ form.person.id_for_label }}">
|
||||||
|
<span class="fas fa-user-edit"></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.organisation.id_for_label }}">Hire Company</label>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-9">
|
||||||
|
<select id="{{ form.organisation.id_for_label }}" name="{{ form.organisation.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='organisation' %}">
|
||||||
|
{% if organisation %}
|
||||||
|
<option value="{{form.organisation.value}}" selected="selected" data-update_url="{% url 'organisation_update' form.organisation.value %}">{{ organisation }}</option>
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-3 align-right">
|
||||||
|
<div class="btn-group">
|
||||||
|
<a href="{% url 'organisation_create' %}" class="btn btn-success modal-href"
|
||||||
|
data-target="#{{ form.organisation.id_for_label }}">
|
||||||
|
<span class="fas fa-plus"></span>
|
||||||
|
</a>
|
||||||
|
<a {% if form.organisation.value %}href="{% url 'organisation_update' form.organisation.value %}"{% endif %} class="btn btn-warning modal-href" id="{{ form.organisation.id_for_label }}-update" data-target="#{{ form.organisation.id_for_label }}">
|
||||||
|
<span class="fas fa-edit"></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{# Event details #}
|
||||||
|
<div class="col-md-6 mb-2">
|
||||||
|
<div class="card card-default">
|
||||||
|
<div class="card-header">Hire Details</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-group" data-toggle="tooltip" title="Name of the event, displays on rigboard and on paperwork">
|
||||||
|
<label for="{{ form.name.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">{{ form.name.label }}</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.name class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.start_date.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">{{ form.start_date.label }}</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="Start date for event, required">
|
||||||
|
{% render_field form.start_date class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-12 col-md-5" data-toggle="tooltip" title="Start time of event, can be left blank">
|
||||||
|
{% render_field form.start_time class+="form-control" step="60" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.end_date.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">{{ form.end_date.label }}</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="End date of event, leave blank if unknown or same as start date">
|
||||||
|
{% render_field form.end_date class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-12 col-md-5" data-toggle="tooltip" title="End time of event, leave blank if unknown">
|
||||||
|
{% render_field form.end_time class+="form-control" step="60" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" data-toggle="tooltip" title="The current status of the event. Only mark as booked once paperwork is received">
|
||||||
|
<label for="{{ form.status.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">{{ form.status.label }}</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.status class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.purchase_order.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">{{ form.purchase_order.label }}</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.purchase_order class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Associated Event(s)</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<select multiple name="events" id="events_id" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='event' %}"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Equipment Information</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.description.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">{{ form.description.label }}</label>
|
||||||
|
<div class="col-sm-12">
|
||||||
|
{% render_field form.description class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.insurance_value.id_for_label }}"
|
||||||
|
class="col-sm-6 col-form-label">{{ form.insurance_value.label }}</label>
|
||||||
|
<div class="col-sm-8 input-group">
|
||||||
|
<div class="input-group-prepend"><span class="input-group-text">£</span></div>
|
||||||
|
{% render_field form.insurance_value class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
<div class="border border-info p-2 rounded mt-1" style="border-width: thin thin thin thick !important;">
|
||||||
|
If this value is greater than £50,000 then please email productions@nottinghamtec.co.uk in addition to complete the additional insurance requirements
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-12 text-right my-3">
|
||||||
|
{% button 'submit' %}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
@@ -9,7 +9,7 @@ register = template.Library()
|
|||||||
|
|
||||||
|
|
||||||
@register.filter(name="markdown")
|
@register.filter(name="markdown")
|
||||||
def markdown_filter(text, input_format='html'):
|
def markdown_filter(text, input_format='html', add_style=""):
|
||||||
# markdown library can't handle text=None
|
# markdown library can't handle text=None
|
||||||
if text is None:
|
if text is None:
|
||||||
return text
|
return text
|
||||||
|
|||||||
@@ -145,11 +145,11 @@ class CreateEvent(FormPage):
|
|||||||
|
|
||||||
def add_person(self):
|
def add_person(self):
|
||||||
self.find_element(*self._add_person_selector).click()
|
self.find_element(*self._add_person_selector).click()
|
||||||
return regions.Modal(self, self.driver.find_element_by_id('modal'))
|
return regions.Modal(self, self.driver.find_element(By.ID, 'modal'))
|
||||||
|
|
||||||
def add_event_item(self):
|
def add_event_item(self):
|
||||||
self.find_element(*self._add_item_selector).click()
|
self.find_element(*self._add_item_selector).click()
|
||||||
element = self.driver.find_element_by_id('itemModal')
|
element = self.driver.find_element(By.ID, 'itemModal')
|
||||||
self.wait.until(EC.visibility_of(element))
|
self.wait.until(EC.visibility_of(element))
|
||||||
return rigs_regions.ItemModal(self, element)
|
return rigs_regions.ItemModal(self, element)
|
||||||
|
|
||||||
|
|||||||
155
RIGS/tests/sample.md
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
An h1 header
|
||||||
|
============
|
||||||
|
|
||||||
|
Paragraphs are separated by a blank line.
|
||||||
|
|
||||||
|
2nd paragraph. *Italic*, **bold**, and `monospace`. Itemized lists
|
||||||
|
look like:
|
||||||
|
|
||||||
|
* this one
|
||||||
|
* that one
|
||||||
|
* the other one
|
||||||
|
|
||||||
|
Note that --- not considering the asterisk --- the actual text
|
||||||
|
content starts at 4-columns in.
|
||||||
|
|
||||||
|
> Block quotes are
|
||||||
|
> written like so.
|
||||||
|
>
|
||||||
|
> They can span multiple paragraphs,
|
||||||
|
> if you like.
|
||||||
|
|
||||||
|
Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all
|
||||||
|
in chapters 12--14"). Three dots ... will be converted to an ellipsis.
|
||||||
|
Unicode is supported.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
An h2 header
|
||||||
|
------------
|
||||||
|
|
||||||
|
Here's a numbered list:
|
||||||
|
|
||||||
|
1. first item
|
||||||
|
2. second item
|
||||||
|
3. third item
|
||||||
|
|
||||||
|
Note again how the actual text starts at 4 columns in (4 characters
|
||||||
|
from the left side). Here's a code sample:
|
||||||
|
|
||||||
|
# Let me re-iterate ...
|
||||||
|
for i in 1 .. 10 { do-something(i) }
|
||||||
|
|
||||||
|
As you probably guessed, indented 4 spaces. By the way, instead of
|
||||||
|
indenting the block, you can use delimited blocks, if you like:
|
||||||
|
|
||||||
|
~~~
|
||||||
|
define foobar() {
|
||||||
|
print "Welcome to flavor country!";
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
(which makes copying & pasting easier). You can optionally mark the
|
||||||
|
delimited block for Pandoc to syntax highlight it:
|
||||||
|
|
||||||
|
~~~python
|
||||||
|
import time
|
||||||
|
# Quick, count to ten!
|
||||||
|
for i in range(10):
|
||||||
|
# (but not *too* quick)
|
||||||
|
time.sleep(0.5)
|
||||||
|
print i
|
||||||
|
~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### An h3 header ###
|
||||||
|
|
||||||
|
Now a nested list:
|
||||||
|
|
||||||
|
1. First, get these ingredients:
|
||||||
|
|
||||||
|
* carrots
|
||||||
|
* celery
|
||||||
|
* lentils
|
||||||
|
|
||||||
|
2. Boil some water.
|
||||||
|
|
||||||
|
3. Dump everything in the pot and follow
|
||||||
|
this algorithm:
|
||||||
|
|
||||||
|
find wooden spoon
|
||||||
|
uncover pot
|
||||||
|
stir
|
||||||
|
cover pot
|
||||||
|
balance wooden spoon precariously on pot handle
|
||||||
|
wait 10 minutes
|
||||||
|
goto first step (or shut off burner when done)
|
||||||
|
|
||||||
|
Do not bump wooden spoon or it will fall.
|
||||||
|
|
||||||
|
Notice again how text always lines up on 4-space indents (including
|
||||||
|
that last line which continues item 3 above).
|
||||||
|
|
||||||
|
Here's a link to [a website](http://foo.bar). Here's a footnote [^1].
|
||||||
|
|
||||||
|
[^1]: Footnote text goes here.
|
||||||
|
|
||||||
|
Tables can look like this:
|
||||||
|
|
||||||
|
size material color
|
||||||
|
---- ------------ ------------
|
||||||
|
9 leather brown
|
||||||
|
10 hemp canvas natural
|
||||||
|
11 glass transparent
|
||||||
|
|
||||||
|
Table: Shoes, their sizes, and what they're made of
|
||||||
|
|
||||||
|
(The above is the caption for the table.) Pandoc also supports
|
||||||
|
multi-line tables:
|
||||||
|
|
||||||
|
-------- -----------------------
|
||||||
|
keyword text
|
||||||
|
-------- -----------------------
|
||||||
|
red Sunsets, apples, and
|
||||||
|
other red or reddish
|
||||||
|
things.
|
||||||
|
|
||||||
|
green Leaves, grass, frogs
|
||||||
|
and other things it's
|
||||||
|
not easy being.
|
||||||
|
-------- -----------------------
|
||||||
|
|
||||||
|
A horizontal rule follows.
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
Here's a definition list:
|
||||||
|
|
||||||
|
apples
|
||||||
|
: Good for making applesauce.
|
||||||
|
oranges
|
||||||
|
: Citrus!
|
||||||
|
tomatoes
|
||||||
|
: There's no "e" in tomatoe.
|
||||||
|
|
||||||
|
Again, text is indented 4 spaces. (Put a blank line between each
|
||||||
|
term/definition pair to spread things out more.)
|
||||||
|
|
||||||
|
Here's a "line block":
|
||||||
|
|
||||||
|
| Line one
|
||||||
|
| Line too
|
||||||
|
| Line tree
|
||||||
|
|
||||||
|
and images can be specified like so:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Inline math equations go in like so: $\\omega = d\\phi / dt$. Display
|
||||||
|
math should get its own line and be put in in double-dollarsigns:
|
||||||
|
|
||||||
|
$$I = \\int \rho R^{2} dV$$
|
||||||
|
|
||||||
|
And note that you can backslash-escape any punctuation characters
|
||||||
|
which you wish to be displayed literally, ex.: \\`foo\\`, \\*bar\\*, etc.
|
||||||
@@ -211,7 +211,7 @@ class TestEventCreate(BaseRigboardTest):
|
|||||||
self.assertEqual("Test Item 1", testitem['name'])
|
self.assertEqual("Test Item 1", testitem['name'])
|
||||||
self.assertEqual("2", testitem['quantity']) # test a couple of "worse case" fields
|
self.assertEqual("2", testitem['quantity']) # test a couple of "worse case" fields
|
||||||
|
|
||||||
total = self.driver.find_element_by_id('total')
|
total = self.driver.find_element(By.ID, 'total')
|
||||||
ActionChains(self.driver).move_to_element(total).perform()
|
ActionChains(self.driver).move_to_element(total).perform()
|
||||||
|
|
||||||
# See new item appear in table
|
# See new item appear in table
|
||||||
@@ -224,9 +224,9 @@ class TestEventCreate(BaseRigboardTest):
|
|||||||
self.assertEqual('47.90', row.subtotal)
|
self.assertEqual('47.90', row.subtotal)
|
||||||
|
|
||||||
# Check totals TODO convert to page properties
|
# Check totals TODO convert to page properties
|
||||||
self.assertEqual("47.90", self.driver.find_element_by_id('sumtotal').text)
|
self.assertEqual("47.90", self.driver.find_element(By.ID, 'sumtotal').text)
|
||||||
self.assertIn("(TBC)", self.driver.find_element_by_id('vat-rate').text)
|
self.assertIn("(TBC)", self.driver.find_element(By.ID, 'vat-rate').text)
|
||||||
self.assertEqual("9.58", self.driver.find_element_by_id('vat').text)
|
self.assertEqual("9.58", self.driver.find_element(By.ID, 'vat').text)
|
||||||
self.assertEqual("57.48", total.text)
|
self.assertEqual("57.48", total.text)
|
||||||
|
|
||||||
self.page.submit()
|
self.page.submit()
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import os
|
||||||
|
import pytest
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
@@ -12,8 +15,6 @@ from pytest_django.asserts import assertRedirects, assertNotContains, assertCont
|
|||||||
from PyRIGS.tests.base import assert_times_almost_equal, assert_oembed, login
|
from PyRIGS.tests.base import assert_times_almost_equal, assert_oembed, login
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
pytestmark = pytest.mark.django_db
|
pytestmark = pytest.mark.django_db
|
||||||
|
|
||||||
|
|
||||||
@@ -371,163 +372,7 @@ def test_ra_redirect(admin_client, admin_user, ra):
|
|||||||
|
|
||||||
|
|
||||||
class TestMarkdownTemplateTags(TestCase):
|
class TestMarkdownTemplateTags(TestCase):
|
||||||
markdown = """
|
markdown = open(os.path.join(settings.BASE_DIR, "RIGS/tests/sample.md")).read()
|
||||||
An h1 header
|
|
||||||
============
|
|
||||||
|
|
||||||
Paragraphs are separated by a blank line.
|
|
||||||
|
|
||||||
2nd paragraph. *Italic*, **bold**, and `monospace`. Itemized lists
|
|
||||||
look like:
|
|
||||||
|
|
||||||
* this one
|
|
||||||
* that one
|
|
||||||
* the other one
|
|
||||||
|
|
||||||
Note that --- not considering the asterisk --- the actual text
|
|
||||||
content starts at 4-columns in.
|
|
||||||
|
|
||||||
> Block quotes are
|
|
||||||
> written like so.
|
|
||||||
>
|
|
||||||
> They can span multiple paragraphs,
|
|
||||||
> if you like.
|
|
||||||
|
|
||||||
Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all
|
|
||||||
in chapters 12--14"). Three dots ... will be converted to an ellipsis.
|
|
||||||
Unicode is supported.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
An h2 header
|
|
||||||
------------
|
|
||||||
|
|
||||||
Here's a numbered list:
|
|
||||||
|
|
||||||
1. first item
|
|
||||||
2. second item
|
|
||||||
3. third item
|
|
||||||
|
|
||||||
Note again how the actual text starts at 4 columns in (4 characters
|
|
||||||
from the left side). Here's a code sample:
|
|
||||||
|
|
||||||
# Let me re-iterate ...
|
|
||||||
for i in 1 .. 10 { do-something(i) }
|
|
||||||
|
|
||||||
As you probably guessed, indented 4 spaces. By the way, instead of
|
|
||||||
indenting the block, you can use delimited blocks, if you like:
|
|
||||||
|
|
||||||
~~~
|
|
||||||
define foobar() {
|
|
||||||
print "Welcome to flavor country!";
|
|
||||||
}
|
|
||||||
~~~
|
|
||||||
|
|
||||||
(which makes copying & pasting easier). You can optionally mark the
|
|
||||||
delimited block for Pandoc to syntax highlight it:
|
|
||||||
|
|
||||||
~~~python
|
|
||||||
import time
|
|
||||||
# Quick, count to ten!
|
|
||||||
for i in range(10):
|
|
||||||
# (but not *too* quick)
|
|
||||||
time.sleep(0.5)
|
|
||||||
print i
|
|
||||||
~~~
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### An h3 header ###
|
|
||||||
|
|
||||||
Now a nested list:
|
|
||||||
|
|
||||||
1. First, get these ingredients:
|
|
||||||
|
|
||||||
* carrots
|
|
||||||
* celery
|
|
||||||
* lentils
|
|
||||||
|
|
||||||
2. Boil some water.
|
|
||||||
|
|
||||||
3. Dump everything in the pot and follow
|
|
||||||
this algorithm:
|
|
||||||
|
|
||||||
find wooden spoon
|
|
||||||
uncover pot
|
|
||||||
stir
|
|
||||||
cover pot
|
|
||||||
balance wooden spoon precariously on pot handle
|
|
||||||
wait 10 minutes
|
|
||||||
goto first step (or shut off burner when done)
|
|
||||||
|
|
||||||
Do not bump wooden spoon or it will fall.
|
|
||||||
|
|
||||||
Notice again how text always lines up on 4-space indents (including
|
|
||||||
that last line which continues item 3 above).
|
|
||||||
|
|
||||||
Here's a link to [a website](http://foo.bar). Here's a footnote [^1].
|
|
||||||
|
|
||||||
[^1]: Footnote text goes here.
|
|
||||||
|
|
||||||
Tables can look like this:
|
|
||||||
|
|
||||||
size material color
|
|
||||||
---- ------------ ------------
|
|
||||||
9 leather brown
|
|
||||||
10 hemp canvas natural
|
|
||||||
11 glass transparent
|
|
||||||
|
|
||||||
Table: Shoes, their sizes, and what they're made of
|
|
||||||
|
|
||||||
(The above is the caption for the table.) Pandoc also supports
|
|
||||||
multi-line tables:
|
|
||||||
|
|
||||||
-------- -----------------------
|
|
||||||
keyword text
|
|
||||||
-------- -----------------------
|
|
||||||
red Sunsets, apples, and
|
|
||||||
other red or reddish
|
|
||||||
things.
|
|
||||||
|
|
||||||
green Leaves, grass, frogs
|
|
||||||
and other things it's
|
|
||||||
not easy being.
|
|
||||||
-------- -----------------------
|
|
||||||
|
|
||||||
A horizontal rule follows.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
Here's a definition list:
|
|
||||||
|
|
||||||
apples
|
|
||||||
: Good for making applesauce.
|
|
||||||
oranges
|
|
||||||
: Citrus!
|
|
||||||
tomatoes
|
|
||||||
: There's no "e" in tomatoe.
|
|
||||||
|
|
||||||
Again, text is indented 4 spaces. (Put a blank line between each
|
|
||||||
term/definition pair to spread things out more.)
|
|
||||||
|
|
||||||
Here's a "line block":
|
|
||||||
|
|
||||||
| Line one
|
|
||||||
| Line too
|
|
||||||
| Line tree
|
|
||||||
|
|
||||||
and images can be specified like so:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Inline math equations go in like so: $\\omega = d\\phi / dt$. Display
|
|
||||||
math should get its own line and be put in in double-dollarsigns:
|
|
||||||
|
|
||||||
$$I = \\int \rho R^{2} dV$$
|
|
||||||
|
|
||||||
And note that you can backslash-escape any punctuation characters
|
|
||||||
which you wish to be displayed literally, ex.: \\`foo\\`, \\*bar\\*, etc.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test_html_safe(self):
|
def test_html_safe(self):
|
||||||
html = markdown_filter(self.markdown)
|
html = markdown_filter(self.markdown)
|
||||||
@@ -556,6 +401,7 @@ which you wish to be displayed literally, ex.: \\`foo\\`, \\*bar\\*, etc.
|
|||||||
description=self.markdown,
|
description=self.markdown,
|
||||||
start_date='2016-01-01',
|
start_date='2016-01-01',
|
||||||
)
|
)
|
||||||
|
event_item = models.EventItem.objects.create(event=event, name="TI I1", quantity=1, cost=1.00, order=1, description="* test \n * test \n * test")
|
||||||
user = models.Profile.objects.create(
|
user = models.Profile.objects.create(
|
||||||
username='RML test',
|
username='RML test',
|
||||||
is_superuser=True, # Don't care about permissions
|
is_superuser=True, # Don't care about permissions
|
||||||
|
|||||||
91
RIGS/urls.py
@@ -5,7 +5,7 @@ from django.views.generic import RedirectView
|
|||||||
|
|
||||||
from PyRIGS.decorators import (api_key_required, has_oembed,
|
from PyRIGS.decorators import (api_key_required, has_oembed,
|
||||||
permission_required_with_403)
|
permission_required_with_403)
|
||||||
from RIGS import finance, ical, rigboard, views, hs
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# People
|
# People
|
||||||
@@ -42,101 +42,112 @@ urlpatterns = [
|
|||||||
name='venue_update'),
|
name='venue_update'),
|
||||||
|
|
||||||
# Rigboard
|
# Rigboard
|
||||||
path('rigboard/', login_required(rigboard.RigboardIndex.as_view()), name='rigboard'),
|
path('rigboard/', login_required(views.RigboardIndex.as_view()), name='rigboard'),
|
||||||
path('rigboard/calendar/', login_required()(rigboard.WebCalendar.as_view()),
|
path('rigboard/calendar/', login_required()(views.WebCalendar.as_view()),
|
||||||
name='web_calendar'),
|
name='web_calendar'),
|
||||||
re_path(r'^rigboard/calendar/(?P<view>(month|week|day))/$',
|
re_path(r'^rigboard/calendar/(?P<view>(month|week|day))/$',
|
||||||
login_required()(rigboard.WebCalendar.as_view()), name='web_calendar'),
|
login_required()(views.WebCalendar.as_view()), name='web_calendar'),
|
||||||
re_path(r'^rigboard/calendar/(?P<view>(month|week|day))/(?P<date>(\d{4}-\d{2}-\d{2}))/$',
|
re_path(r'^rigboard/calendar/(?P<view>(month|week|day))/(?P<date>(\d{4}-\d{2}-\d{2}))/$',
|
||||||
login_required()(rigboard.WebCalendar.as_view()), name='web_calendar'),
|
login_required()(views.WebCalendar.as_view()), name='web_calendar'),
|
||||||
path('rigboard/archive/', RedirectView.as_view(permanent=True, pattern_name='event_archive')),
|
path('rigboard/archive/', RedirectView.as_view(permanent=True, pattern_name='event_archive')),
|
||||||
|
|
||||||
|
|
||||||
path('event/<int:pk>/', has_oembed(oembed_view="event_oembed")(rigboard.EventDetail.as_view()),
|
path('event/<int:pk>/', has_oembed(oembed_view="event_oembed")(views.EventDetail.as_view()),
|
||||||
name='event_detail'),
|
name='event_detail'),
|
||||||
path('event/create/', permission_required_with_403('RIGS.add_event')(rigboard.EventCreate.as_view()),
|
path('event/create/', permission_required_with_403('RIGS.add_event')(views.EventCreate.as_view()),
|
||||||
name='event_create'),
|
name='event_create'),
|
||||||
path('event/archive/', login_required()(rigboard.EventArchive.as_view()),
|
path('event/archive/', login_required()(views.EventArchive.as_view()),
|
||||||
name='event_archive'),
|
name='event_archive'),
|
||||||
path('event/<int:pk>/embed/',
|
path('event/<int:pk>/embed/',
|
||||||
xframe_options_exempt(login_required(login_url='/user/login/embed/')(rigboard.EventEmbed.as_view())),
|
xframe_options_exempt(login_required(login_url='/user/login/embed/')(views.EventEmbed.as_view())),
|
||||||
name='event_embed'),
|
name='event_embed'),
|
||||||
path('event/<int:pk>/oembed_json/', rigboard.EventOEmbed.as_view(),
|
path('event/<int:pk>/oembed_json/', views.EventOEmbed.as_view(),
|
||||||
name='event_oembed'),
|
name='event_oembed'),
|
||||||
path('event/<int:pk>/print/', permission_required_with_403('RIGS.view_event')(rigboard.EventPrint.as_view()),
|
path('event/<int:pk>/print/', permission_required_with_403('RIGS.view_event')(views.EventPrint.as_view()),
|
||||||
name='event_print'),
|
name='event_print'),
|
||||||
path('event/<int:pk>/edit/', permission_required_with_403('RIGS.change_event')(rigboard.EventUpdate.as_view()),
|
path('event/<int:pk>/edit/', permission_required_with_403('RIGS.change_event')(views.EventUpdate.as_view()),
|
||||||
name='event_update'),
|
name='event_update'),
|
||||||
path('event/<int:pk>/duplicate/', permission_required_with_403('RIGS.add_event')(rigboard.EventDuplicate.as_view()),
|
path('event/<int:pk>/duplicate/', permission_required_with_403('RIGS.add_event')(views.EventDuplicate.as_view()),
|
||||||
name='event_duplicate'),
|
name='event_duplicate'),
|
||||||
|
|
||||||
|
|
||||||
|
# Subhire
|
||||||
|
path('subhire/<int:pk>/', views.SubhireDetail.as_view(),
|
||||||
|
name='subhire_detail'),
|
||||||
|
path('subhire/create/', permission_required_with_403('RIGS.add_event')(views.SubhireCreate.as_view()),
|
||||||
|
name='subhire_create'),
|
||||||
|
path('subhire/<int:pk>/edit', views.SubhireEdit.as_view(),
|
||||||
|
name='subhire_edit'),
|
||||||
|
|
||||||
|
|
||||||
# Event H&S
|
# Event H&S
|
||||||
path('event/hs/', permission_required_with_403('RIGS.view_riskassessment')(hs.HSList.as_view()), name='hs_list'),
|
path('event/hs/', permission_required_with_403('RIGS.view_riskassessment')(views.HSList.as_view()), name='hs_list'),
|
||||||
|
|
||||||
path('event/<int:pk>/ra/', permission_required_with_403('RIGS.add_riskassessment')(hs.EventRiskAssessmentCreate.as_view()),
|
path('event/<int:pk>/ra/', permission_required_with_403('RIGS.add_riskassessment')(views.EventRiskAssessmentCreate.as_view()),
|
||||||
name='event_ra'),
|
name='event_ra'),
|
||||||
path('event/ra/<int:pk>/', permission_required_with_403('RIGS.view_riskassessment')(hs.EventRiskAssessmentDetail.as_view()),
|
path('event/ra/<int:pk>/', permission_required_with_403('RIGS.view_riskassessment')(views.EventRiskAssessmentDetail.as_view()),
|
||||||
name='ra_detail'),
|
name='ra_detail'),
|
||||||
path('event/ra/<int:pk>/edit/', permission_required_with_403('RIGS.change_riskassessment')(hs.EventRiskAssessmentEdit.as_view()),
|
path('event/ra/<int:pk>/edit/', permission_required_with_403('RIGS.change_riskassessment')(views.EventRiskAssessmentEdit.as_view()),
|
||||||
name='ra_edit'),
|
name='ra_edit'),
|
||||||
path('event/ra/list', permission_required_with_403('RIGS.view_riskassessment')(hs.EventRiskAssessmentList.as_view()),
|
path('event/ra/list', permission_required_with_403('RIGS.view_riskassessment')(views.EventRiskAssessmentList.as_view()),
|
||||||
name='ra_list'),
|
name='ra_list'),
|
||||||
path('event/ra/<int:pk>/review/', permission_required_with_403('RIGS.review_riskassessment')(hs.EventRiskAssessmentReview.as_view()),
|
path('event/ra/<int:pk>/review/', permission_required_with_403('RIGS.review_riskassessment')(views.EventRiskAssessmentReview.as_view()),
|
||||||
name='ra_review'),
|
name='ra_review'),
|
||||||
|
path('event/ra/<int:pk>/print/', permission_required_with_403('RIGS.view_riskassessment')(views.RAPrint.as_view()), name='ra_print'),
|
||||||
|
|
||||||
path('event/<int:pk>/checklist/', permission_required_with_403('RIGS.add_eventchecklist')(hs.EventChecklistCreate.as_view()),
|
path('event/<int:pk>/checklist/', permission_required_with_403('RIGS.add_eventchecklist')(views.EventChecklistCreate.as_view()),
|
||||||
name='event_ec'),
|
name='event_ec'),
|
||||||
path('event/checklist/<int:pk>/', permission_required_with_403('RIGS.view_eventchecklist')(hs.EventChecklistDetail.as_view()),
|
path('event/checklist/<int:pk>/', permission_required_with_403('RIGS.view_eventchecklist')(views.EventChecklistDetail.as_view()),
|
||||||
name='ec_detail'),
|
name='ec_detail'),
|
||||||
path('event/checklist/<int:pk>/edit/', permission_required_with_403('RIGS.change_eventchecklist')(hs.EventChecklistEdit.as_view()),
|
path('event/checklist/<int:pk>/edit/', permission_required_with_403('RIGS.change_eventchecklist')(views.EventChecklistEdit.as_view()),
|
||||||
name='ec_edit'),
|
name='ec_edit'),
|
||||||
path('event/checklist/list', permission_required_with_403('RIGS.view_eventchecklist')(hs.EventChecklistList.as_view()),
|
path('event/checklist/list', permission_required_with_403('RIGS.view_eventchecklist')(views.EventChecklistList.as_view()),
|
||||||
name='ec_list'),
|
name='ec_list'),
|
||||||
path('event/checklist/<int:pk>/review/', permission_required_with_403('RIGS.review_eventchecklist')(hs.EventChecklistReview.as_view()),
|
path('event/checklist/<int:pk>/review/', permission_required_with_403('RIGS.review_eventchecklist')(views.EventChecklistReview.as_view()),
|
||||||
name='ec_review'),
|
name='ec_review'),
|
||||||
|
|
||||||
# Finance
|
# Finance
|
||||||
path('invoice/', permission_required_with_403('RIGS.view_invoice')(finance.InvoiceIndex.as_view()),
|
path('invoice/', permission_required_with_403('RIGS.view_invoice')(views.InvoiceIndex.as_view()),
|
||||||
name='invoice_list'),
|
name='invoice_list'),
|
||||||
path('invoice/archive/', permission_required_with_403('RIGS.view_invoice')(finance.InvoiceArchive.as_view()),
|
path('invoice/archive/', permission_required_with_403('RIGS.view_invoice')(views.InvoiceArchive.as_view()),
|
||||||
name='invoice_archive'),
|
name='invoice_archive'),
|
||||||
path('invoice/waiting/', permission_required_with_403('RIGS.add_invoice')(finance.InvoiceWaiting.as_view()),
|
path('invoice/waiting/', permission_required_with_403('RIGS.add_invoice')(views.InvoiceWaiting.as_view()),
|
||||||
name='invoice_waiting'),
|
name='invoice_waiting'),
|
||||||
|
|
||||||
path('event/<int:pk>/invoice/', permission_required_with_403('RIGS.add_invoice')(finance.InvoiceEvent.as_view()),
|
path('event/<int:pk>/invoice/', permission_required_with_403('RIGS.add_invoice')(views.InvoiceEvent.as_view()),
|
||||||
name='invoice_event'),
|
name='invoice_event'),
|
||||||
path('event/<int:pk>/invoice/void', permission_required_with_403('RIGS.add_invoice')(finance.InvoiceEvent.as_view()),
|
path('event/<int:pk>/invoice/void', permission_required_with_403('RIGS.add_invoice')(views.InvoiceEvent.as_view()),
|
||||||
name='invoice_event_void', kwargs={'void': True}),
|
name='invoice_event_void', kwargs={'void': True}),
|
||||||
|
|
||||||
path('invoice/<int:pk>/', permission_required_with_403('RIGS.view_invoice')(finance.InvoiceDetail.as_view()),
|
path('invoice/<int:pk>/', permission_required_with_403('RIGS.view_invoice')(views.InvoiceDetail.as_view()),
|
||||||
name='invoice_detail'),
|
name='invoice_detail'),
|
||||||
path('invoice/<int:pk>/print/', permission_required_with_403('RIGS.view_invoice')(finance.InvoicePrint.as_view()),
|
path('invoice/<int:pk>/print/', permission_required_with_403('RIGS.view_invoice')(views.InvoicePrint.as_view()),
|
||||||
name='invoice_print'),
|
name='invoice_print'),
|
||||||
path('invoice/<int:pk>/void/', permission_required_with_403('RIGS.change_invoice')(finance.InvoiceVoid.as_view()),
|
path('invoice/<int:pk>/void/', permission_required_with_403('RIGS.change_invoice')(views.InvoiceVoid.as_view()),
|
||||||
name='invoice_void'),
|
name='invoice_void'),
|
||||||
path('invoice/<int:pk>/delete/',
|
path('invoice/<int:pk>/delete/',
|
||||||
permission_required_with_403('RIGS.change_invoice')(finance.InvoiceDelete.as_view()),
|
permission_required_with_403('RIGS.change_invoice')(views.InvoiceDelete.as_view()),
|
||||||
name='invoice_delete'),
|
name='invoice_delete'),
|
||||||
|
|
||||||
path('payment/create/', permission_required_with_403('RIGS.add_payment')(finance.PaymentCreate.as_view()),
|
path('payment/create/', permission_required_with_403('RIGS.add_payment')(views.PaymentCreate.as_view()),
|
||||||
name='payment_create'),
|
name='payment_create'),
|
||||||
path('payment/<int:pk>/delete/', permission_required_with_403('RIGS.add_payment')(finance.PaymentDelete.as_view()),
|
path('payment/<int:pk>/delete/', permission_required_with_403('RIGS.add_payment')(views.PaymentDelete.as_view()),
|
||||||
name='payment_delete'),
|
name='payment_delete'),
|
||||||
|
|
||||||
# Client event authorisation
|
# Client event authorisation
|
||||||
path('event/<pk>/auth/',
|
path('event/<pk>/auth/',
|
||||||
permission_required_with_403('RIGS.change_event')(rigboard.EventAuthorisationRequest.as_view()),
|
permission_required_with_403('RIGS.change_event')(views.EventAuthorisationRequest.as_view()),
|
||||||
name='event_authorise_request'),
|
name='event_authorise_request'),
|
||||||
path('event/<int:pk>/auth/preview/',
|
path('event/<int:pk>/auth/preview/',
|
||||||
permission_required_with_403('RIGS.change_event')(rigboard.EventAuthoriseRequestEmailPreview.as_view()),
|
permission_required_with_403('RIGS.change_event')(views.EventAuthoriseRequestEmailPreview.as_view()),
|
||||||
name='event_authorise_preview'),
|
name='event_authorise_preview'),
|
||||||
re_path(r'^event/(?P<pk>\d+)/(?P<hmac>[-:\w]+)/$', rigboard.EventAuthorise.as_view(),
|
re_path(r'^event/(?P<pk>\d+)/(?P<hmac>[-:\w]+)/$', views.EventAuthorise.as_view(),
|
||||||
name='event_authorise'),
|
name='event_authorise'),
|
||||||
re_path(r'^event/(?P<pk>\d+)/(?P<hmac>[-:\w]+)/preview/$', rigboard.EventAuthorise.as_view(preview=True),
|
re_path(r'^event/(?P<pk>\d+)/(?P<hmac>[-:\w]+)/preview/$', views.EventAuthorise.as_view(preview=True),
|
||||||
name='event_authorise_form_preview'),
|
name='event_authorise_form_preview'),
|
||||||
|
|
||||||
# ICS Calendar - API key authentication
|
# ICS Calendar - API key authentication
|
||||||
re_path(r'^ical/(?P<api_pk>\d+)/(?P<api_key>\w+)/rigs.ics$', api_key_required(ical.CalendarICS()),
|
re_path(r'^ical/(?P<api_pk>\d+)/(?P<api_key>\w+)/rigs.ics$', api_key_required(views.CalendarICS()),
|
||||||
name="ics_calendar"),
|
name="ics_calendar"),
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
6
RIGS/views/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from .crud import *
|
||||||
|
from .finance import *
|
||||||
|
from .hs import *
|
||||||
|
from .ical import *
|
||||||
|
from .rigboard import *
|
||||||
|
from .subhire import *
|
||||||
@@ -28,7 +28,8 @@ class InvoiceIndex(generic.ListView):
|
|||||||
total = 0
|
total = 0
|
||||||
for i in context['object_list']:
|
for i in context['object_list']:
|
||||||
total += i.balance
|
total += i.balance
|
||||||
context['page_title'] = "Outstanding Invoices ({} Events, £{:.2f})".format(len(list(context['object_list'])), total)
|
event_count = len(list(context['object_list']))
|
||||||
|
context['page_title'] = f"Outstanding Invoices ({event_count} Events, £{total:.2f})"
|
||||||
context['description'] = "Paperwork for these events has been sent to treasury, but the full balance has not yet appeared on a ledger"
|
context['description'] = "Paperwork for these events has been sent to treasury, but the full balance has not yet appeared on a ledger"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ class InvoiceDetail(generic.DetailView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
invoice_date = self.object.invoice_date.strftime("%d/%m/%Y")
|
invoice_date = self.object.invoice_date.strftime("%d/%m/%Y")
|
||||||
context['page_title'] = f"Invoice {self.object.display_id} ({invoice_date}) "
|
context['page_title'] = f"Invoice {self.object.display_id} ({invoice_date})"
|
||||||
if self.object.void:
|
if self.object.void:
|
||||||
context['page_title'] += "<span class='badge badge-warning float-right'>VOID</span>"
|
context['page_title'] += "<span class='badge badge-warning float-right'>VOID</span>"
|
||||||
elif self.object.is_closed:
|
elif self.object.is_closed:
|
||||||
@@ -59,11 +60,14 @@ class InvoicePrint(generic.View):
|
|||||||
object = invoice.event
|
object = invoice.event
|
||||||
template = get_template('event_print.xml')
|
template = get_template('event_print.xml')
|
||||||
|
|
||||||
|
name = re.sub(r'[^a-zA-Z0-9 \n\.]', '', object.name)
|
||||||
|
filename = f"Invoice {invoice.display_id} for {object.display_id} {name}.pdf"
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'object': object,
|
'object': object,
|
||||||
'invoice': invoice,
|
'invoice': invoice,
|
||||||
'current_user': request.user,
|
'current_user': request.user,
|
||||||
'filename': 'Invoice {} for {} {}.pdf'.format(invoice.display_id, object.display_id, re.sub(r'[^a-zA-Z0-9 \n\.]', '', object.name))
|
'filename': filename
|
||||||
}
|
}
|
||||||
|
|
||||||
rml = template.render(context)
|
rml = template.render(context)
|
||||||
@@ -73,7 +77,7 @@ class InvoicePrint(generic.View):
|
|||||||
pdfData = buffer.read()
|
pdfData = buffer.read()
|
||||||
|
|
||||||
response = HttpResponse(content_type='application/pdf')
|
response = HttpResponse(content_type='application/pdf')
|
||||||
response['Content-Disposition'] = 'filename="{}"'.format(context['filename'])
|
response['Content-Disposition'] = f'filename="{filename}"'
|
||||||
response.write(pdfData)
|
response.write(pdfData)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@@ -124,32 +128,7 @@ class InvoiceArchive(generic.ListView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
q = self.request.GET.get('q', "")
|
return self.model.objects.search(self.request.GET.get('q')).order_by('-invoice_date')
|
||||||
|
|
||||||
filter = Q(event__name__icontains=q)
|
|
||||||
|
|
||||||
# try and parse an int
|
|
||||||
try:
|
|
||||||
val = int(q)
|
|
||||||
filter = filter | Q(pk=val)
|
|
||||||
filter = filter | Q(event__pk=val)
|
|
||||||
except: # noqa
|
|
||||||
# not an integer
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
if q[0] == "N":
|
|
||||||
val = int(q[1:])
|
|
||||||
filter = Q(event__pk=val) # If string is Nxxxxx then filter by event number
|
|
||||||
elif q[0] == "#":
|
|
||||||
val = int(q[1:])
|
|
||||||
filter = Q(pk=val) # If string is #xxxxx then filter by invoice number
|
|
||||||
except: # noqa
|
|
||||||
pass
|
|
||||||
|
|
||||||
object_list = self.model.objects.filter(filter).order_by('-invoice_date')
|
|
||||||
|
|
||||||
return object_list
|
|
||||||
|
|
||||||
|
|
||||||
class InvoiceWaiting(generic.ListView):
|
class InvoiceWaiting(generic.ListView):
|
||||||
@@ -163,7 +142,7 @@ class InvoiceWaiting(generic.ListView):
|
|||||||
objects = self.get_queryset()
|
objects = self.get_queryset()
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
total += obj.sum_total
|
total += obj.sum_total
|
||||||
context['page_title'] = "Events for Invoice ({} Events, £{:.2f})".format(len(objects), total)
|
context['page_title'] = f"Events for Invoice ({len(objects)} Events, £{total:.2f})"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@@ -6,11 +6,13 @@ from django.views import generic
|
|||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
|
|
||||||
from RIGS import models, forms
|
from RIGS import models, forms
|
||||||
|
from RIGS.views.rigboard import get_related
|
||||||
|
from PyRIGS.views import PrintView
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentCreate(generic.CreateView):
|
class EventRiskAssessmentCreate(generic.CreateView):
|
||||||
model = models.RiskAssessment
|
model = models.RiskAssessment
|
||||||
template_name = 'risk_assessment_form.html'
|
template_name = 'hs/risk_assessment_form.html'
|
||||||
form_class = forms.EventRiskAssessmentForm
|
form_class = forms.EventRiskAssessmentForm
|
||||||
|
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
@@ -37,7 +39,8 @@ class EventRiskAssessmentCreate(generic.CreateView):
|
|||||||
epk = self.kwargs.get('pk')
|
epk = self.kwargs.get('pk')
|
||||||
event = models.Event.objects.get(pk=epk)
|
event = models.Event.objects.get(pk=epk)
|
||||||
context['event'] = event
|
context['event'] = event
|
||||||
context['page_title'] = 'Create Risk Assessment for Event {}'.format(event.display_id)
|
context['page_title'] = f'Create Risk Assessment for Event {event.display_id}'
|
||||||
|
get_related(context['form'], context)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -46,7 +49,7 @@ class EventRiskAssessmentCreate(generic.CreateView):
|
|||||||
|
|
||||||
class EventRiskAssessmentEdit(generic.UpdateView):
|
class EventRiskAssessmentEdit(generic.UpdateView):
|
||||||
model = models.RiskAssessment
|
model = models.RiskAssessment
|
||||||
template_name = 'risk_assessment_form.html'
|
template_name = 'hs/risk_assessment_form.html'
|
||||||
form_class = forms.EventRiskAssessmentForm
|
form_class = forms.EventRiskAssessmentForm
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -62,24 +65,25 @@ class EventRiskAssessmentEdit(generic.UpdateView):
|
|||||||
ra = models.RiskAssessment.objects.get(pk=rpk)
|
ra = models.RiskAssessment.objects.get(pk=rpk)
|
||||||
context['event'] = ra.event
|
context['event'] = ra.event
|
||||||
context['edit'] = True
|
context['edit'] = True
|
||||||
context['page_title'] = 'Edit Risk Assessment for Event {}'.format(ra.event.display_id)
|
context['page_title'] = f'Edit Risk Assessment for Event {ra.event.display_id}'
|
||||||
|
get_related(context['form'], context)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentDetail(generic.DetailView):
|
class EventRiskAssessmentDetail(generic.DetailView):
|
||||||
model = models.RiskAssessment
|
model = models.RiskAssessment
|
||||||
template_name = 'risk_assessment_detail.html'
|
template_name = 'hs/risk_assessment_detail.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(EventRiskAssessmentDetail, self).get_context_data(**kwargs)
|
context = super(EventRiskAssessmentDetail, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = "Risk Assessment for Event <a href='{}'>{} {}</a>".format(self.object.event.get_absolute_url(), self.object.event.display_id, self.object.event.name)
|
context['page_title'] = f"Risk Assessment for Event <a href='{self.object.event.get_absolute_url()}'>{self.object.event.display_id} {self.object.event.name}</a>"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentList(generic.ListView):
|
class EventRiskAssessmentList(generic.ListView):
|
||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
model = models.RiskAssessment
|
model = models.RiskAssessment
|
||||||
template_name = 'hs_object_list.html'
|
template_name = 'hs/hs_object_list.html'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.exclude(event__status=models.Event.CANCELLED).order_by('reviewed_at').select_related('event')
|
return self.model.objects.exclude(event__status=models.Event.CANCELLED).order_by('reviewed_at').select_related('event')
|
||||||
@@ -108,17 +112,17 @@ class EventRiskAssessmentReview(generic.View):
|
|||||||
|
|
||||||
class EventChecklistDetail(generic.DetailView):
|
class EventChecklistDetail(generic.DetailView):
|
||||||
model = models.EventChecklist
|
model = models.EventChecklist
|
||||||
template_name = 'event_checklist_detail.html'
|
template_name = 'hs/event_checklist_detail.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(EventChecklistDetail, self).get_context_data(**kwargs)
|
context = super(EventChecklistDetail, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = "Event Checklist for Event <a href='{}'>{} {}</a>".format(self.object.event.get_absolute_url(), self.object.event.display_id, self.object.event.name)
|
context['page_title'] = f"Event Checklist for Event <a href='{self.object.event.get_absolute_url()}'>{self.object.event.display_id} {self.object.event.name}</a>"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventChecklistEdit(generic.UpdateView):
|
class EventChecklistEdit(generic.UpdateView):
|
||||||
model = models.EventChecklist
|
model = models.EventChecklist
|
||||||
template_name = 'event_checklist_form.html'
|
template_name = 'hs/event_checklist_form.html'
|
||||||
form_class = forms.EventChecklistForm
|
form_class = forms.EventChecklistForm
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -134,19 +138,14 @@ class EventChecklistEdit(generic.UpdateView):
|
|||||||
ec = models.EventChecklist.objects.get(pk=pk)
|
ec = models.EventChecklist.objects.get(pk=pk)
|
||||||
context['event'] = ec.event
|
context['event'] = ec.event
|
||||||
context['edit'] = True
|
context['edit'] = True
|
||||||
context['page_title'] = 'Edit Event Checklist for Event {}'.format(ec.event.display_id)
|
context['page_title'] = f'Edit Event Checklist for Event {ec.event.display_id}'
|
||||||
form = context['form']
|
get_related(context['form'], context)
|
||||||
# Get some other objects to include in the form. Used when there are errors but also nice and quick.
|
|
||||||
for field, model in form.related_models.items():
|
|
||||||
value = form[field].value()
|
|
||||||
if value is not None and value != '':
|
|
||||||
context[field] = model.objects.get(pk=value)
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventChecklistCreate(generic.CreateView):
|
class EventChecklistCreate(generic.CreateView):
|
||||||
model = models.EventChecklist
|
model = models.EventChecklist
|
||||||
template_name = 'event_checklist_form.html'
|
template_name = 'hs/event_checklist_form.html'
|
||||||
form_class = forms.EventChecklistForm
|
form_class = forms.EventChecklistForm
|
||||||
|
|
||||||
# From both business logic and programming POVs, RAs must exist before ECs!
|
# From both business logic and programming POVs, RAs must exist before ECs!
|
||||||
@@ -158,7 +157,7 @@ class EventChecklistCreate(generic.CreateView):
|
|||||||
ra = models.RiskAssessment.objects.filter(event=event).first()
|
ra = models.RiskAssessment.objects.filter(event=event).first()
|
||||||
|
|
||||||
if ra is None:
|
if ra is None:
|
||||||
messages.error(self.request, 'A Risk Assessment must exist prior to creating any Event Checklists for {}! Please create one now.'.format(event))
|
messages.error(self.request, f'A Risk Assessment must exist prior to creating any Event Checklists for {event}! Please create one now.')
|
||||||
return HttpResponseRedirect(reverse_lazy('event_ra', kwargs={'pk': epk}))
|
return HttpResponseRedirect(reverse_lazy('event_ra', kwargs={'pk': epk}))
|
||||||
|
|
||||||
return super(EventChecklistCreate, self).get(self)
|
return super(EventChecklistCreate, self).get(self)
|
||||||
@@ -175,7 +174,7 @@ class EventChecklistCreate(generic.CreateView):
|
|||||||
epk = self.kwargs.get('pk')
|
epk = self.kwargs.get('pk')
|
||||||
event = models.Event.objects.get(pk=epk)
|
event = models.Event.objects.get(pk=epk)
|
||||||
context['event'] = event
|
context['event'] = event
|
||||||
context['page_title'] = 'Create Event Checklist for Event {}'.format(event.display_id)
|
context['page_title'] = f'Create Event Checklist for Event {event.display_id}'
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -185,7 +184,7 @@ class EventChecklistCreate(generic.CreateView):
|
|||||||
class EventChecklistList(generic.ListView):
|
class EventChecklistList(generic.ListView):
|
||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
model = models.EventChecklist
|
model = models.EventChecklist
|
||||||
template_name = 'hs_object_list.html'
|
template_name = 'hs/hs_object_list.html'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.exclude(event__status=models.Event.CANCELLED).order_by('reviewed_at').select_related('event')
|
return self.model.objects.exclude(event__status=models.Event.CANCELLED).order_by('reviewed_at').select_related('event')
|
||||||
@@ -215,7 +214,7 @@ class EventChecklistReview(generic.View):
|
|||||||
class HSList(generic.ListView):
|
class HSList(generic.ListView):
|
||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
model = models.Event
|
model = models.Event
|
||||||
template_name = 'hs_list.html'
|
template_name = 'hs/hs_list.html'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return models.Event.objects.all().exclude(status=models.Event.CANCELLED).order_by('-start_date').select_related('riskassessment').prefetch_related('checklists')
|
return models.Event.objects.all().exclude(status=models.Event.CANCELLED).order_by('-start_date').select_related('riskassessment').prefetch_related('checklists')
|
||||||
@@ -224,3 +223,13 @@ class HSList(generic.ListView):
|
|||||||
context = super(HSList, self).get_context_data(**kwargs)
|
context = super(HSList, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = 'H&S Overview'
|
context['page_title'] = 'H&S Overview'
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class RAPrint(PrintView):
|
||||||
|
model = models.RiskAssessment
|
||||||
|
template_name = 'hs/ra_print.xml'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['filename'] = f"EventSpecificRiskAssessment_for_{context['object'].event.display_id}.pdf"
|
||||||
|
return context
|
||||||
@@ -93,7 +93,7 @@ class CalendarICS(ICalFeed):
|
|||||||
title += item.name
|
title += item.name
|
||||||
|
|
||||||
# Add the status
|
# Add the status
|
||||||
title += ' (' + str(item.get_status_display()) + ')'
|
title += f' ({item.get_status_display()})'
|
||||||
|
|
||||||
return title
|
return title
|
||||||
|
|
||||||
@@ -101,9 +101,8 @@ class CalendarICS(ICalFeed):
|
|||||||
return item.earliest_time
|
return item.earliest_time
|
||||||
|
|
||||||
def item_end_datetime(self, item):
|
def item_end_datetime(self, item):
|
||||||
if isinstance(item.latest_time, datetime.date): # Ical end_datetime is non-inclusive, so add a day
|
# if isinstance(item.latest_time, datetime.date): # Ical end_datetime is non-inclusive, so add a day
|
||||||
return item.latest_time + datetime.timedelta(days=1)
|
# return item.latest_time + datetime.timedelta(days=1)
|
||||||
|
|
||||||
return item.latest_time
|
return item.latest_time
|
||||||
|
|
||||||
def item_location(self, item):
|
def item_location(self, item):
|
||||||
@@ -115,13 +114,13 @@ class CalendarICS(ICalFeed):
|
|||||||
|
|
||||||
tz = pytz.timezone(self.timezone)
|
tz = pytz.timezone(self.timezone)
|
||||||
|
|
||||||
desc = 'Rig ID = ' + str(item.pk) + '\n'
|
desc = f'Rig ID = {item.display_id}\n'
|
||||||
desc += 'Event = ' + item.name + '\n'
|
desc += f'Event = {item.name}\n'
|
||||||
desc += 'Venue = ' + (item.venue.name if item.venue else '---') + '\n'
|
desc += 'Venue = ' + (item.venue.name if item.venue else '---') + '\n'
|
||||||
if item.is_rig and item.person:
|
if item.is_rig and item.person:
|
||||||
desc += 'Client = ' + item.person.name + (
|
desc += 'Client = ' + item.person.name + (
|
||||||
(' for ' + item.organisation.name) if item.organisation else '') + '\n'
|
(' for ' + item.organisation.name) if item.organisation else '') + '\n'
|
||||||
desc += 'Status = ' + str(item.get_status_display()) + '\n'
|
desc += f'Status = {item.get_status_display()}\n'
|
||||||
desc += 'MIC = ' + (item.mic.name if item.mic else '---') + '\n'
|
desc += 'MIC = ' + (item.mic.name if item.mic else '---') + '\n'
|
||||||
|
|
||||||
desc += '\n'
|
desc += '\n'
|
||||||
@@ -140,23 +139,18 @@ class CalendarICS(ICalFeed):
|
|||||||
|
|
||||||
desc += '\n'
|
desc += '\n'
|
||||||
if item.description:
|
if item.description:
|
||||||
desc += 'Event Description:\n' + item.description + '\n\n'
|
desc += f'Event Description:\n{item.description}\n\n'
|
||||||
# if item.notes: // Need to add proper keyholder checks before this gets put back
|
# if item.notes: // Need to add proper keyholder checks before this gets put back
|
||||||
# desc += 'Notes:\n'+item.notes+'\n\n'
|
# desc += 'Notes:\n'+item.notes+'\n\n'
|
||||||
|
|
||||||
base_url = "https://rigs.nottinghamtec.co.uk"
|
desc += f'URL = https://rigs.nottinghamtec.co.uk{item.get_absolute_url()}'
|
||||||
desc += 'URL = ' + base_url + str(item.get_absolute_url())
|
|
||||||
|
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
def item_link(self, item):
|
def item_link(self, item):
|
||||||
# Make a link to the event in the web interface
|
# Make a link to the event in the web interface
|
||||||
# base_url = "https://pyrigs.nottinghamtec.co.uk"
|
|
||||||
return item.get_absolute_url()
|
return item.get_absolute_url()
|
||||||
|
|
||||||
# def item_created(self, item): #TODO - Implement created date-time (using django-reversion?) - not really necessary though
|
|
||||||
# return ''
|
|
||||||
|
|
||||||
def item_updated(self, item): # some ical clients will display this
|
def item_updated(self, item): # some ical clients will display this
|
||||||
return item.last_edited_at
|
return item.last_edited_at
|
||||||
|
|
||||||
@@ -1,14 +1,9 @@
|
|||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
import urllib.error
|
|
||||||
import urllib.parse
|
|
||||||
import urllib.request
|
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
import premailer
|
import premailer
|
||||||
import simplejson
|
import simplejson
|
||||||
from PyPDF2 import PdfFileMerger, PdfFileReader
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.staticfiles import finders
|
from django.contrib.staticfiles import finders
|
||||||
@@ -24,10 +19,9 @@ from django.urls import reverse_lazy
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
from z3c.rml import rml2pdf
|
|
||||||
|
|
||||||
from PyRIGS import decorators
|
from PyRIGS import decorators
|
||||||
from PyRIGS.views import OEmbedView, is_ajax
|
from PyRIGS.views import OEmbedView, is_ajax, ModalURLMixin, PrintView, get_related
|
||||||
from RIGS import models, forms
|
from RIGS import models, forms
|
||||||
|
|
||||||
__author__ = 'ghost'
|
__author__ = 'ghost'
|
||||||
@@ -53,10 +47,11 @@ class WebCalendar(generic.TemplateView):
|
|||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['view'] = kwargs.get('view', '')
|
context['view'] = kwargs.get('view', '')
|
||||||
context['date'] = kwargs.get('date', '')
|
context['date'] = kwargs.get('date', '')
|
||||||
|
# context['page_title'] = "Calendar"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventDetail(generic.DetailView):
|
class EventDetail(generic.DetailView, ModalURLMixin):
|
||||||
template_name = 'event_detail.html'
|
template_name = 'event_detail.html'
|
||||||
model = models.Event
|
model = models.Event
|
||||||
|
|
||||||
@@ -93,11 +88,8 @@ class EventCreate(generic.CreateView):
|
|||||||
if hasattr(form, 'items_json') and re.search(r'"-\d+"', form['items_json'].value()):
|
if hasattr(form, 'items_json') and re.search(r'"-\d+"', form['items_json'].value()):
|
||||||
messages.info(self.request, "Your item changes have been saved. Please fix the errors and save the event.")
|
messages.info(self.request, "Your item changes have been saved. Please fix the errors and save the event.")
|
||||||
|
|
||||||
# Get some other objects to include in the form. Used when there are errors but also nice and quick.
|
get_related(form, context)
|
||||||
for field, model in form.related_models.items():
|
|
||||||
value = form[field].value()
|
|
||||||
if value is not None and value != '':
|
|
||||||
context[field] = model.objects.get(pk=value)
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -116,11 +108,7 @@ class EventUpdate(generic.UpdateView):
|
|||||||
|
|
||||||
form = context['form']
|
form = context['form']
|
||||||
|
|
||||||
# Get some other objects to include in the form. Used when there are errors but also nice and quick.
|
get_related(form, context)
|
||||||
for field, model in form.related_models.items():
|
|
||||||
value = form[field].value()
|
|
||||||
if value is not None and value != '':
|
|
||||||
context[field] = model.objects.get(pk=value)
|
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -173,35 +161,16 @@ class EventDuplicate(EventUpdate):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventPrint(generic.View):
|
class EventPrint(PrintView):
|
||||||
def get(self, request, pk):
|
model = models.Event
|
||||||
object = get_object_or_404(models.Event, pk=pk)
|
template_name = 'event_print.xml'
|
||||||
template = get_template('event_print.xml')
|
append_terms = True
|
||||||
|
|
||||||
merger = PdfFileMerger()
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
context = {
|
context['quote'] = True
|
||||||
'object': object,
|
context['filename'] = f"Event_{context['object'].display_id}_{context['object_name']}_{context['object'].start_date}.pdf"
|
||||||
'quote': True,
|
return context
|
||||||
'current_user': request.user,
|
|
||||||
'filename': 'Event_{}_{}_{}.pdf'.format(object.display_id, re.sub(r'[^a-zA-Z0-9 \n\.]', '', object.name), object.start_date)
|
|
||||||
}
|
|
||||||
|
|
||||||
rml = template.render(context)
|
|
||||||
buffer = rml2pdf.parseString(rml)
|
|
||||||
merger.append(PdfFileReader(buffer))
|
|
||||||
buffer.close()
|
|
||||||
|
|
||||||
terms = urllib.request.urlopen(settings.TERMS_OF_HIRE_URL)
|
|
||||||
merger.append(BytesIO(terms.read()))
|
|
||||||
|
|
||||||
merged = BytesIO()
|
|
||||||
merger.write(merged)
|
|
||||||
|
|
||||||
response = HttpResponse(content_type='application/pdf')
|
|
||||||
response['Content-Disposition'] = 'filename="{}"'.format(context['filename'])
|
|
||||||
response.write(merged.getvalue())
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
class EventArchive(generic.ListView):
|
class EventArchive(generic.ListView):
|
||||||
@@ -211,7 +180,6 @@ class EventArchive(generic.ListView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
context['start'] = self.request.GET.get('start', None)
|
context['start'] = self.request.GET.get('start', None)
|
||||||
context['end'] = self.request.GET.get('end', datetime.date.today().strftime('%Y-%m-%d'))
|
context['end'] = self.request.GET.get('end', datetime.date.today().strftime('%Y-%m-%d'))
|
||||||
context['statuses'] = models.Event.EVENT_STATUS_CHOICES
|
context['statuses'] = models.Event.EVENT_STATUS_CHOICES
|
||||||
@@ -235,32 +203,17 @@ class EventArchive(generic.ListView):
|
|||||||
filter &= Q(start_date__gte=start)
|
filter &= Q(start_date__gte=start)
|
||||||
|
|
||||||
q = self.request.GET.get('q', "")
|
q = self.request.GET.get('q', "")
|
||||||
|
objects = self.model.objects.all()
|
||||||
|
|
||||||
if q != "":
|
if q:
|
||||||
qfilter = Q(name__icontains=q) | Q(description__icontains=q) | Q(notes__icontains=q)
|
objects = self.model.objects.search(q)
|
||||||
|
|
||||||
# try and parse an int
|
|
||||||
try:
|
|
||||||
val = int(q)
|
|
||||||
qfilter = qfilter | Q(pk=val)
|
|
||||||
except: # noqa not an integer
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
if q[0] == "N":
|
|
||||||
val = int(q[1:])
|
|
||||||
qfilter = Q(pk=val) # If string is N###### then do a simple PK filter
|
|
||||||
except: # noqa
|
|
||||||
pass
|
|
||||||
|
|
||||||
filter &= qfilter
|
|
||||||
|
|
||||||
status = self.request.GET.getlist('status', "")
|
status = self.request.GET.getlist('status', "")
|
||||||
|
|
||||||
if len(status) > 0:
|
if len(status) > 0:
|
||||||
filter &= Q(status__in=status)
|
filter &= Q(status__in=status)
|
||||||
|
|
||||||
qs = self.model.objects.filter(filter).order_by('-start_date')
|
qs = objects.filter(filter).order_by('-start_date')
|
||||||
|
|
||||||
# Preselect related for efficiency
|
# Preselect related for efficiency
|
||||||
qs.select_related('person', 'organisation', 'venue', 'mic')
|
qs.select_related('person', 'organisation', 'venue', 'mic')
|
||||||
@@ -315,7 +268,7 @@ class EventAuthorise(generic.UpdateView):
|
|||||||
messages.add_message(self.request, messages.WARNING,
|
messages.add_message(self.request, messages.WARNING,
|
||||||
"This event has already been authorised, but the amount has changed. " +
|
"This event has already been authorised, but the amount has changed. " +
|
||||||
"Please check the amount and reauthorise.")
|
"Please check the amount and reauthorise.")
|
||||||
return super(EventAuthorise, self).get(request, *args, **kwargs)
|
return super().get(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_form(self, **kwargs):
|
def get_form(self, **kwargs):
|
||||||
form = super().get_form(**kwargs)
|
form = super().get_form(**kwargs)
|
||||||
@@ -384,7 +337,7 @@ class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMix
|
|||||||
context['to_name'] = event.organisation.name
|
context['to_name'] = event.organisation.name
|
||||||
|
|
||||||
msg = EmailMultiAlternatives(
|
msg = EmailMultiAlternatives(
|
||||||
"N%05d | %s - Event Authorisation Request" % (self.object.pk, self.object.name),
|
f"{self.object.display_id} | {self.object.name} - Event Authorisation Request",
|
||||||
get_template("eventauthorisation_client_request.txt").render(context),
|
get_template("eventauthorisation_client_request.txt").render(context),
|
||||||
to=[email],
|
to=[email],
|
||||||
reply_to=[self.request.user.email],
|
reply_to=[self.request.user.email],
|
||||||
48
RIGS/views/subhire.py
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
from django.urls import reverse_lazy
|
||||||
|
from django.views import generic
|
||||||
|
from PyRIGS.views import OEmbedView, is_ajax, ModalURLMixin, PrintView, get_related
|
||||||
|
from RIGS import models, forms
|
||||||
|
|
||||||
|
|
||||||
|
class SubhireDetail(generic.DetailView, ModalURLMixin):
|
||||||
|
template_name = 'subhire_detail.html'
|
||||||
|
model = models.Subhire
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['page_title'] = f"{self.object.display_id} | {self.object.name}"
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class SubhireCreate(generic.CreateView):
|
||||||
|
model = models.Subhire
|
||||||
|
form_class = forms.SubhireForm
|
||||||
|
template_name = 'subhire_form.html'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['page_title'] = "New Subhire"
|
||||||
|
context['edit'] = True
|
||||||
|
form = context['form']
|
||||||
|
get_related(form, context)
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy('subhire_detail', kwargs={'pk': self.object.pk})
|
||||||
|
|
||||||
|
|
||||||
|
class SubhireEdit(generic.UpdateView):
|
||||||
|
model = models.Subhire
|
||||||
|
form_class = forms.SubhireForm
|
||||||
|
template_name = 'subhire_form.html'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['page_title'] = f"Edit Subhire: {self.object.display_id} | {self.object.name}"
|
||||||
|
context['edit'] = True
|
||||||
|
form = context['form']
|
||||||
|
get_related(form, context)
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy('subhire_detail', kwargs={'pk': self.object.pk})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from reversion.admin import VersionAdmin
|
from reversion.admin import VersionAdmin
|
||||||
|
from RIGS.admin import AssociateAdmin
|
||||||
from assets import models as assets
|
from assets import models as assets
|
||||||
|
|
||||||
|
|
||||||
@@ -17,9 +17,13 @@ class AssetStatusAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
|
|
||||||
@admin.register(assets.Supplier)
|
@admin.register(assets.Supplier)
|
||||||
class SupplierAdmin(VersionAdmin):
|
class SupplierAdmin(AssociateAdmin):
|
||||||
list_display = ['id', 'name']
|
list_display = ['id', 'name']
|
||||||
ordering = ['id']
|
ordering = ['id']
|
||||||
|
merge_fields = ['name', 'phone', 'email', 'address', 'notes']
|
||||||
|
|
||||||
|
def get_queryset(self, request):
|
||||||
|
return super(VersionAdmin, self).get_queryset(request)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(assets.Asset)
|
@admin.register(assets.Asset)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class AssetSearchForm(forms.Form):
|
|||||||
category = forms.ModelMultipleChoiceField(models.AssetCategory.objects.all(), required=False)
|
category = forms.ModelMultipleChoiceField(models.AssetCategory.objects.all(), required=False)
|
||||||
status = forms.ModelMultipleChoiceField(models.AssetStatus.objects.all(), required=False)
|
status = forms.ModelMultipleChoiceField(models.AssetStatus.objects.all(), required=False)
|
||||||
is_cable = forms.BooleanField(required=False)
|
is_cable = forms.BooleanField(required=False)
|
||||||
|
cable_type = forms.ModelMultipleChoiceField(models.CableType.objects.all(), required=False)
|
||||||
date_acquired = forms.DateField(required=False)
|
date_acquired = forms.DateField(required=False)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import random
|
|||||||
|
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
from django.db.utils import IntegrityError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
|
|
||||||
@@ -125,5 +126,9 @@ class Command(BaseCommand):
|
|||||||
if i % 3 == 0:
|
if i % 3 == 0:
|
||||||
asset.purchased_from = random.choice(self.suppliers)
|
asset.purchased_from = random.choice(self.suppliers)
|
||||||
|
|
||||||
asset.clean()
|
with transaction.atomic():
|
||||||
asset.save()
|
try:
|
||||||
|
asset.clean()
|
||||||
|
asset.save()
|
||||||
|
except IntegrityError:
|
||||||
|
pass
|
||||||
|
|||||||
19
assets/migrations/0023_alter_asset_purchased_from.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 3.2.12 on 2022-02-14 15:13
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('assets', '0022_alter_cabletype_unique_together'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='asset',
|
||||||
|
name='purchased_from',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assets', to='assets.supplier'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
assets/migrations/0024_alter_asset_salvage_value.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.12 on 2022-02-14 23:43
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('assets', '0023_alter_asset_purchased_from'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='asset',
|
||||||
|
name='salvage_value',
|
||||||
|
field=models.DecimalField(decimal_places=2, max_digits=10, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.12 on 2022-05-26 09:22
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('assets', '0024_alter_asset_salvage_value'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='asset',
|
||||||
|
old_name='salvage_value',
|
||||||
|
new_name='replacement_cost',
|
||||||
|
),
|
||||||
|
]
|
||||||
24
assets/migrations/0026_auto_20220526_1623.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 3.2.12 on 2022-05-26 15:23
|
||||||
|
|
||||||
|
import assets.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('assets', '0025_rename_salvage_value_asset_replacement_cost'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='asset',
|
||||||
|
name='purchase_price',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, validators=[assets.models.validate_positive]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='asset',
|
||||||
|
name='replacement_cost',
|
||||||
|
field=models.DecimalField(decimal_places=2, max_digits=10, null=True, validators=[assets.models.validate_positive]),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -2,11 +2,12 @@ import re
|
|||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import models, connection
|
from django.db import models, connection
|
||||||
|
from django.db.models import Q
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from reversion.models import Version
|
from reversion.models import Version
|
||||||
|
|
||||||
from RIGS.models import Profile
|
from RIGS.models import Profile, ContactableManager
|
||||||
from versioning.versioning import RevisionMixin
|
from versioning.versioning import RevisionMixin
|
||||||
|
|
||||||
|
|
||||||
@@ -46,6 +47,8 @@ class Supplier(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
notes = models.TextField(blank=True, default="")
|
notes = models.TextField(blank=True, default="")
|
||||||
|
|
||||||
|
objects = ContactableManager()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['name']
|
ordering = ['name']
|
||||||
|
|
||||||
@@ -88,23 +91,23 @@ class CableType(models.Model):
|
|||||||
return reverse('cable_type_detail', kwargs={'pk': self.pk})
|
return reverse('cable_type_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
|
|
||||||
|
class AssetManager(models.Manager):
|
||||||
|
def search(self, query=None):
|
||||||
|
qs = self.get_queryset()
|
||||||
|
if query is not None:
|
||||||
|
or_lookup = (Q(asset_id__exact=query.upper()) | Q(description__icontains=query) | Q(serial_number__exact=query))
|
||||||
|
qs = qs.filter(or_lookup).distinct() # distinct() is often necessary with Q lookups
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
def get_available_asset_id(wanted_prefix=""):
|
def get_available_asset_id(wanted_prefix=""):
|
||||||
sql = """
|
last_asset = Asset.objects.filter(asset_id_prefix=wanted_prefix).last()
|
||||||
SELECT a.asset_id_number+1
|
return 9000 if last_asset is None else wanted_prefix + str(last_asset.asset_id_number + 1)
|
||||||
FROM assets_asset a
|
|
||||||
LEFT OUTER JOIN assets_asset b ON
|
|
||||||
(a.asset_id_number + 1 = b.asset_id_number AND
|
def validate_positive(value):
|
||||||
a.asset_id_prefix = b.asset_id_prefix)
|
if value < 0:
|
||||||
WHERE b.asset_id IS NULL AND a.asset_id_number >= %s AND a.asset_id_prefix = %s;
|
raise ValidationError("A price cannot be negative")
|
||||||
"""
|
|
||||||
with connection.cursor() as cursor:
|
|
||||||
cursor.execute(sql, [9000, wanted_prefix])
|
|
||||||
row = cursor.fetchone()
|
|
||||||
if row is None or row[0] is None:
|
|
||||||
return 9000
|
|
||||||
else:
|
|
||||||
return row[0]
|
|
||||||
cursor.close()
|
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
@@ -116,11 +119,11 @@ class Asset(models.Model, RevisionMixin):
|
|||||||
category = models.ForeignKey(to=AssetCategory, on_delete=models.CASCADE)
|
category = models.ForeignKey(to=AssetCategory, on_delete=models.CASCADE)
|
||||||
status = models.ForeignKey(to=AssetStatus, on_delete=models.CASCADE)
|
status = models.ForeignKey(to=AssetStatus, on_delete=models.CASCADE)
|
||||||
serial_number = models.CharField(max_length=150, blank=True)
|
serial_number = models.CharField(max_length=150, blank=True)
|
||||||
purchased_from = models.ForeignKey(to=Supplier, on_delete=models.CASCADE, blank=True, null=True, related_name="assets")
|
purchased_from = models.ForeignKey(to=Supplier, on_delete=models.SET_NULL, blank=True, null=True, related_name="assets")
|
||||||
date_acquired = models.DateField()
|
date_acquired = models.DateField()
|
||||||
date_sold = models.DateField(blank=True, null=True)
|
date_sold = models.DateField(blank=True, null=True)
|
||||||
purchase_price = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
purchase_price = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10, validators=[validate_positive])
|
||||||
salvage_value = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
replacement_cost = models.DecimalField(null=True, decimal_places=2, max_digits=10, validators=[validate_positive])
|
||||||
comments = models.TextField(blank=True)
|
comments = models.TextField(blank=True)
|
||||||
|
|
||||||
# Audit
|
# Audit
|
||||||
@@ -142,6 +145,8 @@ class Asset(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
reversion_perm = 'assets.asset_finance'
|
reversion_perm = 'assets.asset_finance'
|
||||||
|
|
||||||
|
objects = AssetManager()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['asset_id_prefix', 'asset_id_number']
|
ordering = ['asset_id_prefix', 'asset_id_number']
|
||||||
permissions = [
|
permissions = [
|
||||||
@@ -165,12 +170,6 @@ class Asset(models.Model, RevisionMixin):
|
|||||||
errdict["asset_id"] = [
|
errdict["asset_id"] = [
|
||||||
"An Asset ID can only consist of letters and numbers, with a final number"]
|
"An Asset ID can only consist of letters and numbers, with a final number"]
|
||||||
|
|
||||||
if self.purchase_price and self.purchase_price < 0:
|
|
||||||
errdict["purchase_price"] = ["A price cannot be negative"]
|
|
||||||
|
|
||||||
if self.salvage_value and self.salvage_value < 0:
|
|
||||||
errdict["salvage_value"] = ["A price cannot be negative"]
|
|
||||||
|
|
||||||
if self.is_cable:
|
if self.is_cable:
|
||||||
if not self.length or self.length <= 0:
|
if not self.length or self.length <= 0:
|
||||||
errdict["length"] = ["The length of a cable must be more than 0"]
|
errdict["length"] = ["The length of a cable must be more than 0"]
|
||||||
@@ -189,3 +188,7 @@ class Asset(models.Model, RevisionMixin):
|
|||||||
@property
|
@property
|
||||||
def display_id(self):
|
def display_id(self):
|
||||||
return str(self.asset_id)
|
return str(self.asset_id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return f"{self.display_id} | {self.description}"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 18 KiB |
@@ -9,9 +9,11 @@
|
|||||||
date = new Date();
|
date = new Date();
|
||||||
}
|
}
|
||||||
$('#id_date_acquired').val([date.getFullYear(), ('0' + (date.getMonth()+1)).slice(-2), ('0' + date.getDate()).slice(-2)].join('-'));
|
$('#id_date_acquired').val([date.getFullYear(), ('0' + (date.getMonth()+1)).slice(-2), ('0' + date.getDate()).slice(-2)].join('-'));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
function setFieldValue(ID, CSA) {
|
function setFieldValue(ID, CSA) {
|
||||||
$('#' + String(ID)).val(CSA);
|
$('#' + String(ID)).val(CSA);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
function checkIfCableHidden() {
|
function checkIfCableHidden() {
|
||||||
document.getElementById("cable-table").hidden = !document.getElementById("id_is_cable").checked;
|
document.getElementById("cable-table").hidden = !document.getElementById("id_is_cable").checked;
|
||||||
@@ -39,16 +41,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group form-row">
|
<div class="form-group form-row">
|
||||||
{% include 'partials/form_field.html' with field=form.date_acquired col="col-6" %}
|
{% include 'partials/form_field.html' with field=form.date_acquired col="col-6" %}
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-2">
|
||||||
<button class="btn btn-info" onclick="setAcquired(true);" tabindex="-1">Today</button>
|
<button class="btn btn-info" onclick="return setAcquired(true);" tabindex="-1">Today</button>
|
||||||
<button class="btn btn-warning" onclick="setAcquired(false);" tabindex="-1">Unknown</button>
|
<button class="btn btn-warning" onclick="return setAcquired(false);" tabindex="-1">Unknown</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group form-row">
|
<div class="form-group form-row">
|
||||||
{% include 'partials/form_field.html' with field=form.date_sold col="col-6" %}
|
{% include 'partials/form_field.html' with field=form.date_sold col="col-6" %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group form-row">
|
<div class="form-group form-row">
|
||||||
{% include 'partials/form_field.html' with field=form.salvage_value col="col-6" prepend="£" %}
|
{% include 'partials/form_field.html' with field=form.replacement_cost col="col-6" prepend="£" %}
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="form-group form-row">
|
<div class="form-group form-row">
|
||||||
@@ -64,16 +66,16 @@
|
|||||||
<div class="form-group form-row">
|
<div class="form-group form-row">
|
||||||
{% include 'partials/form_field.html' with field=form.length append=form.length.help_text col="col-6" %}
|
{% include 'partials/form_field.html' with field=form.length append=form.length.help_text col="col-6" %}
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<button class="btn btn-danger" onclick="setFieldValue('{{ form.length.id_for_label }}','5');" tabindex="-1" type="button">5{{ form.length.help_text }}</button>
|
<button class="btn btn-danger" onclick="return setFieldValue('{{ form.length.id_for_label }}','5');" tabindex="-1" type="button">5{{ form.length.help_text }}</button>
|
||||||
<button class="btn btn-success" onclick="setFieldValue('{{ form.length.id_for_label }}','10');" tabindex="-1" type="button">10{{ form.length.help_text }}</button>
|
<button class="btn btn-success" onclick="return setFieldValue('{{ form.length.id_for_label }}','10');" tabindex="-1" type="button">10{{ form.length.help_text }}</button>
|
||||||
<button class="btn btn-info" onclick="setFieldValue('{{ form.length.id_for_label }}','20');" tabindex="-1" type="button">20{{ form.length.help_text }}</button>
|
<button class="btn btn-info" onclick="return setFieldValue('{{ form.length.id_for_label }}','20');" tabindex="-1" type="button">20{{ form.length.help_text }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group form-row">
|
<div class="form-group form-row">
|
||||||
{% include 'partials/form_field.html' with field=form.csa append=form.csa.help_text title='CSA' col="col-6" %}
|
{% include 'partials/form_field.html' with field=form.csa append=form.csa.help_text title='CSA' col="col-6" %}
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<button class="btn btn-secondary" onclick="setFieldValue('{{ form.csa.id_for_label }}', '1.5');" tabindex="-1" type="button">1.5{{ form.csa.help_text }}</button>
|
<button class="btn btn-secondary" onclick="return setFieldValue('{{ form.csa.id_for_label }}', '1.5');" tabindex="-1" type="button">1.5{{ form.csa.help_text }}</button>
|
||||||
<button class="btn btn-secondary" onclick="setFieldValue('{{ form.csa.id_for_label }}', '2.5');" tabindex="-1" type="button">2.5{{ form.csa.help_text }}</button>
|
<button class="btn btn-secondary" onclick="return setFieldValue('{{ form.csa.id_for_label }}', '2.5');" tabindex="-1" type="button">2.5{{ form.csa.help_text }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
{% block css %}
|
{% block css %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<link rel="stylesheet" href="{% static 'css/selects.css' %}"/>
|
<link rel="stylesheet" href="{% static 'css/selects.css' %}"/>
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'css/simplemde.min.css' %}">
|
<link rel="stylesheet" type="text/css" href="{% static 'css/easymde.min.css' %}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block preload_js %}
|
{% block preload_js %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script src="{% static 'js/selects.js' %}"></script>
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
<script src="{% static 'js/simplemde.min.js' %}"></script>
|
<script src="{% static 'js/easymde.min.js' %}"></script>
|
||||||
<script src="{% static 'js/interaction.js' %}"></script>
|
<script src="{% static 'js/interaction.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@@ -31,48 +31,8 @@
|
|||||||
checkIfCableHidden();
|
checkIfCableHidden();
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
$('#parent_id')
|
$('document').ready(function(){
|
||||||
.selectpicker({
|
$(document).find(".selectpicker").selectpicker().each(function(){initPicker($(this))});
|
||||||
liveSearch: true
|
|
||||||
})
|
|
||||||
.ajaxSelectPicker({
|
|
||||||
ajax: {
|
|
||||||
url: "{% url 'asset_search_json' %}",
|
|
||||||
type: "GET",
|
|
||||||
data: function () {
|
|
||||||
let params = {
|
|
||||||
{% verbatim %}query: '{{{q}}}'{% endverbatim %}
|
|
||||||
};
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
locale: {
|
|
||||||
emptyTitle: 'Search for item...'
|
|
||||||
},
|
|
||||||
preprocessData: function(data){
|
|
||||||
var assets = [];
|
|
||||||
if(data.length){
|
|
||||||
var len = data.length;
|
|
||||||
for(var i = 0; i < len; i++){
|
|
||||||
var curr = data[i];
|
|
||||||
assets.push(
|
|
||||||
{
|
|
||||||
'value': curr.id,
|
|
||||||
'text': curr.label,
|
|
||||||
'disabled': false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
assets.push(
|
|
||||||
{
|
|
||||||
'value': null,
|
|
||||||
'text': "No parent"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return assets;
|
|
||||||
},
|
|
||||||
preserveSelected: false
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -75,13 +75,13 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||||
<label for="category" class="sr-only">Category</label>
|
<label for="category" class="sr-only">Category</label>
|
||||||
{% render_field form.category|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %}
|
{% render_field form.category|attr:'multiple'|add_class:'selectpicker col-sm' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||||
<label for="status" class="sr-only">Status</label>
|
<label for="status" class="sr-only">Status</label>
|
||||||
{% render_field form.status|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %}
|
{% render_field form.status|attr:'multiple'|add_class:'selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col mt-2">
|
<div class="col mt-2">
|
||||||
@@ -121,6 +121,7 @@
|
|||||||
</button></span>{%endfor%}</p>
|
</button></span>{%endfor%}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<h3>{{ object_list.count }} assets</h3>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col px-0">
|
<div class="col px-0">
|
||||||
{% include 'partials/asset_list_table.html' %}
|
{% include 'partials/asset_list_table.html' %}
|
||||||
|
|||||||
162
assets/templates/cable_list.html
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
{% extends 'base_assets.html' %}
|
||||||
|
{% load button from filters %}
|
||||||
|
{% load ids_from_objects from asset_tags %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" href="{% static 'css/selects.css' %}"/>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block preload_js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/selects.js' %}" async></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script>
|
||||||
|
//Get querystring value
|
||||||
|
function getParameterByName(name) {
|
||||||
|
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
||||||
|
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
||||||
|
results = regex.exec(location.search);
|
||||||
|
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
||||||
|
}
|
||||||
|
//Function used to remove querystring
|
||||||
|
function removeQString(key) {
|
||||||
|
var urlValue=document.location.href;
|
||||||
|
|
||||||
|
//Get query string value
|
||||||
|
var searchUrl=location.search;
|
||||||
|
|
||||||
|
if(key!=="") {
|
||||||
|
oldValue = getParameterByName(key);
|
||||||
|
removeVal=key+"="+oldValue;
|
||||||
|
if(searchUrl.indexOf('?'+removeVal+'&')!== "-1") {
|
||||||
|
urlValue=urlValue.replace('?'+removeVal+'&','?');
|
||||||
|
}
|
||||||
|
else if(searchUrl.indexOf('&'+removeVal+'&')!== "-1") {
|
||||||
|
urlValue=urlValue.replace('&'+removeVal+'&','&');
|
||||||
|
}
|
||||||
|
else if(searchUrl.indexOf('?'+removeVal)!== "-1") {
|
||||||
|
urlValue=urlValue.replace('?'+removeVal,'');
|
||||||
|
}
|
||||||
|
else if(searchUrl.indexOf('&'+removeVal)!== "-1") {
|
||||||
|
urlValue=urlValue.replace('&'+removeVal,'');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var searchUrl=location.search;
|
||||||
|
urlValue=urlValue.replace(searchUrl,'');
|
||||||
|
}
|
||||||
|
history.pushState({state:1, rand: Math.random()}, '', urlValue);
|
||||||
|
window.location.reload(true);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h3>{{ object_list.count }} cables with a total length of {{ total_length|default:"0" }}m</h3>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col px-0">
|
||||||
|
<form id="asset-search-form" method="GET">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="col">
|
||||||
|
<div class="input-group px-1 mb-2 mb-sm-0 flex-nowrap">
|
||||||
|
{% render_field form.q|add_class:'form-control' placeholder='Enter Asset ID/Desc/Serial' %}
|
||||||
|
<label for="q" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||||
|
<span class="input-group-append">{% button 'search' id="id_search" %}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-row mt-2">
|
||||||
|
<div class="col">
|
||||||
|
<div id="category-group" class="form-group px-1">
|
||||||
|
<label for="category" class="sr-only">Category</label>
|
||||||
|
{% render_field form.category|attr:'multiple'|add_class:'selectpicker col-sm pl-0' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div id="status-group" class="form-group px-1">
|
||||||
|
<label for="status" class="sr-only">Status</label>
|
||||||
|
{% render_field form.status|attr:'multiple'|add_class:'selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div class="form-group d-flex flex-nowrap">
|
||||||
|
<label for="cable_type" class="sr-only">Cable Type</label>
|
||||||
|
{% render_field form.cable_type|attr:'multiple'|add_class:'selectpicker col-sm' data-none-selected-text="Cable Type" data-header="Cable Type" data-actions-box="true" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<div class="form-group d-flex flex-nowrap">
|
||||||
|
<label for="date_acquired" class="text-nowrap mt-auto">Date Acquired</label>
|
||||||
|
{% render_field form.date_acquired|add_class:'form-control mx-2' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto mr-auto">
|
||||||
|
<button id="filter-submit" type="submit" class="btn btn-secondary" style="width: 6em">Filter</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row my-2">
|
||||||
|
<div class="col text-right px-0">
|
||||||
|
{% button 'new' 'asset_create' style="width: 6em" %}
|
||||||
|
{% if object_list %}
|
||||||
|
<a class="btn btn-primary" href="{% url 'generate_labels' object_list|ids_from_objects %}"><span class="fas fa-barcode"></span> Generate Labels</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row my-2">
|
||||||
|
<div class="col bg-dark text-white rounded pt-3">
|
||||||
|
{# TODO Gotta be a cleaner way to do this... #}
|
||||||
|
<p><span class="ml-2">Active Filters: </span> {% for filter in category_filters %}<span class="badge badge-info mx-1 ">{{filter}}<button type="button" class="btn btn-link p-0 ml-1 align-baseline">
|
||||||
|
<span aria-hidden="true" class="fas fa-times" onclick="removeQString('category', '{{filter.id}}')"></span>
|
||||||
|
</button></span>{%endfor%}{% for filter in status_filters %}<span class="badge badge-info mx-1 ">{{filter}}<button type="button" class="btn btn-link p-0 ml-1 align-baseline">
|
||||||
|
<span aria-hidden="true" class="fas fa-times" onclick="removeQString('status', '{{filter.id}}')"></span>
|
||||||
|
</button></span>{%endfor%}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col px-0">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Asset ID</th>
|
||||||
|
<th scope="col">Description</th>
|
||||||
|
<th scope="col">Category</th>
|
||||||
|
<th scope="col">Status</th>
|
||||||
|
<th scope="col">Length</th>
|
||||||
|
<th scope="col">Cable Type</th>
|
||||||
|
<th scope="col" class="d-none d-sm-table-cell">Quick Links</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="asset_table_body">
|
||||||
|
{% for item in object_list %}
|
||||||
|
<tr class="table-{{ item.status.display_class|default:'' }} assetRow">
|
||||||
|
<th scope="row" class="align-middle"><a class="assetID" href="{% url 'asset_detail' item.asset_id %}">{{ item.asset_id }}</a></th>
|
||||||
|
<td class="assetDesc"><span class="text-truncate d-inline-block align-middle">{{ item.description }}</span></td>
|
||||||
|
<td class="assetCategory align-middle">{{ item.category }}</td>
|
||||||
|
<td class="assetStatus align-middle">{{ item.status }}</td>
|
||||||
|
<td style="background-color:{% if item.length == 20.0 %}#304486{% elif item.length == 10.0 %}green{%elif item.length == 5.0 %}red{% endif %} !important;">{{ item.length }}m</td>
|
||||||
|
<td>{{ item.cable_type }}</td>
|
||||||
|
<td class="d-none d-sm-table-cell">
|
||||||
|
{% include 'partials/asset_list_buttons.html' %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% empty %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="6">Nothing found</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -12,22 +12,18 @@
|
|||||||
</template>
|
</template>
|
||||||
<stylesheet>
|
<stylesheet>
|
||||||
<blockTableStyle id="table">
|
<blockTableStyle id="table">
|
||||||
<!-- show a grid: this also comes in handy for debugging your tables.-->
|
|
||||||
<lineStyle kind="GRID" colorName="black" thickness="1" start="0,0" stop="-1,-1" />
|
|
||||||
</blockTableStyle>
|
</blockTableStyle>
|
||||||
</stylesheet>
|
</stylesheet>
|
||||||
<story>
|
<story>
|
||||||
<blockTable style="table">
|
<blockTable style="table">
|
||||||
{% for i in images0 %}
|
{% for i in images0 %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% with images0|index:forloop.counter0 as image %}{% if image %}<illustration width="120" height="35"><image file="data:image/png;base64,{{image}}" x="0" y="0"
|
<td>{% with images0|index:forloop.counter0 as image %}{% if image %}<illustration width="180" height="55" borderStrokeWidth="1"
|
||||||
width="120" height="35"/></illustration>{% endif %}{% endwith %}</td>
|
borderStrokeColor="black"><image file="data:image/png;base64,{{image.1}}" x="0" y="0"
|
||||||
<td>{% with images1|index:forloop.counter0 as image %}{% if image %}<illustration width="120" height="35"><image file="data:image/png;base64,{{image}}" x="0" y="0"
|
{% if image.0.csa >= 4 %}width="180" height="55"{% else %}width="130" height="38"{%endif%}/></illustration>{% endif %}{% endwith %}</td>
|
||||||
width="120" height="35"/></illustration>{% endif %}{% endwith %}</td>
|
<td>{% with images1|index:forloop.counter0 as image %}{% if image %}<illustration width="180" height="55"><image file="data:image/png;base64,{{image.1}}" x="0" y="0"
|
||||||
<td>{% with images2|index:forloop.counter0 as image %}{% if image %}<illustration width="120" height="35"><image file="data:image/png;base64,{{image}}" x="0" y="0"
|
{% if image.0.csa >= 4 %}width="180" height="55"{% else %}width="130" height="38"{%endif%}/></illustration>{% endif %}{% endwith %}</td>
|
||||||
width="120" height="35"/></illustration>{% endif %}{% endwith %}</td>
|
<td>{% with images2|index:forloop.counter0 as image %}{% if image %}<illustration width="180" height="55"><image file="data:image/png;base64,{{image.1}}" x="0" y="0" {% if image.0.csa >= 4 %}width="180" height="55"{% else %}width="130" height="38"{%endif%}/></illustration>{% endif %}{% endwith %}</td>
|
||||||
<td>{% with images3|index:forloop.counter0 as image %}{% if image %}<illustration width="120" height="35"><image file="data:image/png;base64,{{image}}" x="0" y="0"
|
|
||||||
width="120" height="35"/></illustration>{% endif %}{% endwith %}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</blockTable>
|
</blockTable>
|
||||||
|
|||||||
14
assets/templates/partials/asset_list_buttons.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{% load button from filters %}
|
||||||
|
{% if audit %}
|
||||||
|
<a type="button" class="btn btn-info btn-sm modal-href" href="{% url 'asset_audit' item.asset_id %}"><i class="fas fa-certificate"></i> Audit</a>
|
||||||
|
{% else %}
|
||||||
|
<div class="btn-group" role="group">
|
||||||
|
{% button 'view' url='asset_detail' pk=item.asset_id clazz="btn-sm" %}
|
||||||
|
{% if perms.assets.change_asset %}
|
||||||
|
{% button 'edit' url='asset_update' pk=item.asset_id clazz="btn-sm" %}
|
||||||
|
{% endif %}
|
||||||
|
{% if perms.assets.add_asset %}
|
||||||
|
{% button 'duplicate' url='asset_duplicate' pk=item.asset_id clazz="btn-sm" %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
@@ -18,19 +18,7 @@
|
|||||||
<td class="assetCategory align-middle">{{ item.category }}</td>
|
<td class="assetCategory align-middle">{{ item.category }}</td>
|
||||||
<td class="assetStatus align-middle">{{ item.status }}</td>
|
<td class="assetStatus align-middle">{{ item.status }}</td>
|
||||||
<td class="d-none d-sm-table-cell">
|
<td class="d-none d-sm-table-cell">
|
||||||
{% if audit %}
|
{% include 'partials/asset_list_buttons.html' %}
|
||||||
<a type="button" class="btn btn-info btn-sm modal-href" href="{% url 'asset_audit' item.asset_id %}"><i class="fas fa-certificate"></i> Audit</a>
|
|
||||||
{% else %}
|
|
||||||
<div class="btn-group" role="group">
|
|
||||||
{% button 'view' url='asset_detail' pk=item.asset_id clazz="btn-sm" %}
|
|
||||||
{% if perms.assets.change_asset %}
|
|
||||||
{% button 'edit' url='asset_update' pk=item.asset_id clazz="btn-sm" %}
|
|
||||||
{% endif %}
|
|
||||||
{% if perms.assets.add_asset %}
|
|
||||||
{% button 'duplicate' url='asset_duplicate' pk=item.asset_id clazz="btn-sm" %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
{% load title_spaced from filters %}
|
{% load title_spaced from filters %}
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
<label for="{{ field.id_for_label }}" {% if col %}class="col-2 col-form-label"{% endif %}>{% if title %}{{ title }}{%else%}{{field.name|title_spaced}}{%endif%}</label>
|
<label for="{{ field.id_for_label }}" {% if col %}class="col-4 col-form-label"{% endif %}>{% if title %}{{ title }}{%else%}{{field.name|title_spaced}}{%endif%}</label>
|
||||||
{% if append or prepend %}
|
{% if append or prepend %}
|
||||||
<div class="input-group {{col}}">
|
<div class="input-group {{col}}">
|
||||||
{% if prepend %}
|
{% if prepend %}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
{% if create or edit or duplicate %}
|
{% if create or edit or duplicate %}
|
||||||
<div class="form-group" id="parent-group">
|
<div class="form-group" id="parent-group">
|
||||||
<label for="selectpicker">Set Parent</label>
|
<label for="selectpicker">Set Parent</label>
|
||||||
<select name="parent" id="parent_id" class="form-control selectpicker" data-live-search="true">
|
<select name="parent" id="parent_id" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='asset' %}?fields=asset_id,description">
|
||||||
{% if object.parent %}
|
{% if object.parent %}
|
||||||
<option value="{{object.parent.pk}}" selected>{{object.parent.description}}</option>
|
<option value="{{object.parent.pk}}" selected>{{object.parent.description}}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<label for="{{ form.purchased_from.id_for_label }}">Supplier</label>
|
<label for="{{ form.purchased_from.id_for_label }}">Supplier</label>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<select id="{{ form.purchased_from.id_for_label }}" name="{{ form.purchased_from.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='supplier' %}">
|
<select id="{{ form.purchased_from.id_for_label }}" name="{{ form.purchased_from.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='supplier' %}">
|
||||||
{% if object.purchased_from %}
|
{% if object.purchased_from %}
|
||||||
<option value="{{form.purchased_from.value}}" selected="selected" data-update_url="{% url 'supplier_update' form.purchased_from.value %}">{{ object.purchased_from }}</option>
|
<option value="{{form.purchased_from.value}}" selected="selected" data-update_url="{% url 'supplier_update' form.purchased_from.value %}">{{ object.purchased_from }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -39,10 +39,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="{{ form.salvage_value.id_for_label }}">Salvage Value</label>
|
<label for="{{ form.salvage_value.id_for_label }}">Replacement Cost</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-prepend"><span class="input-group-text">£</span></div>
|
<div class="input-group-prepend"><span class="input-group-text">£</span></div>
|
||||||
{% render_field form.salvage_value|add_class:'form-control' value=object.salvage_value %}
|
{% render_field form.replacement_cost|add_class:'form-control' value=object.replacement_cost %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
<dd>{% if object.purchased_from %}<a href="{{object.purchased_from.get_absolute_url}}">{{ object.purchased_from }}</a>{%else%}-{%endif%}</dd>
|
<dd>{% if object.purchased_from %}<a href="{{object.purchased_from.get_absolute_url}}">{{ object.purchased_from }}</a>{%else%}-{%endif%}</dd>
|
||||||
<dt>Purchase Price</dt>
|
<dt>Purchase Price</dt>
|
||||||
<dd>£{{ object.purchase_price|default_if_none:'-' }}</dd>
|
<dd>£{{ object.purchase_price|default_if_none:'-' }}</dd>
|
||||||
<dt>Salvage Value</dt>
|
<dt>Replacement Cost</dt>
|
||||||
<dd>£{{ object.salvage_value|default_if_none:'-' }}</dd>
|
<dd>£{{ object.replacement_cost|default_if_none:'-' }}</dd>
|
||||||
<dt>Date Acquired</dt>
|
<dt>Date Acquired</dt>
|
||||||
<dd>{{ object.date_acquired|default_if_none:'-' }}</dd>
|
<dd>{{ object.date_acquired|default_if_none:'-' }}</dd>
|
||||||
{% if object.date_sold %}
|
{% if object.date_sold %}
|
||||||
|
|||||||
@@ -18,18 +18,23 @@ def status(db):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_cable(db, category, status):
|
def cable_type(db):
|
||||||
connector = models.Connector.objects.create(description="16A IEC", current_rating=16, voltage_rating=240, num_pins=3)
|
connector = models.Connector.objects.create(description="16A IEC", current_rating=16, voltage_rating=240, num_pins=3)
|
||||||
cable_type = models.CableType.objects.create(circuits=11, cores=3, plug=connector, socket=connector)
|
cable_type = models.CableType.objects.create(circuits=11, cores=3, plug=connector, socket=connector)
|
||||||
cable = models.Asset.objects.create(asset_id="9666", description="125A -> Jack", comments="The cable from Hell...", status=status, category=category, date_acquired=datetime.date(2006, 6, 6), is_cable=True, cable_type=cable_type, length=10, csa="1.5")
|
yield cable_type
|
||||||
yield cable
|
|
||||||
connector.delete()
|
connector.delete()
|
||||||
cable_type.delete()
|
cable_type.delete()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def test_cable(db, category, status, cable_type):
|
||||||
|
cable = models.Asset.objects.create(asset_id="9666", description="125A -> Jack", comments="The cable from Hell...", status=status, category=category, date_acquired=datetime.date(2006, 6, 6), is_cable=True, cable_type=cable_type, length=10, csa="1.5", replacement_cost=50)
|
||||||
|
yield cable
|
||||||
cable.delete()
|
cable.delete()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_asset(db, category, status):
|
def test_asset(db, category, status):
|
||||||
asset, created = models.Asset.objects.get_or_create(asset_id="91991", description="Spaceflower", status=status, category=category, date_acquired=datetime.date(1991, 12, 26))
|
asset, created = models.Asset.objects.get_or_create(asset_id="91991", description="Spaceflower", status=status, category=category, date_acquired=datetime.date(1991, 12, 26), replacement_cost=100)
|
||||||
yield asset
|
yield asset
|
||||||
asset.delete()
|
asset.delete()
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class AssetForm(FormPage):
|
|||||||
'serial_number': (regions.TextBox, (By.ID, 'id_serial_number')),
|
'serial_number': (regions.TextBox, (By.ID, 'id_serial_number')),
|
||||||
'comments': (regions.SimpleMDETextArea, (By.ID, 'id_comments')),
|
'comments': (regions.SimpleMDETextArea, (By.ID, 'id_comments')),
|
||||||
'purchase_price': (regions.TextBox, (By.ID, 'id_purchase_price')),
|
'purchase_price': (regions.TextBox, (By.ID, 'id_purchase_price')),
|
||||||
'salvage_value': (regions.TextBox, (By.ID, 'id_salvage_value')),
|
'replacement_cost': (regions.TextBox, (By.ID, 'id_replacement_cost')),
|
||||||
'date_acquired': (regions.DatePicker, (By.ID, 'id_date_acquired')),
|
'date_acquired': (regions.DatePicker, (By.ID, 'id_date_acquired')),
|
||||||
'date_sold': (regions.DatePicker, (By.ID, 'id_date_sold')),
|
'date_sold': (regions.DatePicker, (By.ID, 'id_date_sold')),
|
||||||
'category': (regions.SingleSelectPicker, (By.ID, 'id_category')),
|
'category': (regions.SingleSelectPicker, (By.ID, 'id_category')),
|
||||||
@@ -221,7 +221,7 @@ class AssetAuditList(AssetList):
|
|||||||
'description': (regions.TextBox, (By.ID, 'id_description')),
|
'description': (regions.TextBox, (By.ID, 'id_description')),
|
||||||
'is_cable': (regions.CheckBox, (By.ID, 'id_is_cable')),
|
'is_cable': (regions.CheckBox, (By.ID, 'id_is_cable')),
|
||||||
'serial_number': (regions.TextBox, (By.ID, 'id_serial_number')),
|
'serial_number': (regions.TextBox, (By.ID, 'id_serial_number')),
|
||||||
'salvage_value': (regions.TextBox, (By.ID, 'id_salvage_value')),
|
'replacement_cost': (regions.TextBox, (By.ID, 'id_replacement_cost')),
|
||||||
'date_acquired': (regions.DatePicker, (By.ID, 'id_date_acquired')),
|
'date_acquired': (regions.DatePicker, (By.ID, 'id_date_acquired')),
|
||||||
'category': (regions.SingleSelectPicker, (By.ID, 'id_category')),
|
'category': (regions.SingleSelectPicker, (By.ID, 'id_category')),
|
||||||
'status': (regions.SingleSelectPicker, (By.ID, 'id_status')),
|
'status': (regions.SingleSelectPicker, (By.ID, 'id_status')),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@@ -93,6 +94,55 @@ class TestAssetList(AutoLoginTest):
|
|||||||
self.assertEqual("10", asset_ids[1])
|
self.assertEqual("10", asset_ids[1])
|
||||||
|
|
||||||
|
|
||||||
|
def test_cable_create(logged_in_browser, admin_user, live_server, test_asset, category, status, cable_type):
|
||||||
|
page = pages.AssetCreate(logged_in_browser.driver, live_server.url).open()
|
||||||
|
wait = WebDriverWait(logged_in_browser.driver, 20)
|
||||||
|
page.description = str(cable_type)
|
||||||
|
page.category = category.name
|
||||||
|
page.status = status.name
|
||||||
|
page.serial_number = "MELON-MELON-MELON"
|
||||||
|
page.comments = "You might need that"
|
||||||
|
page.replacement_cost = "666"
|
||||||
|
page.is_cable = True
|
||||||
|
|
||||||
|
assert logged_in_browser.driver.find_element(By.ID, 'cable-table').is_displayed()
|
||||||
|
wait.until(animation_is_finished())
|
||||||
|
page.cable_type = str(cable_type)
|
||||||
|
page.length = 10
|
||||||
|
page.csa = "1.5"
|
||||||
|
|
||||||
|
page.submit()
|
||||||
|
assert page.success
|
||||||
|
|
||||||
|
|
||||||
|
def test_asset_edit(logged_in_browser, admin_user, live_server, test_asset):
|
||||||
|
page = pages.AssetEdit(logged_in_browser.driver, live_server.url, asset_id=test_asset.asset_id).open()
|
||||||
|
|
||||||
|
assert logged_in_browser.driver.find_element(By.ID, 'id_asset_id').get_attribute('readonly') is not None
|
||||||
|
|
||||||
|
new_description = "Big Shelf"
|
||||||
|
page.description = new_description
|
||||||
|
|
||||||
|
page.submit()
|
||||||
|
assert page.success
|
||||||
|
|
||||||
|
assert models.Asset.objects.get(asset_id=test_asset.asset_id).description == new_description
|
||||||
|
|
||||||
|
|
||||||
|
def test_asset_duplicate(logged_in_browser, admin_user, live_server, test_asset):
|
||||||
|
page = pages.AssetDuplicate(logged_in_browser.driver, live_server.url, asset_id=test_asset.asset_id).open()
|
||||||
|
|
||||||
|
assert test_asset.asset_id != page.asset_id
|
||||||
|
assert test_asset.description == page.description
|
||||||
|
assert test_asset.status.name == page.status
|
||||||
|
assert test_asset.category.name == page.category
|
||||||
|
assert test_asset.date_acquired == page.date_acquired.date()
|
||||||
|
|
||||||
|
page.submit()
|
||||||
|
assert page.success
|
||||||
|
assert models.Asset.objects.last().description == test_asset.description
|
||||||
|
|
||||||
|
|
||||||
@screenshot_failure_cls
|
@screenshot_failure_cls
|
||||||
class TestAssetForm(AutoLoginTest):
|
class TestAssetForm(AutoLoginTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -129,7 +179,7 @@ class TestAssetForm(AutoLoginTest):
|
|||||||
self.page.comments = comments = "This is actually a sledgehammer, not a cable..."
|
self.page.comments = comments = "This is actually a sledgehammer, not a cable..."
|
||||||
|
|
||||||
self.page.purchase_price = "12.99"
|
self.page.purchase_price = "12.99"
|
||||||
self.page.salvage_value = "99.12"
|
self.page.replacement_cost = "99.12"
|
||||||
self.page.date_acquired = acquired = datetime.date(2020, 5, 2)
|
self.page.date_acquired = acquired = datetime.date(2020, 5, 2)
|
||||||
self.page.purchased_from_selector.toggle()
|
self.page.purchased_from_selector.toggle()
|
||||||
self.assertTrue(self.page.purchased_from_selector.is_open)
|
self.assertTrue(self.page.purchased_from_selector.is_open)
|
||||||
@@ -138,11 +188,11 @@ class TestAssetForm(AutoLoginTest):
|
|||||||
|
|
||||||
self.page.parent_selector.toggle()
|
self.page.parent_selector.toggle()
|
||||||
self.assertTrue(self.page.parent_selector.is_open)
|
self.assertTrue(self.page.parent_selector.is_open)
|
||||||
option = str(self.parent)
|
option = self.parent.asset_id
|
||||||
self.page.parent_selector.search(option)
|
self.page.parent_selector.search(option)
|
||||||
self.driver.implicitly_wait(1)
|
time.sleep(2) # Slow down for javascript
|
||||||
self.page.parent_selector.set_option(option, True)
|
# self.page.parent_selector.set_option(option, True)
|
||||||
self.assertTrue(self.page.parent_selector.options[0].selected)
|
# self.assertTrue(self.page.parent_selector.options[0].selected)
|
||||||
self.page.parent_selector.toggle()
|
self.page.parent_selector.toggle()
|
||||||
|
|
||||||
self.assertFalse(self.driver.find_element_by_id('cable-table').is_displayed())
|
self.assertFalse(self.driver.find_element_by_id('cable-table').is_displayed())
|
||||||
@@ -159,50 +209,6 @@ class TestAssetForm(AutoLoginTest):
|
|||||||
# This one is important as it defaults to today's date
|
# This one is important as it defaults to today's date
|
||||||
self.assertEqual(asset.date_acquired, acquired)
|
self.assertEqual(asset.date_acquired, acquired)
|
||||||
|
|
||||||
def test_cable_create(self):
|
|
||||||
self.page.description = "IEC -> IEC"
|
|
||||||
self.page.category = "Health & Safety"
|
|
||||||
self.page.status = "O.K."
|
|
||||||
self.page.serial_number = "MELON-MELON-MELON"
|
|
||||||
self.page.comments = "You might need that"
|
|
||||||
self.page.is_cable = True
|
|
||||||
|
|
||||||
self.assertTrue(self.driver.find_element_by_id('cable-table').is_displayed())
|
|
||||||
self.wait.until(animation_is_finished())
|
|
||||||
self.page.cable_type = "IEC → IEC"
|
|
||||||
self.page.socket = "IEC"
|
|
||||||
self.page.length = 10
|
|
||||||
self.page.csa = "1.5"
|
|
||||||
|
|
||||||
self.page.submit()
|
|
||||||
self.assertTrue(self.page.success)
|
|
||||||
|
|
||||||
def test_asset_edit(self):
|
|
||||||
self.page = pages.AssetEdit(self.driver, self.live_server_url, asset_id=self.parent.asset_id).open()
|
|
||||||
|
|
||||||
self.assertIsNotNone(self.driver.find_element_by_id('id_asset_id').get_attribute('readonly'))
|
|
||||||
|
|
||||||
new_description = "Big Shelf"
|
|
||||||
self.page.description = new_description
|
|
||||||
|
|
||||||
self.page.submit()
|
|
||||||
self.assertTrue(self.page.success)
|
|
||||||
|
|
||||||
self.assertEqual(models.Asset.objects.get(asset_id=self.parent.asset_id).description, new_description)
|
|
||||||
|
|
||||||
def test_asset_duplicate(self):
|
|
||||||
self.page = pages.AssetDuplicate(self.driver, self.live_server_url, asset_id=self.parent.asset_id).open()
|
|
||||||
|
|
||||||
self.assertNotEqual(self.parent.asset_id, self.page.asset_id)
|
|
||||||
self.assertEqual(self.parent.description, self.page.description)
|
|
||||||
self.assertEqual(self.parent.status.name, self.page.status)
|
|
||||||
self.assertEqual(self.parent.category.name, self.page.category)
|
|
||||||
self.assertEqual(self.parent.date_acquired, self.page.date_acquired.date())
|
|
||||||
|
|
||||||
self.page.submit()
|
|
||||||
self.assertTrue(self.page.success)
|
|
||||||
self.assertEqual(models.Asset.objects.last().description, self.parent.description)
|
|
||||||
|
|
||||||
|
|
||||||
@screenshot_failure_cls
|
@screenshot_failure_cls
|
||||||
class TestSupplierList(AutoLoginTest):
|
class TestSupplierList(AutoLoginTest):
|
||||||
@@ -282,6 +288,28 @@ def test_audit_search(logged_in_browser, live_server, test_asset):
|
|||||||
assert logged_in_browser.is_text_present("Asset with that ID does not exist!")
|
assert logged_in_browser.is_text_present("Asset with that ID does not exist!")
|
||||||
|
|
||||||
|
|
||||||
|
def test_audit_success(logged_in_browser, admin_user, live_server, test_asset):
|
||||||
|
page = pages.AssetAuditList(logged_in_browser.driver, live_server.url).open()
|
||||||
|
wait = WebDriverWait(logged_in_browser.driver, 20)
|
||||||
|
page.set_query(test_asset.asset_id)
|
||||||
|
page.search()
|
||||||
|
wait.until(ec.visibility_of_element_located((By.ID, 'modal')))
|
||||||
|
# Now do it properly
|
||||||
|
page.modal.description = new_desc = "A BIG hammer"
|
||||||
|
page.modal.submit()
|
||||||
|
logged_in_browser.driver.implicitly_wait(4)
|
||||||
|
wait.until(animation_is_finished())
|
||||||
|
submit_time = timezone.now()
|
||||||
|
# Check data is correct
|
||||||
|
test_asset.refresh_from_db()
|
||||||
|
assert test_asset.description in new_desc
|
||||||
|
# Make sure audit 'log' was filled out
|
||||||
|
assert admin_user.initials == test_asset.last_audited_by.initials
|
||||||
|
assert_times_almost_equal(submit_time, test_asset.last_audited_at)
|
||||||
|
# Check we've removed it from the 'needing audit' list
|
||||||
|
assert test_asset.asset_id not in page.assets
|
||||||
|
|
||||||
|
|
||||||
@screenshot_failure_cls
|
@screenshot_failure_cls
|
||||||
class TestAssetAudit(AutoLoginTest):
|
class TestAssetAudit(AutoLoginTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -292,14 +320,14 @@ class TestAssetAudit(AutoLoginTest):
|
|||||||
self.connector = models.Connector.objects.create(description="Trailer Socket", current_rating=1,
|
self.connector = models.Connector.objects.create(description="Trailer Socket", current_rating=1,
|
||||||
voltage_rating=40, num_pins=13)
|
voltage_rating=40, num_pins=13)
|
||||||
models.Asset.objects.create(asset_id="1", description="Trailer Cable", status=self.status,
|
models.Asset.objects.create(asset_id="1", description="Trailer Cable", status=self.status,
|
||||||
category=self.category, date_acquired=datetime.date(2020, 2, 1))
|
category=self.category, date_acquired=datetime.date(2020, 2, 1), replacement_cost=10)
|
||||||
models.Asset.objects.create(asset_id="11", description="Trailerboard", status=self.status,
|
models.Asset.objects.create(asset_id="11", description="Trailerboard", status=self.status,
|
||||||
category=self.category, date_acquired=datetime.date(2020, 2, 1))
|
category=self.category, date_acquired=datetime.date(2020, 2, 1), replacement_cost=10)
|
||||||
models.Asset.objects.create(asset_id="111", description="Erms", status=self.status, category=self.category,
|
models.Asset.objects.create(asset_id="111", description="Erms", status=self.status, category=self.category,
|
||||||
date_acquired=datetime.date(2020, 2, 1))
|
date_acquired=datetime.date(2020, 2, 1), replacement_cost=10)
|
||||||
self.asset = models.Asset.objects.create(asset_id="1111", description="A hammer", status=self.status,
|
self.asset = models.Asset.objects.create(asset_id="1111", description="A hammer", status=self.status,
|
||||||
category=self.category,
|
category=self.category,
|
||||||
date_acquired=datetime.date(2020, 2, 1))
|
date_acquired=datetime.date(2020, 2, 1), replacement_cost=10)
|
||||||
self.page = pages.AssetAuditList(self.driver, self.live_server_url).open()
|
self.page = pages.AssetAuditList(self.driver, self.live_server_url).open()
|
||||||
self.wait = WebDriverWait(self.driver, 20)
|
self.wait = WebDriverWait(self.driver, 20)
|
||||||
|
|
||||||
@@ -315,25 +343,6 @@ class TestAssetAudit(AutoLoginTest):
|
|||||||
self.driver.implicitly_wait(4)
|
self.driver.implicitly_wait(4)
|
||||||
self.assertIn("This field is required.", self.page.modal.errors["Description"])
|
self.assertIn("This field is required.", self.page.modal.errors["Description"])
|
||||||
|
|
||||||
def test_audit_success(self):
|
|
||||||
self.page.set_query(self.asset.asset_id)
|
|
||||||
self.page.search()
|
|
||||||
self.wait.until(ec.visibility_of_element_located((By.ID, 'modal')))
|
|
||||||
# Now do it properly
|
|
||||||
self.page.modal.description = new_desc = "A BIG hammer"
|
|
||||||
self.page.modal.submit()
|
|
||||||
self.driver.implicitly_wait(4)
|
|
||||||
self.wait.until(animation_is_finished())
|
|
||||||
submit_time = timezone.now()
|
|
||||||
# Check data is correct
|
|
||||||
self.asset.refresh_from_db()
|
|
||||||
self.assertEqual(self.asset.description, new_desc)
|
|
||||||
# Make sure audit 'log' was filled out
|
|
||||||
self.assertEqual(self.profile.initials, self.asset.last_audited_by.initials)
|
|
||||||
assert_times_almost_equal(submit_time, self.asset.last_audited_at)
|
|
||||||
# Check we've removed it from the 'needing audit' list
|
|
||||||
self.assertNotIn(self.asset.asset_id, self.page.assets)
|
|
||||||
|
|
||||||
def test_audit_list(self):
|
def test_audit_list(self):
|
||||||
self.assertEqual(models.Asset.objects.filter(last_audited_at=None).count(), len(self.page.assets))
|
self.assertEqual(models.Asset.objects.filter(last_audited_at=None).count(), len(self.page.assets))
|
||||||
asset_row = self.page.assets[0]
|
asset_row = self.page.assets[0]
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ def test_oembed(client, test_asset):
|
|||||||
|
|
||||||
|
|
||||||
def test_asset_create(admin_client):
|
def test_asset_create(admin_client):
|
||||||
response = admin_client.post(reverse('asset_create'), {'date_sold': '2000-01-01', 'date_acquired': '2020-01-01', 'purchase_price': '-30', 'salvage_value': '-30'})
|
response = admin_client.post(reverse('asset_create'), {'date_sold': '2000-01-01', 'date_acquired': '2020-01-01', 'purchase_price': '-30', 'replacement_cost': '-30'})
|
||||||
assertFormError(response, 'form', 'asset_id', 'This field is required.')
|
assertFormError(response, 'form', 'asset_id', 'This field is required.')
|
||||||
assert_asset_form_errors(response)
|
assert_asset_form_errors(response)
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ def test_cable_create(admin_client):
|
|||||||
|
|
||||||
def test_asset_edit(admin_client, test_asset):
|
def test_asset_edit(admin_client, test_asset):
|
||||||
url = reverse('asset_update', kwargs={'pk': test_asset.asset_id})
|
url = reverse('asset_update', kwargs={'pk': test_asset.asset_id})
|
||||||
response = admin_client.post(url, {'date_sold': '2000-12-01', 'date_acquired': '2020-12-01', 'purchase_price': '-50', 'salvage_value': '-50', 'description': "", 'status': "", 'category': ""})
|
response = admin_client.post(url, {'date_sold': '2000-12-01', 'date_acquired': '2020-12-01', 'purchase_price': '-50', 'replacement_cost': '-50', 'description': "", 'status': "", 'category': ""})
|
||||||
assert_asset_form_errors(response)
|
assert_asset_form_errors(response)
|
||||||
|
|
||||||
|
|
||||||
@@ -127,4 +127,4 @@ def assert_asset_form_errors(response):
|
|||||||
assertFormError(response, 'form', 'category', 'This field is required.')
|
assertFormError(response, 'form', 'category', 'This field is required.')
|
||||||
assertFormError(response, 'form', 'date_sold', 'Cannot sell an item before it is acquired')
|
assertFormError(response, 'form', 'date_sold', 'Cannot sell an item before it is acquired')
|
||||||
assertFormError(response, 'form', 'purchase_price', 'A price cannot be negative')
|
assertFormError(response, 'form', 'purchase_price', 'A price cannot be negative')
|
||||||
assertFormError(response, 'form', 'salvage_value', 'A price cannot be negative')
|
assertFormError(response, 'form', 'replacement_cost', 'A price cannot be negative')
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ urlpatterns = [
|
|||||||
path('asset/id/<asset:pk>/duplicate/', permission_required_with_403('assets.add_asset')
|
path('asset/id/<asset:pk>/duplicate/', permission_required_with_403('assets.add_asset')
|
||||||
(views.AssetDuplicate.as_view()), name='asset_duplicate'),
|
(views.AssetDuplicate.as_view()), name='asset_duplicate'),
|
||||||
path('asset/id/<asset:pk>/label', login_required(views.GenerateLabel.as_view()), name='generate_label'),
|
path('asset/id/<asset:pk>/label', login_required(views.GenerateLabel.as_view()), name='generate_label'),
|
||||||
path('asset/<list:ids>/list/label', views.GenerateLabels.as_view(), name='generate_labels'),
|
path('asset/<list:ids>/list/label', views.GenerateLabels.as_view(), name='generate_labels'),
|
||||||
|
|
||||||
|
path('cables/list/', login_required(views.CableList.as_view()), name='cable_list'),
|
||||||
path('cabletype/list/', login_required(views.CableTypeList.as_view()), name='cable_type_list'),
|
path('cabletype/list/', login_required(views.CableTypeList.as_view()), name='cable_type_list'),
|
||||||
path('cabletype/create/', permission_required_with_403('assets.add_cable_type')(views.CableTypeCreate.as_view()), name='cable_type_create'),
|
path('cabletype/create/', permission_required_with_403('assets.add_cable_type')(views.CableTypeCreate.as_view()), name='cable_type_create'),
|
||||||
path('cabletype/<int:pk>/update/', permission_required_with_403('assets.change_cable_type')(views.CableTypeUpdate.as_view()), name='cable_type_update'),
|
path('cabletype/<int:pk>/update/', permission_required_with_403('assets.change_cable_type')(views.CableTypeUpdate.as_view()), name='cable_type_update'),
|
||||||
path('cabletype/<int:pk>/detail/', login_required(views.CableTypeDetail.as_view()), name='cable_type_detail'),
|
path('cabletype/<int:pk>/detail/', login_required(views.CableTypeDetail.as_view()), name='cable_type_detail'),
|
||||||
|
|
||||||
path('asset/search/', login_required(views.AssetSearch.as_view()), name='asset_search_json'),
|
|
||||||
path('asset/id/<str:pk>/embed/',
|
path('asset/id/<str:pk>/embed/',
|
||||||
xframe_options_exempt(
|
xframe_options_exempt(
|
||||||
login_required(login_url='/user/login/embed/')(views.AssetEmbed.as_view())),
|
login_required(login_url='/user/login/embed/')(views.AssetEmbed.as_view())),
|
||||||
@@ -43,6 +43,4 @@ urlpatterns = [
|
|||||||
(views.SupplierCreate.as_view()), name='supplier_create'),
|
(views.SupplierCreate.as_view()), name='supplier_create'),
|
||||||
path('supplier/<int:pk>/edit/', permission_required_with_403('assets.change_supplier')
|
path('supplier/<int:pk>/edit/', permission_required_with_403('assets.change_supplier')
|
||||||
(views.SupplierUpdate.as_view()), name='supplier_update'),
|
(views.SupplierUpdate.as_view()), name='supplier_update'),
|
||||||
|
|
||||||
path('supplier/search/', login_required(views.SupplierSearch.as_view()), name='supplier_search_json'),
|
|
||||||
]
|
]
|
||||||
|
|||||||
102
assets/views.py
@@ -6,7 +6,7 @@ from io import BytesIO
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
from django.db.models import Q
|
from django.db.models import Q, Sum
|
||||||
from django.http import Http404, HttpResponse, JsonResponse
|
from django.http import Http404, HttpResponse, JsonResponse
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@@ -17,7 +17,7 @@ from django.shortcuts import get_object_or_404
|
|||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
|
|
||||||
from PyPDF2 import PdfFileMerger, PdfFileReader
|
from PyPDF2 import PdfFileMerger, PdfFileReader
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont, ImageOps
|
||||||
from barcode import Code39
|
from barcode import Code39
|
||||||
from barcode.writer import ImageWriter
|
from barcode.writer import ImageWriter
|
||||||
from z3c.rml import rml2pdf
|
from z3c.rml import rml2pdf
|
||||||
@@ -25,14 +25,12 @@ from z3c.rml import rml2pdf
|
|||||||
from PyRIGS.views import GenericListView, GenericDetailView, GenericUpdateView, GenericCreateView, ModalURLMixin, \
|
from PyRIGS.views import GenericListView, GenericDetailView, GenericUpdateView, GenericCreateView, ModalURLMixin, \
|
||||||
is_ajax, OEmbedView
|
is_ajax, OEmbedView
|
||||||
from assets import forms, models
|
from assets import forms, models
|
||||||
from assets.models import get_available_asset_id
|
|
||||||
|
|
||||||
|
|
||||||
class AssetList(LoginRequiredMixin, generic.ListView):
|
class AssetList(LoginRequiredMixin, generic.ListView):
|
||||||
model = models.Asset
|
model = models.Asset
|
||||||
template_name = 'asset_list.html'
|
template_name = 'asset_list.html'
|
||||||
paginate_by = 40
|
paginate_by = 40
|
||||||
ordering = ['-pk']
|
|
||||||
hide_hidden_status = True
|
hide_hidden_status = True
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
@@ -50,13 +48,7 @@ class AssetList(LoginRequiredMixin, generic.ListView):
|
|||||||
|
|
||||||
# TODO Feedback to user when search fails
|
# TODO Feedback to user when search fails
|
||||||
query_string = form.cleaned_data['q'] or ""
|
query_string = form.cleaned_data['q'] or ""
|
||||||
if len(query_string) == 0:
|
queryset = models.Asset.objects.search(query=query_string)
|
||||||
queryset = self.model.objects.all()
|
|
||||||
elif len(query_string) >= 3:
|
|
||||||
queryset = self.model.objects.filter(
|
|
||||||
Q(asset_id__exact=query_string.upper()) | Q(description__icontains=query_string) | Q(serial_number__exact=query_string))
|
|
||||||
else:
|
|
||||||
queryset = self.model.objects.filter(Q(asset_id__exact=query_string.upper()))
|
|
||||||
|
|
||||||
if form.cleaned_data['is_cable']:
|
if form.cleaned_data['is_cable']:
|
||||||
queryset = queryset.filter(is_cable=True)
|
queryset = queryset.filter(is_cable=True)
|
||||||
@@ -87,28 +79,29 @@ class AssetList(LoginRequiredMixin, generic.ListView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class AssetSearch(AssetList):
|
class CableList(AssetList):
|
||||||
hide_hidden_status = False
|
template_name = 'cable_list.html'
|
||||||
|
paginator = None
|
||||||
|
|
||||||
def render_to_response(self, context, **response_kwargs):
|
def get_queryset(self):
|
||||||
result = []
|
queryset = super().get_queryset().filter(is_cable=True)
|
||||||
|
|
||||||
for asset in context["object_list"]:
|
if self.form.cleaned_data['cable_type']:
|
||||||
result.append({"id": asset.pk, "label": (asset.asset_id + " | " + asset.description)})
|
queryset = queryset.filter(cable_type__in=self.form.cleaned_data['cable_type'])
|
||||||
|
|
||||||
return JsonResponse(result, safe=False)
|
return queryset
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context["page_title"] = "Cable List"
|
||||||
|
context["total_length"] = self.get_queryset().aggregate(Sum('length'))['length__sum']
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
class AssetIDUrlMixin:
|
class AssetIDUrlMixin:
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
pk = self.kwargs.get(self.pk_url_kwarg)
|
pk = self.kwargs.get(self.pk_url_kwarg)
|
||||||
queryset = models.Asset.objects.filter(asset_id=pk)
|
return get_object_or_404(models.Asset, asset_id=pk)
|
||||||
try:
|
|
||||||
# Get the single item from the filtered queryset
|
|
||||||
obj = queryset.get()
|
|
||||||
except queryset.model.DoesNotExist:
|
|
||||||
raise Http404("No assets found matching the query")
|
|
||||||
return obj
|
|
||||||
|
|
||||||
|
|
||||||
class AssetDetail(LoginRequiredMixin, AssetIDUrlMixin, generic.DetailView):
|
class AssetDetail(LoginRequiredMixin, AssetIDUrlMixin, generic.DetailView):
|
||||||
@@ -158,7 +151,7 @@ class AssetCreate(LoginRequiredMixin, generic.CreateView):
|
|||||||
|
|
||||||
def get_initial(self, *args, **kwargs):
|
def get_initial(self, *args, **kwargs):
|
||||||
initial = super().get_initial(*args, **kwargs)
|
initial = super().get_initial(*args, **kwargs)
|
||||||
initial["asset_id"] = get_available_asset_id()
|
initial["asset_id"] = models.get_available_asset_id()
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -173,6 +166,11 @@ class DuplicateMixin:
|
|||||||
|
|
||||||
|
|
||||||
class AssetDuplicate(DuplicateMixin, AssetIDUrlMixin, AssetCreate):
|
class AssetDuplicate(DuplicateMixin, AssetIDUrlMixin, AssetCreate):
|
||||||
|
def get_initial(self, *args, **kwargs):
|
||||||
|
initial = super().get_initial(*args, **kwargs)
|
||||||
|
initial["asset_id"] = models.get_available_asset_id(wanted_prefix=self.get_object().asset_id_prefix)
|
||||||
|
return initial
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["create"] = None
|
context["create"] = None
|
||||||
@@ -194,7 +192,7 @@ class AssetOEmbed(OEmbedView):
|
|||||||
|
|
||||||
class AssetAuditList(AssetList):
|
class AssetAuditList(AssetList):
|
||||||
template_name = 'asset_audit_list.html'
|
template_name = 'asset_audit_list.html'
|
||||||
hide_hidden_status = False
|
hide_hidden_status = True
|
||||||
|
|
||||||
# TODO Refresh this when the modal is submitted
|
# TODO Refresh this when the modal is submitted
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@@ -242,17 +240,6 @@ class SupplierList(GenericListView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class SupplierSearch(SupplierList):
|
|
||||||
hide_hidden_status = False
|
|
||||||
|
|
||||||
def render_to_response(self, context, **response_kwargs):
|
|
||||||
result = []
|
|
||||||
|
|
||||||
for supplier in context["object_list"]:
|
|
||||||
result.append({"id": supplier.pk, "name": supplier.name})
|
|
||||||
return JsonResponse(result, safe=False)
|
|
||||||
|
|
||||||
|
|
||||||
class SupplierDetail(GenericDetailView):
|
class SupplierDetail(GenericDetailView):
|
||||||
model = models.Supplier
|
model = models.Supplier
|
||||||
|
|
||||||
@@ -292,7 +279,7 @@ class SupplierUpdate(GenericUpdateView, ModalURLMixin):
|
|||||||
form_class = forms.SupplierForm
|
form_class = forms.SupplierForm
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(SupplierUpdate, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
else:
|
else:
|
||||||
@@ -336,7 +323,6 @@ class CableTypeCreate(generic.CreateView):
|
|||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["create"] = True
|
context["create"] = True
|
||||||
context["page_title"] = "Create Cable Type"
|
context["page_title"] = "Create Cable Type"
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -352,7 +338,6 @@ class CableTypeUpdate(generic.UpdateView):
|
|||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["edit"] = True
|
context["edit"] = True
|
||||||
context["page_title"] = f"Edit Cable Type {self.object}"
|
context["page_title"] = f"Edit Cable Type {self.object}"
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -363,7 +348,9 @@ def generate_label(pk):
|
|||||||
black = (0, 0, 0)
|
black = (0, 0, 0)
|
||||||
white = (255, 255, 255)
|
white = (255, 255, 255)
|
||||||
size = (700, 200)
|
size = (700, 200)
|
||||||
font = ImageFont.truetype("static/fonts/OpenSans-Regular.tff", 20)
|
font_size = 22
|
||||||
|
font = ImageFont.truetype("static/fonts/OpenSans-Regular.tff", font_size)
|
||||||
|
heavy_font = ImageFont.truetype("static/fonts/OpenSans-Bold.tff", font_size + 13)
|
||||||
obj = get_object_or_404(models.Asset, asset_id=pk)
|
obj = get_object_or_404(models.Asset, asset_id=pk)
|
||||||
|
|
||||||
asset_id = f"Asset: {obj.asset_id}"
|
asset_id = f"Asset: {obj.asset_id}"
|
||||||
@@ -372,22 +359,25 @@ def generate_label(pk):
|
|||||||
csa = f"CSA: {obj.csa}mm²"
|
csa = f"CSA: {obj.csa}mm²"
|
||||||
|
|
||||||
image = Image.new("RGB", size, white)
|
image = Image.new("RGB", size, white)
|
||||||
|
image = ImageOps.expand(image, border=(5, 5, 5, 5), fill=black)
|
||||||
logo = Image.open("static/imgs/square_logo.png")
|
logo = Image.open("static/imgs/square_logo.png")
|
||||||
draw = ImageDraw.Draw(image)
|
draw = ImageDraw.Draw(image)
|
||||||
|
|
||||||
draw.text((210, 140), asset_id, fill=black, font=font)
|
draw.text((300, 0), asset_id, fill=black, font=heavy_font)
|
||||||
if obj.is_cable:
|
if obj.is_cable:
|
||||||
draw.text((210, 170), length, fill=black, font=font)
|
y = 140
|
||||||
draw.text((360, 170), csa, fill=black, font=font)
|
draw.text((210, y), length, fill=black, font=font)
|
||||||
draw.multiline_text((500, 140), "TEC PA & Lighting\n(0115) 84 68720", fill=black, font=font)
|
if obj.csa:
|
||||||
|
draw.text((365, y), csa, fill=black, font=font)
|
||||||
|
draw.text((210, size[1] - font_size - 8), "TEC PA & Lighting (0115) 84 68720", fill=black, font=font)
|
||||||
|
|
||||||
barcode = Code39(str(obj.asset_id), writer=ImageWriter())
|
barcode = Code39(str(obj.asset_id), writer=ImageWriter())
|
||||||
|
|
||||||
logo_size = (200, 200)
|
logo_size = (200, 200)
|
||||||
image.paste(logo.resize(logo_size, Image.ANTIALIAS))
|
image.paste(logo.resize(logo_size, Image.ANTIALIAS), box=(5, 5))
|
||||||
barcode_image = barcode.render(writer_options={"quiet_zone": 0, "write_text": False})
|
barcode_image = barcode.render(writer_options={"quiet_zone": 0, "write_text": False})
|
||||||
width, height = barcode_image.size
|
width, height = barcode_image.size
|
||||||
image.paste(barcode_image.crop((0, 0, width, 135)), (int(((size[0] + logo_size[0]) - width) / 2), 0))
|
image.paste(barcode_image.crop((0, 0, width, 100)), (int(((size[0] + logo_size[0]) - width) / 2), 40))
|
||||||
|
|
||||||
return image
|
return image
|
||||||
|
|
||||||
@@ -416,14 +406,16 @@ class GenerateLabels(generic.View):
|
|||||||
|
|
||||||
base64_encoded_result_bytes = base64.b64encode(img_bytes)
|
base64_encoded_result_bytes = base64.b64encode(img_bytes)
|
||||||
base64_encoded_result_str = base64_encoded_result_bytes.decode('ascii')
|
base64_encoded_result_str = base64_encoded_result_bytes.decode('ascii')
|
||||||
images.append(base64_encoded_result_str)
|
images.append((get_object_or_404(models.Asset, asset_id=asset_id), base64_encoded_result_str))
|
||||||
|
|
||||||
|
name = f"Asset Label Sheet generated at {timezone.now()}"
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'images0': images[::4],
|
'images0': images[::3],
|
||||||
'images1': images[1::4],
|
'images1': images[1::3],
|
||||||
'images2': images[2::4],
|
'images2': images[2::3],
|
||||||
'images3': images[3::4],
|
# 'images3': images[3::4],
|
||||||
'filename': "Asset Label Sheet generated at {}".format(timezone.now())
|
'filename': name
|
||||||
}
|
}
|
||||||
merger = PdfFileMerger()
|
merger = PdfFileMerger()
|
||||||
|
|
||||||
@@ -435,6 +427,6 @@ class GenerateLabels(generic.View):
|
|||||||
merged = BytesIO()
|
merged = BytesIO()
|
||||||
merger.write(merged)
|
merger.write(merged)
|
||||||
|
|
||||||
response['Content-Disposition'] = 'filename="{}"'.format(context['filename'])
|
response['Content-Disposition'] = f'filename="{name}"'
|
||||||
response.write(merged.getvalue())
|
response.write(merged.getvalue())
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ def admin_user(admin_user):
|
|||||||
admin_user.first_name = "Event"
|
admin_user.first_name = "Event"
|
||||||
admin_user.last_name = "Test"
|
admin_user.last_name = "Test"
|
||||||
admin_user.initials = "ETU"
|
admin_user.initials = "ETU"
|
||||||
|
admin_user.is_approved = True
|
||||||
admin_user.save()
|
admin_user.save()
|
||||||
return admin_user
|
return admin_user
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ function styles(done) {
|
|||||||
'node_modules/fullcalendar/main.css',
|
'node_modules/fullcalendar/main.css',
|
||||||
'node_modules/bootstrap-select/dist/css/bootstrap-select.css',
|
'node_modules/bootstrap-select/dist/css/bootstrap-select.css',
|
||||||
'node_modules/ajax-bootstrap-select/dist/css/ajax-bootstrap-select.css',
|
'node_modules/ajax-bootstrap-select/dist/css/ajax-bootstrap-select.css',
|
||||||
'node_modules/flatpickr/dist/flatpickr.css',
|
'node_modules/easymde/dist/easymde.min.css'
|
||||||
'node_modules/simplemde/dist/simplemde.min.css'
|
|
||||||
])
|
])
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(sass().on('error', sass.logError))
|
.pipe(sass().on('error', sass.logError))
|
||||||
@@ -59,12 +58,11 @@ function scripts() {
|
|||||||
|
|
||||||
'node_modules/html5sortable/dist/html5sortable.min.js',
|
'node_modules/html5sortable/dist/html5sortable.min.js',
|
||||||
'node_modules/clipboard/dist/clipboard.min.js',
|
'node_modules/clipboard/dist/clipboard.min.js',
|
||||||
'node_modules/flatpickr/dist/flatpickr.min.js',
|
|
||||||
'node_modules/moment/moment.js',
|
'node_modules/moment/moment.js',
|
||||||
'node_modules/fullcalendar/main.js',
|
'node_modules/fullcalendar/main.js',
|
||||||
'node_modules/bootstrap-select/dist/js/bootstrap-select.js',
|
'node_modules/bootstrap-select/dist/js/bootstrap-select.js',
|
||||||
'node_modules/ajax-bootstrap-select/dist/js/ajax-bootstrap-select.js',
|
'node_modules/ajax-bootstrap-select/dist/js/ajax-bootstrap-select.js',
|
||||||
'node_modules/simplemde/dist/simplemde.min.js',
|
'node_modules/easymde/dist/easymde.min.js',
|
||||||
'node_modules/konami/konami.js',
|
'node_modules/konami/konami.js',
|
||||||
'pipeline/source_assets/js/**/*.js',])
|
'pipeline/source_assets/js/**/*.js',])
|
||||||
.pipe(gulpif(function(file) { return base_scripts.includes(file.relative);}, con('base.js')))
|
.pipe(gulpif(function(file) { return base_scripts.includes(file.relative);}, con('base.js')))
|
||||||
|
|||||||
225
package-lock.json
generated
@@ -5,6 +5,7 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "PyRIGS",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "Custom",
|
"license": "Custom",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -13,11 +14,11 @@
|
|||||||
"ajax-bootstrap-select": "^1.4.5",
|
"ajax-bootstrap-select": "^1.4.5",
|
||||||
"autocompleter": "^6.1.2",
|
"autocompleter": "^6.1.2",
|
||||||
"autoprefixer": "^10.4.0",
|
"autoprefixer": "^10.4.0",
|
||||||
"bootstrap": "^4.5.2",
|
"bootstrap": "^4.6.1",
|
||||||
"bootstrap-select": "^1.13.17",
|
"bootstrap-select": "^1.13.18",
|
||||||
"clipboard": "^2.0.8",
|
"clipboard": "^2.0.8",
|
||||||
"cssnano": "^5.0.13",
|
"cssnano": "^5.0.13",
|
||||||
"flatpickr": "^4.6.6",
|
"easymde": "^2.16.1",
|
||||||
"fullcalendar": "^5.10.1",
|
"fullcalendar": "^5.10.1",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
@@ -30,11 +31,10 @@
|
|||||||
"html5sortable": "^0.13.3",
|
"html5sortable": "^0.13.3",
|
||||||
"jquery": "^3.6.0",
|
"jquery": "^3.6.0",
|
||||||
"konami": "^1.6.3",
|
"konami": "^1.6.3",
|
||||||
"moment": "^2.27.0",
|
"moment": "^2.29.2",
|
||||||
"node-sass": "^7.0.0",
|
"node-sass": "^7.0.0",
|
||||||
"popper.js": "^1.16.1",
|
"popper.js": "^1.16.1",
|
||||||
"postcss": "^8.4.5",
|
"postcss": "^8.4.5",
|
||||||
"simplemde": "^1.11.2",
|
|
||||||
"uglify-js": "^3.14.5"
|
"uglify-js": "^3.14.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -256,6 +256,24 @@
|
|||||||
"node": ">=10.13.0"
|
"node": ">=10.13.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/codemirror": {
|
||||||
|
"version": "5.60.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-5.60.5.tgz",
|
||||||
|
"integrity": "sha512-TiECZmm8St5YxjFUp64LK0c8WU5bxMDt9YaAek1UqUb9swrSCoJhh92fWu1p3mTEqlHjhB5sY7OFBhWroJXZVg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/tern": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/estree": {
|
||||||
|
"version": "0.0.50",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.50.tgz",
|
||||||
|
"integrity": "sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw=="
|
||||||
|
},
|
||||||
|
"node_modules/@types/marked": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-ZigEmCWdNUU7IjZEuQ/iaimYdDHWHfTe3kg8ORfKjyGYd9RWumPoOJRQXB0bO+XLkNwzCthW3wUIQtANaEZ1ag=="
|
||||||
|
},
|
||||||
"node_modules/@types/minimist": {
|
"node_modules/@types/minimist": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",
|
||||||
@@ -266,6 +284,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz",
|
||||||
"integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw=="
|
"integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/tern": {
|
||||||
|
"version": "0.23.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.4.tgz",
|
||||||
|
"integrity": "sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/estree": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/abbrev": {
|
"node_modules/abbrev": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
||||||
@@ -932,9 +958,17 @@
|
|||||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||||
},
|
},
|
||||||
"node_modules/bootstrap": {
|
"node_modules/bootstrap": {
|
||||||
"version": "4.6.0",
|
"version": "4.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.6.1.tgz",
|
||||||
"integrity": "sha512-Io55IuQY3kydzHtbGvQya3H+KorS/M9rSNyfCGCg9WZ4pyT/lCxIlpJgG1GXW/PswzC84Tr2fBYi+7+jFVQQBw=="
|
"integrity": "sha512-0dj+VgI9Ecom+rvvpNZ4MUZJz8dcX7WCX+eTID9+/8HgOkv3dsRzi8BGeZJCQU6flWQVYxwTQnEZFrmJSEO7og==",
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/bootstrap"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"jquery": "1.9.1 - 3",
|
||||||
|
"popper.js": "^1.16.1"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/bootstrap-select": {
|
"node_modules/bootstrap-select": {
|
||||||
"version": "1.13.18",
|
"version": "1.13.18",
|
||||||
@@ -1579,12 +1613,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/copy-props": {
|
"node_modules/copy-props": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/copy-props/-/copy-props-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/copy-props/-/copy-props-2.0.5.tgz",
|
||||||
"integrity": "sha512-7cjuUME+p+S3HZlbllgsn2CDwS+5eCCX16qBgNC4jgSTf49qR1VKy/Zhl400m0IQXl/bPGEVqncgUUMjrr4s8A==",
|
"integrity": "sha512-XBlx8HSqrT0ObQwmSzM7WE5k8FxTV75h1DX1Z3n6NhQ/UYYAvInWYmG06vFt7hQZArE2fuO62aihiWIVQwh1sw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"each-props": "^1.3.0",
|
"each-props": "^1.3.2",
|
||||||
"is-plain-object": "^2.0.1"
|
"is-plain-object": "^5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/copy-props/node_modules/is-plain-object": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/core-util-is": {
|
"node_modules/core-util-is": {
|
||||||
@@ -2026,6 +2068,18 @@
|
|||||||
"node": ">= 4.0.0"
|
"node": ">= 4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/easymde": {
|
||||||
|
"version": "2.16.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/easymde/-/easymde-2.16.1.tgz",
|
||||||
|
"integrity": "sha512-FihYgjRsKfhGNk89SHSqxKLC4aJ1kfybPWW6iAmtb5GnXu+tnFPSzSaGBmk1RRlCuhFSjhF0SnIMGVPjEzkr6g==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/codemirror": "^5.60.4",
|
||||||
|
"@types/marked": "^4.0.1",
|
||||||
|
"codemirror": "^5.63.1",
|
||||||
|
"codemirror-spell-checker": "1.1.2",
|
||||||
|
"marked": "^4.0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eazy-logger": {
|
"node_modules/eazy-logger": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/eazy-logger/-/eazy-logger-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/eazy-logger/-/eazy-logger-3.1.0.tgz",
|
||||||
@@ -2735,11 +2789,6 @@
|
|||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/flatpickr": {
|
|
||||||
"version": "4.6.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/flatpickr/-/flatpickr-4.6.9.tgz",
|
|
||||||
"integrity": "sha512-F0azNNi8foVWKSF+8X+ZJzz8r9sE1G4hl06RyceIaLvyltKvDl6vqk9Lm/6AUUCi5HWaIjiUbk7UpeE/fOXOpw=="
|
|
||||||
},
|
|
||||||
"node_modules/flush-write-stream": {
|
"node_modules/flush-write-stream": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz",
|
||||||
@@ -2750,12 +2799,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.14.6",
|
"version": "1.14.8",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
|
||||||
"integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==",
|
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||||
|
}
|
||||||
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.0"
|
"node": ">=4.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"debug": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/for-in": {
|
"node_modules/for-in": {
|
||||||
@@ -4868,9 +4928,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/marked": {
|
"node_modules/marked": {
|
||||||
"version": "4.0.8",
|
"version": "4.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/marked/-/marked-4.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-4.0.10.tgz",
|
||||||
"integrity": "sha512-dkpJMIlJpc833hbjjg8jraw1t51e/eKDoG8TFOgc5O0Z77zaYKigYekTDop5AplRoKFGIaoazhYEhGkMtU3IeA==",
|
"integrity": "sha512-+QvuFj0nGgO970fySghXGmuw+Fd0gD2x3+MqCWLIPf5oxdv1Ka6b2q+z9RP01P/IaKPMEramy+7cNy/Lw8c3hw==",
|
||||||
"bin": {
|
"bin": {
|
||||||
"marked": "bin/marked.js"
|
"marked": "bin/marked.js"
|
||||||
},
|
},
|
||||||
@@ -5208,14 +5268,6 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/meow/node_modules/yargs-parser": {
|
|
||||||
"version": "20.2.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
|
|
||||||
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/merge-stream": {
|
"node_modules/merge-stream": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
|
||||||
@@ -5415,9 +5467,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/moment": {
|
"node_modules/moment": {
|
||||||
"version": "2.29.1",
|
"version": "2.29.2",
|
||||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
|
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz",
|
||||||
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
|
"integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
@@ -5441,9 +5493,9 @@
|
|||||||
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ=="
|
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ=="
|
||||||
},
|
},
|
||||||
"node_modules/nanoid": {
|
"node_modules/nanoid": {
|
||||||
"version": "3.1.30",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.30.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz",
|
||||||
"integrity": "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==",
|
"integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==",
|
||||||
"bin": {
|
"bin": {
|
||||||
"nanoid": "bin/nanoid.cjs"
|
"nanoid": "bin/nanoid.cjs"
|
||||||
},
|
},
|
||||||
@@ -7318,16 +7370,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
|
||||||
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ=="
|
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ=="
|
||||||
},
|
},
|
||||||
"node_modules/simplemde": {
|
|
||||||
"version": "1.11.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/simplemde/-/simplemde-1.11.2.tgz",
|
|
||||||
"integrity": "sha1-ojo12XjSxA7wfewAjJLwcNjggOM=",
|
|
||||||
"dependencies": {
|
|
||||||
"codemirror": "*",
|
|
||||||
"codemirror-spell-checker": "*",
|
|
||||||
"marked": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/smart-buffer": {
|
"node_modules/smart-buffer": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
||||||
@@ -8844,7 +8886,6 @@
|
|||||||
"version": "20.2.9",
|
"version": "20.2.9",
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
|
||||||
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==",
|
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
@@ -9113,6 +9154,24 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz",
|
||||||
"integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA=="
|
"integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA=="
|
||||||
},
|
},
|
||||||
|
"@types/codemirror": {
|
||||||
|
"version": "5.60.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-5.60.5.tgz",
|
||||||
|
"integrity": "sha512-TiECZmm8St5YxjFUp64LK0c8WU5bxMDt9YaAek1UqUb9swrSCoJhh92fWu1p3mTEqlHjhB5sY7OFBhWroJXZVg==",
|
||||||
|
"requires": {
|
||||||
|
"@types/tern": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/estree": {
|
||||||
|
"version": "0.0.50",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.50.tgz",
|
||||||
|
"integrity": "sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw=="
|
||||||
|
},
|
||||||
|
"@types/marked": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-ZigEmCWdNUU7IjZEuQ/iaimYdDHWHfTe3kg8ORfKjyGYd9RWumPoOJRQXB0bO+XLkNwzCthW3wUIQtANaEZ1ag=="
|
||||||
|
},
|
||||||
"@types/minimist": {
|
"@types/minimist": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",
|
||||||
@@ -9123,6 +9182,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz",
|
||||||
"integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw=="
|
"integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw=="
|
||||||
},
|
},
|
||||||
|
"@types/tern": {
|
||||||
|
"version": "0.23.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.4.tgz",
|
||||||
|
"integrity": "sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg==",
|
||||||
|
"requires": {
|
||||||
|
"@types/estree": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"abbrev": {
|
"abbrev": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
||||||
@@ -9634,9 +9701,10 @@
|
|||||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||||
},
|
},
|
||||||
"bootstrap": {
|
"bootstrap": {
|
||||||
"version": "4.6.0",
|
"version": "4.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.6.1.tgz",
|
||||||
"integrity": "sha512-Io55IuQY3kydzHtbGvQya3H+KorS/M9rSNyfCGCg9WZ4pyT/lCxIlpJgG1GXW/PswzC84Tr2fBYi+7+jFVQQBw=="
|
"integrity": "sha512-0dj+VgI9Ecom+rvvpNZ4MUZJz8dcX7WCX+eTID9+/8HgOkv3dsRzi8BGeZJCQU6flWQVYxwTQnEZFrmJSEO7og==",
|
||||||
|
"requires": {}
|
||||||
},
|
},
|
||||||
"bootstrap-select": {
|
"bootstrap-select": {
|
||||||
"version": "1.13.18",
|
"version": "1.13.18",
|
||||||
@@ -10551,6 +10619,18 @@
|
|||||||
"lodash": "^4.17.10"
|
"lodash": "^4.17.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"easymde": {
|
||||||
|
"version": "2.16.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/easymde/-/easymde-2.16.1.tgz",
|
||||||
|
"integrity": "sha512-FihYgjRsKfhGNk89SHSqxKLC4aJ1kfybPWW6iAmtb5GnXu+tnFPSzSaGBmk1RRlCuhFSjhF0SnIMGVPjEzkr6g==",
|
||||||
|
"requires": {
|
||||||
|
"@types/codemirror": "^5.60.4",
|
||||||
|
"@types/marked": "^4.0.1",
|
||||||
|
"codemirror": "^5.63.1",
|
||||||
|
"codemirror-spell-checker": "1.1.2",
|
||||||
|
"marked": "^4.0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"eazy-logger": {
|
"eazy-logger": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/eazy-logger/-/eazy-logger-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/eazy-logger/-/eazy-logger-3.1.0.tgz",
|
||||||
@@ -11163,11 +11243,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz",
|
||||||
"integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q=="
|
"integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q=="
|
||||||
},
|
},
|
||||||
"flatpickr": {
|
|
||||||
"version": "4.6.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/flatpickr/-/flatpickr-4.6.9.tgz",
|
|
||||||
"integrity": "sha512-F0azNNi8foVWKSF+8X+ZJzz8r9sE1G4hl06RyceIaLvyltKvDl6vqk9Lm/6AUUCi5HWaIjiUbk7UpeE/fOXOpw=="
|
|
||||||
},
|
|
||||||
"flush-write-stream": {
|
"flush-write-stream": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz",
|
||||||
@@ -11178,9 +11253,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"follow-redirects": {
|
"follow-redirects": {
|
||||||
"version": "1.14.7",
|
"version": "1.14.8",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
|
||||||
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==",
|
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"for-in": {
|
"for-in": {
|
||||||
@@ -13175,11 +13250,6 @@
|
|||||||
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA=="
|
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"yargs-parser": {
|
|
||||||
"version": "20.2.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
|
|
||||||
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w=="
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -13328,9 +13398,9 @@
|
|||||||
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
|
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
|
||||||
},
|
},
|
||||||
"moment": {
|
"moment": {
|
||||||
"version": "2.29.1",
|
"version": "2.29.2",
|
||||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
|
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz",
|
||||||
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
|
"integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg=="
|
||||||
},
|
},
|
||||||
"ms": {
|
"ms": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@@ -13348,9 +13418,9 @@
|
|||||||
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ=="
|
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ=="
|
||||||
},
|
},
|
||||||
"nanoid": {
|
"nanoid": {
|
||||||
"version": "3.1.30",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.30.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz",
|
||||||
"integrity": "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ=="
|
"integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA=="
|
||||||
},
|
},
|
||||||
"nanomatch": {
|
"nanomatch": {
|
||||||
"version": "1.2.13",
|
"version": "1.2.13",
|
||||||
@@ -14810,16 +14880,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
|
||||||
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ=="
|
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ=="
|
||||||
},
|
},
|
||||||
"simplemde": {
|
|
||||||
"version": "1.11.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/simplemde/-/simplemde-1.11.2.tgz",
|
|
||||||
"integrity": "sha1-ojo12XjSxA7wfewAjJLwcNjggOM=",
|
|
||||||
"requires": {
|
|
||||||
"codemirror": "*",
|
|
||||||
"codemirror-spell-checker": "*",
|
|
||||||
"marked": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"smart-buffer": {
|
"smart-buffer": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
||||||
@@ -16128,8 +16188,7 @@
|
|||||||
"yargs-parser": {
|
"yargs-parser": {
|
||||||
"version": "20.2.9",
|
"version": "20.2.9",
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
|
||||||
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==",
|
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"yeast": {
|
"yeast": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
"ajax-bootstrap-select": "^1.4.5",
|
"ajax-bootstrap-select": "^1.4.5",
|
||||||
"autocompleter": "^6.1.2",
|
"autocompleter": "^6.1.2",
|
||||||
"autoprefixer": "^10.4.0",
|
"autoprefixer": "^10.4.0",
|
||||||
"bootstrap": "^4.5.2",
|
"bootstrap": "^4.6.1",
|
||||||
"bootstrap-select": "^1.13.17",
|
"bootstrap-select": "^1.13.18",
|
||||||
"clipboard": "^2.0.8",
|
"clipboard": "^2.0.8",
|
||||||
"cssnano": "^5.0.13",
|
"cssnano": "^5.0.13",
|
||||||
"flatpickr": "^4.6.6",
|
"easymde": "^2.16.1",
|
||||||
"fullcalendar": "^5.10.1",
|
"fullcalendar": "^5.10.1",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
@@ -27,11 +27,10 @@
|
|||||||
"html5sortable": "^0.13.3",
|
"html5sortable": "^0.13.3",
|
||||||
"jquery": "^3.6.0",
|
"jquery": "^3.6.0",
|
||||||
"konami": "^1.6.3",
|
"konami": "^1.6.3",
|
||||||
"moment": "^2.27.0",
|
"moment": "^2.29.2",
|
||||||
"node-sass": "^7.0.0",
|
"node-sass": "^7.0.0",
|
||||||
"popper.js": "^1.16.1",
|
"popper.js": "^1.16.1",
|
||||||
"postcss": "^8.4.5",
|
"postcss": "^8.4.5",
|
||||||
"simplemde": "^1.11.2",
|
|
||||||
"uglify-js": "^3.14.5"
|
"uglify-js": "^3.14.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
marked.setOptions({
|
|
||||||
breaks: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
function setupItemTable(items_json) {
|
function setupItemTable(items_json) {
|
||||||
objectitems = JSON.parse(items_json)
|
objectitems = JSON.parse(items_json)
|
||||||
$.each(objectitems, function (key, val) {
|
$.each(objectitems, function (key, val) {
|
||||||
@@ -37,7 +33,8 @@ function updatePrices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupMDE(selector) {
|
function setupMDE(selector) {
|
||||||
editor = new SimpleMDE({
|
editor = new EasyMDE({
|
||||||
|
autoDownloadFontAwesome: false,
|
||||||
element: $(selector)[0],
|
element: $(selector)[0],
|
||||||
forceSync: true,
|
forceSync: true,
|
||||||
toolbar: ["bold", "italic", "strikethrough", "|", "unordered-list", "ordered-list", "|", "link", "|", "preview", "guide"],
|
toolbar: ["bold", "italic", "strikethrough", "|", "unordered-list", "ordered-list", "|", "link", "|", "preview", "guide"],
|
||||||
@@ -120,7 +117,7 @@ $('body').on('submit', '#item-form', function (e) {
|
|||||||
// update the table
|
// update the table
|
||||||
$row = $('#item-' + pk);
|
$row = $('#item-' + pk);
|
||||||
$row.find('.name').html(escapeHtml(fields.name));
|
$row.find('.name').html(escapeHtml(fields.name));
|
||||||
$row.find('.description').html(marked(fields.description));
|
$row.find('.description').html(fields.description);
|
||||||
$row.find('.cost').html(parseFloat(fields.cost).toFixed(2));
|
$row.find('.cost').html(parseFloat(fields.cost).toFixed(2));
|
||||||
$row.find('.quantity').html(fields.quantity);
|
$row.find('.quantity').html(fields.quantity);
|
||||||
|
|
||||||
|
|||||||
@@ -77,13 +77,13 @@
|
|||||||
border-collapse: separate !important;
|
border-collapse: separate !important;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
}
|
}
|
||||||
.table tr th {
|
#event_table tr th {
|
||||||
border-right: 0 !important;
|
border-right: 0 !important;
|
||||||
}
|
}
|
||||||
.table tr td {
|
#event_table tr td {
|
||||||
border-left: 0 !important;
|
border-left: 0 !important;
|
||||||
}
|
}
|
||||||
.table tr td:not(:last-child) {
|
#event_table tr td:not(:last-child) {
|
||||||
border-right: 0 !important;
|
border-right: 0 !important;
|
||||||
}
|
}
|
||||||
@each $color, $value in $theme-colors {
|
@each $color, $value in $theme-colors {
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
color: $gray-100;
|
color: $gray-100;
|
||||||
}
|
}
|
||||||
input:-webkit-autofill,
|
input:-webkit-autofill,
|
||||||
input:-webkit-autofill:hover,
|
input:-webkit-autofill:hover,
|
||||||
input:-webkit-autofill:focus,
|
input:-webkit-autofill:focus,
|
||||||
textarea:-webkit-autofill,
|
textarea:-webkit-autofill,
|
||||||
textarea:-webkit-autofill:hover,
|
textarea:-webkit-autofill:hover,
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
.editor-toolbar > a.active {
|
.editor-toolbar > a.active {
|
||||||
background: $info !important;
|
background: $info !important;
|
||||||
}
|
}
|
||||||
.cm-s-paper {
|
.cm-s-easymde {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: $darktheme;
|
background-color: $darktheme;
|
||||||
border-color: #bbb;
|
border-color: #bbb;
|
||||||
@@ -153,4 +153,7 @@
|
|||||||
.CodeMirror-cursor {
|
.CodeMirror-cursor {
|
||||||
border-color: white !important;
|
border-color: white !important;
|
||||||
}
|
}
|
||||||
|
.modal {
|
||||||
|
overflow-y: auto !important; //Bootstrap Dark Theme overrides this to none for some insane reason so we need to change it back
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,25 @@ $fa-font-path: '/static/fonts';
|
|||||||
@import "node_modules/@fortawesome/fontawesome-free/scss/fontawesome";
|
@import "node_modules/@fortawesome/fontawesome-free/scss/fontawesome";
|
||||||
@import "node_modules/@fortawesome/fontawesome-free/scss/solid";
|
@import "node_modules/@fortawesome/fontawesome-free/scss/solid";
|
||||||
|
|
||||||
|
html {
|
||||||
|
--brand: #3F58AA;
|
||||||
|
scrollbar-color: #3F58AA Canvas !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root { accent-color: var(--brand); }
|
||||||
|
:focus-visible { outline-color: var(--brand); }
|
||||||
|
::selection { background-color: var(--brand); }
|
||||||
|
::marker { color: var(--brand); }
|
||||||
|
|
||||||
|
:is(
|
||||||
|
::-webkit-calendar-picker-indicator,
|
||||||
|
::-webkit-clear-button,
|
||||||
|
::-webkit-inner-spin-button,
|
||||||
|
::-webkit-outer-spin-button
|
||||||
|
) {
|
||||||
|
color: var(--brand);
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and
|
@media screen and
|
||||||
(prefers-reduced-motion: reduce),
|
(prefers-reduced-motion: reduce),
|
||||||
(update: slow) {
|
(update: slow) {
|
||||||
@@ -116,10 +135,6 @@ textarea {
|
|||||||
hyphens: auto;
|
hyphens: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-dialog {
|
|
||||||
z-index: inherit; // bug fix introduced in 52682ce
|
|
||||||
}
|
|
||||||
|
|
||||||
del {
|
del {
|
||||||
background-color: #f2dede;
|
background-color: #f2dede;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
@@ -179,7 +194,7 @@ svg {
|
|||||||
|
|
||||||
span.fas {
|
span.fas {
|
||||||
padding-left: 0.1em !important;
|
padding-left: 0.1em !important;
|
||||||
padding-right: 0.1em !important;
|
padding-right: 0.3em !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
html.embedded {
|
html.embedded {
|
||||||
@@ -256,3 +271,13 @@ html.embedded {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card, .card-header, .btn, input, select, .CodeMirror, .editor-toolbar, .card-img-top {
|
||||||
|
border-radius: 0 !important;
|
||||||
|
border-top-left-radius: 0 !important;
|
||||||
|
border-top-right-radius: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bootstrap-select, button.btn.dropdown-toggle.bs-placeholder.btn-light {
|
||||||
|
padding-right: 1rem !important;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<form action="" method="post">{% csrf_token %}
|
<form action="" method="post">{% csrf_token %}
|
||||||
<p>The following objects will be merged. Please select the 'master' record which you would like to keep. Other records will have associated events moved to the 'master' copy, and then will be deleted.</p>
|
<p>The following objects will be merged. Please select the 'master' record which you would like to keep. This may take some time.</p>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
{% for form in forms %}
|
{% for form in forms %}
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
<th>{{ field.label }}</th>
|
<th>{{ field.label }}</th>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="radio" name="master" value="{{form.instance.pk|unlocalize}}"></td>
|
<td><input type="radio" name="master" value="{{form.instance.pk|unlocalize}}"></td>
|
||||||
<td>{{form.instance.pk}}</td>
|
<td>{{form.instance.pk}}</td>
|
||||||
@@ -37,4 +37,4 @@
|
|||||||
<input type="submit" value="Merge them" />
|
<input type="submit" value="Merge them" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
{% if not debug %}
|
|
||||||
<script>
|
|
||||||
(function (i, s, o, g, r, a, m) {
|
|
||||||
i['GoogleAnalyticsObject'] = r;
|
|
||||||
i[r] = i[r] || function () {
|
|
||||||
(i[r].q = i[r].q || []).push(arguments)
|
|
||||||
}, i[r].l = 1 * new Date();
|
|
||||||
a = s.createElement(o),
|
|
||||||
m = s.getElementsByTagName(o)[0];
|
|
||||||
a.async = 1;
|
|
||||||
a.src = g;
|
|
||||||
m.parentNode.insertBefore(a, m)
|
|
||||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
|
||||||
ga('create', 'UA-43285686-12', 'auto');
|
|
||||||
{% if user.is_authenticated %}
|
|
||||||
ga('set', '&uid', {{ user.pk }});
|
|
||||||
{% endif %}
|
|
||||||
ga('require', 'linkid', 'linkid.js');
|
|
||||||
ga('send', 'pageview');
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
@@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<a class="skip-link" href='#main'>Skip to content</a>
|
<a class="skip-link" href='#main'>Skip to content</a>
|
||||||
{% include "analytics.html" %}
|
|
||||||
{% block navbar %}
|
{% block navbar %}
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark" role="navigation">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark" role="navigation">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -79,7 +78,6 @@
|
|||||||
<div class="modal fade" id="modal" role="dialog" tabindex=-1></div>
|
<div class="modal fade" id="modal" role="dialog" tabindex=-1></div>
|
||||||
|
|
||||||
<script src="{% static 'js/base.js' %}"></script>
|
<script src="{% static 'js/base.js' %}"></script>
|
||||||
<script src="{% static 'js/marked.min.js' %}"></script>
|
|
||||||
{% include 'partials/dark_theme.html' %}
|
{% include 'partials/dark_theme.html' %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{% include "analytics.html" %}
|
|
||||||
<div class="embed_container">
|
<div class="embed_container">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{% extends override|default:"base_rigs.html" %}
|
{% extends override|default:"base_rigs.html" %}
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
{% load button from filters %}
|
{% load button from filters %}
|
||||||
|
{% load markdown_tags %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
<dd>{{ object.address|linebreaksbr }}</dd>
|
<dd>{{ object.address|linebreaksbr }}</dd>
|
||||||
|
|
||||||
<dt>Notes</dt>
|
<dt>Notes</dt>
|
||||||
<dd>{{ object.notes|linebreaksbr }}</dd>
|
<dd>{{ object.notes|markdown }}</dd>
|
||||||
|
|
||||||
{% if object.three_phase_available is not None %}
|
{% if object.three_phase_available is not None %}
|
||||||
<dt>Three Phase Available</dt>
|
<dt>Three Phase Available</dt>
|
||||||
|
|||||||
@@ -1,6 +1,27 @@
|
|||||||
{% extends override|default:"base_rigs.html" %}
|
{% extends override|default:"base_rigs.html" %}
|
||||||
{% load button from filters %}
|
{% load button from filters %}
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'css/easymde.min.css' %}">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block preload_js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/easymde.min.js' %}"></script>
|
||||||
|
<script src="{% static 'js/interaction.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
setupMDE('.md-enabled');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
@@ -43,7 +64,7 @@
|
|||||||
<label for="{{ form.notes.id_for_label }}"
|
<label for="{{ form.notes.id_for_label }}"
|
||||||
class="col-sm-2 control-label">{{ form.notes.label }}</label>
|
class="col-sm-2 control-label">{{ form.notes.label }}</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
{% render_field form.notes class+="form-control" placeholder=form.notes.label %}
|
{% render_field form.notes class+="form-control md-enabled" placeholder=form.notes.label %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if form.three_phase_available is not None %}
|
{% if form.three_phase_available is not None %}
|
||||||
|
|||||||
@@ -10,43 +10,44 @@
|
|||||||
<h2 class="col-sm-12 pb-3">Welcome back {{ user.get_full_name }}, there {%if rig_count == 1 %}is one rig coming up{%else%}are {{ rig_count|apnumber }} rigs coming up.{%endif%}</h2>
|
<h2 class="col-sm-12 pb-3">Welcome back {{ user.get_full_name }}, there {%if rig_count == 1 %}is one rig coming up{%else%}are {{ rig_count|apnumber }} rigs coming up.{%endif%}</h2>
|
||||||
<div class="col-sm-4 mb-3">
|
<div class="col-sm-4 mb-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<img class="card-img-top" src="{% static 'imgs/rigs.jpg' %}" alt="" style="height: 150px; object-fit: cover;">
|
<img class="card-img-top d-none d-sm-block" src="{% static 'imgs/rigs.jpg' %}" alt="Some lights and haze, very purple" style="height: 150px; object-fit: cover;">
|
||||||
<h4 class="card-header">Rigboard</h4>
|
<h4 class="card-header">Rigboard</h4>
|
||||||
<div class="list-group list-group-flush">
|
<div class="list-group list-group-flush">
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'rigboard' %}"><span class="fas fa-list align-middle"></span><span class="align-middle"> Rigboard</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'rigboard' %}"><span class="fas fa-list align-middle"></span><span class="align-middle"> Rigboard</span></a>
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'web_calendar' %}"><span class="fas fa-calendar align-middle"></span><span class="align-middle"> Calendar</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'web_calendar' %}"><span class="fas fa-calendar align-middle"></span><span class="align-middle"> Calendar</span></a>
|
||||||
{% if perms.RIGS.add_event %}
|
{% if perms.RIGS.add_event %}
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'event_create' %}"><span class="fas fa-plus align-middle"></span><span class="align-middle"> New Event</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'event_create' %}"><span class="fas fa-plus align-middle text-success"></span><span class="align-middle"> New Event</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<a class="list-group-item list-group-item-action" href="{% url 'event_archive' %}"><span class="fas fa-book align-middle"></span><span class="align-middle"> Event Archive</span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4 mb-3">
|
<div class="col-sm-4 mb-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
{% now "m-d" as todays_date %}
|
{% now "m-d" as todays_date %}
|
||||||
<img class="card-img-top" src="{% if todays_date == '04-01' %}{% static 'imgs/tappytaptap.gif' %}{%else%}{% static 'imgs/assets.jpg' %}{%endif%}" alt="" style="height: 150px; object-fit: cover;">
|
<img class="card-img-top d-none d-sm-block" src="{% if todays_date == '04-01' %}{% static 'imgs/tappytaptap.gif' %}{%else%}{% static 'imgs/assets.jpg' %}{%endif%}" alt="M32 sound desk close up of the faders" style="height: 150px; object-fit: cover;">
|
||||||
<h4 class="card-header">Asset Database</h4>
|
<h4 class="card-header">Asset Database</h4>
|
||||||
<div class="list-group list-group-flush">
|
<div class="list-group list-group-flush">
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'asset_index' %}"><span class="fas fa-tag align-middle"></span><span class="align-middle"> Asset List</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'asset_index' %}"><span class="fas fa-tag align-middle"></span><span class="align-middle"> Asset List</span></a>
|
||||||
{% if perms.assets.add_asset %}
|
{% if perms.assets.add_asset %}
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'asset_create' %}"><span class="fas fa-plus align-middle"></span><span class="align-middle"> New Asset</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'asset_create' %}"><span class="fas fa-plus align-middle text-success"></span><span class="align-middle"> New Asset</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'supplier_list' %}"><span class="fas fa-parachute-box align-middle"></span><span class="align-middle"> Supplier List</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'supplier_list' %}"><span class="fas fa-parachute-box align-middle"></span><span class="align-middle"> Supplier List</span></a>
|
||||||
{% if perms.assets.add_supplier %}
|
{% if perms.assets.add_supplier %}
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'supplier_create' %}"><span class="fas fa-plus align-middle"></span><span class="align-middle"> New Supplier</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'supplier_create' %}"><span class="fas fa-plus align-middle text-success"></span><span class="align-middle"> New Supplier</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4 mb-3">
|
<div class="col-sm-4 mb-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<img class="card-img-top" src="{% static 'imgs/training.jpg' %}" alt="" style="height: 150px; object-fit: cover;">
|
<img class="card-img-top d-none d-sm-block" src="{% static 'imgs/training.jpg' %}" alt="People watching a presentation" style="height: 150px; object-fit: cover;">
|
||||||
<h4 class="card-header">Training Database</h4>
|
<h4 class="card-header">Training Database</h4>
|
||||||
<div class="list-group list-group-flush">
|
<div class="list-group list-group-flush">
|
||||||
<a class="list-group-item list-group-item-action text-info" href="{% url 'trainee_detail' request.user.pk %}"><span class="fas fa-file-signature align-middle"></span><span class="align-middle"> My Training Record</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'trainee_detail' request.user.pk %}"><span class="fas fa-file-signature align-middle text-info"></span><span class="align-middle"> My Training Record</span></a>
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'trainee_list' %}"><span class="fas fa-users"></span> Trainee List</a>
|
<a class="list-group-item list-group-item-action" href="{% url 'trainee_list' %}"><span class="fas fa-users"></span><span class="align-middle"> Trainee List</span></a>
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'level_list' %}"><span class="fas fa-layer-group"></span> Level List</a></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'level_list' %}"><span class="fas fa-layer-group"></span> <span class="align-middle">Level List</span></a>
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'item_list' %}"><span class="fas fa-sitemap"></span> Item List</a></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'item_list' %}"><span class="fas fa-sitemap"></span> <span class="align-middle">Item List</span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -57,6 +58,7 @@
|
|||||||
<a class="list-group-item list-group-item-action" href="https://forum.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><span class="fas fa-comment-alt text-primary align-middle"></span><span class="align-middle"> TEC Forum</span></a>
|
<a class="list-group-item list-group-item-action" href="https://forum.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><span class="fas fa-comment-alt text-primary align-middle"></span><span class="align-middle"> TEC Forum</span></a>
|
||||||
<a class="list-group-item list-group-item-action" href="//nottinghamtec.sharepoint.com" target="_blank" rel="noopener noreferrer"><span class="fas fa-folder text-info align-middle"></span><span class="align-middle"> TEC Sharepoint</span></a>
|
<a class="list-group-item list-group-item-action" href="//nottinghamtec.sharepoint.com" target="_blank" rel="noopener noreferrer"><span class="fas fa-folder text-info align-middle"></span><span class="align-middle"> TEC Sharepoint</span></a>
|
||||||
<a class="list-group-item list-group-item-action" href="//wiki.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><span class="fas fa-pen-square align-middle"></span><span class="align-middle"> TEC Wiki</span></a>
|
<a class="list-group-item list-group-item-action" href="//wiki.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><span class="fas fa-pen-square align-middle"></span><span class="align-middle"> TEC Wiki</span></a>
|
||||||
|
<a class="list-group-item list-group-item-action" href="https://secure.jotformeu.com/UoNSU/accident_report_form?studentGroup=Media+or+Service+Group&mediaserviceGroup=TEC" target="_blank" rel="noopener noreferrer"><span class="fas fa-heartbeat align-middle text-danger"></span><span class="align-middle"> H&S Report Form</span></a>
|
||||||
{% if perms.RIGS.change_event %}
|
{% if perms.RIGS.change_event %}
|
||||||
<a class="list-group-item list-group-item-action" href="//members.nottinghamtec.co.uk/price" target="_blank" rel="noopener noreferrer"><span class="fas fa-pound-sign text-warning align-middle"></span><span class="align-middle"> Price List</span></a>
|
<a class="list-group-item list-group-item-action" href="//members.nottinghamtec.co.uk/price" target="_blank" rel="noopener noreferrer"><span class="fas fa-pound-sign text-warning align-middle"></span><span class="align-middle"> Price List</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
<script>
|
<script>
|
||||||
if({{ request.user.dark_theme|lower|default:'false' }} || window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
if({{ request.user.dark_theme|lower|default:'false' }} || window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||||
$('<link>').prependTo('head').attr({type : 'text/css', rel : 'stylesheet'}).attr('href', '{% static "css/dark_screen.css" %}');
|
document.querySelector('head').innerHTML += '<link rel="stylesheet" href="{% static "css/dark_screen.css" %}" type="text/css"/>';
|
||||||
document.body.setAttribute('data-theme', 'dark');
|
document.body.setAttribute('data-theme', 'dark');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
{% load static %}
|
|
||||||
<script>
|
|
||||||
function initDatetime() {
|
|
||||||
$('input[type=datetime-local]').not(':disabled').flatpickr({
|
|
||||||
dateFormat: 'Y-m-dTH:m',
|
|
||||||
enableTime: true,
|
|
||||||
allowInput: true,
|
|
||||||
altInput: true,
|
|
||||||
altFormat: "d/m/y H:m",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$(document).ready(function () {
|
|
||||||
function supportsDateTime() {
|
|
||||||
var input = document.createElement('input');
|
|
||||||
input.setAttribute('type','datetime-local');
|
|
||||||
return input.type !== "text";
|
|
||||||
}
|
|
||||||
//Firefox reports support for datetime-local without properly supporting it. Bah.
|
|
||||||
if(!supportsDateTime() || navigator.userAgent.toLowerCase().indexOf('firefox') > -1){
|
|
||||||
$('<link>')
|
|
||||||
.appendTo('head')
|
|
||||||
.attr({type : 'text/css', rel : 'stylesheet'})
|
|
||||||
.attr('href', '{% static "css/flatpickr.css" %}');
|
|
||||||
$.when(
|
|
||||||
$.getScript( '{% static "js/flatpickr.min.js" %}' ),
|
|
||||||
$.Deferred(function(deferred){
|
|
||||||
$(deferred.resolve);
|
|
||||||
})
|
|
||||||
).done(function(){
|
|
||||||
initDatetime();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1,38 +1,11 @@
|
|||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<form id="searchForm" class="form-inline flex-nowrap mx-md-3 px-2 border border-light rounded w-75" role="form" method="GET" action="{% url 'event_archive' %}">
|
<form id="searchForm" class="form-inline flex-nowrap mx-md-3 px-2 border border-light rounded" role="form" method="GET" action="{% url 'search' %}">
|
||||||
<div class="input-group input-group-sm flex-nowrap">
|
<div class="input-group">
|
||||||
<div class="input-group-prepend">
|
<input id="id_search_input" type="search" name="q" class="form-control form-control-sm" placeholder="Search..." value="{{ request.GET.q }}" />
|
||||||
<input id="id_search_input" type="search" name="q" class="form-control form-control-sm" placeholder="Search..." value="{{ request.GET.q }}" />
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-info form-control form-control-sm btn-sm"><span class="fas fa-search"></span><span class="sr-only"> Search</span></button>
|
||||||
</div>
|
</div>
|
||||||
<select id="search-options" class="custom-select form-control" style="border-top-right-radius: 0px; border-bottom-right-radius: 0px; width: 15ch;">
|
|
||||||
<option selected data-action="{% url 'event_archive' %}" href="#">Events</option>
|
|
||||||
<option data-action="{% url 'person_list' %}" href="#">People</option>
|
|
||||||
<option data-action="{% url 'organisation_list' %}" href="#">Organisations</option>
|
|
||||||
<option data-action="{% url 'venue_list' %}" href="#">Venues</option>
|
|
||||||
{% if perms.RIGS.view_invoice %}
|
|
||||||
<option data-action="{% url 'invoice_archive' %}" href="#">Invoices</option>
|
|
||||||
{% endif %}
|
|
||||||
<option data-action="{% url 'asset_list' %}" href="#">Assets</option>
|
|
||||||
<option data-action="{% url 'supplier_list' %}" href="#">Suppliers</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-info form-control form-control-sm btn-sm w-25" style="border-top-left-radius: 0px;border-bottom-left-radius: 0px;"><span class="fas fa-search"></span><span class="sr-only"> Search</span></button>
|
|
||||||
<a href="{% url 'search_help' %}" class="nav-link modal-href ml-1"><span class="fas fa-question-circle"></span></a>
|
<a href="{% url 'search_help' %}" class="nav-link modal-href ml-1"><span class="fas fa-question-circle"></span></a>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% block js %}
|
|
||||||
<script>
|
|
||||||
$('#search-options').change(function(){
|
|
||||||
$('#searchForm').attr('action', $(this).children('option:selected').data('action'));
|
|
||||||
});
|
|
||||||
$(document).ready(function(){
|
|
||||||
$('#id_search_input').keypress(function (e) {
|
|
||||||
if (e.which == 13) {
|
|
||||||
$('#searchForm').attr('action', $('#search-options option').first().data('action')).submit();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|||||||
48
templates/search_results.html
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{% extends "base_rigs.html" %}
|
||||||
|
|
||||||
|
{% load to_class_name from filters %}
|
||||||
|
{% load markdown_tags %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% include 'partials/search.html' %}
|
||||||
|
{% for object in object_list %}
|
||||||
|
{% with object|to_class_name as klass %}
|
||||||
|
<div class="card m-2">
|
||||||
|
<h4 class="card-header"><a href='{{ object.get_absolute_url }}'>[{{ klass }}] {{ object }}</a>
|
||||||
|
<small>
|
||||||
|
{% if klass == "Event" %}
|
||||||
|
{% if object.venue %}
|
||||||
|
<strong>Venue:</strong> {{ object.venue }}
|
||||||
|
{% endif %}
|
||||||
|
{% if object.is_rig %}
|
||||||
|
<strong>Client:</strong> {{ object.person.name }}
|
||||||
|
{% if object.organisation %}
|
||||||
|
for {{ object.organisation.name }}
|
||||||
|
{% endif %}
|
||||||
|
{% if object.dry_hire %}(Dry Hire){% endif %}
|
||||||
|
{% else %}
|
||||||
|
<strong>Non-Rig</strong>
|
||||||
|
{% endif %}
|
||||||
|
<strong>Times:</strong>
|
||||||
|
{{ object.start_date|date:"D d/m/Y" }}
|
||||||
|
{% if object.has_start_time %}
|
||||||
|
{{ object.start_time|date:"H:i" }}
|
||||||
|
{% endif %}
|
||||||
|
{% if object.end_date or object.has_end_time %}
|
||||||
|
–
|
||||||
|
{% endif %}
|
||||||
|
{% if object.end_date and object.end_date != object.start_date %}
|
||||||
|
{{ object.end_date|date:"D d/m/Y" }}
|
||||||
|
{% endif %}
|
||||||
|
{% if object.has_end_time %}
|
||||||
|
{{ object.end_time|date:"H:i" }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</small>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
{% endwith %}
|
||||||
|
{% empty %}
|
||||||
|
<h3 class="py-3 text-warning">No results found</h3>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock content %}
|
||||||
@@ -2,10 +2,14 @@ from django.contrib import admin
|
|||||||
from training import models
|
from training import models
|
||||||
from reversion.admin import VersionAdmin
|
from reversion.admin import VersionAdmin
|
||||||
|
|
||||||
# admin.site.register(models.Trainee, VersionAdmin)
|
|
||||||
admin.site.register(models.TrainingCategory, VersionAdmin)
|
admin.site.register(models.TrainingCategory, VersionAdmin)
|
||||||
admin.site.register(models.TrainingItem, VersionAdmin)
|
admin.site.register(models.TrainingItem, VersionAdmin)
|
||||||
admin.site.register(models.TrainingLevel, VersionAdmin)
|
admin.site.register(models.TrainingLevel, VersionAdmin)
|
||||||
admin.site.register(models.TrainingItemQualification, VersionAdmin)
|
|
||||||
admin.site.register(models.TrainingLevelQualification, VersionAdmin)
|
admin.site.register(models.TrainingLevelQualification, VersionAdmin)
|
||||||
admin.site.register(models.TrainingLevelRequirement, VersionAdmin)
|
admin.site.register(models.TrainingLevelRequirement, VersionAdmin)
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(models.TrainingItemQualification)
|
||||||
|
class TrainingItemQualificationAdmin(VersionAdmin):
|
||||||
|
list_display = ['__str__', 'trainee']
|
||||||
|
|||||||
@@ -1,36 +1,50 @@
|
|||||||
|
import datetime
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from training import models
|
from training import models
|
||||||
from RIGS.models import Profile
|
|
||||||
|
|
||||||
|
|
||||||
class QualificationForm(forms.ModelForm):
|
class QualificationForm(forms.ModelForm):
|
||||||
|
related_models = {
|
||||||
|
'item': models.TrainingItem,
|
||||||
|
'supervisor': models.Trainee
|
||||||
|
}
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.TrainingItemQualification
|
model = models.TrainingItemQualification
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
pk = kwargs.pop('pk', None)
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.fields['trainee'].initial = Profile.objects.get(pk=pk)
|
|
||||||
self.fields['date'].widget.format = '%Y-%m-%d'
|
|
||||||
|
|
||||||
def clean_date(self):
|
def clean_date(self):
|
||||||
date = self.cleaned_data['date']
|
date = self.cleaned_data.get('date')
|
||||||
if date > date.today():
|
if date > date.today():
|
||||||
raise forms.ValidationError('Qualification date may not be in the future')
|
raise forms.ValidationError('Qualification date may not be in the future')
|
||||||
return date
|
return date
|
||||||
|
|
||||||
def clean_supervisor(self):
|
def clean_supervisor(self):
|
||||||
supervisor = self.cleaned_data['supervisor']
|
supervisor = self.cleaned_data.get('supervisor')
|
||||||
if supervisor.pk == self.cleaned_data['trainee'].pk:
|
if supervisor.pk == self.cleaned_data.get('trainee').pk:
|
||||||
raise forms.ValidationError('One may not supervise oneself...')
|
raise forms.ValidationError('One may not supervise oneself...')
|
||||||
if not supervisor.is_supervisor:
|
|
||||||
raise forms.ValidationError('Selected supervisor must actually *be* a supervisor...')
|
|
||||||
return supervisor
|
return supervisor
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['date'].widget.format = '%Y-%m-%d'
|
||||||
|
|
||||||
|
|
||||||
|
class AddQualificationForm(QualificationForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
pk = kwargs.pop('pk', None)
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
if pk:
|
||||||
|
self.fields['trainee'].initial = models.Trainee.objects.get(pk=pk)
|
||||||
|
|
||||||
|
|
||||||
class RequirementForm(forms.ModelForm):
|
class RequirementForm(forms.ModelForm):
|
||||||
|
related_models = {
|
||||||
|
'item': models.TrainingItem
|
||||||
|
}
|
||||||
|
|
||||||
depth = forms.ChoiceField(choices=models.TrainingItemQualification.CHOICES)
|
depth = forms.ChoiceField(choices=models.TrainingItemQualification.CHOICES)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -41,3 +55,26 @@ class RequirementForm(forms.ModelForm):
|
|||||||
pk = kwargs.pop('pk', None)
|
pk = kwargs.pop('pk', None)
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['level'].initial = models.TrainingLevel.objects.get(pk=pk)
|
self.fields['level'].initial = models.TrainingLevel.objects.get(pk=pk)
|
||||||
|
|
||||||
|
|
||||||
|
class SessionLogForm(forms.Form):
|
||||||
|
trainees = forms.ModelMultipleChoiceField(models.Trainee.objects.all())
|
||||||
|
items_0 = forms.ModelMultipleChoiceField(models.TrainingItem.objects.all(), required=False)
|
||||||
|
items_1 = forms.ModelMultipleChoiceField(models.TrainingItem.objects.all(), required=False)
|
||||||
|
items_2 = forms.ModelMultipleChoiceField(models.TrainingItem.objects.all(), required=False)
|
||||||
|
supervisor = forms.ModelChoiceField(models.Trainee.objects.all())
|
||||||
|
date = forms.DateField(initial=datetime.date.today)
|
||||||
|
notes = forms.CharField(required=False, widget=forms.Textarea)
|
||||||
|
|
||||||
|
related_models = {
|
||||||
|
'supervisor': models.Trainee
|
||||||
|
}
|
||||||
|
|
||||||
|
def clean_date(self):
|
||||||
|
return QualificationForm.clean_date(self)
|
||||||
|
|
||||||
|
def clean_supervisor(self):
|
||||||
|
supervisor = self.cleaned_data['supervisor']
|
||||||
|
if supervisor in self.cleaned_data.get('trainees', []):
|
||||||
|
raise forms.ValidationError('One may not supervise oneself...')
|
||||||
|
return supervisor
|
||||||
|
|||||||