mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-08 07:59:42 +00:00
Compare commits
86 Commits
data-inges
...
08a55644c5
| Author | SHA1 | Date | |
|---|---|---|---|
|
08a55644c5
|
|||
|
b3939d8426
|
|||
|
f775cee7dd
|
|||
|
f5d875d153
|
|||
|
f88f418503
|
|||
|
f3d9646607
|
|||
|
798689403d
|
|||
|
d1069a1745
|
|||
|
238d53a547
|
|||
|
8756e7f880
|
|||
|
25c9cf25f7
|
|||
|
ad66f434de
|
|||
|
1aae2bff28
|
|||
|
9302cccd58
|
|||
|
123c8bfd80
|
|||
|
02af3870aa
|
|||
|
6d3a861df5
|
|||
|
0e07c50c18
|
|||
|
8505d5e93a
|
|||
|
ff780f2042
|
|||
|
4a6d69c002
|
|||
|
28a70667c2
|
|||
|
5edb61f243
|
|||
|
4e4492bc01
|
|||
|
697024e91b
|
|||
|
b5e80382b9
|
|||
|
ffbcfe28a9
|
|||
|
10af465a06
|
|||
|
f1af5925b1
|
|||
|
b3adadceff
|
|||
|
2044cbdac2
|
|||
|
a789184c1c
|
|||
|
cebff5adda
|
|||
| cc538c659c | |||
| f3409d0680 | |||
| 1a30a418b1 | |||
| 3aeafde96e | |||
| f4a163f63c | |||
| e14e250896 | |||
| 59a9fd5bb4 | |||
| 925498be02 | |||
| 6c9e360927 | |||
| c02e2e6bbf | |||
| be5aa892f0 | |||
| 23ac9fb62a | |||
| 7f05468483 | |||
| 5a36e33bf0 | |||
| b3ceed777e | |||
| a7119599ca | |||
| 2396e27943 | |||
| 8204fdae1f | |||
| 0b0043f6f7 | |||
| 5a8011a8e3 | |||
| 7062ccd5f8 | |||
| 9b525759f4 | |||
| a9b034255e | |||
| 6676183443 | |||
| 3f93cebf41 | |||
| 603e919ad0 | |||
| a0b70a3cac | |||
| a11e32252f | |||
| e48e016cb9 | |||
| ef1d9868da | |||
| 788fb3efe6 | |||
| 4f912932ca | |||
| 0598612c15 | |||
| 656f9fdd25 | |||
| ccda38918c | |||
| a1edf80dd0 | |||
| 83fe526cbd | |||
| 1d63bd940d | |||
| c090163f40 | |||
| baa3b2c9c6 | |||
| 462a16ec42 | |||
| 6cb3d1855a | |||
| 9279131edf | |||
| 3853ad0871 | |||
| 7eea868575 | |||
| fc6e66c7f5 | |||
| 01ed05ecd9 | |||
| 20e5d25130 | |||
| 11db880ac3 | |||
| 87caab6c8e | |||
| d79366d2e6 | |||
| 10f2152d8b | |||
| 0154ecb6d8 |
14
.github/workflows/deploy.yml
vendored
14
.github/workflows/deploy.yml
vendored
@@ -1,14 +0,0 @@
|
|||||||
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"
|
|
||||||
5
.github/workflows/django.yml
vendored
5
.github/workflows/django.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.9.1
|
python-version: 3.9
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
id: pcache
|
id: pcache
|
||||||
with:
|
with:
|
||||||
@@ -27,7 +27,8 @@ jobs:
|
|||||||
${{ runner.os }}-pipenv-
|
${{ runner.os }}-pipenv-
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip pipenv
|
python -m pip install --upgrade pip
|
||||||
|
pip install pipenv
|
||||||
pipenv install -d
|
pipenv install -d
|
||||||
# if: steps.pcache.outputs.cache-hit != 'true'
|
# if: steps.pcache.outputs.cache-hit != 'true'
|
||||||
- name: Cache Static Files
|
- name: Cache Static Files
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -26,7 +26,6 @@ var/
|
|||||||
.installed.cfg
|
.installed.cfg
|
||||||
*.egg
|
*.egg
|
||||||
node_modules/
|
node_modules/
|
||||||
data/
|
|
||||||
|
|
||||||
# Continer extras
|
# Continer extras
|
||||||
.vagrant
|
.vagrant
|
||||||
|
|||||||
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
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"]
|
||||||
26
Pipfile
26
Pipfile
@@ -19,10 +19,11 @@ cssselect = "~=1.1.0"
|
|||||||
cssutils = "~=1.0.2"
|
cssutils = "~=1.0.2"
|
||||||
dj-database-url = "~=0.5.0"
|
dj-database-url = "~=0.5.0"
|
||||||
dj-static = "~=0.0.6"
|
dj-static = "~=0.0.6"
|
||||||
Django = "~=3.2"
|
Django = "~=3.1.5"
|
||||||
django-debug-toolbar = "~=3.2"
|
django-debug-toolbar = "~=3.2"
|
||||||
django-filter = "~=2.4.0"
|
django-filter = "~=2.4.0"
|
||||||
django-ical = "~=1.7.1"
|
django-ical = "~=1.7.1"
|
||||||
|
django-recaptcha = "~=2.0.6"
|
||||||
django-recurrence = "~=1.10.3"
|
django-recurrence = "~=1.10.3"
|
||||||
django-registration-redux = "~=2.9"
|
django-registration-redux = "~=2.9"
|
||||||
django-reversion = "~=3.0.9"
|
django-reversion = "~=3.0.9"
|
||||||
@@ -33,36 +34,38 @@ 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"
|
importlib-metadata = "~=3.4.0"
|
||||||
|
lxml = "~=4.6.2"
|
||||||
Markdown = "~=3.3.3"
|
Markdown = "~=3.3.3"
|
||||||
msgpack = "~=1.0.2"
|
msgpack = "~=1.0.2"
|
||||||
pep517 = "~=0.9.1"
|
pep517 = "~=0.9.1"
|
||||||
Pillow = "~=9.0.0"
|
Pillow = "~=8.1.0"
|
||||||
premailer = "~=3.7.0"
|
premailer = "~=3.7.0"
|
||||||
progress = "~=1.5"
|
progress = "~=1.5"
|
||||||
psutil = "~=5.8.0"
|
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.27.5"
|
PyPDF2 = "~=1.26.0"
|
||||||
PyPOM = "~=2.2.0"
|
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 = "*"
|
reportlab = "~=3.5.59"
|
||||||
requests = "~=2.25.1"
|
requests = "~=2.25.1"
|
||||||
retrying = "~=1.3.3"
|
retrying = "~=1.3.3"
|
||||||
simplejson = "~=3.17.2"
|
simplejson = "~=3.17.2"
|
||||||
six = "~=1.15.0"
|
six = "~=1.15.0"
|
||||||
soupsieve = "~=2.1"
|
soupsieve = "~=2.1"
|
||||||
sqlparse = "~=0.4.2"
|
sqlparse = "~=0.4.1"
|
||||||
static3 = "~=0.7.0"
|
static3 = "~=0.7.0"
|
||||||
svg2rlg = "~=0.3"
|
svg2rlg = "~=0.3"
|
||||||
tini = "~=3.0.1"
|
tini = "~=3.0.1"
|
||||||
tornado = "~=6.1"
|
tornado = "~=6.1"
|
||||||
urllib3 = "~=1.26.5"
|
urllib3 = "~=1.26.2"
|
||||||
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"
|
||||||
@@ -74,14 +77,6 @@ zipp = "~=3.4.0"
|
|||||||
"zope.schema" = "~=6.0.1"
|
"zope.schema" = "~=6.0.1"
|
||||||
sentry-sdk = "*"
|
sentry-sdk = "*"
|
||||||
diff-match-patch = "*"
|
diff-match-patch = "*"
|
||||||
python-barcode = "*"
|
|
||||||
django-hCaptcha = "*"
|
|
||||||
importlib-metadata = "*"
|
|
||||||
django-hcaptcha = "*"
|
|
||||||
"z3c.rml" = "*"
|
|
||||||
pikepdf = "*"
|
|
||||||
django-queryable-properties = "*"
|
|
||||||
django-mass-edit = "*"
|
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
selenium = "~=3.141.0"
|
selenium = "~=3.141.0"
|
||||||
@@ -93,7 +88,6 @@ pytest-django = "*"
|
|||||||
pluggy = "*"
|
pluggy = "*"
|
||||||
pytest-splinter = "*"
|
pytest-splinter = "*"
|
||||||
pytest = "*"
|
pytest = "*"
|
||||||
pytest-reverse = "*"
|
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.9"
|
python_version = "3.9"
|
||||||
|
|||||||
1322
Pipfile.lock
generated
1322
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -9,8 +9,9 @@ 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'] = f"{request.scheme}://{request.META['HTTP_HOST']}{reverse(oembed_view, kwargs=kwargs)}"
|
context['oembed_url'] = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'],
|
||||||
context['login_url'] = f"{login_url}?{REDIRECT_FIELD_NAME}={request.get_full_path()}"
|
reverse(oembed_view, kwargs=kwargs))
|
||||||
|
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
|
||||||
|
|
||||||
@@ -24,7 +25,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(f'{login_url}?{REDIRECT_FIELD_NAME}={request.get_full_path()}')
|
return HttpResponseRedirect('%s?%s=%s' % (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__
|
||||||
@@ -54,7 +55,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(f'{login_url}?{REDIRECT_FIELD_NAME}={request.get_full_path()}')
|
return HttpResponseRedirect('%s?%s=%s' % (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
|
||||||
|
|||||||
@@ -61,14 +61,12 @@ INSTALLED_APPS = (
|
|||||||
'users',
|
'users',
|
||||||
'RIGS',
|
'RIGS',
|
||||||
'assets',
|
'assets',
|
||||||
'training',
|
|
||||||
|
|
||||||
'debug_toolbar',
|
'debug_toolbar',
|
||||||
'registration',
|
'registration',
|
||||||
'reversion',
|
'reversion',
|
||||||
|
'captcha',
|
||||||
'widget_tweaks',
|
'widget_tweaks',
|
||||||
'hcaptcha',
|
|
||||||
'massadmin',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE = (
|
MIDDLEWARE = (
|
||||||
@@ -188,9 +186,12 @@ LOGOUT_URL = '/user/logout/'
|
|||||||
|
|
||||||
ACCOUNT_ACTIVATION_DAYS = 7
|
ACCOUNT_ACTIVATION_DAYS = 7
|
||||||
|
|
||||||
# CAPTCHA settings
|
# reCAPTCHA settings
|
||||||
HCAPTCHA_SITEKEY = env('HCAPTCHA_SITEKEY', '10000000-ffff-ffff-ffff-000000000001')
|
RECAPTCHA_PUBLIC_KEY = env('RECAPTCHA_PUBLIC_KEY', default="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI") # If not set, use development key
|
||||||
HCAPTCHA_SECRET = env('HCAPTCHA_SECRET', '0x0000000000000000000000000000000000000000')
|
RECAPTCHA_PRIVATE_KEY = env('RECAPTCHA_PUBLIC_KEY', default="6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe") # If not set, use development key
|
||||||
|
NOCAPTCHA = True
|
||||||
|
|
||||||
|
SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error']
|
||||||
|
|
||||||
# Email
|
# Email
|
||||||
EMAILER_TEST = False
|
EMAILER_TEST = False
|
||||||
@@ -261,5 +262,3 @@ USE_GRAVATAR = True
|
|||||||
|
|
||||||
TERMS_OF_HIRE_URL = "http://www.nottinghamtec.co.uk/terms.pdf"
|
TERMS_OF_HIRE_URL = "http://www.nottinghamtec.co.uk/terms.pdf"
|
||||||
AUTHORISATION_NOTIFICATION_ADDRESS = 'productions@nottinghamtec.co.uk'
|
AUTHORISATION_NOTIFICATION_ADDRESS = 'productions@nottinghamtec.co.uk'
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class BootstrapSelectElement(Region):
|
|||||||
return [self.BootstrapSelectOption(self, i) for i in options]
|
return [self.BootstrapSelectOption(self, i) for i in options]
|
||||||
|
|
||||||
def set_option(self, name, selected):
|
def set_option(self, name, selected):
|
||||||
options = [x for x in self.options if x.name == name]
|
options = list((x for x in self.options if x.name == name))
|
||||||
assert len(options) == 1
|
assert len(options) == 1
|
||||||
options[0].set_selected(selected)
|
options[0].set_selected(selected)
|
||||||
|
|
||||||
@@ -117,15 +117,6 @@ class TextBox(Region):
|
|||||||
self.root.send_keys(value)
|
self.root.send_keys(value)
|
||||||
|
|
||||||
|
|
||||||
class SimpleMDETextArea(Region):
|
|
||||||
@property
|
|
||||||
def value(self):
|
|
||||||
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):
|
|
||||||
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):
|
||||||
def toggle(self):
|
def toggle(self):
|
||||||
self.root.click()
|
self.root.click()
|
||||||
@@ -145,7 +136,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, f"//label[@for='{self.root.get_attribute('id')}_{value}']").click()
|
self.find_element(By.XPATH, "//label[@for='{}_{}']".format(self.root.get_attribute("id"), value)).click()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self):
|
def value(self):
|
||||||
|
|||||||
@@ -8,14 +8,18 @@ from pytest_django.asserts import assertRedirects, assertContains, assertNotCont
|
|||||||
from pytest_django.asserts import assertTemplateUsed, assertInHTML
|
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
|
||||||
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
|
||||||
|
import pytest
|
||||||
|
from django.core.management import call_command
|
||||||
from django.template.defaultfilters import striptags
|
from django.template.defaultfilters import striptags
|
||||||
from django.urls.exceptions import NoReverseMatch
|
from django.urls.exceptions import NoReverseMatch
|
||||||
|
|
||||||
from django.test import TestCase, TransactionTestCase
|
from RIGS.models import Event
|
||||||
|
from assets.models import Asset
|
||||||
|
from django.db import connection
|
||||||
|
from django.test import TestCase
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +49,7 @@ def get_request_url(url):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("command", ['generateSampleAssetsData', 'generateSampleRIGSData', 'generateSampleUserData',
|
@pytest.mark.parametrize("command", ['generateSampleAssetsData', 'generateSampleRIGSData', 'generateSampleUserData',
|
||||||
'deleteSampleData', 'generateSampleTrainingData', 'generate_sample_training_users'])
|
'deleteSampleData'])
|
||||||
def test_production_exception(command):
|
def test_production_exception(command):
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
with pytest.raises(CommandError, match=".*production"):
|
with pytest.raises(CommandError, match=".*production"):
|
||||||
@@ -63,84 +67,79 @@ class TestSampleDataGenerator(TestCase):
|
|||||||
assert Event.objects.all().count() == 0
|
assert Event.objects.all().count() == 0
|
||||||
|
|
||||||
|
|
||||||
@override_settings(DEBUG=True)
|
class TestSampleDataGenerator(TestCase):
|
||||||
@pytest.mark.skip(reason="broken")
|
@override_settings(DEBUG=True)
|
||||||
def test_unauthenticated(client): # Nothing should be available to the unauthenticated
|
def setUp(self):
|
||||||
call_command('generateSampleData')
|
call_command('generateSampleData')
|
||||||
for url in find_urls_recursive(urls.urlpatterns):
|
|
||||||
request_url = get_request_url(url)
|
def test_unauthenticated(self): # Nothing should be available to the unauthenticated
|
||||||
if request_url and 'user' not in request_url: # User module is full of edge cases
|
for url in find_urls_recursive(urls.urlpatterns):
|
||||||
response = client.get(request_url, follow=True, HTTP_HOST='example.com')
|
request_url = get_request_url(url)
|
||||||
assertContains(response, 'Login')
|
if request_url and 'user' not in request_url: # User module is full of edge cases
|
||||||
if 'application/json+oembed' in response.content.decode():
|
response = self.client.get(request_url, follow=True, HTTP_HOST='example.com')
|
||||||
assertTemplateUsed(response, 'login_redirect.html')
|
assertContains(response, 'Login')
|
||||||
else:
|
if 'application/json+oembed' in response.content.decode():
|
||||||
if "embed" in str(url):
|
assertTemplateUsed(response, 'login_redirect.html')
|
||||||
expected_url = "{0}?next={1}".format(reverse('login_embed'), request_url)
|
|
||||||
else:
|
else:
|
||||||
expected_url = "{0}?next={1}".format(reverse('login'), request_url)
|
if "embed" in str(url):
|
||||||
assertRedirects(response, expected_url)
|
expected_url = "{0}?next={1}".format(reverse('login_embed'), request_url)
|
||||||
call_command('deleteSampleData')
|
else:
|
||||||
|
expected_url = "{0}?next={1}".format(reverse('login'), request_url)
|
||||||
|
assertRedirects(response, expected_url)
|
||||||
|
|
||||||
|
def test_page_titles(self):
|
||||||
|
assert self.client.login(username='superuser', password='superuser')
|
||||||
|
for url in filter((lambda u: "embed" not in u.name), find_urls_recursive(urls.urlpatterns)):
|
||||||
|
request_url = get_request_url(url)
|
||||||
|
response = self.client.get(request_url)
|
||||||
|
if hasattr(response, "context_data") and "page_title" in response.context_data:
|
||||||
|
expected_title = striptags(response.context_data["page_title"])
|
||||||
|
assertInHTML('<title>{} | Rig Information Gathering System'.format(expected_title),
|
||||||
|
response.content.decode())
|
||||||
|
print("{} | {}".format(request_url, expected_title)) # If test fails, tell me where!
|
||||||
|
self.client.logout()
|
||||||
|
|
||||||
@override_settings(DEBUG=True)
|
def test_basic_access(self):
|
||||||
@pytest.mark.skip(reason="broken")
|
assert self.client.login(username="basic", password="basic")
|
||||||
def test_basic_access(client):
|
|
||||||
call_command('generateSampleData')
|
|
||||||
assert client.login(username="basic", password="basic")
|
|
||||||
|
|
||||||
url = reverse('asset_list')
|
url = reverse('asset_list')
|
||||||
response = client.get(url)
|
response = self.client.get(url)
|
||||||
# Check edit and duplicate buttons NOT shown in list
|
# Check edit and duplicate buttons NOT shown in list
|
||||||
assertNotContains(response, 'Edit')
|
assertNotContains(response, 'Edit')
|
||||||
assertNotContains(response,
|
assertNotContains(response,
|
||||||
'Duplicate') # If this line is randomly failing, check the debug toolbar HTML hasn't crept in
|
'Duplicate') # If this line is randomly failing, check the debug toolbar HTML hasn't crept in
|
||||||
|
|
||||||
url = reverse('asset_detail', kwargs={'pk': Asset.objects.first().asset_id})
|
url = reverse('asset_detail', kwargs={'pk': Asset.objects.first().asset_id})
|
||||||
response = client.get(url)
|
response = self.client.get(url)
|
||||||
assertNotContains(response, 'Purchase Details')
|
assertNotContains(response, 'Purchase Details')
|
||||||
assertNotContains(response, 'View Revision History')
|
assertNotContains(response, 'View Revision History')
|
||||||
|
|
||||||
urlz = {'asset_history', 'asset_update', 'asset_duplicate'}
|
urlz = {'asset_history', 'asset_update', 'asset_duplicate'}
|
||||||
for url_name in urlz:
|
for url_name in urlz:
|
||||||
request_url = reverse(url_name, kwargs={'pk': Asset.objects.first().asset_id})
|
request_url = reverse(url_name, kwargs={'pk': Asset.objects.first().asset_id})
|
||||||
response = client.get(request_url, follow=True)
|
response = self.client.get(request_url, follow=True)
|
||||||
|
assert response.status_code == 403
|
||||||
|
|
||||||
|
request_url = reverse('supplier_create')
|
||||||
|
response = self.client.get(request_url, follow=True)
|
||||||
assert response.status_code == 403
|
assert response.status_code == 403
|
||||||
|
|
||||||
request_url = reverse('supplier_create')
|
request_url = reverse('supplier_update', kwargs={'pk': 1})
|
||||||
response = client.get(request_url, follow=True)
|
response = self.client.get(request_url, follow=True)
|
||||||
assert response.status_code == 403
|
assert response.status_code == 403
|
||||||
|
self.client.logout()
|
||||||
|
|
||||||
request_url = reverse('supplier_update', kwargs={'pk': 1})
|
def test_keyholder_access(self):
|
||||||
response = client.get(request_url, follow=True)
|
assert self.client.login(username="keyholder", password="keyholder")
|
||||||
assert response.status_code == 403
|
|
||||||
client.logout()
|
|
||||||
call_command('deleteSampleData')
|
|
||||||
|
|
||||||
|
url = reverse('asset_list')
|
||||||
|
response = self.client.get(url)
|
||||||
|
# Check edit and duplicate buttons shown in list
|
||||||
|
assertContains(response, 'Edit')
|
||||||
|
assertContains(response, 'Duplicate')
|
||||||
|
|
||||||
@override_settings(DEBUG=True)
|
url = reverse('asset_detail', kwargs={'pk': Asset.objects.first().asset_id})
|
||||||
@pytest.mark.skip(reason="broken")
|
response = self.client.get(url)
|
||||||
def test_keyholder_access(client):
|
assertContains(response, 'Purchase Details')
|
||||||
call_command('generateSampleData')
|
assertContains(response, 'View Revision History')
|
||||||
assert client.login(username="keyholder", password="keyholder")
|
self.client.logout()
|
||||||
|
|
||||||
url = reverse('asset_list')
|
|
||||||
response = client.get(url)
|
|
||||||
# Check edit and duplicate buttons shown in list
|
|
||||||
assertContains(response, 'Edit')
|
|
||||||
assertContains(response, 'Duplicate')
|
|
||||||
|
|
||||||
url = reverse('asset_detail', kwargs={'pk': Asset.objects.first().asset_id})
|
|
||||||
response = client.get(url)
|
|
||||||
assertContains(response, 'Purchase Details')
|
|
||||||
assertContains(response, 'View Revision History')
|
|
||||||
client.logout()
|
|
||||||
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)
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ urlpatterns = [
|
|||||||
path('', include('versioning.urls')),
|
path('', include('versioning.urls')),
|
||||||
path('', include('RIGS.urls')),
|
path('', include('RIGS.urls')),
|
||||||
path('assets/', include('assets.urls')),
|
path('assets/', include('assets.urls')),
|
||||||
path('training/', include('training.urls')),
|
|
||||||
|
|
||||||
path('', login_required(views.Index.as_view()), name='index'),
|
path('', login_required(views.Index.as_view()), name='index'),
|
||||||
|
|
||||||
@@ -23,12 +22,10 @@ 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")),
|
||||||
]
|
]
|
||||||
|
|||||||
177
PyRIGS/views.py
177
PyRIGS/views.py
@@ -1,52 +1,32 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import operator
|
import operator
|
||||||
import re
|
|
||||||
import urllib.error
|
|
||||||
import urllib.parse
|
|
||||||
import urllib.request
|
|
||||||
|
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from itertools import chain
|
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
from PyPDF2 import PdfFileMerger, PdfFileReader
|
import simplejson
|
||||||
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, JsonResponse
|
from django.http import HttpResponse
|
||||||
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
|
||||||
from training import models as training_models
|
|
||||||
|
|
||||||
|
|
||||||
def is_ajax(request):
|
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().get_context_data(**kwargs)
|
context = super(Index, self).get_context_data(**kwargs)
|
||||||
context['rig_count'] = models.Event.objects.rig_count()
|
context['rig_count'] = models.Event.objects.rig_count()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -58,9 +38,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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
perms = {
|
perms = {
|
||||||
@@ -69,9 +47,7 @@ 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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@@ -99,9 +75,6 @@ class SecureAPIRequest(generic.View):
|
|||||||
fields = request.GET.get('fields', None)
|
fields = request.GET.get('fields', None)
|
||||||
if fields:
|
if fields:
|
||||||
fields = fields.split(",")
|
fields = fields.split(",")
|
||||||
filters = request.GET.get('filters', [])
|
|
||||||
if filters:
|
|
||||||
filters = filters.split(",")
|
|
||||||
|
|
||||||
# Supply data for one record
|
# Supply data for one record
|
||||||
if pk:
|
if pk:
|
||||||
@@ -122,13 +95,8 @@ class SecureAPIRequest(generic.View):
|
|||||||
for field in fields:
|
for field in fields:
|
||||||
q = Q(**{field + "__icontains": part})
|
q = Q(**{field + "__icontains": part})
|
||||||
qs.append(q)
|
qs.append(q)
|
||||||
|
|
||||||
queries.append(reduce(operator.or_, qs))
|
queries.append(reduce(operator.or_, qs))
|
||||||
|
|
||||||
for f in filters:
|
|
||||||
q = Q(**{f: True})
|
|
||||||
queries.append(q)
|
|
||||||
|
|
||||||
# Build the data response list
|
# Build the data response list
|
||||||
results = []
|
results = []
|
||||||
query = reduce(operator.and_, queries)
|
query = reduce(operator.and_, queries)
|
||||||
@@ -140,13 +108,14 @@ 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(f"{model}_update", kwargs={'pk': o.pk})
|
data['update'] = reverse("%s_update" % model, kwargs={'pk': o.pk})
|
||||||
except NoReverseMatch:
|
except NoReverseMatch:
|
||||||
pass
|
pass
|
||||||
results.append(data)
|
results.append(data)
|
||||||
|
|
||||||
# return a data response
|
# return a data response
|
||||||
return JsonResponse(results, safe=False)
|
json = simplejson.dumps(results)
|
||||||
|
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)
|
||||||
@@ -171,7 +140,8 @@ class SecureAPIRequest(generic.View):
|
|||||||
}
|
}
|
||||||
|
|
||||||
results.append(data)
|
results.append(data)
|
||||||
return JsonResponse(results, safe=False)
|
json = simplejson.dumps(results)
|
||||||
|
return HttpResponse(json, content_type="application/json") # Always json
|
||||||
|
|
||||||
return HttpResponse(model)
|
return HttpResponse(model)
|
||||||
|
|
||||||
@@ -195,14 +165,27 @@ class GenericListView(generic.ListView):
|
|||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(GenericListView, self).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):
|
||||||
object_list = self.model.objects.search(query=self.request.GET.get('q', ""))
|
q = 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 != "":
|
||||||
@@ -214,8 +197,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().get_context_data(**kwargs)
|
context = super(GenericDetailView, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = f"{self.model.__name__} | {self.object.name}"
|
context['page_title'] = "{} | {}".format(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
|
||||||
@@ -225,8 +208,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().get_context_data(**kwargs)
|
context = super(GenericUpdateView, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = f"Edit {self.model.__name__}"
|
context['page_title'] = "Edit {}".format(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
|
||||||
@@ -236,60 +219,13 @@ 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().get_context_data(**kwargs)
|
context = super(GenericCreateView, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = f"Create {self.model.__name__}"
|
context['page_title'] = "Create {}".format(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'
|
||||||
|
|
||||||
@@ -309,57 +245,14 @@ 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 = f"{request.scheme}://{request.META['HTTP_HOST']}{embed_url}"
|
full_url = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'], embed_url)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'html': f'<iframe src="{full_url}" frameborder="0" width="100%" height="250"></iframe>',
|
'html': '<iframe src="{0}" frameborder="0" width="100%" height="250"></iframe>'.format(full_url),
|
||||||
'version': '1.0',
|
'version': '1.0',
|
||||||
'type': 'rich',
|
'type': 'rich',
|
||||||
'height': '250'
|
'height': '250'
|
||||||
}
|
}
|
||||||
|
|
||||||
return JsonResponse(data)
|
json = simplejson.JSONEncoderForHTML().encode(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
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
default_app_config = 'RIGS.apps.RIGSAppConfig'
|
||||||
|
|||||||
195
RIGS/admin.py
195
RIGS/admin.py
@@ -8,153 +8,30 @@ 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
|
||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
from users import forms as user_forms
|
from users import forms as user_forms
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
admin.site.register(models.VatRate, VersionAdmin)
|
admin.site.register(models.VatRate, VersionAdmin)
|
||||||
admin.site.register(models.Event, VersionAdmin)
|
admin.site.register(models.Event, VersionAdmin)
|
||||||
admin.site.register(models.EventItem, VersionAdmin)
|
admin.site.register(models.EventItem, VersionAdmin)
|
||||||
admin.site.register(models.Invoice, VersionAdmin)
|
admin.site.register(models.Invoice, VersionAdmin)
|
||||||
|
|
||||||
|
|
||||||
@transaction.atomic() # Copied from django-extensions. GenericForeignKey support removed as unnecessary.
|
def approve_user(modeladmin, request, queryset):
|
||||||
def merge_model_instances(primary_object, alias_objects):
|
queryset.update(is_approved=True)
|
||||||
"""
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
class AssociateAdmin(VersionAdmin):
|
approve_user.short_description = "Approve selected users"
|
||||||
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, AssociateAdmin):
|
class ProfileAdmin(UserAdmin):
|
||||||
list_display = ('username', 'name', 'is_approved', 'is_staff', 'is_superuser', 'is_supervisor', 'number_of_events')
|
# Don't know how to add 'is_approved' whilst preserving the default list...
|
||||||
list_display_links = ['username']
|
list_filter = ('is_approved', 'is_active', 'is_staff', 'is_superuser', 'groups')
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, {'fields': ('username', 'password')}),
|
(None, {'fields': ('username', 'password')}),
|
||||||
(_('Personal info'), {
|
(_('Personal info'), {
|
||||||
@@ -172,12 +49,62 @@ class ProfileAdmin(UserAdmin, AssociateAdmin):
|
|||||||
)
|
)
|
||||||
form = user_forms.ProfileChangeForm
|
form = user_forms.ProfileChangeForm
|
||||||
add_form = user_forms.ProfileCreationForm
|
add_form = user_forms.ProfileCreationForm
|
||||||
actions = ['approve_user', 'merge']
|
actions = [approve_user]
|
||||||
|
|
||||||
merge_fields = ['username', 'first_name', 'last_name', 'initials', 'email', 'phone', 'is_supervisor']
|
|
||||||
|
|
||||||
def approve_user(modeladmin, request, queryset):
|
class AssociateAdmin(VersionAdmin):
|
||||||
queryset.update(is_approved=True)
|
list_display = ('id', 'name', 'number_of_events')
|
||||||
|
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)
|
||||||
|
|||||||
@@ -24,17 +24,29 @@ class InvoiceIndex(generic.ListView):
|
|||||||
template_name = 'invoice_list.html'
|
template_name = 'invoice_list.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(InvoiceIndex, self).get_context_data(**kwargs)
|
||||||
total = 0
|
total = 0
|
||||||
for i in context['object_list']:
|
for i in context['object_list']:
|
||||||
total += i.balance
|
total += i.balance
|
||||||
event_count = len(list(context['object_list']))
|
context['page_title'] = "Outstanding Invoices ({} Events, £{:.2f})".format(len(list(context['object_list'])), total)
|
||||||
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
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.outstanding_invoices()
|
# Manual query is the only way I have found to do this efficiently. Not ideal but needs must
|
||||||
|
sql = "SELECT * FROM " \
|
||||||
|
"(SELECT " \
|
||||||
|
"(SELECT COUNT(p.amount) FROM \"RIGS_payment\" AS p WHERE p.invoice_id=\"RIGS_invoice\".id) AS \"payment_count\", " \
|
||||||
|
"(SELECT SUM(ei.cost * ei.quantity) FROM \"RIGS_eventitem\" AS ei WHERE ei.event_id=\"RIGS_invoice\".event_id) AS \"cost\", " \
|
||||||
|
"(SELECT SUM(p.amount) FROM \"RIGS_payment\" AS p WHERE p.invoice_id=\"RIGS_invoice\".id) AS \"payments\", " \
|
||||||
|
"\"RIGS_invoice\".\"id\", \"RIGS_invoice\".\"event_id\", \"RIGS_invoice\".\"invoice_date\", \"RIGS_invoice\".\"void\" FROM \"RIGS_invoice\") " \
|
||||||
|
"AS sub " \
|
||||||
|
"WHERE (((cost > 0.0) AND (payment_count=0)) OR (cost - payments) <> 0.0) AND void = '0'" \
|
||||||
|
"ORDER BY invoice_date"
|
||||||
|
|
||||||
|
query = self.model.objects.raw(sql)
|
||||||
|
|
||||||
|
return query
|
||||||
|
|
||||||
|
|
||||||
class InvoiceDetail(generic.DetailView):
|
class InvoiceDetail(generic.DetailView):
|
||||||
@@ -42,15 +54,8 @@ class InvoiceDetail(generic.DetailView):
|
|||||||
template_name = 'invoice_detail.html'
|
template_name = 'invoice_detail.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(InvoiceDetail, self).get_context_data(**kwargs)
|
||||||
invoice_date = self.object.invoice_date.strftime("%d/%m/%Y")
|
context['page_title'] = "Invoice {} ({})".format(self.object.display_id, self.object.invoice_date.strftime("%d/%m/%Y"))
|
||||||
context['page_title'] = f"Invoice {self.object.display_id} ({invoice_date})"
|
|
||||||
if self.object.void:
|
|
||||||
context['page_title'] += "<span class='badge badge-warning float-right'>VOID</span>"
|
|
||||||
elif self.object.is_closed:
|
|
||||||
context['page_title'] += "<span class='badge badge-success float-right'>PAID</span>"
|
|
||||||
else:
|
|
||||||
context['page_title'] += "<span class='badge badge-info float-right'>OUTSTANDING</span>"
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
@@ -60,14 +65,11 @@ 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': filename
|
'filename': 'Invoice {} for {} {}.pdf'.format(invoice.display_id, object.display_id, re.sub(r'[^a-zA-Z0-9 \n\.]', '', object.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
rml = template.render(context)
|
rml = template.render(context)
|
||||||
@@ -77,7 +79,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'] = f'filename="{filename}"'
|
response['Content-Disposition'] = 'filename="{}"'.format(context['filename'])
|
||||||
response.write(pdfData)
|
response.write(pdfData)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@@ -122,13 +124,38 @@ class InvoiceArchive(generic.ListView):
|
|||||||
paginate_by = 25
|
paginate_by = 25
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(InvoiceArchive, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = "Invoice Archive"
|
context['page_title'] = "Invoice Archive"
|
||||||
context['description'] = "This page displays all invoices: outstanding, paid, and void"
|
context['description'] = "This page displays all invoices: outstanding, paid, and void"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.search(self.request.GET.get('q')).order_by('-invoice_date')
|
q = self.request.GET.get('q', "")
|
||||||
|
|
||||||
|
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):
|
||||||
@@ -142,11 +169,28 @@ 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'] = f"Events for Invoice ({len(objects)} Events, £{total:.2f})"
|
context['page_title'] = "Events for Invoice ({} Events, £{:.2f})".format(len(objects), total)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.waiting_invoices()
|
return self.get_objects()
|
||||||
|
|
||||||
|
def get_objects(self):
|
||||||
|
# TODO find a way to select items
|
||||||
|
events = self.model.objects.filter(
|
||||||
|
(
|
||||||
|
Q(start_date__lte=datetime.date.today(), end_date__isnull=True) | # Starts before with no end
|
||||||
|
Q(end_date__lte=datetime.date.today()) # Has end date, finishes before
|
||||||
|
) & Q(invoice__isnull=True) & # Has not already been invoiced
|
||||||
|
Q(is_rig=True) # Is a rig (not non-rig)
|
||||||
|
|
||||||
|
).order_by('start_date') \
|
||||||
|
.select_related('person',
|
||||||
|
'organisation',
|
||||||
|
'venue', 'mic') \
|
||||||
|
.prefetch_related('items')
|
||||||
|
|
||||||
|
return events
|
||||||
|
|
||||||
|
|
||||||
class InvoiceEvent(generic.View):
|
class InvoiceEvent(generic.View):
|
||||||
@@ -176,7 +220,7 @@ class PaymentCreate(generic.CreateView):
|
|||||||
template_name = 'payment_form.html'
|
template_name = 'payment_form.html'
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super().get_initial()
|
initial = super(generic.CreateView, self).get_initial()
|
||||||
invoicepk = self.request.GET.get('invoice', self.request.POST.get('invoice', None))
|
invoicepk = self.request.GET.get('invoice', self.request.POST.get('invoice', None))
|
||||||
if invoicepk is None:
|
if invoicepk is None:
|
||||||
raise Http404()
|
raise Http404()
|
||||||
@@ -8,7 +8,6 @@ from django.utils import timezone
|
|||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
from training.models import TrainingLevel
|
|
||||||
|
|
||||||
# Override the django form defaults to use the HTML date/time/datetime UI elements
|
# Override the django form defaults to use the HTML date/time/datetime UI elements
|
||||||
forms.DateField.widget = forms.DateInput(attrs={'type': 'date'})
|
forms.DateField.widget = forms.DateInput(attrs={'type': 'date'})
|
||||||
@@ -97,10 +96,10 @@ class EventForm(forms.ModelForm):
|
|||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
'You haven\'t provided any client contact details. Please add a person or organisation.',
|
'You haven\'t provided any client contact details. Please add a person or organisation.',
|
||||||
code='contact')
|
code='contact')
|
||||||
return super().clean()
|
return super(EventForm, self).clean()
|
||||||
|
|
||||||
def save(self, commit=True):
|
def save(self, commit=True):
|
||||||
m = super().save(commit=False)
|
m = super(EventForm, self).save(commit=False)
|
||||||
|
|
||||||
if (commit):
|
if (commit):
|
||||||
m.save()
|
m.save()
|
||||||
@@ -139,7 +138,7 @@ class BaseClientEventAuthorisationForm(forms.ModelForm):
|
|||||||
|
|
||||||
class InternalClientEventAuthorisationForm(BaseClientEventAuthorisationForm):
|
class InternalClientEventAuthorisationForm(BaseClientEventAuthorisationForm):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super(InternalClientEventAuthorisationForm, self).__init__(**kwargs)
|
||||||
self.fields['uni_id'].required = True
|
self.fields['uni_id'].required = True
|
||||||
self.fields['account_code'].required = True
|
self.fields['account_code'].required = True
|
||||||
|
|
||||||
@@ -153,12 +152,8 @@ 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(EventRiskAssessmentForm, self).__init__(*args, **kwargs)
|
||||||
for name, field in self.fields.items():
|
for name, field in self.fields.items():
|
||||||
if str(name) == 'supervisor_consulted':
|
if str(name) == 'supervisor_consulted':
|
||||||
field.widget = forms.CheckboxInput()
|
field.widget = forms.CheckboxInput()
|
||||||
@@ -169,16 +164,13 @@ class EventRiskAssessmentForm(forms.ModelForm):
|
|||||||
], attrs={'class': 'custom-control-input', 'required': 'true'})
|
], attrs={'class': 'custom-control-input', 'required': 'true'})
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if self.cleaned_data.get('big_power'):
|
|
||||||
if not self.cleaned_data.get('power_mic').level_qualifications.filter(level__department=TrainingLevel.POWER).exists():
|
|
||||||
self.add_error('power_mic', forms.ValidationError("Your Power MIC must be a Power Technician.", code="power_tech_required"))
|
|
||||||
# Check expected values
|
# Check expected values
|
||||||
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(f"<li>{self._meta.model._meta.get_field(field).help_text}</li>")
|
unexpected_values.append("<li>{}</li>".format(self._meta.model._meta.get_field(field).help_text))
|
||||||
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(f"Your answers to these questions: <ul>{''.join([str(elem) for elem in unexpected_values])}</ul> require consulting with a supervisor.", code='unusual_answers')
|
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')
|
||||||
return super(EventRiskAssessmentForm, self).clean()
|
return super(EventRiskAssessmentForm, self).clean()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -189,7 +181,7 @@ class EventRiskAssessmentForm(forms.ModelForm):
|
|||||||
|
|
||||||
class EventChecklistForm(forms.ModelForm):
|
class EventChecklistForm(forms.ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super(EventChecklistForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['date'].widget.format = '%Y-%m-%d'
|
self.fields['date'].widget.format = '%Y-%m-%d'
|
||||||
for name, field in self.fields.items():
|
for name, field in self.fields.items():
|
||||||
if field.__class__ == forms.NullBooleanField:
|
if field.__class__ == forms.NullBooleanField:
|
||||||
@@ -239,9 +231,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[f'{field}_{pk}']
|
value = self.data['{}_{}'.format(field, pk)]
|
||||||
if value == '':
|
if value == '':
|
||||||
raise forms.ValidationError(f'Add a {field} to crewmember {pk}', code=f'{field}_mismatch')
|
raise forms.ValidationError('Add a {} to crewmember {}'.format(field, pk), code='{}_mismatch'.format(field))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
item = models.EventChecklistCrew.objects.get(pk=pk)
|
item = models.EventChecklistCrew.objects.get(pk=pk)
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ 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 = 'hs/risk_assessment_form.html'
|
template_name = 'risk_assessment_form.html'
|
||||||
form_class = forms.EventRiskAssessmentForm
|
form_class = forms.EventRiskAssessmentForm
|
||||||
|
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
@@ -39,8 +37,7 @@ 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'] = f'Create Risk Assessment for Event {event.display_id}'
|
context['page_title'] = 'Create Risk Assessment for Event {}'.format(event.display_id)
|
||||||
get_related(context['form'], context)
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -49,7 +46,7 @@ class EventRiskAssessmentCreate(generic.CreateView):
|
|||||||
|
|
||||||
class EventRiskAssessmentEdit(generic.UpdateView):
|
class EventRiskAssessmentEdit(generic.UpdateView):
|
||||||
model = models.RiskAssessment
|
model = models.RiskAssessment
|
||||||
template_name = 'hs/risk_assessment_form.html'
|
template_name = 'risk_assessment_form.html'
|
||||||
form_class = forms.EventRiskAssessmentForm
|
form_class = forms.EventRiskAssessmentForm
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -65,28 +62,22 @@ 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'] = f'Edit Risk Assessment for Event {ra.event.display_id}'
|
context['page_title'] = 'Edit Risk Assessment for Event {}'.format(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 = 'hs/risk_assessment_detail.html'
|
template_name = 'risk_assessment_detail.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(EventRiskAssessmentDetail, self).get_context_data(**kwargs)
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentList(generic.ListView):
|
class EventRiskAssessmentList(generic.ListView):
|
||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
model = models.RiskAssessment
|
model = models.RiskAssessment
|
||||||
template_name = 'hs/hs_object_list.html'
|
template_name = '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.order_by('reviewed_at').select_related('event')
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(EventRiskAssessmentList, self).get_context_data(**kwargs)
|
context = super(EventRiskAssessmentList, self).get_context_data(**kwargs)
|
||||||
@@ -112,17 +103,17 @@ class EventRiskAssessmentReview(generic.View):
|
|||||||
|
|
||||||
class EventChecklistDetail(generic.DetailView):
|
class EventChecklistDetail(generic.DetailView):
|
||||||
model = models.EventChecklist
|
model = models.EventChecklist
|
||||||
template_name = 'hs/event_checklist_detail.html'
|
template_name = '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'] = f"Event Checklist for Event <a href='{self.object.event.get_absolute_url()}'>{self.object.event.display_id} {self.object.event.name}</a>"
|
context['page_title'] = "Event Checklist for Event {} {}".format(self.object.event.display_id, self.object.event.name)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventChecklistEdit(generic.UpdateView):
|
class EventChecklistEdit(generic.UpdateView):
|
||||||
model = models.EventChecklist
|
model = models.EventChecklist
|
||||||
template_name = 'hs/event_checklist_form.html'
|
template_name = 'event_checklist_form.html'
|
||||||
form_class = forms.EventChecklistForm
|
form_class = forms.EventChecklistForm
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -138,14 +129,19 @@ 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'] = f'Edit Event Checklist for Event {ec.event.display_id}'
|
context['page_title'] = 'Edit Event Checklist for Event {}'.format(ec.event.display_id)
|
||||||
get_related(context['form'], context)
|
form = context['form']
|
||||||
|
# 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 = 'hs/event_checklist_form.html'
|
template_name = '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!
|
||||||
@@ -157,7 +153,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, f'A Risk Assessment must exist prior to creating any Event Checklists for {event}! Please create one now.')
|
messages.error(self.request, 'A Risk Assessment must exist prior to creating any Event Checklists for {}! Please create one now.'.format(event))
|
||||||
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)
|
||||||
@@ -174,7 +170,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'] = f'Create Event Checklist for Event {event.display_id}'
|
context['page_title'] = 'Create Event Checklist for Event {}'.format(event.display_id)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -184,10 +180,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/hs_object_list.html'
|
template_name = 'hs_object_list.html'
|
||||||
|
|
||||||
def get_queryset(self):
|
|
||||||
return self.model.objects.exclude(event__status=models.Event.CANCELLED).order_by('reviewed_at').select_related('event')
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(EventChecklistList, self).get_context_data(**kwargs)
|
context = super(EventChecklistList, self).get_context_data(**kwargs)
|
||||||
@@ -214,22 +207,12 @@ 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/hs_list.html'
|
template_name = '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().order_by('-start_date').select_related('riskassessment').prefetch_related('checklists')
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
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 += f' ({item.get_status_display()})'
|
title += ' (' + str(item.get_status_display()) + ')'
|
||||||
|
|
||||||
return title
|
return title
|
||||||
|
|
||||||
@@ -101,8 +101,9 @@ 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):
|
||||||
@@ -114,13 +115,13 @@ class CalendarICS(ICalFeed):
|
|||||||
|
|
||||||
tz = pytz.timezone(self.timezone)
|
tz = pytz.timezone(self.timezone)
|
||||||
|
|
||||||
desc = f'Rig ID = {item.display_id}\n'
|
desc = 'Rig ID = ' + str(item.pk) + '\n'
|
||||||
desc += f'Event = {item.name}\n'
|
desc += '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 += f'Status = {item.get_status_display()}\n'
|
desc += 'Status = ' + str(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'
|
||||||
@@ -139,18 +140,23 @@ class CalendarICS(ICalFeed):
|
|||||||
|
|
||||||
desc += '\n'
|
desc += '\n'
|
||||||
if item.description:
|
if item.description:
|
||||||
desc += f'Event Description:\n{item.description}\n\n'
|
desc += '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'
|
||||||
|
|
||||||
desc += f'URL = https://rigs.nottinghamtec.co.uk{item.get_absolute_url()}'
|
base_url = "https://rigs.nottinghamtec.co.uk"
|
||||||
|
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
|
||||||
|
|
||||||
@@ -3,7 +3,6 @@ from django.core.management.base import BaseCommand, CommandError
|
|||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from assets import models
|
from assets import models
|
||||||
from RIGS import models as rigsmodels
|
from RIGS import models as rigsmodels
|
||||||
from training import models as tmodels
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@@ -32,11 +31,6 @@ class Command(BaseCommand):
|
|||||||
self.delete_objects(rigsmodels.Payment)
|
self.delete_objects(rigsmodels.Payment)
|
||||||
self.delete_objects(rigsmodels.RiskAssessment)
|
self.delete_objects(rigsmodels.RiskAssessment)
|
||||||
self.delete_objects(rigsmodels.EventChecklist)
|
self.delete_objects(rigsmodels.EventChecklist)
|
||||||
self.delete_objects(tmodels.TrainingCategory)
|
|
||||||
self.delete_objects(tmodels.TrainingItem)
|
|
||||||
self.delete_objects(tmodels.TrainingLevel)
|
|
||||||
self.delete_objects(tmodels.TrainingItemQualification)
|
|
||||||
self.delete_objects(tmodels.TrainingLevelRequirement)
|
|
||||||
|
|
||||||
def delete_objects(self, model):
|
def delete_objects(self, model):
|
||||||
for obj in model.objects.all():
|
for obj in model.objects.all():
|
||||||
|
|||||||
@@ -12,4 +12,3 @@ class Command(BaseCommand):
|
|||||||
call_command('generateSampleUserData')
|
call_command('generateSampleUserData')
|
||||||
call_command('generateSampleRIGSData')
|
call_command('generateSampleRIGSData')
|
||||||
call_command('generateSampleAssetsData')
|
call_command('generateSampleAssetsData')
|
||||||
call_command('generateSampleTrainingData')
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class Command(BaseCommand):
|
|||||||
profiles = models.Profile.objects.all()
|
profiles = models.Profile.objects.all()
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
print("Generating rigboard data")
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
if not (settings.DEBUG or settings.STAGING):
|
if not (settings.DEBUG or settings.STAGING):
|
||||||
@@ -36,7 +35,6 @@ class Command(BaseCommand):
|
|||||||
self.setup_organisations()
|
self.setup_organisations()
|
||||||
self.setup_venues()
|
self.setup_venues()
|
||||||
self.setup_events()
|
self.setup_events()
|
||||||
print("Done generating rigboard data")
|
|
||||||
|
|
||||||
def setup_people(self):
|
def setup_people(self):
|
||||||
names = ["Regulus Black", "Sirius Black", "Lavender Brown", "Cho Chang", "Vincent Crabbe", "Vincent Crabbe",
|
names = ["Regulus Black", "Sirius Black", "Lavender Brown", "Cho Chang", "Vincent Crabbe", "Vincent Crabbe",
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import RIGS.models
|
import RIGS.models
|
||||||
import versioning
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@@ -26,6 +25,6 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
bases=(models.Model, versioning.versioning.RevisionMixin),
|
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import RIGS.models
|
import RIGS.models
|
||||||
import versioning
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@@ -22,6 +21,6 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
bases=(models.Model, versioning.versioning.RevisionMixin),
|
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import RIGS.models
|
import RIGS.models
|
||||||
import versioning
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@@ -42,7 +41,7 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
bases=(models.Model, versioning.versioning.RevisionMixin),
|
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='EventItem',
|
name='EventItem',
|
||||||
@@ -71,7 +70,7 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
bases=(models.Model, versioning.versioning.RevisionMixin),
|
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import RIGS.models
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import versioning
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@@ -59,7 +58,7 @@ class Migration(migrations.Migration):
|
|||||||
'ordering': ['event'],
|
'ordering': ['event'],
|
||||||
'permissions': [('review_eventchecklist', 'Can review Event Checklists')],
|
'permissions': [('review_eventchecklist', 'Can review Event Checklists')],
|
||||||
},
|
},
|
||||||
bases=(models.Model, versioning.versioning.RevisionMixin),
|
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='EventChecklistCrew',
|
name='EventChecklistCrew',
|
||||||
@@ -70,7 +69,7 @@ class Migration(migrations.Migration):
|
|||||||
('end', models.DateTimeField()),
|
('end', models.DateTimeField()),
|
||||||
('checklist', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='crew', to='RIGS.eventchecklist')),
|
('checklist', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='crew', to='RIGS.eventchecklist')),
|
||||||
],
|
],
|
||||||
bases=(models.Model, versioning.versioning.RevisionMixin),
|
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='EventChecklistVehicle',
|
name='EventChecklistVehicle',
|
||||||
@@ -79,7 +78,7 @@ class Migration(migrations.Migration):
|
|||||||
('vehicle', models.CharField(max_length=255)),
|
('vehicle', models.CharField(max_length=255)),
|
||||||
('checklist', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='vehicles', to='RIGS.eventchecklist')),
|
('checklist', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='vehicles', to='RIGS.eventchecklist')),
|
||||||
],
|
],
|
||||||
bases=(models.Model, versioning.versioning.RevisionMixin),
|
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='RiskAssessment',
|
name='RiskAssessment',
|
||||||
@@ -118,7 +117,7 @@ class Migration(migrations.Migration):
|
|||||||
'ordering': ['event'],
|
'ordering': ['event'],
|
||||||
'permissions': [('review_riskassessment', 'Can review Risk Assessments')],
|
'permissions': [('review_riskassessment', 'Can review Risk Assessments')],
|
||||||
},
|
},
|
||||||
bases=(models.Model, versioning.versioning.RevisionMixin),
|
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.RemoveField(
|
migrations.RemoveField(
|
||||||
model_name='eventcrew',
|
model_name='eventcrew',
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
# Generated by Django 3.1.7 on 2021-03-02 11:48
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
def postgres_migration_prep(apps, schema_editor):
|
|
||||||
model = apps.get_model("RIGS", "Event")
|
|
||||||
for field in ["auth_request_to", "collector", "description", "notes", "purchase_order"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
model = apps.get_model("RIGS", "EventAuthorisation")
|
|
||||||
for field in ["account_code", "uni_id"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
model = apps.get_model("RIGS", "EventChecklist")
|
|
||||||
for field in ["extinguishers_location", "hs_location", "w1_description", "w2_description", "w3_description"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
model = apps.get_model("RIGS", "EventItem")
|
|
||||||
for field in ["description"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
model = apps.get_model("RIGS", "Organisation")
|
|
||||||
for field in ["address", "email", "notes", "phone"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
model = apps.get_model("RIGS", "Payment")
|
|
||||||
for field in ["method"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
model = apps.get_model("RIGS", "Person")
|
|
||||||
for field in ["address", "email", "notes", "phone"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
model = apps.get_model("RIGS", "Profile")
|
|
||||||
for field in ["phone"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
model = apps.get_model("RIGS", "RiskAssessment")
|
|
||||||
for field in ["general_notes", "persons_responsible_structures", "power_notes", "rigging_plan", "sound_notes"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
model = apps.get_model("RIGS", "Venue")
|
|
||||||
for field in ["address", "email", "notes", "phone"]:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('RIGS', '0039_auto_20210123_1910'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(postgres_migration_prep, migrations.RunPython.noop)
|
|
||||||
]
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 3.2.11 on 2022-01-09 14:56
|
# Generated by Django 3.1.5 on 2021-02-06 10:43
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
@@ -6,13 +6,13 @@ from django.db import migrations, models
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('RIGS', '0043_auto_20211027_1519'),
|
('RIGS', '0039_auto_20210123_1910'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='profile',
|
model_name='profile',
|
||||||
name='is_supervisor',
|
name='dark_theme',
|
||||||
field=models.BooleanField(default=False),
|
field=models.BooleanField(default=False),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 3.1.7 on 2021-03-02 12:04
|
# Generated by Django 3.1.5 on 2021-02-08 16:03
|
||||||
|
|
||||||
import RIGS.models
|
import RIGS.models
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
@@ -7,27 +7,10 @@ from django.db import migrations, models
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('RIGS', '0040_auto_20210302_1148'),
|
('RIGS', '0040_profile_dark_theme'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='event',
|
|
||||||
name='meet_info',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='event',
|
|
||||||
name='payment_method',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='event',
|
|
||||||
name='payment_received',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='profile',
|
|
||||||
name='dark_theme',
|
|
||||||
field=models.BooleanField(default=False),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='auth_request_to',
|
name='auth_request_to',
|
||||||
@@ -43,11 +26,26 @@ class Migration(migrations.Migration):
|
|||||||
name='description',
|
name='description',
|
||||||
field=models.TextField(blank=True, default=''),
|
field=models.TextField(blank=True, default=''),
|
||||||
),
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='meet_info',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=255),
|
||||||
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='notes',
|
name='notes',
|
||||||
field=models.TextField(blank=True, default=''),
|
field=models.TextField(blank=True, default=''),
|
||||||
),
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='payment_method',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='payment_received',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=255),
|
||||||
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='purchase_order',
|
name='purchase_order',
|
||||||
@@ -146,7 +144,7 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='profile',
|
model_name='profile',
|
||||||
name='phone',
|
name='phone',
|
||||||
field=models.CharField(blank=True, default='', max_length=13),
|
field=models.CharField(default='', max_length=13, null=True),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='riskassessment',
|
model_name='riskassessment',
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
# Generated by Django 3.1.13 on 2021-10-07 22:38
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('RIGS', '0041_auto_20210302_1204'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='eventchecklist',
|
|
||||||
name='fd_earth_fault',
|
|
||||||
field=models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>)', max_digits=5, null=True, verbose_name='Earth Fault Loop Impedance'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='eventchecklist',
|
|
||||||
name='w1_earth_fault',
|
|
||||||
field=models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>)', max_digits=5, null=True, verbose_name='Earth Fault Loop Impedance'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='eventchecklist',
|
|
||||||
name='w2_earth_fault',
|
|
||||||
field=models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>)', max_digits=5, null=True, verbose_name='Earth Fault Loop Impedance'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='eventchecklist',
|
|
||||||
name='w3_earth_fault',
|
|
||||||
field=models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>)', max_digits=5, null=True, verbose_name='Earth Fault Loop Impedance'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 3.1.13 on 2021-10-27 14:19
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('RIGS', '0042_auto_20211007_2338'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='profile',
|
|
||||||
name='initials',
|
|
||||||
field=models.CharField(max_length=5, null=True),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
221
RIGS/models.py
221
RIGS/models.py
@@ -8,7 +8,6 @@ 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
|
||||||
@@ -18,31 +17,16 @@ 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):
|
||||||
initials = models.CharField(max_length=5, null=True, blank=False)
|
initials = models.CharField(max_length=5, unique=True, null=True, blank=False)
|
||||||
phone = models.CharField(max_length=13, blank=True, default='')
|
phone = models.CharField(max_length=13, null=True, default='')
|
||||||
api_key = models.CharField(max_length=40, blank=True, editable=False, default='')
|
api_key = models.CharField(max_length=40, blank=True, editable=False, default='')
|
||||||
is_approved = models.BooleanField(default=False)
|
is_approved = models.BooleanField(default=False)
|
||||||
# Currently only populated by the admin approval email. TODO: Populate it each time we send any email, might need that...
|
# Currently only populated by the admin approval email. TODO: Populate it each time we send any email, might need that...
|
||||||
last_emailed = models.DateTimeField(blank=True, null=True)
|
last_emailed = models.DateTimeField(blank=True, null=True)
|
||||||
dark_theme = models.BooleanField(default=False)
|
dark_theme = models.BooleanField(default=False)
|
||||||
is_supervisor = models.BooleanField(default=False)
|
|
||||||
|
|
||||||
reversion_hide = True
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def make_api_key(cls):
|
def make_api_key(cls):
|
||||||
@@ -63,7 +47,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 += f' "{self.initials}"'
|
name += ' "{}"'.format(self.initials)
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -81,28 +65,50 @@ class Profile(AbstractUser):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
# TODO move to versioning - currently get import errors with that
|
||||||
|
|
||||||
class ContactableManager(models.Manager):
|
|
||||||
def search(self, query=None):
|
|
||||||
qs = self.get_queryset()
|
|
||||||
if query is not None:
|
|
||||||
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)
|
|
||||||
|
|
||||||
or_lookup = filter_by_pk(or_lookup, query)
|
class RevisionMixin(object):
|
||||||
|
@property
|
||||||
|
def is_first_version(self):
|
||||||
|
versions = Version.objects.get_for_object(self)
|
||||||
|
return len(versions) == 1
|
||||||
|
|
||||||
qs = qs.filter(or_lookup).distinct() # distinct() is often necessary with Q lookups
|
@property
|
||||||
return qs
|
def current_version(self):
|
||||||
|
version = Version.objects.get_for_object(self).select_related('revision').first()
|
||||||
|
return version
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_edited_at(self):
|
||||||
|
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 "V{0} | R{1}".format(version.pk, 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='')
|
|
||||||
notes = models.TextField(blank=True, default='')
|
|
||||||
|
|
||||||
objects = ContactableManager()
|
address = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
|
notes = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
@@ -135,12 +141,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:
|
||||||
@@ -200,7 +206,7 @@ class VatRate(models.Model, RevisionMixin):
|
|||||||
get_latest_by = 'start_at'
|
get_latest_by = 'start_at'
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.comment} {self.start_at} @ {self.as_percent}%"
|
return self.comment + " " + str(self.start_at) + " @ " + str(self.as_percent) + "%"
|
||||||
|
|
||||||
|
|
||||||
class Venue(models.Model, RevisionMixin):
|
class Venue(models.Model, RevisionMixin):
|
||||||
@@ -209,9 +215,8 @@ 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='')
|
|
||||||
|
|
||||||
objects = ContactableManager()
|
address = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
@@ -273,36 +278,6 @@ class EventManager(models.Manager):
|
|||||||
).count()
|
).count()
|
||||||
return event_count
|
return event_count
|
||||||
|
|
||||||
def waiting_invoices(self):
|
|
||||||
events = self.filter(
|
|
||||||
(
|
|
||||||
models.Q(start_date__lte=datetime.date.today(), end_date__isnull=True) | # Starts before with no end
|
|
||||||
models.Q(end_date__lte=datetime.date.today()) # Or has end date, finishes before
|
|
||||||
) & models.Q(invoice__isnull=True) & # Has not already been invoiced
|
|
||||||
models.Q(is_rig=True) # Is a rig (not non-rig)
|
|
||||||
).order_by('start_date') \
|
|
||||||
.select_related('person', 'organisation', 'venue', 'mic') \
|
|
||||||
.prefetch_related('items')
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
or_lookup = filter_by_pk(or_lookup, query)
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(follow=['items'])
|
@reversion.register(follow=['items'])
|
||||||
class Event(models.Model, RevisionMixin):
|
class Event(models.Model, RevisionMixin):
|
||||||
@@ -337,6 +312,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
end_time = models.TimeField(blank=True, null=True)
|
end_time = models.TimeField(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)
|
||||||
|
meet_info = models.CharField(max_length=255, blank=True, default='')
|
||||||
|
|
||||||
# Crew management
|
# Crew management
|
||||||
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,
|
||||||
@@ -345,6 +321,8 @@ class Event(models.Model, RevisionMixin):
|
|||||||
verbose_name="MIC", on_delete=models.CASCADE)
|
verbose_name="MIC", on_delete=models.CASCADE)
|
||||||
|
|
||||||
# Monies
|
# Monies
|
||||||
|
payment_method = models.CharField(max_length=255, blank=True, default='')
|
||||||
|
payment_received = models.CharField(max_length=255, blank=True, default='')
|
||||||
purchase_order = models.CharField(max_length=255, blank=True, default='', verbose_name='PO')
|
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')
|
||||||
|
|
||||||
@@ -355,11 +333,10 @@ class Event(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def display_id(self):
|
def display_id(self):
|
||||||
if self.pk:
|
if self.is_rig:
|
||||||
if self.is_rig:
|
return str("N%05d" % self.pk)
|
||||||
return f"N{self.pk:05d}"
|
else:
|
||||||
return self.pk
|
return self.pk
|
||||||
return "????"
|
|
||||||
|
|
||||||
# Calculated values
|
# Calculated values
|
||||||
"""
|
"""
|
||||||
@@ -382,9 +359,6 @@ class Event(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def vat(self):
|
def vat(self):
|
||||||
# No VAT is owed on internal transfers
|
|
||||||
if self.internal:
|
|
||||||
return 0
|
|
||||||
return Decimal(self.sum_total * self.vat_rate.rate).quantize(Decimal('.01'))
|
return Decimal(self.sum_total * self.vat_rate.rate).quantize(Decimal('.01'))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -484,7 +458,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
return reverse('event_detail', kwargs={'pk': self.pk})
|
return reverse('event_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.display_id}: {self.name}"
|
return "{}: {}".format(self.display_id, self.name)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
errdict = {}
|
errdict = {}
|
||||||
@@ -530,11 +504,11 @@ class EventItem(models.Model, RevisionMixin):
|
|||||||
ordering = ['order']
|
ordering = ['order']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.event_id}.{self.order}: {self.event.name} | {self.name}"
|
return "{}.{}: {} | {}".format(self.event_id, self.order, self.event.name, self.name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return f"item {self.name}"
|
return str("item {}".format(self.name))
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
@@ -552,52 +526,7 @@ class EventAuthorisation(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return f"{self.event.display_id} (requested by {self.sent_by.initials})"
|
return "{} (requested by {})".format(self.event.display_id, self.sent_by.initials)
|
||||||
|
|
||||||
|
|
||||||
class InvoiceManager(models.Manager):
|
|
||||||
def outstanding_invoices(self):
|
|
||||||
# Manual query is the only way I have found to do this efficiently. Not ideal but needs must
|
|
||||||
sql = "SELECT * FROM " \
|
|
||||||
"(SELECT " \
|
|
||||||
"(SELECT COUNT(p.amount) FROM \"RIGS_payment\" AS p WHERE p.invoice_id=\"RIGS_invoice\".id) AS \"payment_count\", " \
|
|
||||||
"(SELECT SUM(ei.cost * ei.quantity) FROM \"RIGS_eventitem\" AS ei WHERE ei.event_id=\"RIGS_invoice\".event_id) AS \"cost\", " \
|
|
||||||
"(SELECT SUM(p.amount) FROM \"RIGS_payment\" AS p WHERE p.invoice_id=\"RIGS_invoice\".id) AS \"payments\", " \
|
|
||||||
"\"RIGS_invoice\".\"id\", \"RIGS_invoice\".\"event_id\", \"RIGS_invoice\".\"invoice_date\", \"RIGS_invoice\".\"void\" FROM \"RIGS_invoice\") " \
|
|
||||||
"AS sub " \
|
|
||||||
"WHERE (((cost > 0.0) AND (payment_count=0)) OR (cost - payments) <> 0.0) AND void = '0'" \
|
|
||||||
"ORDER BY invoice_date"
|
|
||||||
|
|
||||||
query = self.raw(sql)
|
|
||||||
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'])
|
||||||
@@ -608,8 +537,6 @@ class Invoice(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
reversion_perm = 'RIGS.view_invoice'
|
reversion_perm = 'RIGS.view_invoice'
|
||||||
|
|
||||||
objects = InvoiceManager()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sum_total(self):
|
def sum_total(self):
|
||||||
return self.event.sum_total
|
return self.event.sum_total
|
||||||
@@ -638,14 +565,14 @@ class Invoice(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return f"{self.display_id} for Event {self.event.display_id}"
|
return "#{} for Event {}".format(self.display_id, self.event.display_id)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.display_id}: {self.event} (£{self.balance:.2f})"
|
return "%i: %s (%.2f)" % (self.pk, self.event, self.balance)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def display_id(self):
|
def display_id(self):
|
||||||
return f"#{self.pk:05d}"
|
return "{:05d}".format(self.pk)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-invoice_date']
|
ordering = ['-invoice_date']
|
||||||
@@ -674,11 +601,11 @@ class Payment(models.Model, RevisionMixin):
|
|||||||
reversion_hide = True
|
reversion_hide = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.get_method_display()}: {self.amount}"
|
return "%s: %d" % (self.get_method_display(), self.amount)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return f"payment of £{self.amount}"
|
return str("payment of £{}".format(self.amount))
|
||||||
|
|
||||||
|
|
||||||
def validate_url(value):
|
def validate_url(value):
|
||||||
@@ -708,6 +635,7 @@ class RiskAssessment(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
# Power
|
# Power
|
||||||
big_power = models.BooleanField(help_text="Does the event require larger power supplies than 13A or 16A single phase wall sockets, or draw more than 20A total current?")
|
big_power = models.BooleanField(help_text="Does the event require larger power supplies than 13A or 16A single phase wall sockets, or draw more than 20A total current?")
|
||||||
|
# If yes to the above two, you must answer...
|
||||||
power_mic = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='power_mic', blank=True, null=True,
|
power_mic = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='power_mic', blank=True, null=True,
|
||||||
verbose_name="Power MIC", on_delete=models.CASCADE, help_text="Who is the Power MIC? (if yes to the above question, this person <em>must</em> be a Power Technician or Power Supervisor)")
|
verbose_name="Power MIC", on_delete=models.CASCADE, help_text="Who is the Power MIC? (if yes to the above question, this person <em>must</em> be a Power Technician or Power Supervisor)")
|
||||||
outside = models.BooleanField(help_text="Is the event outdoors?")
|
outside = models.BooleanField(help_text="Is the event outdoors?")
|
||||||
@@ -750,7 +678,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 Doesn't require checking with a super either way
|
'big_power': False,
|
||||||
'generators': False,
|
'generators': False,
|
||||||
'other_companies_power': False,
|
'other_companies_power': False,
|
||||||
'nonstandard_equipment_power': False,
|
'nonstandard_equipment_power': False,
|
||||||
@@ -779,7 +707,7 @@ class RiskAssessment(models.Model, RevisionMixin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def fieldz(self):
|
def fields(self):
|
||||||
return [n.name for n in list(self._meta.get_fields()) if n.name != 'reviewed_at' and n.name != 'reviewed_by' and not n.is_relation and not n.auto_created]
|
return [n.name for n in list(self._meta.get_fields()) if n.name != 'reviewed_at' and n.name != 'reviewed_by' and not n.is_relation and not n.auto_created]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -792,22 +720,15 @@ 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 f"{self.pk} | {self.event}"
|
return "%i - %s" % (self.pk, self.event)
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(follow=['vehicles', 'crew'])
|
@reversion.register(follow=['vehicles', 'crew'])
|
||||||
@@ -846,21 +767,21 @@ class EventChecklist(models.Model, RevisionMixin):
|
|||||||
fd_voltage_l2 = models.IntegerField(blank=True, null=True, verbose_name="First Distro Voltage L2-N", help_text="L2 - N")
|
fd_voltage_l2 = models.IntegerField(blank=True, null=True, verbose_name="First Distro Voltage L2-N", help_text="L2 - N")
|
||||||
fd_voltage_l3 = models.IntegerField(blank=True, null=True, verbose_name="First Distro Voltage L3-N", help_text="L3 - N")
|
fd_voltage_l3 = models.IntegerField(blank=True, null=True, verbose_name="First Distro Voltage L3-N", help_text="L3 - N")
|
||||||
fd_phase_rotation = models.BooleanField(blank=True, null=True, verbose_name="Phase Rotation", help_text="Phase Rotation<br><small>(if required)</small>")
|
fd_phase_rotation = models.BooleanField(blank=True, null=True, verbose_name="Phase Rotation", help_text="Phase Rotation<br><small>(if required)</small>")
|
||||||
fd_earth_fault = models.DecimalField(blank=True, null=True, max_digits=5, decimal_places=2, verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
fd_earth_fault = models.IntegerField(blank=True, null=True, verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
||||||
fd_pssc = models.IntegerField(blank=True, null=True, verbose_name="PSCC", help_text="Prospective Short Circuit Current")
|
fd_pssc = models.IntegerField(blank=True, null=True, verbose_name="PSCC", help_text="Prospective Short Circuit Current")
|
||||||
# Worst case points
|
# Worst case points
|
||||||
w1_description = models.CharField(blank=True, default='', max_length=255, help_text="Description")
|
w1_description = models.CharField(blank=True, default='', max_length=255, help_text="Description")
|
||||||
w1_polarity = models.BooleanField(blank=True, null=True, help_text="Polarity Checked?")
|
w1_polarity = models.BooleanField(blank=True, null=True, help_text="Polarity Checked?")
|
||||||
w1_voltage = models.IntegerField(blank=True, null=True, help_text="Voltage")
|
w1_voltage = models.IntegerField(blank=True, null=True, help_text="Voltage")
|
||||||
w1_earth_fault = models.DecimalField(blank=True, null=True, max_digits=5, decimal_places=2, verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
w1_earth_fault = models.IntegerField(blank=True, null=True, help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
||||||
w2_description = models.CharField(blank=True, default='', max_length=255, help_text="Description")
|
w2_description = models.CharField(blank=True, default='', max_length=255, help_text="Description")
|
||||||
w2_polarity = models.BooleanField(blank=True, null=True, help_text="Polarity Checked?")
|
w2_polarity = models.BooleanField(blank=True, null=True, help_text="Polarity Checked?")
|
||||||
w2_voltage = models.IntegerField(blank=True, null=True, help_text="Voltage")
|
w2_voltage = models.IntegerField(blank=True, null=True, help_text="Voltage")
|
||||||
w2_earth_fault = models.DecimalField(blank=True, null=True, max_digits=5, decimal_places=2, verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
w2_earth_fault = models.IntegerField(blank=True, null=True, help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
||||||
w3_description = models.CharField(blank=True, default='', max_length=255, help_text="Description")
|
w3_description = models.CharField(blank=True, default='', max_length=255, help_text="Description")
|
||||||
w3_polarity = models.BooleanField(blank=True, null=True, help_text="Polarity Checked?")
|
w3_polarity = models.BooleanField(blank=True, null=True, help_text="Polarity Checked?")
|
||||||
w3_voltage = models.IntegerField(blank=True, null=True, help_text="Voltage")
|
w3_voltage = models.IntegerField(blank=True, null=True, help_text="Voltage")
|
||||||
w3_earth_fault = models.DecimalField(blank=True, null=True, max_digits=5, decimal_places=2, verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
w3_earth_fault = models.IntegerField(blank=True, null=True, help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
||||||
|
|
||||||
all_rcds_tested = models.BooleanField(blank=True, null=True, help_text="All circuit RCDs tested?<br><small>(using test button)</small>")
|
all_rcds_tested = models.BooleanField(blank=True, null=True, help_text="All circuit RCDs tested?<br><small>(using test button)</small>")
|
||||||
public_sockets_tested = models.BooleanField(blank=True, null=True, help_text="Public/Performer accessible circuits tested?<br><small>(using socket tester)</small>")
|
public_sockets_tested = models.BooleanField(blank=True, null=True, help_text="Public/Performer accessible circuits tested?<br><small>(using socket tester)</small>")
|
||||||
@@ -871,16 +792,16 @@ class EventChecklist(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
inverted_fields = []
|
inverted_fields = []
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def fields(self):
|
||||||
|
return [n.name for n in list(self._meta.get_fields()) if n.name != 'reviewed_at' and n.name != 'reviewed_by' and not n.is_relation and not n.auto_created]
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['event']
|
ordering = ['event']
|
||||||
permissions = [
|
permissions = [
|
||||||
('review_eventchecklist', 'Can review Event Checklists')
|
('review_eventchecklist', 'Can review Event Checklists')
|
||||||
]
|
]
|
||||||
|
|
||||||
@cached_property
|
|
||||||
def fieldz(self):
|
|
||||||
return [n.name for n in list(self._meta.get_fields()) if n.name != 'reviewed_at' and n.name != 'reviewed_by' and not n.is_relation and not n.auto_created]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return str(self.event)
|
return str(self.event)
|
||||||
@@ -889,7 +810,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 f"{self.pk} - {self.event}"
|
return "%i - %s" % (self.pk, self.event)
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
@@ -901,7 +822,7 @@ class EventChecklistVehicle(models.Model, RevisionMixin):
|
|||||||
reversion_hide = True
|
reversion_hide = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.vehicle} driven by {self.driver}"
|
return "{} driven by {}".format(self.vehicle, str(self.driver))
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
@@ -919,4 +840,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 f"{self.crewmember} ({self.role})"
|
return "{} ({})".format(str(self.crewmember), self.role)
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
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
|
||||||
@@ -19,9 +24,10 @@ 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, ModalURLMixin, PrintView, get_related
|
from PyRIGS.views import OEmbedView, is_ajax
|
||||||
from RIGS import models, forms
|
from RIGS import models, forms
|
||||||
|
|
||||||
__author__ = 'ghost'
|
__author__ = 'ghost'
|
||||||
@@ -32,7 +38,7 @@ class RigboardIndex(generic.TemplateView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
# get super context
|
# get super context
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(RigboardIndex, self).get_context_data(**kwargs)
|
||||||
|
|
||||||
# call out method to get current events
|
# call out method to get current events
|
||||||
context['events'] = models.Event.objects.current_events().select_related('riskassessment', 'invoice').prefetch_related('checklists')
|
context['events'] = models.Event.objects.current_events().select_related('riskassessment', 'invoice').prefetch_related('checklists')
|
||||||
@@ -44,27 +50,22 @@ class WebCalendar(generic.TemplateView):
|
|||||||
template_name = 'calendar.html'
|
template_name = 'calendar.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(WebCalendar, self).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, ModalURLMixin):
|
class EventDetail(generic.DetailView):
|
||||||
template_name = 'event_detail.html'
|
template_name = 'event_detail.html'
|
||||||
model = models.Event
|
model = models.Event
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(EventDetail, self).get_context_data(**kwargs)
|
||||||
title = f"{self.object.display_id} | {self.object.name}"
|
title = "{} | {}".format(self.object.display_id, self.object.name)
|
||||||
if self.object.dry_hire:
|
if self.object.dry_hire:
|
||||||
title += " <span class='badge badge-secondary'>Dry Hire</span>"
|
title += " <span class='badge badge-secondary'>Dry Hire</span>"
|
||||||
context['page_title'] = title
|
context['page_title'] = title
|
||||||
if is_ajax(self.request):
|
|
||||||
context['override'] = "base_ajax.html"
|
|
||||||
else:
|
|
||||||
context['override'] = 'base_assets.html'
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ class EventCreate(generic.CreateView):
|
|||||||
template_name = 'event_form.html'
|
template_name = 'event_form.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(EventCreate, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = "New Event"
|
context['page_title'] = "New Event"
|
||||||
context['edit'] = True
|
context['edit'] = True
|
||||||
context['currentVAT'] = models.VatRate.objects.current_rate()
|
context['currentVAT'] = models.VatRate.objects.current_rate()
|
||||||
@@ -92,8 +93,11 @@ 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_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)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -106,13 +110,17 @@ class EventUpdate(generic.UpdateView):
|
|||||||
template_name = 'event_form.html'
|
template_name = 'event_form.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(EventUpdate, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = f"Event {self.object.display_id}"
|
context['page_title'] = "Event {}".format(self.object.display_id)
|
||||||
context['edit'] = True
|
context['edit'] = True
|
||||||
|
|
||||||
form = context['form']
|
form = context['form']
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -126,7 +134,7 @@ class EventUpdate(generic.UpdateView):
|
|||||||
if hasattr(self.object, 'authorised'):
|
if hasattr(self.object, 'authorised'):
|
||||||
messages.warning(self.request,
|
messages.warning(self.request,
|
||||||
'This event has already been authorised by the client, any changes to the price will require reauthorisation.')
|
'This event has already been authorised by the client, any changes to the price will require reauthorisation.')
|
||||||
return super().render_to_response(context, **response_kwargs)
|
return super(EventUpdate, self).render_to_response(context, **response_kwargs)
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy('event_detail', kwargs={'pk': self.object.pk})
|
return reverse_lazy('event_detail', kwargs={'pk': self.object.pk})
|
||||||
@@ -134,7 +142,7 @@ class EventUpdate(generic.UpdateView):
|
|||||||
|
|
||||||
class EventDuplicate(EventUpdate):
|
class EventDuplicate(EventUpdate):
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
old = super().get_object(queryset) # Get the object (the event you're duplicating)
|
old = super(EventDuplicate, self).get_object(queryset) # Get the object (the event you're duplicating)
|
||||||
new = copy.copy(old) # Make a copy of the object in memory
|
new = copy.copy(old) # Make a copy of the object in memory
|
||||||
new.based_on = old # Make the new event based on the old event
|
new.based_on = old # Make the new event based on the old event
|
||||||
new.purchase_order = None # Remove old PO
|
new.purchase_order = None # Remove old PO
|
||||||
@@ -143,7 +151,6 @@ class EventDuplicate(EventUpdate):
|
|||||||
# Clear checked in by if it's a dry hire
|
# Clear checked in by if it's a dry hire
|
||||||
if new.dry_hire is True:
|
if new.dry_hire is True:
|
||||||
new.checked_in_by = None
|
new.checked_in_by = None
|
||||||
new.collector = None
|
|
||||||
|
|
||||||
# Remove all the authorisation information from the new event
|
# Remove all the authorisation information from the new event
|
||||||
new.auth_request_to = ''
|
new.auth_request_to = ''
|
||||||
@@ -159,22 +166,41 @@ class EventDuplicate(EventUpdate):
|
|||||||
return new
|
return new
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(EventDuplicate, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = f"Duplicate of Event {self.object.display_id}"
|
context['page_title'] = "Duplicate of Event {}".format(self.object.display_id)
|
||||||
context["duplicate"] = True
|
context["duplicate"] = True
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventPrint(PrintView):
|
class EventPrint(generic.View):
|
||||||
model = models.Event
|
def get(self, request, pk):
|
||||||
template_name = 'event_print.xml'
|
object = get_object_or_404(models.Event, pk=pk)
|
||||||
append_terms = True
|
template = get_template('event_print.xml')
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
merger = PdfFileMerger()
|
||||||
context = super().get_context_data(**kwargs)
|
|
||||||
context['quote'] = True
|
context = {
|
||||||
context['filename'] = f"Event_{context['object'].display_id}_{context['object_name']}_{context['object'].start_date}.pdf"
|
'object': object,
|
||||||
return context
|
'quote': True,
|
||||||
|
'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):
|
||||||
@@ -183,7 +209,9 @@ class EventArchive(generic.ListView):
|
|||||||
paginate_by = 25
|
paginate_by = 25
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
# get super context
|
||||||
|
context = super(EventArchive, self).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
|
||||||
@@ -207,22 +235,37 @@ 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 != "":
|
||||||
objects = self.model.objects.search(q)
|
qfilter = Q(name__icontains=q) | Q(description__icontains=q) | Q(notes__icontains=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 = objects.filter(filter).order_by('-start_date')
|
qs = self.model.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')
|
||||||
|
|
||||||
if not qs.exists():
|
if len(qs) == 0:
|
||||||
messages.add_message(self.request, messages.WARNING, "No events have been found matching those criteria.")
|
messages.add_message(self.request, messages.WARNING, "No events have been found matching those criteria.")
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
@@ -239,7 +282,7 @@ class EventAuthorise(generic.UpdateView):
|
|||||||
self.template_name = self.success_template
|
self.template_name = self.success_template
|
||||||
messages.add_message(self.request, messages.SUCCESS,
|
messages.add_message(self.request, messages.SUCCESS,
|
||||||
'Success! Your event has been authorised. ' +
|
'Success! Your event has been authorised. ' +
|
||||||
f'You will also receive email confirmation to {self.object.email}.')
|
'You will also receive email confirmation to %s.' % self.object.email)
|
||||||
return self.render_to_response(self.get_context_data())
|
return self.render_to_response(self.get_context_data())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -253,10 +296,10 @@ class EventAuthorise(generic.UpdateView):
|
|||||||
return forms.InternalClientEventAuthorisationForm
|
return forms.InternalClientEventAuthorisationForm
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(EventAuthorise, self).get_context_data(**kwargs)
|
||||||
context['event'] = self.event
|
context['event'] = self.event
|
||||||
context['tos_url'] = settings.TERMS_OF_HIRE_URL
|
context['tos_url'] = settings.TERMS_OF_HIRE_URL
|
||||||
context['page_title'] = f"{self.event.display_id}: {self.event.name}"
|
context['page_title'] = "{}: {}".format(self.event.display_id, self.event.name)
|
||||||
if self.event.dry_hire:
|
if self.event.dry_hire:
|
||||||
context['page_title'] += ' <span class="badge badge-secondary align-top">Dry Hire</span>'
|
context['page_title'] += ' <span class="badge badge-secondary align-top">Dry Hire</span>'
|
||||||
context['preview'] = self.preview
|
context['preview'] = self.preview
|
||||||
@@ -272,10 +315,10 @@ 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().get(request, *args, **kwargs)
|
return super(EventAuthorise, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_form(self, **kwargs):
|
def get_form(self, **kwargs):
|
||||||
form = super().get_form(**kwargs)
|
form = super(EventAuthorise, self).get_form(**kwargs)
|
||||||
form.instance.event = self.event
|
form.instance.event = self.event
|
||||||
form.instance.email = self.request.email
|
form.instance.email = self.request.email
|
||||||
form.instance.sent_by = self.request.sent_by
|
form.instance.sent_by = self.request.sent_by
|
||||||
@@ -291,7 +334,7 @@ class EventAuthorise(generic.UpdateView):
|
|||||||
except (signing.BadSignature, AssertionError, KeyError, models.Profile.DoesNotExist):
|
except (signing.BadSignature, AssertionError, KeyError, models.Profile.DoesNotExist):
|
||||||
raise SuspiciousOperation(
|
raise SuspiciousOperation(
|
||||||
"This URL is invalid. Please ask your TEC contact for a new URL")
|
"This URL is invalid. Please ask your TEC contact for a new URL")
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super(EventAuthorise, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMixin):
|
class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMixin):
|
||||||
@@ -301,7 +344,7 @@ class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMix
|
|||||||
|
|
||||||
@method_decorator(decorators.nottinghamtec_address_required)
|
@method_decorator(decorators.nottinghamtec_address_required)
|
||||||
def dispatch(self, *args, **kwargs):
|
def dispatch(self, *args, **kwargs):
|
||||||
return super().dispatch(*args, **kwargs)
|
return super(EventAuthorisationRequest, self).dispatch(*args, **kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def object(self):
|
def object(self):
|
||||||
@@ -341,7 +384,7 @@ class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMix
|
|||||||
context['to_name'] = event.organisation.name
|
context['to_name'] = event.organisation.name
|
||||||
|
|
||||||
msg = EmailMultiAlternatives(
|
msg = EmailMultiAlternatives(
|
||||||
f"{self.object.display_id} | {self.object.name} - Event Authorisation Request",
|
"N%05d | %s - Event Authorisation Request" % (self.object.pk, self.object.name),
|
||||||
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],
|
||||||
@@ -362,13 +405,13 @@ class EventAuthoriseRequestEmailPreview(generic.DetailView):
|
|||||||
|
|
||||||
def render_to_response(self, context, **response_kwargs):
|
def render_to_response(self, context, **response_kwargs):
|
||||||
css = finders.find('css/email.css')
|
css = finders.find('css/email.css')
|
||||||
response = super().render_to_response(context, **response_kwargs)
|
response = super(EventAuthoriseRequestEmailPreview, self).render_to_response(context, **response_kwargs)
|
||||||
assert isinstance(response, HttpResponse)
|
assert isinstance(response, HttpResponse)
|
||||||
response.content = premailer.Premailer(response.rendered_content, external_styles=css).transform()
|
response.content = premailer.Premailer(response.rendered_content, external_styles=css).transform()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(EventAuthoriseRequestEmailPreview, self).get_context_data(**kwargs)
|
||||||
context['hmac'] = signing.dumps({
|
context['hmac'] = signing.dumps({
|
||||||
'pk': self.object.pk,
|
'pk': self.object.pk,
|
||||||
'email': self.request.GET.get('email', 'hello@world.test'),
|
'email': self.request.GET.get('email', 'hello@world.test'),
|
||||||
@@ -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 = f"{instance.event.display_id} | {instance.event.name} - Event Authorised"
|
subject = "N%05d | %s - Event Authorised" % (instance.event.pk, instance.event.name)
|
||||||
|
|
||||||
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(f'{instance.event.display_id} - {escapedEventName} - CONFIRMATION.pdf',
|
client_email.attach('N%05d - %s - CONFIRMATION.pdf' % (instance.event.pk, escapedEventName),
|
||||||
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(
|
||||||
f"{context['number_of_users']} new users awaiting approval on RIGS",
|
"%s new users awaiting approval on RIGS" % (context['number_of_users']),
|
||||||
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],
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 278 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.4 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 852 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 164 KiB |
6
RIGS/static/js/marked.min.js
vendored
6
RIGS/static/js/marked.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,139 +0,0 @@
|
|||||||
<?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>
|
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load invoices_waiting from filters %}
|
|
||||||
{% load invoices_outstanding from filters %}
|
|
||||||
{% load total_invoices_todo from filters %}
|
|
||||||
|
|
||||||
{% block titleheader %}
|
{% block titleheader %}
|
||||||
<a class="navbar-brand" style="margin-left: auto; margin-right: auto;" href="/">RIGS</a>
|
<a class="navbar-brand" href="/">RIGS</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block titleelements %}
|
{% block titleelements %}
|
||||||
@@ -47,17 +44,14 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.RIGS.view_invoice %}
|
{% if perms.RIGS.view_invoice %}
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
{% total_invoices_todo as todo %}
|
|
||||||
{% invoices_waiting as waiting %}
|
|
||||||
{% invoices_outstanding as outstanding %}
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownInvoices" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownInvoices" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
Invoices <span class="badge {% if todo == 0 %}badge-success{% else %}badge-danger{% endif %} badge-pill">{{ todo }}</span>
|
Invoices
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdownInvoices">
|
<div class="dropdown-menu" aria-labelledby="navbarDropdownInvoices">
|
||||||
{% if perms.RIGS.add_invoice %}
|
{% if perms.RIGS.add_invoice %}
|
||||||
<a class="dropdown-item text-nowrap" href="{% url 'invoice_waiting' %}"><span class="fas fa-briefcase text-danger"></span> Waiting <span class="badge {% if waiting == 0 %}badge-success{% else %}badge-danger{% endif %} badge-pill">{{ waiting }}</span></a>
|
<a class="dropdown-item" href="{% url 'invoice_waiting' %}"><span class="fas fa-briefcase text-danger"></span> Waiting</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="dropdown-item" href="{% url 'invoice_list' %}"><span class="fas fa-pound-sign text-warning"></span> Outstanding <span class="badge {% if outstanding == 0 %}badge-success{% else %}badge-danger{% endif %} badge-pill">{{ outstanding }}</span></a>
|
<a class="dropdown-item" href="{% url 'invoice_list' %}"><span class="fas fa-pound-sign text-warning"></span> Outstanding</a>
|
||||||
<a class="dropdown-item" href="{% url 'invoice_archive' %}"><span class="fas fa-book"></span> Archive</a>
|
<a class="dropdown-item" href="{% url 'invoice_archive' %}"><span class="fas fa-book"></span> Archive</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -27,12 +27,15 @@
|
|||||||
|
|
||||||
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
|
||||||
@@ -55,10 +58,8 @@
|
|||||||
};
|
};
|
||||||
$(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 + " 23:59").format("YYYY-MM-DD[T]HH:mm:ss")
|
end = moment(end).add(1, 'days') //End date is non-inclusive, so add a day
|
||||||
allDay = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
thisEvent = {
|
thisEvent = {
|
||||||
@@ -66,8 +67,7 @@
|
|||||||
'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"){
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 text-right my-3">
|
<div class="col-12 text-right my-3">
|
||||||
{% button 'edit' url='ec_edit' pk=object.pk %}
|
{% button 'edit' url='ec_edit' pk=object.pk %}
|
||||||
{% button 'view' url='event_detail' pk=object.event.pk text="Event" %}
|
{% button 'view' url='event_detail' pk=object.pk text="Event" %}
|
||||||
{% include 'partials/review_status.html' with perm=perms.RIGS.review_eventchecklist review='ec_review' %}
|
{% include 'partials/review_status.html' with perm=perms.RIGS.review_eventchecklist review='ec_review' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -32,11 +32,7 @@
|
|||||||
</dd>
|
</dd>
|
||||||
<dt class="col-6">{{ object|help_text:'power_mic' }}</dt>
|
<dt class="col-6">{{ object|help_text:'power_mic' }}</dt>
|
||||||
<dd class="col-6">
|
<dd class="col-6">
|
||||||
{% if object.power_mic %}
|
|
||||||
<a href="{% url 'profile_detail' object.power_mic.pk %}">{{ object.power_mic.name }}</a>
|
<a href="{% url 'profile_detail' object.power_mic.pk %}">{{ object.power_mic.name }}</a>
|
||||||
{% else %}
|
|
||||||
None
|
|
||||||
{% endif %}
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<p>List vehicles and their drivers</p>
|
<p>List vehicles and their drivers</p>
|
||||||
@@ -102,10 +98,6 @@
|
|||||||
<td>{{crew.role}}</td>
|
<td>{{crew.role}}</td>
|
||||||
<td>{{crew.end}}</td>
|
<td>{{crew.end}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
|
||||||
<tr>
|
|
||||||
<td colspan="4" class="text-center bg-warning">Apparently this event happened by magic...</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -113,27 +105,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<div class="card-header">Power {% include 'partials/event_size.html' with object=object.event.riskassessment %}</div>
|
<div class="card-header">Power {% include 'partials/event_size.html' with object=object.event.riskassessment %}</div>
|
||||||
|
{% if object.event.riskassessment.event_size != 2 %}
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{% if object.event.riskassessment.event_size == 0 %}
|
{% if object.event.riskassessment.event_size == 1 %}
|
||||||
<dl class="row">
|
|
||||||
<dt class="col-10">{{ object|help_text:'rcds'|safe }}</dt>
|
|
||||||
<dd class="col-2">
|
|
||||||
{{ object.rcds|yesnoi }}
|
|
||||||
</dd>
|
|
||||||
<dt class="col-10">{{ object|help_text:'supply_test'|safe }}</dt>
|
|
||||||
<dd class="col-2">
|
|
||||||
{{ object.supply_test|yesnoi }}
|
|
||||||
</dd>
|
|
||||||
<dt class="col-10">{{ object|help_text:'earthing'|safe }}</dt>
|
|
||||||
<dd class="col-2">
|
|
||||||
{{ object.earthing|yesnoi }}
|
|
||||||
</dd>
|
|
||||||
<dt class="col-10">{{ object|help_text:'pat'|safe }}</dt>
|
|
||||||
<dd class="col-2">
|
|
||||||
{{ object.pat|yesnoi }}
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
{% else %}
|
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
<dt class="col-10">{{ object|help_text:'source_rcd'|safe }}</dt>
|
<dt class="col-10">{{ object|help_text:'source_rcd'|safe }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-2">
|
||||||
@@ -238,8 +212,28 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<hr>
|
<hr>
|
||||||
{% include 'partials/ec_power_info.html' %}
|
{% include 'partials/ec_power_info.html' %}
|
||||||
|
{% else %}
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-10">{{ object|help_text:'rcds'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.rcds|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-10">{{ object|help_text:'supply_test'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.supply_test|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-10">{{ object|help_text:'earthing'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.earthing|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-10">{{ object|help_text:'pat'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.pat|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 text-right">
|
<div class="col-12 text-right">
|
||||||
{% button 'edit' url='ec_edit' pk=object.pk %}
|
{% button 'edit' url='ec_edit' pk=object.pk %}
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
<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) {
|
||||||
@@ -242,19 +244,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% elif event.riskassessment.event_size == 1 %}
|
||||||
<div class="row my-3" id="size-1">
|
<div class="row my-3" id="size-1">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{% if event.riskassessment.event_size == 1 %}
|
|
||||||
<div class="card border-warning">
|
<div class="card border-warning">
|
||||||
<div class="card-header">Electrical Checks <small>for ‘Medium’ TEC Events </small></div>
|
<div class="card-header">Electrical Checks <small>for ‘Medium’ TEC Events </small></div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{% else %}
|
|
||||||
<div class="card border-danger">
|
|
||||||
<div class="card-header">Electrical Checks <small>for ‘Large’ TEC Events</small></div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="alert alert-danger"><strong>Here be dragons. Ensure you have appeased the Power Gods before continuing... (If you didn't check with a Supervisor, <em>you cannot continue your event!</em>)</strong></div>
|
|
||||||
{% endif %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.source_rcd %}
|
{% include 'partials/checklist_checkbox.html' with formitem=form.source_rcd %}
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.labelling %}
|
{% include 'partials/checklist_checkbox.html' with formitem=form.labelling %}
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.earthing %}
|
{% include 'partials/checklist_checkbox.html' with formitem=form.earthing %}
|
||||||
@@ -344,6 +339,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="row my-3" id="size-2">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card border-danger">
|
||||||
|
<div class="card-header">Electrical Checks <small>for ‘Large’ TEC Events</small></div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p>Outside the scope of this assessment. <strong>I really hope you checked with a supervisor...</strong></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="row mt-3">
|
<div class="row mt-3">
|
||||||
<div class="col-sm-12 text-right">
|
<div class="col-sm-12 text-right">
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
||||||
|
{% load linkornone from filters %}
|
||||||
{% load markdown_tags %}
|
{% load namewithnotes from filters %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row my-3 py-3">
|
<div class="row my-3 py-3">
|
||||||
@@ -14,7 +14,50 @@
|
|||||||
{% if object.is_rig and perms.RIGS.view_event %}
|
{% if object.is_rig and perms.RIGS.view_event %}
|
||||||
{# only need contact details for a rig #}
|
{# only need contact details for a rig #}
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{% include 'partials/contact_details.html' %}
|
{% if event.person %}
|
||||||
|
<div class="card card-default mb-3">
|
||||||
|
<div class="card-header">Contact Details</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-sm-6">Person</dt>
|
||||||
|
<dd class="col-sm-6">
|
||||||
|
{% if object.person %}
|
||||||
|
<a href="{% url 'person_detail' object.person.pk %}" class="modal-href">
|
||||||
|
{{ object.person|namewithnotes:'person_detail' }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-sm-6">Email</dt>
|
||||||
|
<dd class="col-sm-6">{{ object.person.email|linkornone:'mailto' }}</dd>
|
||||||
|
<dt class="col-sm-6">Phone Number</dt>
|
||||||
|
<dd class="col-sm-6">{{ object.person.phone|linkornone:'tel' }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if event.organisation %}
|
||||||
|
<div class="card card-default">
|
||||||
|
<div class="card-header">Organisation</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-sm-6">Organisation</dt>
|
||||||
|
<dd class="col-sm-6">
|
||||||
|
{% if object.organisation %}
|
||||||
|
<a href="{% url 'organisation_detail' object.organisation.pk %}" class="modal-href">
|
||||||
|
{{ object.organisation|namewithnotes:'organisation_detail' }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-sm-6">Email</dt>
|
||||||
|
<dd class="col-sm-6">{{ object.organisation.email|linkornone:'mailto' }}</dd>
|
||||||
|
<dt class="col-sm-6">Phone Number</dt>
|
||||||
|
<dd class="col-sm-6">{{ object.organisation.phone|linkornone:'tel' }}</dd>
|
||||||
|
<dt class="col-sm-6">Has SU Account</dt>
|
||||||
|
<dd class="col-sm-6">{{ event.organisation.union_account|yesno|capfirst }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
@@ -45,10 +88,10 @@
|
|||||||
{% if perms.RIGS.view_event %}
|
{% if perms.RIGS.view_event %}
|
||||||
<h4>Notes</h4>
|
<h4>Notes</h4>
|
||||||
<hr>
|
<hr>
|
||||||
<p class="dont-break-out">{{ event.notes|markdown }}</p>
|
<p class="dont-break-out">{{ event.notes|linebreaksbr }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br>
|
<br>
|
||||||
{% include 'partials/item_table.html' %}
|
{% include 'item_table.html' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,13 +8,11 @@
|
|||||||
{% 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/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/easymde.min.js' %}"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
@@ -23,30 +21,24 @@
|
|||||||
<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 () {
|
||||||
dur = matches ? 0 : 500;
|
dur = matches ? 0 : 500;
|
||||||
{% if object.pk %}
|
{% if not object.pk and not form.errors %}
|
||||||
// Editing
|
$('.form-hws').slideUp(dur, function () {
|
||||||
{% if not object.is_rig %}
|
$('.form-is_rig').slideUp(dur);
|
||||||
|
});
|
||||||
|
{% elif not object.pk and form.errors %}
|
||||||
|
if ($('#{{form.is_rig.auto_id}}').attr('checked') !== 'checked') {
|
||||||
$('.form-is_rig').hide();
|
$('.form-is_rig').hide();
|
||||||
{% endif %}
|
}
|
||||||
//Creation
|
{% endif %}
|
||||||
{% else %}
|
{% if not object.pk %}
|
||||||
// If there were errors, apply the previous Rig/not-Rig selection
|
|
||||||
{% if form.errors %}
|
|
||||||
$('.form-hws').show();
|
|
||||||
if ($('#{{form.is_rig.auto_id}}').attr('checked') !== 'checked') {
|
|
||||||
$('.form-is_rig').hide();
|
|
||||||
}
|
|
||||||
{% else %}
|
|
||||||
//Initial hide
|
|
||||||
$('.form-hws').slideUp(dur);
|
|
||||||
{% endif %}
|
|
||||||
//Button handling
|
|
||||||
$('#is_rig-selector button').on('click', function () {
|
$('#is_rig-selector button').on('click', function () {
|
||||||
$('.form-non_rig').slideDown(dur); //Non rig stuff also needed for rig, so always slide down
|
$('.form-non_rig').slideDown(dur);
|
||||||
if ($(this).data('is_rig') === 1) {
|
if ($(this).data('is_rig') === 1) {
|
||||||
$('#{{form.is_rig.auto_id}}').prop('checked', true);
|
$('#{{form.is_rig.auto_id}}').prop('checked', true);
|
||||||
if ($('.form-non_rig').is(':hidden')) {
|
if ($('.form-non_rig').is(':hidden')) {
|
||||||
@@ -56,6 +48,7 @@
|
|||||||
}
|
}
|
||||||
$('.form-hws, .form-hws .form-is_rig').css('overflow', 'visible');
|
$('.form-hws, .form-hws .form-is_rig').css('overflow', 'visible');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$('#{{form.is_rig.auto_id}}').prop('checked', false);
|
$('#{{form.is_rig.auto_id}}').prop('checked', false);
|
||||||
$('.form-is_rig').slideUp(dur);
|
$('.form-is_rig').slideUp(dur);
|
||||||
}
|
}
|
||||||
@@ -63,26 +56,23 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
});
|
});
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
setupMDE('#id_description');
|
|
||||||
setupMDE('#id_notes');
|
|
||||||
setupMDE('#item_description');
|
|
||||||
|
|
||||||
$('#itemModal').on('shown.bs.modal', function (e) {
|
|
||||||
$('#item_description').data('mde_editor').value(
|
|
||||||
$('#item_description').val()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
setupItemTable($("#{{ form.items_json.id_for_label }}").val());
|
setupItemTable($("#{{ form.items_json.id_for_label }}").val());
|
||||||
});
|
});
|
||||||
$(function () {
|
$(function () {
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
<noscript>
|
||||||
|
<style>
|
||||||
|
.form-hws {
|
||||||
|
display: inherit !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</noscript>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include 'partials/item_modal.html' %}
|
{% include 'item_modal.html' %}
|
||||||
<form class="itemised_form" role="form" method="POST">
|
<form class="itemised_form" role="form" method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -122,7 +112,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="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='person' %}">
|
<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' %}">
|
||||||
{% 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 %}
|
||||||
@@ -149,7 +139,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="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='organisation' %}" >
|
<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' %}" >
|
||||||
{% 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 %}
|
||||||
@@ -178,7 +168,7 @@
|
|||||||
<label for="{{ form.description.id_for_label }}"
|
<label for="{{ form.description.id_for_label }}"
|
||||||
class="col-sm-4 col-form-label">{{ form.description.label }}</label>
|
class="col-sm-4 col-form-label">{{ form.description.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-8">
|
||||||
{% render_field form.description class+="form-control" %}
|
{% render_field form.description class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -207,7 +197,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="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='venue' %}">
|
<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' %}">
|
||||||
{% 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 %}
|
||||||
@@ -277,8 +267,10 @@
|
|||||||
</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">
|
||||||
{{ form.dry_hire.label }} {% render_field form.dry_hire %}
|
{% render_field form.dry_hire %}{{ form.dry_hire.label }}
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -300,7 +292,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="px-0 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="form-control 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 %}
|
||||||
@@ -314,7 +306,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="px-0 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="form-control 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 %}
|
||||||
@@ -334,7 +326,7 @@
|
|||||||
|
|
||||||
<div class="form-group" data-toggle="tooltip" title="The purchase order number (for external clients)">
|
<div class="form-group" data-toggle="tooltip" title="The purchase order number (for external clients)">
|
||||||
<label for="{{ form.purchase_order.id_for_label }}"
|
<label for="{{ form.purchase_order.id_for_label }}"
|
||||||
class="col-sm-4 col-fitem_tableorm-label">{{ form.purchase_order.label }}</label>
|
class="col-sm-4 col-form-label">{{ form.purchase_order.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
{% render_field form.purchase_order class+="form-control" %}
|
{% render_field form.purchase_order class+="form-control" %}
|
||||||
@@ -353,10 +345,10 @@
|
|||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<div class="form-group" data-toggle="tooltip" title="Notes on the event. This is only visible to keyholders, and is not displayed on the paperwork">
|
<div class="form-group" data-toggle="tooltip" title="Notes on the event. This is only visible to keyholders, and is not displayed on the paperwork">
|
||||||
<label for="{{ form.notes.id_for_label }}">{{ form.notes.label }}</label>
|
<label for="{{ form.notes.id_for_label }}">{{ form.notes.label }}</label>
|
||||||
{% render_field form.notes class+="form-control md-enabled" %}
|
{% render_field form.notes class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% include 'partials/item_table.html' %}
|
{% include 'item_table.html' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,128 @@
|
|||||||
{% extends 'base_print.xml' %}
|
<?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>
|
||||||
|
|
||||||
{% block content %}
|
<stylesheet>
|
||||||
{% include "event_print_page.xml" %}
|
<initialize>
|
||||||
{% endblock %}
|
<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>
|
||||||
|
</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,17 +1,19 @@
|
|||||||
{% 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 }}'</h1>
|
<h1><b>N{{ object.pk|stringformat:"05d" }}:</b> '{{ object.name }}'<small></small></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>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<keepInFrame maxHeight="500" onOverflow="shrink">
|
<keepInFrame>
|
||||||
{{ object.description|default_if_none:""|markdown:"rml" }}
|
<para style="style.event_description">
|
||||||
|
{{ object.description|default_if_none:""|linebreaksxml }}
|
||||||
|
</para>
|
||||||
</keepInFrame>
|
</keepInFrame>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -178,36 +180,39 @@
|
|||||||
{% for item in object.items.all %}
|
{% for item in object.items.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<para><b>{{ item.name }}</b></para>
|
<para>{{ item.name }}
|
||||||
{% if item.description %}
|
{% if item.description %}
|
||||||
{{ item.description|markdown:"rml" }}
|
</para>
|
||||||
{% endif %}
|
<para style="item_description">
|
||||||
|
<em>{{ item.description|linebreaksxml }}</em>
|
||||||
|
</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>
|
||||||
<td>£{{ item.total_cost|floatformat:2 }}</td>
|
<td>£ {{ item.total_cost|floatformat:2 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</blockTable>
|
</blockTable>
|
||||||
<keepTogether>
|
<keepTogether>
|
||||||
<blockTable style="totalTable" colWidths="300,115,80">
|
<blockTable style="totalTable" colWidths="300,115,80">
|
||||||
{% if object.vat > 0 %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% if quote %}VAT Registration Number: 170734807</td>
|
<td>{% if quote %}VAT Registration Number: 170734807{% endif %}</td>
|
||||||
<td>Total (ex. VAT){% endif %}</td>
|
<td>Total (ex. VAT)</td>
|
||||||
<td>£ {{ object.sum_total|floatformat:2 }}</td>
|
<td>£ {{ object.sum_total|floatformat:2 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if quote %}
|
{% if quote %}
|
||||||
<para>This quote is valid for 30 days unless otherwise arranged.</para>
|
<para>
|
||||||
|
This quote is valid for 30 days unless otherwise arranged.
|
||||||
|
</para>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if object.vat > 0 %}
|
|
||||||
<td>VAT @ {{ object.vat_rate.as_percent|floatformat:2 }}%</td>
|
<td>VAT @ {{ object.vat_rate.as_percent|floatformat:2 }}%</td>
|
||||||
<td>£{{ object.vat|floatformat:2 }}</td>
|
<td>£ {{ object.vat|floatformat:2 }}</td>
|
||||||
{% endif %}
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@@ -219,7 +224,7 @@
|
|||||||
</td>
|
</td>
|
||||||
{% if invoice %}
|
{% if invoice %}
|
||||||
<td>Total</td>
|
<td>Total</td>
|
||||||
<td>£{{ object.total|floatformat:2 }}</td>
|
<td>£ {{ object.total|floatformat:2 }}</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>
|
<td>
|
||||||
<para>
|
<para>
|
||||||
@@ -228,7 +233,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<para>
|
<para>
|
||||||
<b>£{{ object.total|floatformat:2 }}</b>
|
<b>£ {{ object.total|floatformat:2 }}</b>
|
||||||
</para>
|
</para>
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -262,7 +267,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{ payment.get_method_display }}</td>
|
<td>{{ payment.get_method_display }}</td>
|
||||||
<td>{{ payment.date }}</td>
|
<td>{{ payment.date }}</td>
|
||||||
<td>£{{ payment.amount|floatformat:2 }}</td>
|
<td>£ {{ payment.amount|floatformat:2 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</blockTable>
|
</blockTable>
|
||||||
@@ -270,18 +275,18 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Payment Total</td>
|
<td>Payment Total</td>
|
||||||
<td>£{{ object.invoice.payment_total|floatformat:2 }}</td>
|
<td>£ {{ object.invoice.payment_total|floatformat:2 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<para>
|
<para>
|
||||||
<b>Balance</b> {% if object.vat > 0 %}(ex. VAT){% endif %}
|
<b>Balance</b> (ex. VAT)
|
||||||
</para>
|
</para>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<para>
|
<para>
|
||||||
<b>£{{ object.invoice.balance|floatformat:2 }}</b>
|
<b>£ {{ object.invoice.balance|floatformat:2 }}</b>
|
||||||
</para>
|
</para>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -311,7 +316,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>General Enquires and 24 Hour Emergency Contact: 0115 84 68720</td>
|
<td>General Enquires and 24 Hour Emergency Contact: 0115 84 68720</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% elif object.vat > 0 %}
|
{% else %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<para>VAT Registration Number: 170734807</para>
|
<para>VAT Registration Number: 170734807</para>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
{% with object=event auth=True %}
|
{% with object=event auth=True %}
|
||||||
{% include 'partials/item_table.html' %}
|
{% include 'item_table.html' %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,13 +5,15 @@
|
|||||||
<p>Hi {{ to_name|default:"there" }},</p>
|
<p>Hi {{ to_name|default:"there" }},</p>
|
||||||
|
|
||||||
<p><b>{{ request.user.get_full_name }}</b> has requested that you authorise <b>{{ object.display_id }}
|
<p><b>{{ request.user.get_full_name }}</b> has requested that you authorise <b>{{ object.display_id }}
|
||||||
| {{ object.name }}</b>{% if not to_name %} on behalf of <b>{% if object.person %}{{ object.person.name }}{% else %}{{ object.organisation.name }}{% endif %}</b>{% endif %}.</p>
|
| {{ object.name }}</b>{% if not to_name %} on behalf of <b>{{ object.person.name }}</b>{% endif %}.</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Please find the link below to complete the event booking process.
|
Please find the link below to complete the event booking process.
|
||||||
Remember that only Presidents or Treasurers are allowed to sign off payments. You may need to forward
|
{% if object.event.organisation and object.event.organisation.union_account %}{# internal #}
|
||||||
this
|
Remember that only Presidents or Treasurers are allowed to sign off payments. You may need to forward
|
||||||
email on.
|
this
|
||||||
|
email on.
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Hi {{ to_name|default:"there" }},
|
Hi {{ to_name|default:"there" }},
|
||||||
|
|
||||||
{{ request.user.get_full_name }} has requested that you authorise N{{ object.pk|stringformat:"05d" }}| {{ object.name }}{% if not to_name %} on behalf of {% if object.person %}{{ object.person.name }}{% else %}{{ object.organisation.name }}{% endif %}{% endif %}.
|
{{ request.user.get_full_name }} has requested that you authorise N{{ object.pk|stringformat:"05d" }}| {{ object.name }}{% if not to_name %} on behalf of {{ object.person.name }}{% endif %}.
|
||||||
|
|
||||||
Please find the link below to complete the event booking process.
|
Please find the link below to complete the event booking process.
|
||||||
{% if object.event.organisation and object.event.organisation.union_account %}{# internal #}
|
{% if object.event.organisation and object.event.organisation.union_account %}{# internal #}
|
||||||
|
|||||||
@@ -1,48 +1,24 @@
|
|||||||
{% extends request.is_ajax|yesno:'base_ajax.html,base_rigs.html' %}
|
{% extends request.is_ajax|yesno:'base_ajax.html,base_rigs.html' %}
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
{% load static %}
|
|
||||||
{% load button from filters %}
|
|
||||||
|
|
||||||
{% 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">
|
||||||
<div class="alert alert-warning pb-0">
|
<div class="alert alert-warning">
|
||||||
<h1>Send authorisation request email.</h1>
|
<h1>Send authorisation request email.</h1>
|
||||||
<p>Pressing send will email the address provided. <strong>Please triple check everything before continuing.</strong></p>
|
<p>Pressing send will email the address provided. Please triple check everything before continuing.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alert alert-info pb-0">
|
<div class="alert alert-info">
|
||||||
{% if object.person.email or object.organisation.email %}
|
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
{% 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>{{ object.person.email }}</dd>
|
||||||
{% endif %}
|
|
||||||
{% 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>{{ object.organisation.email }}</dd>
|
||||||
{% endif %}
|
|
||||||
</dl>
|
</dl>
|
||||||
{% else %}
|
|
||||||
<p>No email addresses saved to the client ಠ_ಠ</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
<form action="{{ form.action|default:request.path }}" method="POST" id="auth-request-form">
|
<form action="{{ form.action|default:request.path }}" method="POST" id="auth-request-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|||||||
@@ -1,135 +0,0 @@
|
|||||||
{% 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 %}
|
|
||||||
@@ -4,11 +4,10 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table mb-0 table-sm">
|
<table class="table mb-0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Event</th>
|
<th scope="col">Event</th>
|
||||||
<th scope="col">MIC</th>
|
|
||||||
<th scope="col">Dates</th>
|
<th scope="col">Dates</th>
|
||||||
<th scope="col">RA</th>
|
<th scope="col">RA</th>
|
||||||
<th scope="col">Checklists</th>
|
<th scope="col">Checklists</th>
|
||||||
@@ -17,8 +16,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for event in object_list %}
|
{% for event in object_list %}
|
||||||
<tr id="event_row">
|
<tr id="event_row">
|
||||||
<th scope="row" id="event_number"><a href="{% url 'event_detail' event.pk %}">{{ event }}</a><br><small>{{ event.get_status_display }}</small></th>
|
<th scope="row" id="event_number"><a href="{% url 'event_detail' event.pk %}">{{ event }}</a></th>
|
||||||
<td>{% if event.mic is not None %}<a href="{% url 'profile_detail' event.mic.pk %}">{% else %}<span class="text-danger">{% endif %}{{ event.mic }}{% if event.mic is not None %}</a>{% else %}</span>{%endif%}</td>
|
|
||||||
<!--Dates-->
|
<!--Dates-->
|
||||||
<td id="event_dates">
|
<td id="event_dates">
|
||||||
<span><strong>{{ event.start_date|date:"D d/m/Y" }}</strong></span>
|
<span><strong>{{ event.start_date|date:"D d/m/Y" }}</strong></span>
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table mb-0 table-sm">
|
<table class="table mb-0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Event</th>
|
<th scope="col">Event</th>
|
||||||
{# mmm hax #}
|
{# mmm hax #}
|
||||||
{% if object_list.0 != None %}
|
{% if object_list.0 != None %}
|
||||||
{% for field in object_list.0.fieldz %}
|
{% for field in object_list.0.fields %}
|
||||||
<th scope="col">{{ object_list.0|verbose_name:field|title }}</th>
|
<th scope="col">{{ object_list.0|verbose_name:field|title }}</th>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
{% for object in object_list %}
|
{% for object in object_list %}
|
||||||
<tr class="{% if object.reviewed_by %}table-success{%endif%}">
|
<tr class="{% if object.reviewed_by %}table-success{%endif%}">
|
||||||
{# General #}
|
{# General #}
|
||||||
<th scope="row"><a href="{% url 'event_detail' object.event.pk %}">{{ object.event }}</a><br><small>{{ object.event.get_status_display }}</small></th>
|
<th scope="row"><a href="{% url 'event_detail' object.event.pk %}">{{ object.event }}</a></th>
|
||||||
{% for field in object_list.0.fieldz %}
|
{% for field in object_list.0.fields %}
|
||||||
<td>{{ object|get_field:field }}</td>
|
<td>{{ object|get_field:field }}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{# Buttons #}
|
{# Buttons #}
|
||||||
@@ -2,88 +2,102 @@
|
|||||||
{% load button from filters %}
|
{% load button from filters %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row py-4">
|
<div class="col-sm-12">
|
||||||
<div class="col-sm-12 text-right px-0">
|
<div class="row justify-content-end py-3">
|
||||||
<div class="btn-group">
|
<div class="col-sm-4 text-right">
|
||||||
<a href="{% url 'event_detail' object.event.pk %}" class="btn btn-primary">Open Event Page <span class="fas fa-eye"></span></a>
|
<div class="btn-group btn-page">
|
||||||
<a href="{% url 'invoice_delete' object.pk %}" class="btn btn-danger" title="Delete Invoice">
|
<a href="{% url 'invoice_delete' object.pk %}" class="btn btn-danger" title="Delete Invoice">
|
||||||
<span class="fas fa-times"></span> <span
|
<span class="fas fa-times"></span> <span
|
||||||
class="d-none d-sm-inline">Delete</span>
|
class="d-none d-sm-inline">Delete</span>
|
||||||
</a>
|
|
||||||
<a href="{% url 'invoice_void' object.pk %}" class="btn btn-warning" title="Void Invoice">
|
|
||||||
<span class="fas fa-ban"></span> <span
|
|
||||||
class="d-none d-sm-inline">Void</span>
|
|
||||||
</a>
|
|
||||||
{% button 'print' url='invoice_print' pk=object.pk %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div class="row py-4">
|
|
||||||
{% with object.event as object %}
|
|
||||||
<div class="col-sm-6">
|
|
||||||
{% include 'partials/contact_details.html' %}
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6">
|
|
||||||
{% include 'partials/event_details.html' %}
|
|
||||||
</div>
|
|
||||||
{% if object.event.internal %}
|
|
||||||
<div class="col-sm-6">
|
|
||||||
{% include 'partials/auth_details.html' %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endwith %}
|
|
||||||
</div>
|
|
||||||
<div class="row py-4">
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="card card-default">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="text-right py-3">
|
|
||||||
<a href="{% url 'payment_create' %}?invoice={{ object.pk }}"
|
|
||||||
class="btn btn-success modal-href"
|
|
||||||
data-target="#{{ form.person.id_for_label }}">
|
|
||||||
<span class="fas fa-plus"></span> Add
|
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{% url 'invoice_void' object.pk %}" class="btn btn-warning" title="Void Invoice">
|
||||||
|
<span class="fas fa-ban"></span> <span
|
||||||
|
class="d-none d-sm-inline">Void</span>
|
||||||
|
</a>
|
||||||
|
{% button 'print' url='invoice_print' pk=object.pk %}
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Date</th>
|
|
||||||
<th scope="col">Amount</th>
|
|
||||||
<th scope="col">Method</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for payment in object.payment_set.all %}
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{ payment.date }}</th>
|
|
||||||
<td>{{ payment.amount|floatformat:2 }}</td>
|
|
||||||
<td>{{ payment.get_method_display }}</td>
|
|
||||||
<td>
|
|
||||||
<a href="{% url 'payment_delete' payment.pk %}" class="btn btn-small btn-danger"><span class="fas fa-times"></span></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
<tr>
|
|
||||||
<td class="text-right"><strong>Balance:</strong></td>
|
|
||||||
<td>{{ object.balance|floatformat:2 }}</td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-sm-6">
|
<div class="row">
|
||||||
<div class="card">
|
<div class="col-sm-6">
|
||||||
{% with object.event as object %}
|
<div class="card card-default">
|
||||||
{% include 'partials/item_table.html' %}
|
<div class="card-header">Invoice Details<span class="float-right">
|
||||||
{% endwith %}
|
{% if object.void %}(VOID){% elif object.is_closed %}(PAID){% else %}(OUTSTANDING){% endif %}
|
||||||
|
</span></div>
|
||||||
|
<div class="card-body">
|
||||||
|
{% if object.event.organisation %}
|
||||||
|
{{ object.event.organisation.name }}<br/>
|
||||||
|
{{ object.event.organisation.address|linebreaksbr }}
|
||||||
|
{% else %}
|
||||||
|
{{ object.event.person.name }}<br/>
|
||||||
|
{{ object.event.person.address|linebreaksbr }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
{% include 'partials/event_details.html' %}
|
||||||
|
</div>
|
||||||
|
{% if object.event.internal %}
|
||||||
|
<div class="col-sm-6">
|
||||||
|
{% include 'partials/auth_details.html' %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row py-4">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="card card-default">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="text-right py-3">
|
||||||
|
<a href="{% url 'payment_create' %}?invoice={{ object.pk }}"
|
||||||
|
class="btn btn-success modal-href"
|
||||||
|
data-target="#{{ form.person.id_for_label }}">
|
||||||
|
<span class="fas fa-plus"></span> Add
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Date</th>
|
||||||
|
<th scope="col">Amount</th>
|
||||||
|
<th scope="col">Method</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for payment in object.payment_set.all %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{ payment.date }}</th>
|
||||||
|
<td>{{ payment.amount|floatformat:2 }}</td>
|
||||||
|
<td>{{ payment.get_method_display }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{% url 'payment_delete' payment.pk %}" class="btn btn-small btn-danger"><span class="fas fa-times"></span></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-right"><strong>Balance:</strong></td>
|
||||||
|
<td>{{ object.balance|floatformat:2 }}</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="card">
|
||||||
|
{% with object.event as object %}
|
||||||
|
{% include 'item_table.html' %}
|
||||||
|
{% endwith %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 text-right">
|
||||||
|
{% include 'partials/last_edited.html' with target="invoice_history" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="col-12 text-right">
|
|
||||||
{% include 'partials/last_edited.html' with target="invoice_history" %}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
id="item_name"/>
|
id="item_name"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group form-row" data-toggle="tooltip" title="A detailed description of the kit. MD enabled.">
|
<div class="form-group form-row">
|
||||||
<label for="item_description" class="col-sm-2 col-form-label">Description</label>
|
<label for="item_description" class="col-sm-2 col-form-label">Description</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<textarea type="text" placeholder="Description" class="form-control md-enabled"
|
<textarea type="text" placeholder="Description" class="form-control"
|
||||||
id="item_description" rows="8"></textarea>
|
id="item_description" rows="8"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
{% load markdown_tags %}
|
|
||||||
<tr id="item-{{item.pk}}" data-pk="{{item.pk}}" class="item_row">
|
<tr id="item-{{item.pk}}" data-pk="{{item.pk}}" class="item_row">
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
<span class="name">{{ item.name }}</span>
|
<span class="name">{{ item.name }}</span>
|
||||||
<div class="item-description">
|
<div class="item-description">
|
||||||
<em class="description">{{item.description|markdown}}</em>
|
<em class="description">{{item.description|linebreaksbr}}</em>
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
{% if perms.RIGS.view_event %}
|
{% if perms.RIGS.view_event %}
|
||||||
<td>£<span class="cost">{{item.cost|floatformat:2}}</span></td>
|
<td>£ <span class="cost">{{item.cost|floatformat:2}}</span></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="quantity">{{item.quantity}}</td>
|
<td class="quantity">{{item.quantity}}</td>
|
||||||
{% if perms.RIGS.view_event %}
|
{% if perms.RIGS.view_event %}
|
||||||
<td>£<span class="sub-total" data-subtotal="{{item.total_cost}}">{{item.total_cost|floatformat:2}}</span></td>
|
<td>£ <span class="sub-total" data-subtotal="{{item.total_cost}}">{{item.total_cost|floatformat:2}}</span></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if edit %}
|
{% if edit %}
|
||||||
<td class="vert-align text-right">
|
<td class="vert-align text-right">
|
||||||
@@ -23,17 +23,16 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody id="item-table-body">
|
<tbody id="item-table-body">
|
||||||
{% for item in object.items.all %}
|
{% for item in object.items.all %}
|
||||||
{% include 'partials/item_row.html' %}
|
{% include 'item_row.html' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
{% if auth or perms.RIGS.view_event %}
|
{% if auth or perms.RIGS.view_event %}
|
||||||
<tfoot style="font-weight: bold">
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="3" colspan="2"></td>
|
<td rowspan="3" colspan="2"></td>
|
||||||
<td>Total {% if object.vat > 0 or not object.pk %}(ex. VAT){% endif %}</td>
|
<td>Total (ex. VAT)</td>
|
||||||
<td colspan="2">£<span id="sumtotal">{{object.sum_total|default:0|floatformat:2}}</span></td>
|
<td colspan="2">£ <span id="sumtotal">{{object.sum_total|default:0|floatformat:2}}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% if object.vat > 0 or not object.pk %}
|
|
||||||
<tr>
|
<tr>
|
||||||
{% if not object.pk %}
|
{% if not object.pk %}
|
||||||
<td id="vat-rate" data-rate="{{currentVAT.rate}}">VAT @
|
<td id="vat-rate" data-rate="{{currentVAT.rate}}">VAT @
|
||||||
@@ -42,13 +41,12 @@
|
|||||||
<td id="vat-rate" data-rate="{{object.vat_rate.rate}}">VAT @
|
<td id="vat-rate" data-rate="{{object.vat_rate.rate}}">VAT @
|
||||||
{{object.vat_rate.as_percent|floatformat|default:"TBD"}}%</td>
|
{{object.vat_rate.as_percent|floatformat|default:"TBD"}}%</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td colspan="2">£<span id="vat">{{object.vat|default:0|floatformat:2}}</span></td>
|
<td colspan="2">£ <span id="vat">{{object.vat|default:0|floatformat:2}}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Total</td>
|
<td>Total</td>
|
||||||
<td colspan="2">£<span id="total">{{object.total|default:0|floatformat:2}}</span></td>
|
<td colspan="2">£ <span id="total">{{object.total|default:0|floatformat:2}}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
|
||||||
</tfoot>
|
</tfoot>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
@@ -61,9 +59,9 @@
|
|||||||
<em class="description"></em>
|
<em class="description"></em>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>£<span class="cost"></span></td>
|
<td>£ <span class="cost"></span></td>
|
||||||
<td class="quantity"></td>
|
<td class="quantity"></td>
|
||||||
<td>£<span class="sub-total"></span></td>
|
<td>£ <span class="sub-total"></span></td>
|
||||||
{% if edit %}
|
{% if edit %}
|
||||||
<td class="vert-align text-right">
|
<td class="vert-align text-right">
|
||||||
<div class="btn-group" role="group" aria-label="Action buttons">
|
<div class="btn-group" role="group" aria-label="Action buttons">
|
||||||
@@ -1,29 +1,27 @@
|
|||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
{% if event.person %}
|
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<div class="card-header">Contact Details</div>
|
<div class="card-header">Contact Details</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
<dt class="col-sm-5">Person</dt>
|
<dt class="col-sm-5">Person</dt>
|
||||||
<dd class="col-sm-7">
|
<dd class="col-sm-7">
|
||||||
{{ event.person.name }}
|
{% if event.person %}
|
||||||
|
{{ event.person.name }}
|
||||||
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
{% if event.person.email %}
|
|
||||||
<dt class="col-sm-5">Email</dt>
|
<dt class="col-sm-5">Email</dt>
|
||||||
<dd class="col-sm-7">
|
<dd class="col-sm-7">
|
||||||
<span class="overflow-ellipsis">{{ event.person.email }}</span>
|
<span class="overflow-ellipsis">{{ event.person.email }}</span>
|
||||||
</dd>
|
</dd>
|
||||||
{% endif %}
|
|
||||||
{% if event.person.phone %}
|
|
||||||
<dt class="col-sm-5">Phone Number</dt>
|
<dt class="col-sm-5">Phone Number</dt>
|
||||||
<dd class="col-sm-7">{{ event.person.phone }}</dd>
|
<dd class="col-sm-7">{{ event.person.phone }}</dd>
|
||||||
{% endif %}
|
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
{% if event.organisation %}
|
{% if event.organisation %}
|
||||||
<div class="card">
|
<div class="card mt-3">
|
||||||
<div class="card-header">Organisation Details</div>
|
<div class="card-header">Organisation Details</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
@@ -31,10 +29,9 @@
|
|||||||
<dd class="col-sm-7">
|
<dd class="col-sm-7">
|
||||||
{{ event.organisation.name }}
|
{{ event.organisation.name }}
|
||||||
</dd>
|
</dd>
|
||||||
{% if event.organisation.phone %}
|
|
||||||
<dt class="col-sm-5">Phone Number</dt>
|
<dt class="col-sm-5">Phone Number</dt>
|
||||||
<dd class="col-sm-7">{{ event.organisation.phone }}</dd>
|
<dd class="col-sm-7">{{ object.organisation.phone }}</dd>
|
||||||
{% endif %}
|
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -46,12 +43,15 @@
|
|||||||
<div class="card-header">Event Info</div>
|
<div class="card-header">Event Info</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
{% if event.venue %}
|
|
||||||
<dt class="col-sm-5">Event Venue</dt>
|
<dt class="col-sm-5">Event Venue</dt>
|
||||||
<dd class="col-sm-7">
|
<dd class="col-sm-7">
|
||||||
{{ event.venue }}
|
{% if object.venue %}
|
||||||
|
<a href="{% url 'venue_detail' object.venue.pk %}" class="modal-href">
|
||||||
|
{{ object.venue }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
{% endif %}
|
|
||||||
<dt class="col-sm-5">Status</dt>
|
<dt class="col-sm-5">Status</dt>
|
||||||
<dd class="col-sm-7">{{ event.get_status_display }}</dd>
|
<dd class="col-sm-7">{{ event.get_status_display }}</dd>
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
{% load linkornone from filters %}
|
|
||||||
{% load namewithnotes from filters %}
|
|
||||||
|
|
||||||
{% if object.person %}
|
|
||||||
<div class="card card-default mb-3">
|
|
||||||
<div class="card-header">Person Details</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<dl class="row">
|
|
||||||
<dt class="col-sm-6">Person</dt>
|
|
||||||
<dd class="col-sm-6">
|
|
||||||
{% if object.person %}
|
|
||||||
<a href="{% url 'person_detail' object.person.pk %}" class="modal-href">
|
|
||||||
{{ object.person|namewithnotes:'person_detail' }}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</dd>
|
|
||||||
<dt class="col-sm-6">Email</dt>
|
|
||||||
<dd class="col-sm-6">{{ object.person.email|linkornone:'mailto' }}</dd>
|
|
||||||
<dt class="col-sm-6">Phone Number</dt>
|
|
||||||
<dd class="col-sm-6">{{ object.person.phone|linkornone:'tel' }}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% if object.organisation %}
|
|
||||||
<div class="card card-default">
|
|
||||||
<div class="card-header">Organisation Details</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<dl class="row">
|
|
||||||
<dt class="col-sm-6">Organisation</dt>
|
|
||||||
<dd class="col-sm-6">
|
|
||||||
{% if object.organisation %}
|
|
||||||
<a href="{% url 'organisation_detail' object.organisation.pk %}" class="modal-href">
|
|
||||||
{{ object.organisation|namewithnotes:'organisation_detail' }}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</dd>
|
|
||||||
<dt class="col-sm-6">Email</dt>
|
|
||||||
<dd class="col-sm-6">{{ object.organisation.email|linkornone:'mailto' }}</dd>
|
|
||||||
<dt class="col-sm-6">Phone Number</dt>
|
|
||||||
<dd class="col-sm-6">{{ object.organisation.phone|linkornone:'tel' }}</dd>
|
|
||||||
<dt class="col-sm-6">Has SU Account</dt>
|
|
||||||
<dd class="col-sm-6">{{ object.organisation.union_account|yesno|capfirst }}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
@@ -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 disabled
|
btn-success active
|
||||||
{% 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 %}
|
||||||
"
|
"
|
||||||
{% if event.authorised %}aria-disabled="true"{% else %}href="{% url 'event_authorise_request' object.pk %}"{% endif %}>
|
href="{% url 'event_authorise_request' object.pk %}">
|
||||||
<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 %}
|
||||||
@@ -47,7 +47,5 @@
|
|||||||
class="fas fa-pound-sign"></span>
|
class="fas fa-pound-sign"></span>
|
||||||
<span class="d-none d-sm-inline">Invoice</span></a>
|
<span class="d-none d-sm-inline">Invoice</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<a href="https://docs.google.com/forms/d/e/1FAIpQLSf-TBOuJZCTYc2L8DWdAaC3_Werq0ulsUs8-6G85I6pA9WVsg/viewform" class="btn btn-danger"><span class="fas fa-file-invoice-dollar"></span> <span class="d-none d-sm-inline">Subhire Insurance Form</span></a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{% load namewithnotes from filters %}
|
{% load namewithnotes from filters %}
|
||||||
{% load markdown_tags %}
|
|
||||||
<div class="card card-info">
|
<div class="card card-info">
|
||||||
<div class="card-header">Event Info</div>
|
<div class="card-header">Event Info</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -15,7 +14,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|markdown }}{% if object.venue.three_phase_available %}<br>(Three phase available){%endif%}
|
{{ object.venue.notes }}{% if object.venue.three_phase_available %}<br>(Three phase available){%endif%}
|
||||||
</dd>
|
</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@
|
|||||||
<dd class="col-sm-12"> </dd>
|
<dd class="col-sm-12"> </dd>
|
||||||
|
|
||||||
<dt class="col-sm-6">Event Description</dt>
|
<dt class="col-sm-6">Event Description</dt>
|
||||||
<dd class="dont-break-out col-sm-12">{{ event.description|markdown }}</dd>
|
<dd class="dont-break-out col-sm-12">{{ event.description|linebreaksbr }}</dd>
|
||||||
|
|
||||||
<dd class="col-sm-12"> </dd>
|
<dd class="col-sm-12"> </dd>
|
||||||
|
|
||||||
|
|||||||
@@ -6,17 +6,13 @@
|
|||||||
<span class="badge badge-success">PO: {{ event.purchase_order }}</span>
|
<span class="badge badge-success">PO: {{ event.purchase_order }}</span>
|
||||||
{% elif event.authorised %}
|
{% elif event.authorised %}
|
||||||
<span class="badge badge-success">Authorisation: Complete <span class="fas fa-check"></span></span>
|
<span class="badge badge-success">Authorisation: Complete <span class="fas fa-check"></span></span>
|
||||||
{% elif event.authorisation and event.authorisation.amount != event.total and event.authorisation.last_edited_at > event.auth_request_at %}
|
|
||||||
<span class="badge badge-warning"> Authorisation: Issue <span class="fas fa-exclamation-circle"></span></span>
|
|
||||||
{% elif event.auth_request_to %}
|
|
||||||
<span class="badge badge-info"> Authorisation: Sent <span class="fas fa-paper-plane"></span></span>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="badge badge-danger">Authorisation: <span class="fas fa-times"></span></span>
|
<span class="badge badge-danger">Authorisation: <span class="fas fa-times"></span></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not event.dry_hire %}
|
{% if not event.dry_hire %}
|
||||||
{% if event.riskassessment %}
|
{% if event.riskassessment %}
|
||||||
<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>
|
<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>
|
||||||
{% 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,105 +1,147 @@
|
|||||||
{% load namewithnotes from filters %}
|
{% load namewithnotes from filters %}
|
||||||
{% load markdown_tags %}
|
<style>
|
||||||
<div class="table-responsive">
|
#event_table {
|
||||||
<table class="table mb-0" id="event_table">
|
display: grid;
|
||||||
<thead>
|
grid-template-columns: 0.5fr 1fr 4fr 1fr;
|
||||||
<tr>
|
column-gap: 1em;
|
||||||
<th scope="col">#</th>
|
}
|
||||||
<th scope="col">Dates & Times</th>
|
.eventgrid {
|
||||||
<th scope="col">Event Details</th>
|
display: inherit;
|
||||||
<th scope="col">MIC</th>
|
grid-column: 1/5;
|
||||||
</tr>
|
grid-template-columns: subgrid;
|
||||||
</thead>
|
padding: 1em;
|
||||||
<tbody>
|
}
|
||||||
{% for event in events %}
|
.grid-header {
|
||||||
<tr class="{% if event.cancelled %}
|
border-bottom: 1px solid grey;
|
||||||
table-secondary
|
border-top: 1px solid grey;
|
||||||
|
}
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
#event_table {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
.eventgrid {
|
||||||
|
grid-column: 1/1;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
.grid-header {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#event_dates {
|
||||||
|
order: 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
#event_table {
|
||||||
|
grid-template-columns: 0.5fr 1fr;
|
||||||
|
column-gap: 0.5em;
|
||||||
|
}
|
||||||
|
.eventgrid {
|
||||||
|
grid-column: 1/3;
|
||||||
|
}
|
||||||
|
#event_dates {
|
||||||
|
grid-row: 2;
|
||||||
|
grid-column: 1;
|
||||||
|
}
|
||||||
|
#event_number {
|
||||||
|
grid-row: 1;
|
||||||
|
grid-column: 1;
|
||||||
|
}
|
||||||
|
#event_mic {
|
||||||
|
grid-column: 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div id="event_table">
|
||||||
|
<div class="eventgrid grid-header font-weight-bold">
|
||||||
|
<div id="event_number">#</div>
|
||||||
|
<div id="event_dates">Dates & Times</div>
|
||||||
|
<div>Event Details</div>
|
||||||
|
<div id="event_mic">MIC</div>
|
||||||
|
</div>
|
||||||
|
{% for event in events %}
|
||||||
|
<div class="eventgrid {% if event.cancelled %}
|
||||||
|
bg-secondary
|
||||||
{% elif not event.is_rig %}
|
{% elif not event.is_rig %}
|
||||||
table-info
|
bg-info
|
||||||
{% elif not event.mic %}
|
{% elif not event.mic %}
|
||||||
table-danger
|
bg-danger
|
||||||
{% elif event.confirmed and event.authorised %}
|
{% elif event.confirmed and event.authorised %}
|
||||||
{% if event.dry_hire or event.riskassessment %}
|
{% if event.dry_hire or event.riskassessment %}
|
||||||
table-success
|
bg-success
|
||||||
{% else %}
|
{% else %}
|
||||||
table-warning
|
bg-warning
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
table-warning
|
bg-warning
|
||||||
{% endif %}" {% if event.cancelled %}style="opacity: 50% !important;"{% endif %} id="event_row">
|
{% endif %}" {% if event.cancelled %}style="opacity: 50% !important;"{% endif %} id="event_row">
|
||||||
<!---Number-->
|
<!---Number-->
|
||||||
<th scope="row" id="event_number">{{ event.display_id }}</th>
|
<div class="font-weight-bold d-none d-sm-block" id="event_number">{{ event.display_id }}</div>
|
||||||
<!--Dates & Times-->
|
<!--Dates & Times-->
|
||||||
<td id="event_dates" style="text-align: justify;">
|
<div id="event_dates">
|
||||||
{% if not event.cancelled %}
|
<span class="text-nowrap attribute">Start: <strong>{{ event.start_date|date:"D d/m/Y" }}</strong>
|
||||||
{% if event.meet_at %}
|
{% if event.has_start_time %}
|
||||||
<span class="text-nowrap">Meet: <strong>{{ event.meet_at|date:"D d/m/Y H:i" }}</strong></span>
|
{{ event.start_time|date:"H:i" }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if event.access_at %}
|
</span>
|
||||||
<br><span class="text-nowrap">Access: <strong>{{ event.access_at|date:"D d/m/Y H:i" }}</strong></span>
|
{% if event.end_date %}
|
||||||
{% endif %}
|
<br>
|
||||||
|
<span class="text-nowrap">End: {% if event.end_date != event.start_date %}<strong>{{ event.end_date|date:"D d/m/Y" }}</strong>{% endif %}
|
||||||
|
{% if event.has_end_time %}
|
||||||
|
{{ event.end_time|date:"H:i" }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="text-nowrap">Start: <strong>{{ event.start_date|date:"D d/m/Y" }}
|
|
||||||
{% if event.has_start_time %}
|
|
||||||
{{ event.start_time|date:"H:i" }}
|
|
||||||
{% endif %}</strong>
|
|
||||||
</span>
|
</span>
|
||||||
{% if event.end_date %}
|
{% endif %}
|
||||||
<br>
|
{% if not event.cancelled %}
|
||||||
<span class="text-nowrap">End: {% if event.end_date != event.start_date %}<strong>{{ event.end_date|date:"D d/m/Y" }}{% endif %}
|
{% if event.meet_at %}
|
||||||
{% if event.has_end_time %}
|
<br><span>Crew meet: <strong>{{ event.meet_at|date:"H:i" }}</strong> {{ event.meet_at|date:"(d/m/Y)" }}</span>
|
||||||
{{ event.end_time|date:"H:i" }}
|
|
||||||
{% endif %}</strong>
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
{% if event.access_at %}
|
||||||
<!---Details-->
|
<br><span>Access at: <strong>{{ event.access_at|date:"H:i" }}</strong> {{ event.access_at|date:"(d/m/Y)" }}</span>
|
||||||
<td id="event_details" class="w-100">
|
{% endif %}
|
||||||
<h4>
|
{% endif %}
|
||||||
<a href="{% url 'event_detail' event.pk %}">
|
</div>
|
||||||
{{ event.name }}
|
<!---Details-->
|
||||||
|
<div id="event_details" class="w-100">
|
||||||
|
<h4>
|
||||||
|
<a href="{% url 'event_detail' event.pk %}">
|
||||||
|
{{ event.name }}
|
||||||
|
</a>
|
||||||
|
{% if event.venue %}
|
||||||
|
<small>at {{ event.venue|namewithnotes:'venue_detail' }}</small>
|
||||||
|
{% endif %}
|
||||||
|
{% if event.dry_hire %}
|
||||||
|
<span class="badge badge-secondary">Dry Hire</span>
|
||||||
|
{% endif %}
|
||||||
|
</h4>
|
||||||
|
{% if event.is_rig and not event.cancelled %}
|
||||||
|
<h5>
|
||||||
|
{{ event.person.name }}
|
||||||
|
{% if event.organisation %}
|
||||||
|
for {{ event.organisation.name }}
|
||||||
|
{% endif %}
|
||||||
|
</h5>
|
||||||
|
{% endif %}
|
||||||
|
{% if not event.cancelled and event.description %}
|
||||||
|
<p>{{ event.description|linebreaksbr }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% include 'partials/event_status.html' %}
|
||||||
|
</div>
|
||||||
|
<!---MIC-->
|
||||||
|
<div id="event_mic" class="text-nowrap">
|
||||||
|
<span class="d-md-none align-middle">MIC:</span>
|
||||||
|
{% if event.mic %}
|
||||||
|
{% if perms.RIGS.view_profile %}
|
||||||
|
<a href="{% url 'profile_detail' event.mic.pk %}" class="modal-href">
|
||||||
|
{% endif %}
|
||||||
|
<img src="{{ event.mic.profile_picture }}" class="event-mic-photo"/>
|
||||||
|
{{ event.mic }}
|
||||||
|
{% if perms.RIGS.view_profile %}
|
||||||
</a>
|
</a>
|
||||||
{% if event.venue %}
|
|
||||||
<small>at {{ event.venue|namewithnotes:'venue_detail' }}</small>
|
|
||||||
{% endif %}
|
|
||||||
{% if event.dry_hire %}
|
|
||||||
<span class="badge badge-secondary">Dry Hire</span>
|
|
||||||
{% endif %}
|
|
||||||
</h4>
|
|
||||||
{% if event.is_rig and not event.cancelled %}
|
|
||||||
<h5>
|
|
||||||
<a href="{{ event.person.get_absolute_url }}">{{ event.person.name }}</a>
|
|
||||||
{% if event.organisation %}
|
|
||||||
for <a href="{{ event.organisation.get_absolute_url }}">{{ event.organisation.name }}</a>
|
|
||||||
{% endif %}
|
|
||||||
</h5>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not event.cancelled and event.description %}
|
{% elif event.is_rig %}
|
||||||
<p>{{ event.description|markdown }}</p>
|
<span class="fas fa-exclamation"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include 'partials/event_status.html' %}
|
</div>
|
||||||
</td>
|
</div>
|
||||||
<!---MIC-->
|
{% endfor %}
|
||||||
<td id="event_mic" class="text-nowrap">
|
|
||||||
{% if event.mic %}
|
|
||||||
{% if perms.RIGS.view_profile %}
|
|
||||||
<a href="{% url 'profile_detail' event.mic.pk %}" class="modal-href">
|
|
||||||
{% endif %}
|
|
||||||
<img src="{{ event.mic.profile_picture }}" class="event-mic-photo"/>
|
|
||||||
{{ event.mic }}
|
|
||||||
{% if perms.RIGS.view_profile %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% elif event.is_rig %}
|
|
||||||
<span class="fas fa-user-slash"></span>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% empty %}
|
|
||||||
<tr class="bg-warning">
|
|
||||||
<td colspan="4">No events found</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row align-items-center justify-content-between py-2 align-middle">
|
<div class="row align-items-center justify-content-between py-2 align-middle">
|
||||||
<div class="col-sm-12 col-md align-middle">
|
<div class="col-sm-12 col-md align-middle d-flex flex-wrap">
|
||||||
Key: <span class="table-success mr-1 px-2 rounded">Ready</span><span class="table-warning mr-1 px-2 rounded">Action Required</span><span class="table-danger mr-1 px-2 rounded">Needs MIC</span><span class="table-secondary mr-1 px-2 rounded">Cancelled</span><span class="table-info px-2 rounded">Non-Rig</span>
|
Key: <span class="table-success mr-1 px-2 rounded">Ready</span><span class="table-warning mr-1 px-2 rounded text-nowrap">Action Required</span><span class="table-danger mr-1 px-2 rounded text-nowrap">Needs MIC</span><span class="table-secondary mr-1 px-2 rounded">Cancelled</span><span class="table-info px-2 rounded text-nowrap">Non-Rig</span>
|
||||||
</div>
|
</div>
|
||||||
{% if perms.RIGS.add_event %}
|
{% if perms.RIGS.add_event %}
|
||||||
<div class="col text-right">
|
<div class="col text-right">
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
||||||
{% load filters %}
|
{% block title %}Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}{% endblock %}
|
||||||
|
{% load help_text from filters %}
|
||||||
|
{% load yesnoi from filters %}
|
||||||
|
{% load linkornone from filters %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row py-3">
|
<div class="row py-3">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
<h3>Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}</h3>
|
||||||
<div class="card card-default mb-3">
|
<div class="card card-default mb-3">
|
||||||
<div class="card-header">General</div>
|
<div class="card-header">General</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -45,13 +49,13 @@
|
|||||||
</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:object.event.mic }}
|
{{ object.power_mic.name|default:'None' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-6">{{ object|help_text:'outside' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'generators' }}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
{{ object.outside|yesnoi:'invert' }}
|
{{ object.outside|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-6">{{ object|help_text:'generators' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'outside' }}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
{{ object.generators|yesnoi:'invert' }}
|
{{ object.generators|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
@@ -93,69 +97,62 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="card card-default mb-3">
|
||||||
<div class="col-lg-6 col-12">
|
<div class="card-header">Site Details</div>
|
||||||
<div class="card card-default mb-3">
|
<div class="card-body">
|
||||||
<div class="card-header">Site Details</div>
|
<dl class="row">
|
||||||
<div class="card-body">
|
<dt class="col-sm-6">{{ object|help_text:'known_venue' }}</dt>
|
||||||
<dl class="row">
|
<dd class="col-sm-6">
|
||||||
<dt class="col-10">{{ object|help_text:'known_venue' }}</dt>
|
{{ object.known_venue|yesnoi:'invert' }}
|
||||||
<dd class="col-2">
|
</dd>
|
||||||
{{ object.known_venue|yesnoi:'invert' }}
|
<dt class="col-sm-6">{{ object|help_text:'safe_loading'|safe }}</dt>
|
||||||
</dd>
|
<dd class="col-sm-6">
|
||||||
<dt class="col-10">{{ object|help_text:'safe_loading'|safe }}</dt>
|
{{ object.safe_loading|yesnoi:'invert' }}
|
||||||
<dd class="col-2">
|
</dd>
|
||||||
{{ object.safe_loading|yesnoi:'invert' }}
|
<dt class="col-sm-6">{{ object|help_text:'safe_storage' }}</dt>
|
||||||
</dd>
|
<dd class="col-sm-6">
|
||||||
<dt class="col-10">{{ object|help_text:'safe_storage' }}</dt>
|
{{ object.safe_storage|yesnoi:'invert' }}
|
||||||
<dd class="col-2">
|
</dd>
|
||||||
{{ object.safe_storage|yesnoi:'invert' }}
|
<dt class="col-sm-6">{{ object|help_text:'area_outside_of_control' }}</dt>
|
||||||
</dd>
|
<dd class="col-sm-6">
|
||||||
<dt class="col-10">{{ object|help_text:'area_outside_of_control' }}</dt>
|
{{ object.area_outside_of_control|yesnoi:'invert' }}
|
||||||
<dd class="col-2">
|
</dd>
|
||||||
{{ object.area_outside_of_control|yesnoi:'invert' }}
|
<dt class="col-sm-6">{{ object|help_text:'barrier_required' }}</dt>
|
||||||
</dd>
|
<dd class="col-sm-6">
|
||||||
<dt class="col-10">{{ object|help_text:'barrier_required' }}</dt>
|
{{ object.barrier_required|yesnoi:'invert' }}
|
||||||
<dd class="col-2">
|
</dd>
|
||||||
{{ object.barrier_required|yesnoi:'invert' }}
|
<dt class="col-sm-6">{{ object|help_text:'nonstandard_emergency_procedure' }}</dt>
|
||||||
</dd>
|
<dd class="col-sm-6">
|
||||||
<dt class="col-10">{{ object|help_text:'nonstandard_emergency_procedure' }}</dt>
|
{{ object.nonstandard_emergency_procedure|yesnoi:'invert' }}
|
||||||
<dd class="col-2">
|
</dd>
|
||||||
{{ object.nonstandard_emergency_procedure|yesnoi:'invert' }}
|
</dl>
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-12">
|
</div>
|
||||||
<div class="card card-default mb-3">
|
<div class="card card-default mb-3">
|
||||||
<div class="card-header">Structures</div>
|
<div class="card-header">Structures</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
<dt class="col-10">{{ object|help_text:'special_structures' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'special_structures' }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-sm-6">
|
||||||
{{ object.special_structures|yesnoi:'invert' }}
|
{{ object.special_structures|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-10">{{ object|help_text:'suspended_structures' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'suspended_structures' }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-sm-6">
|
||||||
{{ object.suspended_structures|yesnoi:'invert' }}
|
{{ object.suspended_structures|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-12">{{ object|help_text:'persons_responsible_structures' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'persons_responsible_structures' }}</dt>
|
||||||
<dd class="col-12">
|
<dd class="col-sm-6">
|
||||||
{{ object.persons_responsible_structures|default:'N/A'|linebreaks }}
|
{{ object.persons_responsible_structures.name|default:'N/A'|linebreaks }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-12">{{ object|help_text:'rigging_plan'|safe }}</dt>
|
<dt class="col-6">{{ object|help_text:'rigging_plan'|safe }}</dt>
|
||||||
<dd class="col-12">
|
<dd class="col-6">
|
||||||
{{ object.rigging_plan|linkornone|default:'N/A' }}
|
{{ object.rigging_plan|linkornone }}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
@@ -5,14 +5,17 @@
|
|||||||
{% load nice_errors from filters %}
|
{% load nice_errors from filters %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
<link rel="stylesheet" href="{% static 'css/selects.css' %}"/>
|
<link rel="stylesheet" href="{% static 'css/selects.css' %}"/>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block preload_js %}
|
{% block preload_js %}
|
||||||
|
{{ block.super }}
|
||||||
<script src="{% static 'js/selects.js' %}" async></script>
|
<script src="{% static 'js/selects.js' %}" async></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
<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>
|
||||||
|
|
||||||
@@ -98,9 +101,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="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="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
{% if power_mic %}
|
{% if object.power_mic %}
|
||||||
<option value="{{form.power_mic.value}}" selected="selected">{{ power_mic }}</option>
|
<option value="{{object.power_mic.pk}}" selected="selected">{{ object.power_mic.name }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -114,8 +114,10 @@ def orderby(request, field, attr):
|
|||||||
|
|
||||||
return dict_.urlencode()
|
return dict_.urlencode()
|
||||||
|
|
||||||
|
# Used for accessing outside of a form, i.e. in detail views of RiskAssessment and EventChecklist
|
||||||
|
|
||||||
@register.filter(needs_autoescape=True) # Used for accessing outside of a form, i.e. in detail views of RiskAssessment and EventChecklist
|
|
||||||
|
@register.filter(needs_autoescape=True)
|
||||||
def get_field(obj, field, autoescape=True):
|
def get_field(obj, field, autoescape=True):
|
||||||
value = getattr(obj, field)
|
value = getattr(obj, field)
|
||||||
if(isinstance(value, bool)):
|
if(isinstance(value, bool)):
|
||||||
@@ -210,25 +212,8 @@ def button(type, url=None, pk=None, clazz="", icon=None, text="", id=None, style
|
|||||||
clazz += " btn-primary "
|
clazz += " btn-primary "
|
||||||
icon = "fa-plus"
|
icon = "fa-plus"
|
||||||
text = "New"
|
text = "New"
|
||||||
elif type == 'copy':
|
|
||||||
return {'copy': True, 'id': id, 'style': style}
|
|
||||||
elif type == 'search':
|
elif type == 'search':
|
||||||
return {'submit': True, 'class': 'btn-info', 'icon': 'fa-search', 'text': 'Search', 'id': id, 'style': style}
|
return {'submit': True, 'class': 'btn-info', 'icon': 'fa-search', 'text': 'Search', 'id': id, 'style': style}
|
||||||
elif type == 'submit':
|
elif type == 'submit':
|
||||||
return {'submit': True, 'class': 'btn-primary', 'icon': 'fa-save', 'text': 'Save', 'id': id, 'style': style}
|
return {'submit': True, 'class': 'btn-primary', 'icon': 'fa-save', 'text': 'Save', 'id': id, 'style': style}
|
||||||
return {'target': url, 'pk': pk, 'class': clazz, 'icon': icon, 'text': text, 'id': id, 'style': style}
|
return {'target': url, 'pk': pk, 'class': clazz, 'icon': icon, 'text': text, 'id': id, 'style': style}
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag # TODO Can these be done with annotation/aggregation?
|
|
||||||
def invoices_waiting():
|
|
||||||
return len(models.Event.objects.waiting_invoices())
|
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
|
||||||
def invoices_outstanding():
|
|
||||||
return len(models.Invoice.objects.outstanding_invoices())
|
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
|
||||||
def total_invoices_todo():
|
|
||||||
return len(models.Event.objects.waiting_invoices()) + len(models.Invoice.objects.outstanding_invoices())
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
from bs4 import BeautifulSoup
|
|
||||||
from django import template
|
|
||||||
from django.utils.safestring import mark_safe
|
|
||||||
import markdown
|
|
||||||
|
|
||||||
__author__ = 'ghost'
|
|
||||||
|
|
||||||
register = template.Library()
|
|
||||||
|
|
||||||
|
|
||||||
@register.filter(name="markdown")
|
|
||||||
def markdown_filter(text, input_format='html', add_style=""):
|
|
||||||
# markdown library can't handle text=None
|
|
||||||
if text is None:
|
|
||||||
return text
|
|
||||||
html = markdown.markdown(text, extensions=['markdown.extensions.nl2br'])
|
|
||||||
# Convert format to RML
|
|
||||||
soup = BeautifulSoup(html, "html.parser")
|
|
||||||
# Prevent code injection
|
|
||||||
for script in soup('script'):
|
|
||||||
script.string = "Your script shall not pass!"
|
|
||||||
if input_format == 'html':
|
|
||||||
return mark_safe('<div class="markdown">' + str(soup) + '</div>')
|
|
||||||
elif input_format == 'rml':
|
|
||||||
|
|
||||||
# Image aren't supported so remove them
|
|
||||||
for img in soup('img'):
|
|
||||||
img.parent.extract()
|
|
||||||
|
|
||||||
# <code> should become <font>
|
|
||||||
for c in soup('code'):
|
|
||||||
c.name = 'font'
|
|
||||||
c['face'] = "Courier"
|
|
||||||
|
|
||||||
# blockquotes don't exist but we can still do something to show
|
|
||||||
for bq in soup('blockquote'):
|
|
||||||
bq.name = 'pre'
|
|
||||||
bq.string = bq.text
|
|
||||||
|
|
||||||
for alist in soup.find_all(['ul', 'ol']):
|
|
||||||
alist['style'] = alist.name
|
|
||||||
for li in alist.find_all('li', recursive=False):
|
|
||||||
text = li.find(text=True)
|
|
||||||
text.wrap(soup.new_tag('p'))
|
|
||||||
|
|
||||||
if alist.parent.name != 'li':
|
|
||||||
indent = soup.new_tag('indent')
|
|
||||||
indent['left'] = '0.6cm'
|
|
||||||
|
|
||||||
alist.wrap(indent)
|
|
||||||
|
|
||||||
# Paragraphs have a different tag
|
|
||||||
for p in soup('p'):
|
|
||||||
p.name = 'para'
|
|
||||||
|
|
||||||
return mark_safe(str(soup))
|
|
||||||
@@ -53,7 +53,7 @@ class EventDetail(BasePage):
|
|||||||
|
|
||||||
# TODO Refactor into regions to match template fragmentation
|
# TODO Refactor into regions to match template fragmentation
|
||||||
_event_name_selector = (By.XPATH, '//h2')
|
_event_name_selector = (By.XPATH, '//h2')
|
||||||
_person_panel_selector = (By.XPATH, '//div[contains(text(), "Person Details")]/..')
|
_person_panel_selector = (By.XPATH, '//div[contains(text(), "Contact Details")]/..')
|
||||||
_name_selector = (By.XPATH, '//dt[text()="Person"]/following-sibling::dd[1]')
|
_name_selector = (By.XPATH, '//dt[text()="Person"]/following-sibling::dd[1]')
|
||||||
_email_selector = (By.XPATH, '//dt[text()="Email"]/following-sibling::dd[1]')
|
_email_selector = (By.XPATH, '//dt[text()="Email"]/following-sibling::dd[1]')
|
||||||
_phone_selector = (By.XPATH, '//dt[text()="Phone Number"]/following-sibling::dd[1]')
|
_phone_selector = (By.XPATH, '//dt[text()="Phone Number"]/following-sibling::dd[1]')
|
||||||
@@ -96,7 +96,7 @@ class CreateEvent(FormPage):
|
|||||||
_warning_selector = (By.XPATH, '/html/body/div[1]/div[1]')
|
_warning_selector = (By.XPATH, '/html/body/div[1]/div[1]')
|
||||||
|
|
||||||
form_items = {
|
form_items = {
|
||||||
'description': (regions.SimpleMDETextArea, (By.ID, 'id_description')),
|
'description': (regions.TextBox, (By.ID, 'id_description')),
|
||||||
|
|
||||||
'name': (regions.TextBox, (By.ID, 'id_name')),
|
'name': (regions.TextBox, (By.ID, 'id_name')),
|
||||||
'start_date': (regions.DatePicker, (By.ID, 'id_start_date')),
|
'start_date': (regions.DatePicker, (By.ID, 'id_start_date')),
|
||||||
@@ -110,7 +110,7 @@ class CreateEvent(FormPage):
|
|||||||
'collected_by': (regions.TextBox, (By.ID, 'id_collector')),
|
'collected_by': (regions.TextBox, (By.ID, 'id_collector')),
|
||||||
'po': (regions.TextBox, (By.ID, 'id_purchase_order')),
|
'po': (regions.TextBox, (By.ID, 'id_purchase_order')),
|
||||||
|
|
||||||
'notes': (regions.SimpleMDETextArea, (By.ID, 'id_notes'))
|
'notes': (regions.TextBox, (By.ID, 'id_notes'))
|
||||||
}
|
}
|
||||||
|
|
||||||
def select_event_type(self, type_name):
|
def select_event_type(self, type_name):
|
||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from pypom import Region
|
from pypom import Region
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
from PyRIGS.tests.regions import TextBox, Modal, SimpleMDETextArea
|
from PyRIGS.tests.regions import TextBox, Modal
|
||||||
|
|
||||||
|
|
||||||
class Header(Region):
|
class Header(Region):
|
||||||
@@ -42,7 +42,7 @@ class ItemModal(Modal):
|
|||||||
|
|
||||||
form_items = {
|
form_items = {
|
||||||
'name': (TextBox, (By.ID, 'item_name')),
|
'name': (TextBox, (By.ID, 'item_name')),
|
||||||
'description': (SimpleMDETextArea, (By.ID, 'item_description')),
|
'description': (TextBox, (By.ID, 'item_description')),
|
||||||
'quantity': (TextBox, (By.ID, 'item_quantity')),
|
'quantity': (TextBox, (By.ID, 'item_quantity')),
|
||||||
'price': (TextBox, (By.ID, 'item_cost'))
|
'price': (TextBox, (By.ID, 'item_cost'))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,155 +0,0 @@
|
|||||||
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()
|
||||||
@@ -721,12 +721,12 @@ def test_ec_create_medium(logged_in_browser, live_server, admin_user, medium_ra)
|
|||||||
page.fd_voltage_l2 = 235
|
page.fd_voltage_l2 = 235
|
||||||
page.fd_voltage_l3 = 0
|
page.fd_voltage_l3 = 0
|
||||||
page.fd_phase_rotation = True
|
page.fd_phase_rotation = True
|
||||||
page.fd_earth_fault = "1.21"
|
page.fd_earth_fault = 666
|
||||||
page.fd_pssc = 1984
|
page.fd_pssc = 1984
|
||||||
page.w1_description = "In the carpark, by the bins"
|
page.w1_description = "In the carpark, by the bins"
|
||||||
page.w1_polarity = True
|
page.w1_polarity = True
|
||||||
page.w1_voltage = 240
|
page.w1_voltage = 240
|
||||||
page.w1_earth_fault = "0.42"
|
page.w1_earth_fault = 333
|
||||||
|
|
||||||
page.submit()
|
page.submit()
|
||||||
assert page.success
|
assert page.success
|
||||||
|
|||||||
@@ -1,13 +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
|
||||||
from django.utils.safestring import SafeText
|
|
||||||
from RIGS.templatetags.markdown_tags import markdown_filter
|
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from pytest_django.asserts import assertRedirects, assertNotContains, assertContains
|
from pytest_django.asserts import assertRedirects, assertNotContains, assertContains
|
||||||
@@ -15,6 +10,8 @@ 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
|
||||||
|
|
||||||
|
|
||||||
@@ -173,7 +170,6 @@ class TestInvoiceDelete(TestCase):
|
|||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
cls.profile = models.Profile.objects.create(username="testuser1", email="1@test.com", is_superuser=True,
|
cls.profile = models.Profile.objects.create(username="testuser1", email="1@test.com", is_superuser=True,
|
||||||
is_active=True, is_staff=True)
|
is_active=True, is_staff=True)
|
||||||
cls.vatrate = models.VatRate.objects.create(start_at='2014-03-05', rate=0.20, comment='test1')
|
|
||||||
cls.events = {
|
cls.events = {
|
||||||
1: models.Event.objects.create(name="TE E1", start_date=date.today()),
|
1: models.Event.objects.create(name="TE E1", start_date=date.today()),
|
||||||
2: models.Event.objects.create(name="TE E2", start_date=date.today())
|
2: models.Event.objects.create(name="TE E2", start_date=date.today())
|
||||||
@@ -285,11 +281,11 @@ def test_xframe_headers(admin_client, basic_event):
|
|||||||
|
|
||||||
response = admin_client.get(event_url, follow=True)
|
response = admin_client.get(event_url, follow=True)
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
response.headers["X-Frame-Options"]
|
response._headers["X-Frame-Options"]
|
||||||
|
|
||||||
response = admin_client.get(login_url, follow=True)
|
response = admin_client.get(login_url, follow=True)
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
response.headers["X-Frame-Options"]
|
response._headers["X-Frame-Options"]
|
||||||
|
|
||||||
|
|
||||||
def test_oembed(client, basic_event):
|
def test_oembed(client, basic_event):
|
||||||
@@ -367,60 +363,6 @@ def test_checklist_review(admin_client, admin_user, checklist):
|
|||||||
def test_ra_redirect(admin_client, admin_user, ra):
|
def test_ra_redirect(admin_client, admin_user, ra):
|
||||||
request_url = reverse('event_ra', kwargs={'pk': ra.event.pk})
|
request_url = reverse('event_ra', kwargs={'pk': ra.event.pk})
|
||||||
expected_url = reverse('ra_edit', kwargs={'pk': ra.pk})
|
expected_url = reverse('ra_edit', kwargs={'pk': ra.pk})
|
||||||
|
|
||||||
response = admin_client.get(request_url, follow=True)
|
response = admin_client.get(request_url, follow=True)
|
||||||
assertRedirects(response, expected_url, status_code=302, target_status_code=200)
|
assertRedirects(response, expected_url, status_code=302, target_status_code=200)
|
||||||
|
|
||||||
|
|
||||||
class TestMarkdownTemplateTags(TestCase):
|
|
||||||
markdown = open(os.path.join(settings.BASE_DIR, "RIGS/tests/sample.md")).read()
|
|
||||||
|
|
||||||
def test_html_safe(self):
|
|
||||||
html = markdown_filter(self.markdown)
|
|
||||||
self.assertIsInstance(html, SafeText)
|
|
||||||
|
|
||||||
def test_img_strip(self):
|
|
||||||
rml = markdown_filter(self.markdown, 'rml')
|
|
||||||
self.assertNotIn("<img", rml)
|
|
||||||
|
|
||||||
def test_code(self):
|
|
||||||
rml = markdown_filter(self.markdown, 'rml')
|
|
||||||
self.assertIn('<font face="Courier">monospace</font>', rml)
|
|
||||||
|
|
||||||
def test_blockquote(self):
|
|
||||||
rml = markdown_filter(self.markdown, 'rml')
|
|
||||||
self.assertIn("<pre>\nBlock quotes", rml)
|
|
||||||
|
|
||||||
def test_lists(self):
|
|
||||||
rml = markdown_filter(self.markdown, 'rml')
|
|
||||||
self.assertIn("<li><para>second item</para></li>", rml) # <ol>
|
|
||||||
self.assertIn("<li><para>that one</para></li>", rml) # <ul>
|
|
||||||
|
|
||||||
def test_in_print(self):
|
|
||||||
event = models.Event.objects.create(
|
|
||||||
name="MD Print Test",
|
|
||||||
description=self.markdown,
|
|
||||||
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(
|
|
||||||
username='RML test',
|
|
||||||
is_superuser=True, # Don't care about permissions
|
|
||||||
is_active=True,
|
|
||||||
)
|
|
||||||
user.set_password('rmltester')
|
|
||||||
user.save()
|
|
||||||
|
|
||||||
self.assertTrue(self.client.login(username=user.username, password='rmltester'))
|
|
||||||
response = self.client.get(reverse('event_print', kwargs={'pk': event.pk}))
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
# By the time we have a PDF it should be larger than the original by some margin
|
|
||||||
# RML hard fails if something doesn't work
|
|
||||||
self.assertGreater(len(response.content), len(self.markdown))
|
|
||||||
|
|
||||||
def test_nonetype(self):
|
|
||||||
html = markdown_filter(None)
|
|
||||||
self.assertIsNone(html)
|
|
||||||
|
|
||||||
def test_linebreaks(self):
|
|
||||||
html = markdown_filter(self.markdown)
|
|
||||||
self.assertIn("Itemized lists<br/>\nlook like", html)
|
|
||||||
|
|||||||
81
RIGS/urls.py
81
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 . import views
|
from RIGS import finance, ical, rigboard, views, hs
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# People
|
# People
|
||||||
@@ -42,102 +42,101 @@ urlpatterns = [
|
|||||||
name='venue_update'),
|
name='venue_update'),
|
||||||
|
|
||||||
# Rigboard
|
# Rigboard
|
||||||
path('rigboard/', login_required(views.RigboardIndex.as_view()), name='rigboard'),
|
path('rigboard/', login_required(rigboard.RigboardIndex.as_view()), name='rigboard'),
|
||||||
path('rigboard/calendar/', login_required()(views.WebCalendar.as_view()),
|
path('rigboard/calendar/', login_required()(rigboard.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()(views.WebCalendar.as_view()), name='web_calendar'),
|
login_required()(rigboard.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()(views.WebCalendar.as_view()), name='web_calendar'),
|
login_required()(rigboard.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")(views.EventDetail.as_view()),
|
path('event/<int:pk>/', has_oembed(oembed_view="event_oembed")(rigboard.EventDetail.as_view()),
|
||||||
name='event_detail'),
|
name='event_detail'),
|
||||||
path('event/create/', permission_required_with_403('RIGS.add_event')(views.EventCreate.as_view()),
|
path('event/create/', permission_required_with_403('RIGS.add_event')(rigboard.EventCreate.as_view()),
|
||||||
name='event_create'),
|
name='event_create'),
|
||||||
path('event/archive/', login_required()(views.EventArchive.as_view()),
|
path('event/archive/', login_required()(rigboard.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/')(views.EventEmbed.as_view())),
|
xframe_options_exempt(login_required(login_url='/user/login/embed/')(rigboard.EventEmbed.as_view())),
|
||||||
name='event_embed'),
|
name='event_embed'),
|
||||||
path('event/<int:pk>/oembed_json/', views.EventOEmbed.as_view(),
|
path('event/<int:pk>/oembed_json/', rigboard.EventOEmbed.as_view(),
|
||||||
name='event_oembed'),
|
name='event_oembed'),
|
||||||
path('event/<int:pk>/print/', permission_required_with_403('RIGS.view_event')(views.EventPrint.as_view()),
|
path('event/<int:pk>/print/', permission_required_with_403('RIGS.view_event')(rigboard.EventPrint.as_view()),
|
||||||
name='event_print'),
|
name='event_print'),
|
||||||
path('event/<int:pk>/edit/', permission_required_with_403('RIGS.change_event')(views.EventUpdate.as_view()),
|
path('event/<int:pk>/edit/', permission_required_with_403('RIGS.change_event')(rigboard.EventUpdate.as_view()),
|
||||||
name='event_update'),
|
name='event_update'),
|
||||||
path('event/<int:pk>/duplicate/', permission_required_with_403('RIGS.add_event')(views.EventDuplicate.as_view()),
|
path('event/<int:pk>/duplicate/', permission_required_with_403('RIGS.add_event')(rigboard.EventDuplicate.as_view()),
|
||||||
name='event_duplicate'),
|
name='event_duplicate'),
|
||||||
|
|
||||||
# Event H&S
|
# Event H&S
|
||||||
path('event/hs/', permission_required_with_403('RIGS.view_riskassessment')(views.HSList.as_view()), name='hs_list'),
|
path('event/hs/', permission_required_with_403('RIGS.view_riskassessment')(hs.HSList.as_view()), name='hs_list'),
|
||||||
|
|
||||||
path('event/<int:pk>/ra/', permission_required_with_403('RIGS.add_riskassessment')(views.EventRiskAssessmentCreate.as_view()),
|
path('event/<int:pk>/ra/', permission_required_with_403('RIGS.add_riskassessment')(hs.EventRiskAssessmentCreate.as_view()),
|
||||||
name='event_ra'),
|
name='event_ra'),
|
||||||
path('event/ra/<int:pk>/', permission_required_with_403('RIGS.view_riskassessment')(views.EventRiskAssessmentDetail.as_view()),
|
path('event/ra/<int:pk>/', permission_required_with_403('RIGS.view_riskassessment')(hs.EventRiskAssessmentDetail.as_view()),
|
||||||
name='ra_detail'),
|
name='ra_detail'),
|
||||||
path('event/ra/<int:pk>/edit/', permission_required_with_403('RIGS.change_riskassessment')(views.EventRiskAssessmentEdit.as_view()),
|
path('event/ra/<int:pk>/edit/', permission_required_with_403('RIGS.change_riskassessment')(hs.EventRiskAssessmentEdit.as_view()),
|
||||||
name='ra_edit'),
|
name='ra_edit'),
|
||||||
path('event/ra/list', permission_required_with_403('RIGS.view_riskassessment')(views.EventRiskAssessmentList.as_view()),
|
path('event/ra/list', permission_required_with_403('RIGS.view_riskassessment')(hs.EventRiskAssessmentList.as_view()),
|
||||||
name='ra_list'),
|
name='ra_list'),
|
||||||
path('event/ra/<int:pk>/review/', permission_required_with_403('RIGS.review_riskassessment')(views.EventRiskAssessmentReview.as_view()),
|
path('event/ra/<int:pk>/review/', permission_required_with_403('RIGS.review_riskassessment')(hs.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')(views.EventChecklistCreate.as_view()),
|
path('event/<int:pk>/checklist/', permission_required_with_403('RIGS.add_eventchecklist')(hs.EventChecklistCreate.as_view()),
|
||||||
name='event_ec'),
|
name='event_ec'),
|
||||||
path('event/checklist/<int:pk>/', permission_required_with_403('RIGS.view_eventchecklist')(views.EventChecklistDetail.as_view()),
|
path('event/checklist/<int:pk>/', permission_required_with_403('RIGS.view_eventchecklist')(hs.EventChecklistDetail.as_view()),
|
||||||
name='ec_detail'),
|
name='ec_detail'),
|
||||||
path('event/checklist/<int:pk>/edit/', permission_required_with_403('RIGS.change_eventchecklist')(views.EventChecklistEdit.as_view()),
|
path('event/checklist/<int:pk>/edit/', permission_required_with_403('RIGS.change_eventchecklist')(hs.EventChecklistEdit.as_view()),
|
||||||
name='ec_edit'),
|
name='ec_edit'),
|
||||||
path('event/checklist/list', permission_required_with_403('RIGS.view_eventchecklist')(views.EventChecklistList.as_view()),
|
path('event/checklist/list', permission_required_with_403('RIGS.view_eventchecklist')(hs.EventChecklistList.as_view()),
|
||||||
name='ec_list'),
|
name='ec_list'),
|
||||||
path('event/checklist/<int:pk>/review/', permission_required_with_403('RIGS.review_eventchecklist')(views.EventChecklistReview.as_view()),
|
path('event/checklist/<int:pk>/review/', permission_required_with_403('RIGS.review_eventchecklist')(hs.EventChecklistReview.as_view()),
|
||||||
name='ec_review'),
|
name='ec_review'),
|
||||||
|
|
||||||
# Finance
|
# Finance
|
||||||
path('invoice/', permission_required_with_403('RIGS.view_invoice')(views.InvoiceIndex.as_view()),
|
path('invoice/', permission_required_with_403('RIGS.view_invoice')(finance.InvoiceIndex.as_view()),
|
||||||
name='invoice_list'),
|
name='invoice_list'),
|
||||||
path('invoice/archive/', permission_required_with_403('RIGS.view_invoice')(views.InvoiceArchive.as_view()),
|
path('invoice/archive/', permission_required_with_403('RIGS.view_invoice')(finance.InvoiceArchive.as_view()),
|
||||||
name='invoice_archive'),
|
name='invoice_archive'),
|
||||||
path('invoice/waiting/', permission_required_with_403('RIGS.add_invoice')(views.InvoiceWaiting.as_view()),
|
path('invoice/waiting/', permission_required_with_403('RIGS.add_invoice')(finance.InvoiceWaiting.as_view()),
|
||||||
name='invoice_waiting'),
|
name='invoice_waiting'),
|
||||||
|
|
||||||
path('event/<int:pk>/invoice/', permission_required_with_403('RIGS.add_invoice')(views.InvoiceEvent.as_view()),
|
path('event/<int:pk>/invoice/', permission_required_with_403('RIGS.add_invoice')(finance.InvoiceEvent.as_view()),
|
||||||
name='invoice_event'),
|
name='invoice_event'),
|
||||||
path('event/<int:pk>/invoice/void', permission_required_with_403('RIGS.add_invoice')(views.InvoiceEvent.as_view()),
|
path('event/<int:pk>/invoice/void', permission_required_with_403('RIGS.add_invoice')(finance.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')(views.InvoiceDetail.as_view()),
|
path('invoice/<int:pk>/', permission_required_with_403('RIGS.view_invoice')(finance.InvoiceDetail.as_view()),
|
||||||
name='invoice_detail'),
|
name='invoice_detail'),
|
||||||
path('invoice/<int:pk>/print/', permission_required_with_403('RIGS.view_invoice')(views.InvoicePrint.as_view()),
|
path('invoice/<int:pk>/print/', permission_required_with_403('RIGS.view_invoice')(finance.InvoicePrint.as_view()),
|
||||||
name='invoice_print'),
|
name='invoice_print'),
|
||||||
path('invoice/<int:pk>/void/', permission_required_with_403('RIGS.change_invoice')(views.InvoiceVoid.as_view()),
|
path('invoice/<int:pk>/void/', permission_required_with_403('RIGS.change_invoice')(finance.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')(views.InvoiceDelete.as_view()),
|
permission_required_with_403('RIGS.change_invoice')(finance.InvoiceDelete.as_view()),
|
||||||
name='invoice_delete'),
|
name='invoice_delete'),
|
||||||
|
|
||||||
path('payment/create/', permission_required_with_403('RIGS.add_payment')(views.PaymentCreate.as_view()),
|
path('payment/create/', permission_required_with_403('RIGS.add_payment')(finance.PaymentCreate.as_view()),
|
||||||
name='payment_create'),
|
name='payment_create'),
|
||||||
path('payment/<int:pk>/delete/', permission_required_with_403('RIGS.add_payment')(views.PaymentDelete.as_view()),
|
path('payment/<int:pk>/delete/', permission_required_with_403('RIGS.add_payment')(finance.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')(views.EventAuthorisationRequest.as_view()),
|
permission_required_with_403('RIGS.change_event')(rigboard.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')(views.EventAuthoriseRequestEmailPreview.as_view()),
|
permission_required_with_403('RIGS.change_event')(rigboard.EventAuthoriseRequestEmailPreview.as_view()),
|
||||||
name='event_authorise_preview'),
|
name='event_authorise_preview'),
|
||||||
re_path(r'^event/(?P<pk>\d+)/(?P<hmac>[-:\w]+)/$', views.EventAuthorise.as_view(),
|
re_path(r'^event/(?P<pk>\d+)/(?P<hmac>[-:\w]+)/$', rigboard.EventAuthorise.as_view(),
|
||||||
name='event_authorise'),
|
name='event_authorise'),
|
||||||
re_path(r'^event/(?P<pk>\d+)/(?P<hmac>[-:\w]+)/preview/$', views.EventAuthorise.as_view(preview=True),
|
re_path(r'^event/(?P<pk>\d+)/(?P<hmac>[-:\w]+)/preview/$', rigboard.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(views.CalendarICS()),
|
re_path(r'^ical/(?P<api_pk>\d+)/(?P<api_key>\w+)/rigs.ics$', api_key_required(ical.CalendarICS()),
|
||||||
name="ics_calendar"),
|
name="ics_calendar"),
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class PersonList(GenericListView):
|
|||||||
model = models.Person
|
model = models.Person
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(PersonList, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = "People"
|
context['page_title'] = "People"
|
||||||
context['create'] = 'person_create'
|
context['create'] = 'person_create'
|
||||||
context['edit'] = 'person_update'
|
context['edit'] = 'person_update'
|
||||||
@@ -19,7 +19,7 @@ class PersonDetail(GenericDetailView):
|
|||||||
model = models.Person
|
model = models.Person
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(PersonDetail, self).get_context_data(**kwargs)
|
||||||
context['history_link'] = 'person_history'
|
context['history_link'] = 'person_history'
|
||||||
context['detail_link'] = 'person_detail'
|
context['detail_link'] = 'person_detail'
|
||||||
context['update_link'] = 'person_update'
|
context['update_link'] = 'person_update'
|
||||||
@@ -49,7 +49,7 @@ class OrganisationList(GenericListView):
|
|||||||
model = models.Organisation
|
model = models.Organisation
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(OrganisationList, self).get_context_data(**kwargs)
|
||||||
context['create'] = 'organisation_create'
|
context['create'] = 'organisation_create'
|
||||||
context['edit'] = 'organisation_update'
|
context['edit'] = 'organisation_update'
|
||||||
context['can_edit'] = self.request.user.has_perm('RIGS.change_organisation')
|
context['can_edit'] = self.request.user.has_perm('RIGS.change_organisation')
|
||||||
@@ -62,7 +62,7 @@ class OrganisationDetail(GenericDetailView):
|
|||||||
model = models.Organisation
|
model = models.Organisation
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(OrganisationDetail, self).get_context_data(**kwargs)
|
||||||
context['history_link'] = 'organisation_history'
|
context['history_link'] = 'organisation_history'
|
||||||
context['detail_link'] = 'organisation_detail'
|
context['detail_link'] = 'organisation_detail'
|
||||||
context['update_link'] = 'organisation_update'
|
context['update_link'] = 'organisation_update'
|
||||||
@@ -92,7 +92,7 @@ class VenueList(GenericListView):
|
|||||||
model = models.Venue
|
model = models.Venue
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(VenueList, self).get_context_data(**kwargs)
|
||||||
context['create'] = 'venue_create'
|
context['create'] = 'venue_create'
|
||||||
context['edit'] = 'venue_update'
|
context['edit'] = 'venue_update'
|
||||||
context['can_edit'] = self.request.user.has_perm('RIGS.change_venue')
|
context['can_edit'] = self.request.user.has_perm('RIGS.change_venue')
|
||||||
@@ -104,7 +104,7 @@ class VenueDetail(GenericDetailView):
|
|||||||
model = models.Venue
|
model = models.Venue
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(VenueDetail, self).get_context_data(**kwargs)
|
||||||
context['history_link'] = 'venue_history'
|
context['history_link'] = 'venue_history'
|
||||||
context['detail_link'] = 'venue_detail'
|
context['detail_link'] = 'venue_detail'
|
||||||
context['update_link'] = 'venue_update'
|
context['update_link'] = 'venue_update'
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
from .crud import *
|
|
||||||
from .finance import *
|
|
||||||
from .hs import *
|
|
||||||
from .ical import *
|
|
||||||
from .rigboard import *
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
default_app_config = 'assets.apps.AssetsAppConfig'
|
||||||
|
|||||||
@@ -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,13 +17,9 @@ class AssetStatusAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
|
|
||||||
@admin.register(assets.Supplier)
|
@admin.register(assets.Supplier)
|
||||||
class SupplierAdmin(AssociateAdmin):
|
class SupplierAdmin(VersionAdmin):
|
||||||
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)
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import urllib.parse
|
|
||||||
|
|
||||||
|
|
||||||
class AssetIDConverter: # Forces lowercase to uppercase
|
|
||||||
regex = '[^/]+'
|
|
||||||
|
|
||||||
def to_python(self, value):
|
|
||||||
return str(value).upper()
|
|
||||||
|
|
||||||
def to_url(self, value):
|
|
||||||
return str(value).upper()
|
|
||||||
|
|
||||||
|
|
||||||
class ListConverter:
|
|
||||||
regex = '[^/]+'
|
|
||||||
|
|
||||||
def to_python(self, value):
|
|
||||||
return value.split(',')
|
|
||||||
|
|
||||||
def to_url(self, value):
|
|
||||||
string = ""
|
|
||||||
for i in value:
|
|
||||||
string += "," + str(i)
|
|
||||||
return string[1:]
|
|
||||||
@@ -3,6 +3,7 @@ from django.db.models import Q
|
|||||||
|
|
||||||
from assets import models
|
from assets import models
|
||||||
|
|
||||||
|
|
||||||
class AssetForm(forms.ModelForm):
|
class AssetForm(forms.ModelForm):
|
||||||
related_models = {
|
related_models = {
|
||||||
'asset': models.Asset,
|
'asset': models.Asset,
|
||||||
@@ -31,9 +32,6 @@ class AssetSearchForm(forms.Form):
|
|||||||
q = forms.CharField(required=False)
|
q = forms.CharField(required=False)
|
||||||
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)
|
|
||||||
cable_type = forms.ModelMultipleChoiceField(models.CableType.objects.all(), required=False)
|
|
||||||
date_acquired = forms.DateField(required=False)
|
|
||||||
|
|
||||||
|
|
||||||
class SupplierForm(forms.ModelForm):
|
class SupplierForm(forms.ModelForm):
|
||||||
@@ -46,3 +44,11 @@ class CableTypeForm(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = models.CableType
|
model = models.CableType
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
form_data = self.cleaned_data
|
||||||
|
queryset = models.CableType.objects.filter(Q(plug=form_data['plug']) & Q(socket=form_data['socket']) & Q(circuits=form_data['circuits']) & Q(cores=form_data['cores']))
|
||||||
|
# Being identical to itself shouldn't count...
|
||||||
|
if queryset.exists() and self.instance.pk != queryset[0].pk:
|
||||||
|
raise forms.ValidationError("A cable type that exactly matches this one already exists, please use that instead.", code="notunique")
|
||||||
|
return form_data
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ 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
|
||||||
|
|
||||||
@@ -21,7 +20,6 @@ class Command(BaseCommand):
|
|||||||
assets = []
|
assets = []
|
||||||
|
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
print("Generating sample assets data")
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
if not (settings.DEBUG or settings.STAGING):
|
if not (settings.DEBUG or settings.STAGING):
|
||||||
@@ -36,7 +34,6 @@ class Command(BaseCommand):
|
|||||||
self.create_assets()
|
self.create_assets()
|
||||||
self.create_connectors()
|
self.create_connectors()
|
||||||
self.create_cables()
|
self.create_cables()
|
||||||
print("Done generating sample assets data")
|
|
||||||
|
|
||||||
def create_categories(self):
|
def create_categories(self):
|
||||||
choices = ['Case', 'Video', 'General', 'Sound', 'Lighting', 'Rigging']
|
choices = ['Case', 'Video', 'General', 'Sound', 'Lighting', 'Rigging']
|
||||||
@@ -126,9 +123,5 @@ 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)
|
||||||
|
|
||||||
with transaction.atomic():
|
asset.clean()
|
||||||
try:
|
asset.save()
|
||||||
asset.clean()
|
|
||||||
asset.save()
|
|
||||||
except IntegrityError:
|
|
||||||
pass
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ def add_default(apps, schema_editor):
|
|||||||
Connector = apps.get_model('assets', 'Connector')
|
Connector = apps.get_model('assets', 'Connector')
|
||||||
for cable_type in CableType.objects.all():
|
for cable_type in CableType.objects.all():
|
||||||
if cable_type.plug is None:
|
if cable_type.plug is None:
|
||||||
cable_type.plug = Connector.objects.first()
|
cable_type.plug = Connector.first()
|
||||||
if cable_type.socket is None:
|
if cable_type.socket is None:
|
||||||
cable_type.socket = Connector.objects.first()
|
cable_type.socket = Connector.first()
|
||||||
cable_type.save()
|
cable_type.save()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 3.1.7 on 2021-03-02 12:04
|
# Generated by Django 3.1.5 on 2021-02-08 16:03
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
@@ -7,7 +7,7 @@ import django.db.models.deletion
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('assets', '0020_auto_20210302_1201'),
|
('assets', '0019_fix_cabletype'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# Generated by Django 3.1.7 on 2021-03-02 12:01
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
def postgres_migration_prep(apps, schema_editor):
|
|
||||||
model = apps.get_model("assets", "Supplier")
|
|
||||||
fields = ["address", "email", "notes", "phone"]
|
|
||||||
for field in fields:
|
|
||||||
filter_param = {"{}__isnull".format(field): True}
|
|
||||||
update_param = {field: ""}
|
|
||||||
model.objects.filter(**filter_param).update(**update_param)
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('assets', '0019_fix_cabletype'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(postgres_migration_prep, migrations.RunPython.noop)
|
|
||||||
]
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# Generated by Django 3.2.11 on 2022-01-12 19:11
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('assets', '0021_auto_20210302_1204'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterUniqueTogether(
|
|
||||||
name='cabletype',
|
|
||||||
unique_together={('plug', 'socket', 'circuits', 'cores')},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# 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'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# 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),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -2,13 +2,11 @@ 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, ContactableManager
|
from RIGS.models import RevisionMixin, Profile
|
||||||
from versioning.versioning import RevisionMixin
|
|
||||||
|
|
||||||
|
|
||||||
class AssetCategory(models.Model):
|
class AssetCategory(models.Model):
|
||||||
@@ -47,13 +45,11 @@ 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']
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('supplier_detail', kwargs={'pk': self.pk})
|
return reverse('supplier_list')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
@@ -79,30 +75,31 @@ class CableType(models.Model):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['plug', 'socket', '-circuits']
|
ordering = ['plug', 'socket', '-circuits']
|
||||||
unique_together = ['plug', 'socket', 'circuits', 'cores']
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.plug and self.socket:
|
if self.plug and self.socket:
|
||||||
return f"{self.plug.description} → {self.socket.description}"
|
return "%s → %s" % (self.plug.description, self.socket.description)
|
||||||
else:
|
else:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
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=""):
|
||||||
last_asset = Asset.objects.filter(asset_id_prefix=wanted_prefix).last()
|
sql = """
|
||||||
return 9000 if last_asset is None else wanted_prefix + str(last_asset.asset_id_number + 1)
|
SELECT a.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
|
||||||
|
a.asset_id_prefix = b.asset_id_prefix)
|
||||||
|
WHERE b.asset_id IS NULL AND a.asset_id_number >= %s AND a.asset_id_prefix = %s;
|
||||||
|
"""
|
||||||
|
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
|
||||||
@@ -114,11 +111,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.SET_NULL, blank=True, null=True, related_name="assets")
|
purchased_from = models.ForeignKey(to=Supplier, on_delete=models.CASCADE, 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)
|
||||||
salvage_value = models.DecimalField(null=True, decimal_places=2, max_digits=10)
|
salvage_value = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
||||||
comments = models.TextField(blank=True)
|
comments = models.TextField(blank=True)
|
||||||
|
|
||||||
# Audit
|
# Audit
|
||||||
@@ -140,8 +137,6 @@ 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 = [
|
||||||
@@ -149,7 +144,7 @@ class Asset(models.Model, RevisionMixin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.asset_id} | {self.description}"
|
return "{} | {}".format(self.asset_id, self.description)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('asset_detail', kwargs={'pk': self.asset_id})
|
return reverse('asset_detail', kwargs={'pk': self.asset_id})
|
||||||
@@ -189,7 +184,3 @@ 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}"
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB |
@@ -64,16 +64,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="setFieldValue('{{ form.length.id_for_label }}','5');" tabindex="-1">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="setFieldValue('{{ form.length.id_for_label }}','10');" tabindex="-1">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="setFieldValue('{{ form.length.id_for_label }}','20');" tabindex="-1">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="setFieldValue('{{ form.csa.id_for_label }}', '1.5');" tabindex="-1">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="setFieldValue('{{ form.csa.id_for_label }}', '2.5');" tabindex="-1">2.5{{ form.csa.help_text }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
});
|
});
|
||||||
$('#searchButton').click(function (e) {
|
$('#searchButton').click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var url = "{% url 'asset_audit' None %}".replace('None', $("#{{form.q.id_for_label}}").val());
|
var url = "{% url 'asset_audit' None %}";
|
||||||
|
var id = $("#{{form.q.id_for_label}}").val();
|
||||||
|
url = url.replace('None', id);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
success: function(){
|
success: function(){
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row justify-content-end">
|
|
||||||
{% include 'partials/asset_buttons.html' %}
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
{% include 'partials/asset_detail_form.html' %}
|
{% include 'partials/asset_detail_form.html' %}
|
||||||
|
|||||||
@@ -5,14 +5,11 @@
|
|||||||
{% 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/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/easymde.min.js' %}"></script>
|
|
||||||
<script src="{% static 'js/interaction.js' %}"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
@@ -31,13 +28,48 @@
|
|||||||
checkIfCableHidden();
|
checkIfCableHidden();
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
$('document').ready(function(){
|
$('#parent_id')
|
||||||
$(document).find(".selectpicker").selectpicker().each(function(){initPicker($(this))});
|
.selectpicker({
|
||||||
});
|
liveSearch: true
|
||||||
</script>
|
})
|
||||||
<script>
|
.ajaxSelectPicker({
|
||||||
$(document).ready(function () {
|
ajax: {
|
||||||
setupMDE('#id_comments');
|
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>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{% extends 'base_assets.html' %}
|
{% extends 'base_assets.html' %}
|
||||||
{% load paginator from filters %}
|
{% load paginator from filters %}
|
||||||
{% load button from filters %}
|
{% load button from filters %}
|
||||||
{% load ids_from_objects from asset_tags %}
|
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
@@ -61,54 +60,27 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col px-0">
|
<div class="col px-0">
|
||||||
<form id="asset-search-form" method="GET">
|
<form id="asset-search-form" method="GET" class="form-inline justify-content-end">
|
||||||
<div class="form-row">
|
<div class="input-group px-1 mb-2 mb-sm-0 flex-nowrap">
|
||||||
<div class="col">
|
{% render_field form.q|add_class:'form-control' placeholder='Enter Asset ID/Desc/Serial' %}
|
||||||
<div class="input-group px-1 mb-2 mb-sm-0 flex-nowrap">
|
<label for="q" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||||
{% render_field form.q|add_class:'form-control' placeholder='Enter Asset ID/Desc/Serial' %}
|
<span class="input-group-append">{% button 'search' id="id_search" %}</span>
|
||||||
<label for="q" class="sr-only">Asset ID/Description/Serial Number:</label>
|
</div>
|
||||||
<span class="input-group-append">{% button 'search' id="id_search" %}</span>
|
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||||
</div>
|
<label for="category" class="sr-only">Category</label>
|
||||||
</div>
|
{% 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" %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row mt-2">
|
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||||
<div class="col">
|
<label for="status" class="sr-only">Status</label>
|
||||||
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
{% 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" %}
|
||||||
<label for="category" class="sr-only">Category</label>
|
</div>
|
||||||
{% render_field form.category|attr:'multiple'|add_class:'selectpicker col-sm' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %}
|
<button id="filter-submit" type="submit" class="btn btn-secondary" style="width: 6em">Filter</button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
|
||||||
<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 mt-2">
|
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
{% render_field form.is_cable|add_class:'form-check-input' %}
|
|
||||||
<label class="form-check-label" for="is_cable">Only Cables?</label>
|
|
||||||
</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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row my-2">
|
<div class="row my-2">
|
||||||
<div class="col text-right px-0">
|
<div class="col text-right px-0">
|
||||||
{% button 'new' 'asset_create' style="width: 6em" %}
|
{% 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>
|
</div>
|
||||||
<div class="row my-2">
|
<div class="row my-2">
|
||||||
@@ -121,7 +93,6 @@
|
|||||||
</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' %}
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
{% 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 %}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
{% extends 'base_assets.html' %}
|
|
||||||
{% load widget_tweaks %}
|
|
||||||
{% load button from filters %}
|
|
||||||
{% load cache %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
{% if create %}
|
|
||||||
<form method="POST" action="{% url 'cable_test'%}">
|
|
||||||
{% elif edit %}
|
|
||||||
<form method="POST" action="{% url 'cable_test' object.id %}">
|
|
||||||
{% endif %}
|
|
||||||
{% include 'form_errors.html' %}
|
|
||||||
{% csrf_token %}
|
|
||||||
<input type="hidden" name="id" value="{{ object.id|default:0 }}" hidden="">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
{% for field in form %}
|
|
||||||
<div class="form-group">
|
|
||||||
{% include 'partials/form_field.html' with field=field %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
<div class="text-right">
|
|
||||||
{% button 'submit' %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE document SYSTEM "rml.dtd">
|
|
||||||
{% load multiply from filters %}
|
|
||||||
{% load index from asset_tags %}
|
|
||||||
<document filename="{{filename}}">
|
|
||||||
<template>
|
|
||||||
<pageTemplate id="main">
|
|
||||||
<pageGraphics>
|
|
||||||
</pageGraphics>
|
|
||||||
<frame id="first" x1="5" y1="-10" width="581" height="842"/>
|
|
||||||
</pageTemplate>
|
|
||||||
</template>
|
|
||||||
<stylesheet>
|
|
||||||
<blockTableStyle id="table">
|
|
||||||
</blockTableStyle>
|
|
||||||
</stylesheet>
|
|
||||||
<story>
|
|
||||||
<blockTable style="table">
|
|
||||||
{% for i in images0 %}
|
|
||||||
<tr>
|
|
||||||
<td>{% with images0|index:forloop.counter0 as image %}{% if image %}<illustration width="180" height="55" borderStrokeWidth="1"
|
|
||||||
borderStrokeColor="black"><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 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"
|
|
||||||
{% if image.0.csa >= 4 %}width="180" height="55"{% else %}width="130" height="38"{%endif%}/></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>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</blockTable>
|
|
||||||
</story>
|
|
||||||
</document>
|
|
||||||
@@ -11,8 +11,7 @@
|
|||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
{% button 'edit' url='asset_update' pk=object.asset_id %}
|
{% button 'edit' url='asset_update' pk=object.asset_id %}
|
||||||
{% button 'duplicate' url='asset_duplicate' pk=object.asset_id %}
|
{% button 'duplicate' url='asset_duplicate' pk=object.asset_id %}
|
||||||
<a type="button" class="btn btn-info" href="{% url 'asset_audit' object.asset_id %}"><span class="fas fa-certificate"></span> Audit</a>
|
<a type="button" class="btn btn-info" href="{% url 'asset_audit' object.asset_id %}"><i class="fas fa-certificate"></i> Audit</a>
|
||||||
<a type="button" class="btn btn-primary" href="{% url 'generate_label' object.asset_id %}"><span class="fas fa-barcode"></span> Generate Label</a>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if create or edit or duplicate %}
|
{% if create or edit or duplicate %}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user