mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-10 00:39:40 +00:00
Compare commits
90 Commits
c537118037
...
optimisati
| Author | SHA1 | Date | |
|---|---|---|---|
|
d6c789d90a
|
|||
|
4fe7b874a4
|
|||
|
ac0425740e
|
|||
|
5382d8ae00
|
|||
|
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 |
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
|
||||||
|
|||||||
17
Pipfile
17
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,11 +34,12 @@ 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"
|
||||||
@@ -55,12 +57,12 @@ 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"
|
"z3c.rml" = "~=4.1.2"
|
||||||
@@ -75,10 +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 = "*"
|
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
selenium = "~=3.141.0"
|
selenium = "~=3.141.0"
|
||||||
@@ -90,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"
|
||||||
|
|||||||
1074
Pipfile.lock
generated
1074
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -61,13 +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',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE = (
|
MIDDLEWARE = (
|
||||||
@@ -187,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
|
||||||
@@ -260,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.nextSibling.CodeMirror.getDoc().getValue();", self.root.get_attribute("id"))
|
|
||||||
|
|
||||||
def set_value(self, value):
|
|
||||||
self.driver.execute_script("document.querySelector('#' + arguments[0]).nextSibling.nextSibling.CodeMirror.getDoc().setValue(arguments[1]);", self.root.get_attribute("id"), value)
|
|
||||||
|
|
||||||
|
|
||||||
class CheckBox(Region):
|
class CheckBox(Region):
|
||||||
def toggle(self):
|
def toggle(self):
|
||||||
self.root.click()
|
self.root.click()
|
||||||
|
|||||||
@@ -8,13 +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 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
|
||||||
|
|
||||||
|
|
||||||
@@ -44,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"):
|
||||||
@@ -62,14 +67,16 @@ class TestSampleDataGenerator(TestCase):
|
|||||||
assert Event.objects.all().count() == 0
|
assert Event.objects.all().count() == 0
|
||||||
|
|
||||||
|
|
||||||
|
class TestSampleDataGenerator(TestCase):
|
||||||
@override_settings(DEBUG=True)
|
@override_settings(DEBUG=True)
|
||||||
@pytest.mark.skip(reason="broken")
|
def setUp(self):
|
||||||
def test_unauthenticated(client): # Nothing should be available to the unauthenticated
|
|
||||||
call_command('generateSampleData')
|
call_command('generateSampleData')
|
||||||
|
|
||||||
|
def test_unauthenticated(self): # Nothing should be available to the unauthenticated
|
||||||
for url in find_urls_recursive(urls.urlpatterns):
|
for url in find_urls_recursive(urls.urlpatterns):
|
||||||
request_url = get_request_url(url)
|
request_url = get_request_url(url)
|
||||||
if request_url and 'user' not in request_url: # User module is full of edge cases
|
if request_url and 'user' not in request_url: # User module is full of edge cases
|
||||||
response = client.get(request_url, follow=True, HTTP_HOST='example.com')
|
response = self.client.get(request_url, follow=True, HTTP_HOST='example.com')
|
||||||
assertContains(response, 'Login')
|
assertContains(response, 'Login')
|
||||||
if 'application/json+oembed' in response.content.decode():
|
if 'application/json+oembed' in response.content.decode():
|
||||||
assertTemplateUsed(response, 'login_redirect.html')
|
assertTemplateUsed(response, 'login_redirect.html')
|
||||||
@@ -79,59 +86,60 @@ def test_unauthenticated(client): # Nothing should be available to the unauthen
|
|||||||
else:
|
else:
|
||||||
expected_url = "{0}?next={1}".format(reverse('login'), request_url)
|
expected_url = "{0}?next={1}".format(reverse('login'), request_url)
|
||||||
assertRedirects(response, expected_url)
|
assertRedirects(response, expected_url)
|
||||||
call_command('deleteSampleData')
|
|
||||||
|
|
||||||
|
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
|
assert response.status_code == 403
|
||||||
|
|
||||||
request_url = reverse('supplier_create')
|
request_url = reverse('supplier_create')
|
||||||
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
|
||||||
|
|
||||||
request_url = reverse('supplier_update', kwargs={'pk': 1})
|
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
|
||||||
client.logout()
|
self.client.logout()
|
||||||
call_command('deleteSampleData')
|
|
||||||
|
|
||||||
|
def test_keyholder_access(self):
|
||||||
@override_settings(DEBUG=True)
|
assert self.client.login(username="keyholder", password="keyholder")
|
||||||
@pytest.mark.skip(reason="broken")
|
|
||||||
def test_keyholder_access(client):
|
|
||||||
call_command('generateSampleData')
|
|
||||||
assert client.login(username="keyholder", password="keyholder")
|
|
||||||
|
|
||||||
url = reverse('asset_list')
|
url = reverse('asset_list')
|
||||||
response = client.get(url)
|
response = self.client.get(url)
|
||||||
# Check edit and duplicate buttons shown in list
|
# Check edit and duplicate buttons shown in list
|
||||||
assertContains(response, 'Edit')
|
assertContains(response, 'Edit')
|
||||||
assertContains(response, 'Duplicate')
|
assertContains(response, 'Duplicate')
|
||||||
|
|
||||||
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)
|
||||||
assertContains(response, 'Purchase Details')
|
assertContains(response, 'Purchase Details')
|
||||||
assertContains(response, 'View Revision History')
|
assertContains(response, 'View Revision History')
|
||||||
client.logout()
|
self.client.logout()
|
||||||
call_command('deleteSampleData')
|
|
||||||
|
|||||||
@@ -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'),
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ from django.views.decorators.clickjacking import xframe_options_exempt
|
|||||||
|
|
||||||
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):
|
||||||
@@ -39,8 +38,7 @@ class SecureAPIRequest(generic.View):
|
|||||||
'organisation': models.Organisation,
|
'organisation': models.Organisation,
|
||||||
'profile': models.Profile,
|
'profile': models.Profile,
|
||||||
'event': models.Event,
|
'event': models.Event,
|
||||||
'supplier': asset_models.Supplier,
|
'supplier': asset_models.Supplier
|
||||||
'training_item': training_models.TrainingItem,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
perms = {
|
perms = {
|
||||||
@@ -49,8 +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,
|
||||||
'supplier': None,
|
'supplier': None
|
||||||
'training_item': None, # TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@@ -78,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:
|
||||||
@@ -101,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)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
default_app_config = 'RIGS.apps.RIGSAppConfig'
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ 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)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ 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
|
||||||
@@ -33,7 +33,20 @@ class InvoiceIndex(generic.ListView):
|
|||||||
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):
|
||||||
@@ -41,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
|
||||||
|
|
||||||
|
|
||||||
@@ -118,7 +124,7 @@ 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
|
||||||
@@ -167,7 +173,24 @@ class InvoiceWaiting(generic.ListView):
|
|||||||
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):
|
||||||
@@ -197,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
|
||||||
|
|
||||||
@@ -154,7 +153,7 @@ class EventAuthorisationRequestForm(forms.Form):
|
|||||||
|
|
||||||
class EventRiskAssessmentForm(forms.ModelForm):
|
class EventRiskAssessmentForm(forms.ModelForm):
|
||||||
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()
|
||||||
@@ -165,9 +164,6 @@ 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():
|
||||||
@@ -185,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:
|
||||||
|
|||||||
14
RIGS/hs.py
14
RIGS/hs.py
@@ -70,11 +70,6 @@ class EventRiskAssessmentDetail(generic.DetailView):
|
|||||||
model = models.RiskAssessment
|
model = models.RiskAssessment
|
||||||
template_name = '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'] = "Risk Assessment for Event <a href='{}'>{} {}</a>".format(self.object.event.get_absolute_url(), self.object.event.display_id, self.object.event.name)
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentList(generic.ListView):
|
class EventRiskAssessmentList(generic.ListView):
|
||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
@@ -82,7 +77,7 @@ class EventRiskAssessmentList(generic.ListView):
|
|||||||
template_name = '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,7 +107,7 @@ class EventChecklistDetail(generic.DetailView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(EventChecklistDetail, self).get_context_data(**kwargs)
|
context = super(EventChecklistDetail, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = "Event Checklist for Event <a href='{}'>{} {}</a>".format(self.object.event.get_absolute_url(), self.object.event.display_id, self.object.event.name)
|
context['page_title'] = "Event Checklist for Event {} {}".format(self.object.event.display_id, self.object.event.name)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
@@ -187,9 +182,6 @@ class EventChecklistList(generic.ListView):
|
|||||||
model = models.EventChecklist
|
model = models.EventChecklist
|
||||||
template_name = '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)
|
||||||
context['title'] = 'Event Checklist'
|
context['title'] = 'Event Checklist'
|
||||||
@@ -218,7 +210,7 @@ class HSList(generic.ListView):
|
|||||||
template_name = '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)
|
||||||
|
|||||||
@@ -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,4 +1,4 @@
|
|||||||
# Generated by Django 3.1.13 on 2021-10-27 14:19
|
# Generated by Django 3.1.7 on 2021-03-02 11:21
|
||||||
|
|
||||||
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', '0042_auto_20211007_2338'),
|
('RIGS', '0041_auto_20210208_1603'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='profile',
|
model_name='profile',
|
||||||
name='initials',
|
name='phone',
|
||||||
field=models.CharField(max_length=5, null=True),
|
field=models.CharField(blank=True, default='', max_length=13),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -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'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
@@ -20,16 +20,13 @@ from reversion.models import Version
|
|||||||
|
|
||||||
|
|
||||||
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, blank=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):
|
||||||
@@ -68,8 +65,10 @@ 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 RevisionMixin:
|
|
||||||
|
class RevisionMixin(object):
|
||||||
@property
|
@property
|
||||||
def is_first_version(self):
|
def is_first_version(self):
|
||||||
versions = Version.objects.get_for_object(self)
|
versions = Version.objects.get_for_object(self)
|
||||||
@@ -99,7 +98,7 @@ class RevisionMixin:
|
|||||||
version = self.current_version
|
version = self.current_version
|
||||||
if version is None:
|
if version is None:
|
||||||
return None
|
return None
|
||||||
return f"V{version.pk} | R{version.revision.pk}"
|
return "V{0} | R{1}".format(version.pk, version.revision.pk)
|
||||||
|
|
||||||
|
|
||||||
class Person(models.Model, RevisionMixin):
|
class Person(models.Model, RevisionMixin):
|
||||||
@@ -207,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):
|
||||||
@@ -279,19 +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
|
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(follow=['items'])
|
@reversion.register(follow=['items'])
|
||||||
class Event(models.Model, RevisionMixin):
|
class Event(models.Model, RevisionMixin):
|
||||||
@@ -326,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,
|
||||||
@@ -334,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')
|
||||||
|
|
||||||
@@ -344,14 +333,11 @@ 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 str("N%05d" % self.pk)
|
||||||
|
else:
|
||||||
return self.pk
|
return self.pk
|
||||||
|
|
||||||
return "????"
|
|
||||||
|
|
||||||
# Calculated values
|
# Calculated values
|
||||||
"""
|
"""
|
||||||
EX Vat
|
EX Vat
|
||||||
@@ -373,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'))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -475,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 = {}
|
||||||
@@ -521,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
|
||||||
@@ -543,24 +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
|
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(follow=['payment_set'])
|
@reversion.register(follow=['payment_set'])
|
||||||
@@ -571,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
|
||||||
@@ -671,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?")
|
||||||
@@ -802,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>")
|
||||||
|
|||||||
@@ -38,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')
|
||||||
@@ -50,7 +50,7 @@ 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', '')
|
||||||
return context
|
return context
|
||||||
@@ -61,8 +61,8 @@ class EventDetail(generic.DetailView):
|
|||||||
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
|
||||||
@@ -84,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()
|
||||||
@@ -110,8 +110,8 @@ 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']
|
||||||
@@ -134,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})
|
||||||
@@ -142,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
|
||||||
@@ -151,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 = ''
|
||||||
@@ -167,8 +166,8 @@ 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
|
||||||
|
|
||||||
@@ -210,7 +209,8 @@ 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'))
|
||||||
@@ -265,7 +265,7 @@ class EventArchive(generic.ListView):
|
|||||||
# 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
|
||||||
@@ -282,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
|
||||||
@@ -296,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
|
||||||
@@ -318,7 +318,7 @@ class EventAuthorise(generic.UpdateView):
|
|||||||
return super(EventAuthorise, self).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
|
||||||
@@ -334,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):
|
||||||
@@ -344,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):
|
||||||
@@ -405,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'),
|
||||||
|
|||||||
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: 6.3 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,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>
|
||||||
|
|||||||
@@ -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 %}
|
||||||
|
|||||||
@@ -244,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 %}
|
||||||
@@ -346,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/simplemde.min.css' %}">
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block preload_js %}
|
{% block preload_js %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script src="{% static 'js/selects.js' %}"></script>
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
<script src="{% static 'js/simplemde.min.js' %}"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
@@ -29,26 +27,18 @@
|
|||||||
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);
|
||||||
$('.form-is_rig').hide();
|
});
|
||||||
{% endif %}
|
{% elif not object.pk and form.errors %}
|
||||||
//Creation
|
|
||||||
{% else %}
|
|
||||||
// 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') {
|
if ($('#{{form.is_rig.auto_id}}').attr('checked') !== 'checked') {
|
||||||
$('.form-is_rig').hide();
|
$('.form-is_rig').hide();
|
||||||
}
|
}
|
||||||
{% else %}
|
|
||||||
//Initial hide
|
|
||||||
$('.form-hws').slideUp(dur);
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
//Button handling
|
{% if not object.pk %}
|
||||||
$('#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')) {
|
||||||
@@ -58,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);
|
||||||
}
|
}
|
||||||
@@ -65,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">
|
||||||
@@ -180,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>
|
||||||
@@ -338,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" %}
|
||||||
@@ -357,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>
|
||||||
|
|||||||
@@ -74,14 +74,6 @@
|
|||||||
<lineStyle kind="linebelow" start="3,0" stop="3,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"/>
|
<lineStyle kind="linebelow" start="5,0" stop="5,0" colorName="black"/>
|
||||||
</blockTableStyle>
|
</blockTableStyle>
|
||||||
|
|
||||||
<listStyle name="ol"
|
|
||||||
bulletFormat="%s."
|
|
||||||
bulletFontSize="10" />
|
|
||||||
|
|
||||||
<listStyle name="ul"
|
|
||||||
start="bulletchar"
|
|
||||||
bulletFontSize="10"/>
|
|
||||||
</stylesheet>
|
</stylesheet>
|
||||||
|
|
||||||
<template > {# Note: page is 595x842 points (1 point=1/72in) #}
|
<template > {# Note: page is 595x842 points (1 point=1/72in) #}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
{% load markdown_tags %}
|
|
||||||
{% load filters %}
|
{% load filters %}
|
||||||
|
|
||||||
<setNextFrame name="main"/>
|
<setNextFrame name="main"/>
|
||||||
<nextFrame/>
|
<nextFrame/>
|
||||||
<blockTable style="headLayout" colWidths="330,165">
|
<blockTable style="headLayout" colWidths="330,165">
|
||||||
@@ -12,8 +10,10 @@
|
|||||||
<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>
|
||||||
@@ -184,7 +184,7 @@
|
|||||||
{% if item.description %}
|
{% if item.description %}
|
||||||
</para>
|
</para>
|
||||||
<para style="item_description">
|
<para style="item_description">
|
||||||
{{ item.description|markdown:"rml" }}
|
<em>{{ item.description|linebreaksxml }}</em>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -198,13 +198,11 @@
|
|||||||
</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 %}
|
||||||
@@ -213,10 +211,8 @@
|
|||||||
</para>
|
</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>
|
||||||
@@ -285,7 +281,7 @@
|
|||||||
<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>
|
||||||
@@ -320,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.
|
||||||
|
{% if object.event.organisation and object.event.organisation.union_account %}{# internal #}
|
||||||
Remember that only Presidents or Treasurers are allowed to sign off payments. You may need to forward
|
Remember that only Presidents or Treasurers are allowed to sign off payments. You may need to forward
|
||||||
this
|
this
|
||||||
email on.
|
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 %}
|
||||||
|
|||||||
@@ -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,7 +15,7 @@
|
|||||||
<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>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
{% 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.fieldz %}
|
||||||
<td>{{ object|get_field:field }}</td>
|
<td>{{ object|get_field:field }}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
{% 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>
|
||||||
@@ -17,11 +17,24 @@
|
|||||||
{% button 'print' url='invoice_print' pk=object.pk %}
|
{% button 'print' url='invoice_print' pk=object.pk %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
</div>
|
||||||
<div class="row py-4">
|
|
||||||
{% with object.event as object %}
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
{% include 'partials/contact_details.html' %}
|
<div class="card card-default">
|
||||||
|
<div class="card-header">Invoice Details<span class="float-right">
|
||||||
|
{% 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>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
{% include 'partials/event_details.html' %}
|
{% include 'partials/event_details.html' %}
|
||||||
@@ -31,8 +44,8 @@
|
|||||||
{% include 'partials/auth_details.html' %}
|
{% include 'partials/auth_details.html' %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row py-4">
|
<div class="row py-4">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="card card-default">
|
<div class="card card-default">
|
||||||
@@ -78,7 +91,7 @@
|
|||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
{% with object.event as object %}
|
{% with object.event as object %}
|
||||||
{% include 'partials/item_table.html' %}
|
{% include 'item_table.html' %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -86,4 +99,5 @@
|
|||||||
<div class="col-12 text-right">
|
<div class="col-12 text-right">
|
||||||
{% include 'partials/last_edited.html' with target="invoice_history" %}
|
{% include 'partials/last_edited.html' with target="invoice_history" %}
|
||||||
</div>
|
</div>
|
||||||
|
</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 @
|
||||||
@@ -48,7 +47,6 @@
|
|||||||
<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">
|
||||||
|
{% if event.person %}
|
||||||
{{ event.person.name }}
|
{{ 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 %}
|
||||||
</dd>
|
<a href="{% url 'venue_detail' object.venue.pk %}" class="modal-href">
|
||||||
|
{{ object.venue }}
|
||||||
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
|
||||||
<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">{{ event.organisation.union_account|yesno|capfirst }}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
@@ -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">
|
||||||
@@ -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,10 +6,6 @@
|
|||||||
<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 %}
|
||||||
|
|||||||
@@ -30,25 +30,25 @@
|
|||||||
<th scope="row" id="event_number">{{ event.display_id }}</th>
|
<th scope="row" id="event_number">{{ event.display_id }}</th>
|
||||||
<!--Dates & Times-->
|
<!--Dates & Times-->
|
||||||
<td id="event_dates">
|
<td id="event_dates">
|
||||||
<span class="text-nowrap">Start: <strong>{{ event.start_date|date:"D d/m/Y" }}
|
<span class="text-nowrap">Start: <strong>{{ event.start_date|date:"D d/m/Y" }}</strong>
|
||||||
{% if event.has_start_time %}
|
{% if event.has_start_time %}
|
||||||
{{ event.start_time|date:"H:i" }}
|
{{ event.start_time|date:"H:i" }}
|
||||||
{% endif %}</strong>
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
{% if event.end_date %}
|
{% if event.end_date %}
|
||||||
<br>
|
<br>
|
||||||
<span class="text-nowrap">End: {% if event.end_date != event.start_date %}<strong>{{ event.end_date|date:"D d/m/Y" }}{% endif %}
|
<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 %}
|
{% if event.has_end_time %}
|
||||||
{{ event.end_time|date:"H:i" }}
|
{{ event.end_time|date:"H:i" }}
|
||||||
{% endif %}</strong>
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not event.cancelled %}
|
{% if not event.cancelled %}
|
||||||
{% if event.meet_at %}
|
{% if event.meet_at %}
|
||||||
<br><span class="text-nowrap">Meet: <strong>{{ event.meet_at|date:"D d/m/Y H:i" }}</strong></span>
|
<br><span>Crew meet: <strong>{{ event.meet_at|date:"H:i" }}</strong> {{ event.meet_at|date:"(d/m/Y)" }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if event.access_at %}
|
{% if event.access_at %}
|
||||||
<br><span class="text-nowrap">Access: <strong>{{ event.access_at|date:" D d/m/Y H:i" }}</strong></span>
|
<br><span>Access at: <strong>{{ event.access_at|date:"H:i" }}</strong> {{ event.access_at|date:"(d/m/Y)" }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
@@ -67,9 +67,9 @@
|
|||||||
</h4>
|
</h4>
|
||||||
{% if event.is_rig and not event.cancelled %}
|
{% if event.is_rig and not event.cancelled %}
|
||||||
<h5>
|
<h5>
|
||||||
<a href="{{ event.person.get_absolute_url }}">{{ event.person.name }}</a>
|
{{ event.person.name }}
|
||||||
{% if event.organisation %}
|
{% if event.organisation %}
|
||||||
for <a href="{{ event.organisation.get_absolute_url }}">{{ event.organisation.name }}</a>
|
for {{ event.organisation.name }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</h5>
|
</h5>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif event.is_rig %}
|
{% elif event.is_rig %}
|
||||||
<span class="fas fa-user-slash"></span>
|
<span class="fas fa-exclamation"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
||||||
|
{% block title %}Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}{% endblock %}
|
||||||
{% load help_text from filters %}
|
{% load help_text from filters %}
|
||||||
{% load yesnoi from filters %}
|
{% load yesnoi from filters %}
|
||||||
{% load linkornone from filters %}
|
{% load linkornone from filters %}
|
||||||
@@ -6,6 +7,7 @@
|
|||||||
{% 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">
|
||||||
@@ -49,11 +51,11 @@
|
|||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
{{ object.power_mic.name|default:'None' }}
|
{{ 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>
|
||||||
@@ -95,67 +97,61 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-6 col-12">
|
|
||||||
<div class="card card-default mb-3">
|
<div class="card card-default mb-3">
|
||||||
<div class="card-header">Site Details</div>
|
<div class="card-header">Site Details</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
<dt class="col-10">{{ object|help_text:'known_venue' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'known_venue' }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-sm-6">
|
||||||
{{ object.known_venue|yesnoi:'invert' }}
|
{{ object.known_venue|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-10">{{ object|help_text:'safe_loading'|safe }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'safe_loading'|safe }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-sm-6">
|
||||||
{{ object.safe_loading|yesnoi:'invert' }}
|
{{ object.safe_loading|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-10">{{ object|help_text:'safe_storage' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'safe_storage' }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-sm-6">
|
||||||
{{ object.safe_storage|yesnoi:'invert' }}
|
{{ object.safe_storage|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-10">{{ object|help_text:'area_outside_of_control' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'area_outside_of_control' }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-sm-6">
|
||||||
{{ object.area_outside_of_control|yesnoi:'invert' }}
|
{{ object.area_outside_of_control|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-10">{{ object|help_text:'barrier_required' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'barrier_required' }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-sm-6">
|
||||||
{{ object.barrier_required|yesnoi:'invert' }}
|
{{ object.barrier_required|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-10">{{ object|help_text:'nonstandard_emergency_procedure' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'nonstandard_emergency_procedure' }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-sm-6">
|
||||||
{{ object.nonstandard_emergency_procedure|yesnoi:'invert' }}
|
{{ object.nonstandard_emergency_procedure|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="col-lg-6 col-12">
|
|
||||||
<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.name|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">
|
||||||
<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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -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'):
|
|
||||||
# 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):
|
||||||
|
|||||||
@@ -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'))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ from datetime import date
|
|||||||
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
|
||||||
@@ -172,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())
|
||||||
@@ -284,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):
|
||||||
@@ -366,215 +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 = """
|
|
||||||
An h1 header
|
|
||||||
============
|
|
||||||
|
|
||||||
Paragraphs are separated by a blank line.
|
|
||||||
|
|
||||||
2nd paragraph. *Italic*, **bold**, and `monospace`. Itemized lists
|
|
||||||
look like:
|
|
||||||
|
|
||||||
* this one
|
|
||||||
* that one
|
|
||||||
* the other one
|
|
||||||
|
|
||||||
Note that --- not considering the asterisk --- the actual text
|
|
||||||
content starts at 4-columns in.
|
|
||||||
|
|
||||||
> Block quotes are
|
|
||||||
> written like so.
|
|
||||||
>
|
|
||||||
> They can span multiple paragraphs,
|
|
||||||
> if you like.
|
|
||||||
|
|
||||||
Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all
|
|
||||||
in chapters 12--14"). Three dots ... will be converted to an ellipsis.
|
|
||||||
Unicode is supported.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
An h2 header
|
|
||||||
------------
|
|
||||||
|
|
||||||
Here's a numbered list:
|
|
||||||
|
|
||||||
1. first item
|
|
||||||
2. second item
|
|
||||||
3. third item
|
|
||||||
|
|
||||||
Note again how the actual text starts at 4 columns in (4 characters
|
|
||||||
from the left side). Here's a code sample:
|
|
||||||
|
|
||||||
# Let me re-iterate ...
|
|
||||||
for i in 1 .. 10 { do-something(i) }
|
|
||||||
|
|
||||||
As you probably guessed, indented 4 spaces. By the way, instead of
|
|
||||||
indenting the block, you can use delimited blocks, if you like:
|
|
||||||
|
|
||||||
~~~
|
|
||||||
define foobar() {
|
|
||||||
print "Welcome to flavor country!";
|
|
||||||
}
|
|
||||||
~~~
|
|
||||||
|
|
||||||
(which makes copying & pasting easier). You can optionally mark the
|
|
||||||
delimited block for Pandoc to syntax highlight it:
|
|
||||||
|
|
||||||
~~~python
|
|
||||||
import time
|
|
||||||
# Quick, count to ten!
|
|
||||||
for i in range(10):
|
|
||||||
# (but not *too* quick)
|
|
||||||
time.sleep(0.5)
|
|
||||||
print i
|
|
||||||
~~~
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### An h3 header ###
|
|
||||||
|
|
||||||
Now a nested list:
|
|
||||||
|
|
||||||
1. First, get these ingredients:
|
|
||||||
|
|
||||||
* carrots
|
|
||||||
* celery
|
|
||||||
* lentils
|
|
||||||
|
|
||||||
2. Boil some water.
|
|
||||||
|
|
||||||
3. Dump everything in the pot and follow
|
|
||||||
this algorithm:
|
|
||||||
|
|
||||||
find wooden spoon
|
|
||||||
uncover pot
|
|
||||||
stir
|
|
||||||
cover pot
|
|
||||||
balance wooden spoon precariously on pot handle
|
|
||||||
wait 10 minutes
|
|
||||||
goto first step (or shut off burner when done)
|
|
||||||
|
|
||||||
Do not bump wooden spoon or it will fall.
|
|
||||||
|
|
||||||
Notice again how text always lines up on 4-space indents (including
|
|
||||||
that last line which continues item 3 above).
|
|
||||||
|
|
||||||
Here's a link to [a website](http://foo.bar). Here's a footnote [^1].
|
|
||||||
|
|
||||||
[^1]: Footnote text goes here.
|
|
||||||
|
|
||||||
Tables can look like this:
|
|
||||||
|
|
||||||
size material color
|
|
||||||
---- ------------ ------------
|
|
||||||
9 leather brown
|
|
||||||
10 hemp canvas natural
|
|
||||||
11 glass transparent
|
|
||||||
|
|
||||||
Table: Shoes, their sizes, and what they're made of
|
|
||||||
|
|
||||||
(The above is the caption for the table.) Pandoc also supports
|
|
||||||
multi-line tables:
|
|
||||||
|
|
||||||
-------- -----------------------
|
|
||||||
keyword text
|
|
||||||
-------- -----------------------
|
|
||||||
red Sunsets, apples, and
|
|
||||||
other red or reddish
|
|
||||||
things.
|
|
||||||
|
|
||||||
green Leaves, grass, frogs
|
|
||||||
and other things it's
|
|
||||||
not easy being.
|
|
||||||
-------- -----------------------
|
|
||||||
|
|
||||||
A horizontal rule follows.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
Here's a definition list:
|
|
||||||
|
|
||||||
apples
|
|
||||||
: Good for making applesauce.
|
|
||||||
oranges
|
|
||||||
: Citrus!
|
|
||||||
tomatoes
|
|
||||||
: There's no "e" in tomatoe.
|
|
||||||
|
|
||||||
Again, text is indented 4 spaces. (Put a blank line between each
|
|
||||||
term/definition pair to spread things out more.)
|
|
||||||
|
|
||||||
Here's a "line block":
|
|
||||||
|
|
||||||
| Line one
|
|
||||||
| Line too
|
|
||||||
| Line tree
|
|
||||||
|
|
||||||
and images can be specified like so:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Inline math equations go in like so: $\\omega = d\\phi / dt$. Display
|
|
||||||
math should get its own line and be put in in double-dollarsigns:
|
|
||||||
|
|
||||||
$$I = \\int \rho R^{2} dV$$
|
|
||||||
|
|
||||||
And note that you can backslash-escape any punctuation characters
|
|
||||||
which you wish to be displayed literally, ex.: \\`foo\\`, \\*bar\\*, etc.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test_html_safe(self):
|
|
||||||
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',
|
|
||||||
)
|
|
||||||
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)
|
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
default_app_config = 'assets.apps.AssetsAppConfig'
|
||||||
|
|||||||
@@ -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:]
|
|
||||||
@@ -32,8 +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)
|
|
||||||
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
|
||||||
|
|||||||
@@ -20,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):
|
||||||
@@ -35,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']
|
||||||
|
|||||||
@@ -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')},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -6,8 +6,7 @@ from django.urls import reverse
|
|||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from reversion.models import Version
|
from reversion.models import Version
|
||||||
|
|
||||||
from RIGS.models import Profile
|
from RIGS.models import RevisionMixin, Profile
|
||||||
from versioning.versioning import RevisionMixin
|
|
||||||
|
|
||||||
|
|
||||||
class AssetCategory(models.Model):
|
class AssetCategory(models.Model):
|
||||||
@@ -50,7 +49,7 @@ class Supplier(models.Model, RevisionMixin):
|
|||||||
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
|
||||||
@@ -76,17 +75,13 @@ 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})
|
|
||||||
|
|
||||||
|
|
||||||
def get_available_asset_id(wanted_prefix=""):
|
def get_available_asset_id(wanted_prefix=""):
|
||||||
sql = """
|
sql = """
|
||||||
@@ -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})
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 24 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/simplemde.min.css' %}">
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block preload_js %}
|
{% block preload_js %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script src="{% static 'js/selects.js' %}"></script>
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
<script src="{% static 'js/simplemde.min.js' %}"></script>
|
|
||||||
<script src="{% static 'js/interaction.js' %}"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
@@ -37,7 +34,7 @@
|
|||||||
})
|
})
|
||||||
.ajaxSelectPicker({
|
.ajaxSelectPicker({
|
||||||
ajax: {
|
ajax: {
|
||||||
url: "{% url 'asset_search_json' %}",
|
url: '{% url 'asset_search_json' %}',
|
||||||
type: "GET",
|
type: "GET",
|
||||||
data: function () {
|
data: function () {
|
||||||
let params = {
|
let params = {
|
||||||
@@ -75,11 +72,6 @@
|
|||||||
preserveSelected: false
|
preserveSelected: false
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
setupMDE('#id_comments');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -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="col">
|
|
||||||
<div class="input-group px-1 mb-2 mb-sm-0 flex-nowrap">
|
<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' %}
|
{% 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>
|
<label for="q" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||||
<span class="input-group-append">{% button 'search' id="id_search" %}</span>
|
<span class="input-group-append">{% button 'search' id="id_search" %}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row mt-2">
|
|
||||||
<div class="col">
|
|
||||||
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||||
<label for="category" class="sr-only">Category</label>
|
<label for="category" class="sr-only">Category</label>
|
||||||
{% render_field form.category|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %}
|
{% render_field form.category|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||||
<label for="status" class="sr-only">Status</label>
|
<label for="status" class="sr-only">Status</label>
|
||||||
{% render_field form.status|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %}
|
{% render_field form.status|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %}
|
||||||
</div>
|
</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>
|
<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">
|
||||||
|
|||||||
@@ -1,35 +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">
|
|
||||||
<!-- show a grid: this also comes in handy for debugging your tables.-->
|
|
||||||
<lineStyle kind="GRID" colorName="black" thickness="1" start="0,0" stop="-1,-1" />
|
|
||||||
</blockTableStyle>
|
|
||||||
</stylesheet>
|
|
||||||
<story>
|
|
||||||
<blockTable style="table">
|
|
||||||
{% for i in images0 %}
|
|
||||||
<tr>
|
|
||||||
<td>{% with images0|index:forloop.counter0 as image %}{% if image %}<illustration width="120" height="35"><image file="data:image/png;base64,{{image}}" x="0" y="0"
|
|
||||||
width="120" height="35"/></illustration>{% endif %}{% endwith %}</td>
|
|
||||||
<td>{% with images1|index:forloop.counter0 as image %}{% if image %}<illustration width="120" height="35"><image file="data:image/png;base64,{{image}}" x="0" y="0"
|
|
||||||
width="120" height="35"/></illustration>{% endif %}{% endwith %}</td>
|
|
||||||
<td>{% with images2|index:forloop.counter0 as image %}{% if image %}<illustration width="120" height="35"><image file="data:image/png;base64,{{image}}" x="0" y="0"
|
|
||||||
width="120" height="35"/></illustration>{% endif %}{% endwith %}</td>
|
|
||||||
<td>{% with images3|index:forloop.counter0 as image %}{% if image %}<illustration width="120" height="35"><image file="data:image/png;base64,{{image}}" x="0" y="0"
|
|
||||||
width="120" height="35"/></illustration>{% endif %}{% endwith %}</td>
|
|
||||||
</tr>
|
|
||||||
{% 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 %}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
{% load markdown_tags %}
|
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
Asset Details
|
Asset Details
|
||||||
@@ -40,14 +38,14 @@
|
|||||||
<!---TODO: Lower default number of lines in comments box-->
|
<!---TODO: Lower default number of lines in comments box-->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="{{ form.comments.id_for_label }}">Comments</label>
|
<label for="{{ form.comments.id_for_label }}">Comments</label>
|
||||||
{% render_field form.comments|add_class:'form-control md-enabled' %}
|
{% render_field form.comments|add_class:'form-control' %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<dt>Asset ID</dt>
|
<dt>Asset ID</dt>
|
||||||
<dd>{{ object.asset_id }}</dd>
|
<dd>{{ object.asset_id }}</dd>
|
||||||
|
|
||||||
<dt>Description</dt>
|
<dt>Description</dt>
|
||||||
<dd>{{ object.description }}</dd>
|
<dd style="overflow-wrap: break-word;">{{ object.description }}</dd>
|
||||||
|
|
||||||
<dt>Category</dt>
|
<dt>Category</dt>
|
||||||
<dd>{{ object.category }}</dd>
|
<dd>{{ object.category }}</dd>
|
||||||
@@ -59,7 +57,7 @@
|
|||||||
<dd>{{ object.serial_number|default:'-' }}</dd>
|
<dd>{{ object.serial_number|default:'-' }}</dd>
|
||||||
|
|
||||||
<dt>Comments</dt>
|
<dt>Comments</dt>
|
||||||
<dd style="overflow-wrap: break-word;">{{ object.comments|default:'-'|markdown }}</dd>
|
<dd style="overflow-wrap: break-word;">{{ object.comments|default:'-'|linebreaksbr }}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,9 +17,11 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Cable Type</dt>
|
<dt>Cable Type</dt>
|
||||||
<dd>{% if object.cable_type %}<a href="{{object.cable_type.get_absolute_url}}">{{ object.cable_type }}</a>{%else%}-{%endif%}</dd>
|
<dd>{{ object.cable_type|default_if_none:'-' }}</dd>
|
||||||
|
|
||||||
<dt>Length</dt>
|
<dt>Length</dt>
|
||||||
<dd>{{ object.length|default_if_none:'-' }}m</dd>
|
<dd>{{ object.length|default_if_none:'-' }}m</dd>
|
||||||
|
|
||||||
<dt>Cross Sectional Area</dt>
|
<dt>Cross Sectional Area</dt>
|
||||||
<dd>{{ object.csa|default_if_none:'-' }}mm²</dd>
|
<dd>{{ object.csa|default_if_none:'-' }}mm²</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -28,13 +28,13 @@
|
|||||||
|
|
||||||
<dt>Children</dt>
|
<dt>Children</dt>
|
||||||
{% if object.asset_parent.all %}
|
{% if object.asset_parent.all %}
|
||||||
<div style="max-height: 200px; overflow-y: auto; -webkit-overflow-scrolling: touch; ">
|
|
||||||
{% for child in object.asset_parent.all %}
|
{% for child in object.asset_parent.all %}
|
||||||
<dd>
|
<dd>
|
||||||
<a href="{% url 'asset_detail' child.asset_id %}">{{ child }}</a>
|
<a href="{% url 'asset_detail' child.asset_id %}">
|
||||||
|
{{ child.asset_id }} - {{ child.description }}
|
||||||
|
</a>
|
||||||
</dd>
|
</dd>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<dd><span>-</span></dd>
|
<dd><span>-</span></dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
{% load linkornone from filters %}
|
|
||||||
<div class="card mb-2">
|
<div class="card mb-2">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
Purchase Details
|
Purchase Details
|
||||||
@@ -8,27 +7,12 @@
|
|||||||
{% if create or edit or duplicate %}
|
{% if create or edit or duplicate %}
|
||||||
<div class="form-group" id="purchased-from-group">
|
<div class="form-group" id="purchased-from-group">
|
||||||
<label for="{{ form.purchased_from.id_for_label }}">Supplier</label>
|
<label for="{{ form.purchased_from.id_for_label }}">Supplier</label>
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<select id="{{ form.purchased_from.id_for_label }}" name="{{ form.purchased_from.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='supplier' %}">
|
<select id="{{ form.purchased_from.id_for_label }}" name="{{ form.purchased_from.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='supplier' %}">
|
||||||
{% if object.purchased_from %}
|
{% if object.purchased_from %}
|
||||||
<option value="{{form.purchased_from.value}}" selected="selected" data-update_url="{% url 'supplier_update' form.purchased_from.value %}">{{ object.purchased_from }}</option>
|
<option value="{{form.purchased_from.value}}" selected="selected" data-update_url="{% url 'supplier_update' form.purchased_from.value %}">{{ object.purchased_from }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col align-right">
|
|
||||||
<div class="btn-group">
|
|
||||||
<a href="{% url 'supplier_create' %}" class="btn btn-success modal-href"
|
|
||||||
data-target="#{{ form.purchased_from.id_for_label }}">
|
|
||||||
<span class="fas fa-plus"></span>
|
|
||||||
</a>
|
|
||||||
<a {% if form.supplier.value %}href="{% url 'supplier_update' form.purchased_from.value %}"{% endif %} class="btn btn-warning modal-href" id="{{ form.purchased_from.id_for_label }}-update" data-target="#{{ form.purchased_from.id_for_label }}">
|
|
||||||
<span class="fas fa-edit"></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="{{ form.purchase_price.id_for_label }}">Purchase Price</label>
|
<label for="{{ form.purchase_price.id_for_label }}">Purchase Price</label>
|
||||||
@@ -67,11 +51,14 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Purchased From</dt>
|
<dt>Purchased From</dt>
|
||||||
<dd>{% if object.purchased_from %}<a href="{{object.purchased_from.get_absolute_url}}">{{ object.purchased_from }}</a>{%else%}-{%endif%}</dd>
|
<dd>{{ object.purchased_from|default_if_none:'-' }}</dd>
|
||||||
|
|
||||||
<dt>Purchase Price</dt>
|
<dt>Purchase Price</dt>
|
||||||
<dd>£{{ object.purchase_price|default_if_none:'-' }}</dd>
|
<dd>£{{ object.purchase_price|default_if_none:'-' }}</dd>
|
||||||
|
|
||||||
<dt>Salvage Value</dt>
|
<dt>Salvage Value</dt>
|
||||||
<dd>£{{ object.salvage_value|default_if_none:'-' }}</dd>
|
<dd>£{{ object.salvage_value|default_if_none:'-' }}</dd>
|
||||||
|
|
||||||
<dt>Date Acquired</dt>
|
<dt>Date Acquired</dt>
|
||||||
<dd>{{ object.date_acquired|default_if_none:'-' }}</dd>
|
<dd>{{ object.date_acquired|default_if_none:'-' }}</dd>
|
||||||
{% if object.date_sold %}
|
{% if object.date_sold %}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
from django import template
|
|
||||||
from assets import models
|
|
||||||
|
|
||||||
register = template.Library()
|
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
|
||||||
def ids_from_objects(object_list):
|
|
||||||
id_list = []
|
|
||||||
for obj in object_list:
|
|
||||||
id_list.append(obj.asset_id)
|
|
||||||
return id_list
|
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
|
||||||
def index(indexable, i):
|
|
||||||
return indexable[i] if i < len(indexable) else None
|
|
||||||
@@ -70,14 +70,14 @@ class AssetList(BasePage):
|
|||||||
|
|
||||||
|
|
||||||
class AssetForm(FormPage):
|
class AssetForm(FormPage):
|
||||||
_purchased_from_select_locator = (By.XPATH, '//div[@id="purchased-from-group"]/div/div/div')
|
_purchased_from_select_locator = (By.CSS_SELECTOR, 'div#purchased-from-group>div.bootstrap-select')
|
||||||
_parent_select_locator = (By.CSS_SELECTOR, 'div#parent-group>div.bootstrap-select')
|
_parent_select_locator = (By.CSS_SELECTOR, 'div#parent-group>div.bootstrap-select')
|
||||||
form_items = {
|
form_items = {
|
||||||
'asset_id': (regions.TextBox, (By.ID, 'id_asset_id')),
|
'asset_id': (regions.TextBox, (By.ID, 'id_asset_id')),
|
||||||
'description': (regions.TextBox, (By.ID, 'id_description')),
|
'description': (regions.TextBox, (By.ID, 'id_description')),
|
||||||
'is_cable': (regions.CheckBox, (By.ID, 'id_is_cable')),
|
'is_cable': (regions.CheckBox, (By.ID, 'id_is_cable')),
|
||||||
'serial_number': (regions.TextBox, (By.ID, 'id_serial_number')),
|
'serial_number': (regions.TextBox, (By.ID, 'id_serial_number')),
|
||||||
'comments': (regions.SimpleMDETextArea, (By.ID, 'id_comments')),
|
'comments': (regions.TextBox, (By.ID, 'id_comments')),
|
||||||
'purchase_price': (regions.TextBox, (By.ID, 'id_purchase_price')),
|
'purchase_price': (regions.TextBox, (By.ID, 'id_purchase_price')),
|
||||||
'salvage_value': (regions.TextBox, (By.ID, 'id_salvage_value')),
|
'salvage_value': (regions.TextBox, (By.ID, 'id_salvage_value')),
|
||||||
'date_acquired': (regions.DatePicker, (By.ID, 'id_date_acquired')),
|
'date_acquired': (regions.DatePicker, (By.ID, 'id_date_acquired')),
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class TestAssetForm(AutoLoginTest):
|
|||||||
def test_asset_edit(self):
|
def test_asset_edit(self):
|
||||||
self.page = pages.AssetEdit(self.driver, self.live_server_url, asset_id=self.parent.asset_id).open()
|
self.page = pages.AssetEdit(self.driver, self.live_server_url, asset_id=self.parent.asset_id).open()
|
||||||
|
|
||||||
self.assertIsNotNone(self.driver.find_element_by_id('id_asset_id').get_attribute('readonly'))
|
self.assertTrue(self.driver.find_element_by_id('id_asset_id').get_attribute('readonly') is not None)
|
||||||
|
|
||||||
new_description = "Big Shelf"
|
new_description = "Big Shelf"
|
||||||
self.page.description = new_description
|
self.page.description = new_description
|
||||||
@@ -335,7 +335,7 @@ class TestAssetAudit(AutoLoginTest):
|
|||||||
self.assertNotIn(self.asset.asset_id, self.page.assets)
|
self.assertNotIn(self.asset.asset_id, self.page.assets)
|
||||||
|
|
||||||
def test_audit_list(self):
|
def test_audit_list(self):
|
||||||
self.assertEqual(models.Asset.objects.filter(last_audited_at=None).count(), len(self.page.assets))
|
self.assertEqual(len(models.Asset.objects.filter(last_audited_at=None)), len(self.page.assets))
|
||||||
asset_row = self.page.assets[0]
|
asset_row = self.page.assets[0]
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@class,'btn') and contains(., 'Audit')]").click()
|
self.driver.find_element(By.XPATH, "//a[contains(@class,'btn') and contains(., 'Audit')]").click()
|
||||||
self.wait.until(ec.visibility_of_element_located((By.ID, 'modal')))
|
self.wait.until(ec.visibility_of_element_located((By.ID, 'modal')))
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ def test_x_frame_headers(client, django_user_model, test_asset):
|
|||||||
|
|
||||||
response = client.get(asset_url, follow=True)
|
response = client.get(asset_url, follow=True)
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
response.headers["X-Frame-Options"]
|
response._headers["X-Frame-Options"]
|
||||||
|
|
||||||
response = client.get(login_url, follow=True)
|
response = 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, test_asset):
|
def test_oembed(client, test_asset):
|
||||||
@@ -105,6 +105,7 @@ def test_asset_edit(admin_client, test_asset):
|
|||||||
|
|
||||||
def test_cable_edit(admin_client, test_cable):
|
def test_cable_edit(admin_client, test_cable):
|
||||||
url = reverse('asset_update', kwargs={'pk': test_cable.asset_id})
|
url = reverse('asset_update', kwargs={'pk': test_cable.asset_id})
|
||||||
|
# TODO Why do I have to send is_cable=True here?
|
||||||
response = admin_client.post(url, {'is_cable': True, 'length': -3, 'csa': -3})
|
response = admin_client.post(url, {'is_cable': True, 'length': -3, 'csa': -3})
|
||||||
|
|
||||||
# TODO Can't figure out how to select the 'none' option...
|
# TODO Can't figure out how to select the 'none' option...
|
||||||
|
|||||||
@@ -1,26 +1,21 @@
|
|||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.urls import path, register_converter
|
from django.urls import path
|
||||||
from django.views.decorators.clickjacking import xframe_options_exempt
|
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||||
|
|
||||||
from PyRIGS.decorators import has_oembed, permission_required_with_403
|
from PyRIGS.decorators import has_oembed, permission_required_with_403
|
||||||
from PyRIGS.views import OEmbedView
|
from PyRIGS.views import OEmbedView
|
||||||
from . import views, converters
|
from assets import views
|
||||||
|
|
||||||
register_converter(converters.AssetIDConverter, 'asset')
|
|
||||||
register_converter(converters.ListConverter, 'list')
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', login_required(views.AssetList.as_view()), name='asset_index'),
|
path('', login_required(views.AssetList.as_view()), name='asset_index'),
|
||||||
path('asset/list/', login_required(views.AssetList.as_view()), name='asset_list'),
|
path('asset/list/', login_required(views.AssetList.as_view()), name='asset_list'),
|
||||||
path('asset/id/<asset:pk>/', has_oembed(oembed_view="asset_oembed")(views.AssetDetail.as_view()), name='asset_detail'),
|
path('asset/id/<str:pk>/', has_oembed(oembed_view="asset_oembed")(views.AssetDetail.as_view()), name='asset_detail'),
|
||||||
path('asset/create/', permission_required_with_403('assets.add_asset')
|
path('asset/create/', permission_required_with_403('assets.add_asset')
|
||||||
(views.AssetCreate.as_view()), name='asset_create'),
|
(views.AssetCreate.as_view()), name='asset_create'),
|
||||||
path('asset/id/<asset:pk>/edit/', permission_required_with_403('assets.change_asset')
|
path('asset/id/<str:pk>/edit/', permission_required_with_403('assets.change_asset')
|
||||||
(views.AssetEdit.as_view()), name='asset_update'),
|
(views.AssetEdit.as_view()), name='asset_update'),
|
||||||
path('asset/id/<asset:pk>/duplicate/', permission_required_with_403('assets.add_asset')
|
path('asset/id/<str:pk>/duplicate/', permission_required_with_403('assets.add_asset')
|
||||||
(views.AssetDuplicate.as_view()), name='asset_duplicate'),
|
(views.AssetDuplicate.as_view()), name='asset_duplicate'),
|
||||||
path('asset/id/<asset:pk>/label', login_required(views.GenerateLabel.as_view()), name='generate_label'),
|
|
||||||
path('asset/<list:ids>/list/label', views.GenerateLabels.as_view(), name='generate_labels'),
|
|
||||||
|
|
||||||
path('cabletype/list/', login_required(views.CableTypeList.as_view()), name='cable_type_list'),
|
path('cabletype/list/', login_required(views.CableTypeList.as_view()), name='cable_type_list'),
|
||||||
path('cabletype/create/', permission_required_with_403('assets.add_cable_type')(views.CableTypeCreate.as_view()), name='cable_type_create'),
|
path('cabletype/create/', permission_required_with_403('assets.add_cable_type')(views.CableTypeCreate.as_view()), name='cable_type_create'),
|
||||||
|
|||||||
136
assets/views.py
136
assets/views.py
@@ -1,8 +1,4 @@
|
|||||||
import simplejson
|
import simplejson
|
||||||
import random
|
|
||||||
import base64
|
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
@@ -13,14 +9,6 @@ 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 django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.shortcuts import get_object_or_404
|
|
||||||
from django.template.loader import get_template
|
|
||||||
|
|
||||||
from PyPDF2 import PdfFileMerger, PdfFileReader
|
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
|
||||||
from barcode import Code39
|
|
||||||
from barcode.writer import ImageWriter
|
|
||||||
from z3c.rml import rml2pdf
|
|
||||||
|
|
||||||
from PyRIGS.views import GenericListView, GenericDetailView, GenericUpdateView, GenericCreateView, ModalURLMixin, \
|
from PyRIGS.views import GenericListView, GenericDetailView, GenericUpdateView, GenericCreateView, ModalURLMixin, \
|
||||||
is_ajax, OEmbedView
|
is_ajax, OEmbedView
|
||||||
@@ -54,15 +42,9 @@ class AssetList(LoginRequiredMixin, generic.ListView):
|
|||||||
queryset = self.model.objects.all()
|
queryset = self.model.objects.all()
|
||||||
elif len(query_string) >= 3:
|
elif len(query_string) >= 3:
|
||||||
queryset = self.model.objects.filter(
|
queryset = self.model.objects.filter(
|
||||||
Q(asset_id__exact=query_string.upper()) | Q(description__icontains=query_string) | Q(serial_number__exact=query_string))
|
Q(asset_id__exact=query_string) | Q(description__icontains=query_string) | Q(serial_number__exact=query_string))
|
||||||
else:
|
else:
|
||||||
queryset = self.model.objects.filter(Q(asset_id__exact=query_string.upper()))
|
queryset = self.model.objects.filter(Q(asset_id__exact=query_string))
|
||||||
|
|
||||||
if form.cleaned_data['is_cable']:
|
|
||||||
queryset = queryset.filter(is_cable=True)
|
|
||||||
|
|
||||||
if form.cleaned_data['date_acquired']:
|
|
||||||
queryset = queryset.filter(date_acquired=form.cleaned_data['date_acquired'])
|
|
||||||
|
|
||||||
if form.cleaned_data['category']:
|
if form.cleaned_data['category']:
|
||||||
queryset = queryset.filter(category__in=form.cleaned_data['category'])
|
queryset = queryset.filter(category__in=form.cleaned_data['category'])
|
||||||
@@ -76,7 +58,7 @@ class AssetList(LoginRequiredMixin, generic.ListView):
|
|||||||
return queryset.select_related('category', 'status')
|
return queryset.select_related('category', 'status')
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(AssetList, self).get_context_data(**kwargs)
|
||||||
context["form"] = self.form
|
context["form"] = self.form
|
||||||
if hasattr(self.form, 'cleaned_data'):
|
if hasattr(self.form, 'cleaned_data'):
|
||||||
context["category_filters"] = self.form.cleaned_data.get('category')
|
context["category_filters"] = self.form.cleaned_data.get('category')
|
||||||
@@ -117,7 +99,7 @@ class AssetDetail(LoginRequiredMixin, AssetIDUrlMixin, generic.DetailView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["page_title"] = f"Asset {self.object.display_id}"
|
context["page_title"] = "Asset {}".format(self.object.display_id)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
@@ -130,7 +112,7 @@ class AssetEdit(LoginRequiredMixin, AssetIDUrlMixin, generic.UpdateView):
|
|||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["edit"] = True
|
context["edit"] = True
|
||||||
context["connectors"] = models.Connector.objects.all()
|
context["connectors"] = models.Connector.objects.all()
|
||||||
context["page_title"] = f"Edit Asset: {self.object.display_id}"
|
context["page_title"] = "Edit Asset: {}".format(self.object.display_id)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -150,7 +132,7 @@ class AssetCreate(LoginRequiredMixin, generic.CreateView):
|
|||||||
form_class = forms.AssetForm
|
form_class = forms.AssetForm
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(AssetCreate, self).get_context_data(**kwargs)
|
||||||
context["create"] = True
|
context["create"] = True
|
||||||
context["connectors"] = models.Connector.objects.all()
|
context["connectors"] = models.Connector.objects.all()
|
||||||
context["page_title"] = "Create Asset"
|
context["page_title"] = "Create Asset"
|
||||||
@@ -177,9 +159,8 @@ class AssetDuplicate(DuplicateMixin, AssetIDUrlMixin, AssetCreate):
|
|||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["create"] = None
|
context["create"] = None
|
||||||
context["duplicate"] = True
|
context["duplicate"] = True
|
||||||
old_id = self.get_object().asset_id
|
context['previous_asset_id'] = self.get_object().asset_id
|
||||||
context['previous_asset_id'] = old_id
|
context["page_title"] = "Duplication of Asset: {}".format(context['previous_asset_id'])
|
||||||
context["page_title"] = f"Duplication of Asset: {old_id}"
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
@@ -202,7 +183,7 @@ class AssetAuditList(AssetList):
|
|||||||
return self.model.objects.filter(Q(last_audited_at__isnull=True)).select_related('category', 'status')
|
return self.model.objects.filter(Q(last_audited_at__isnull=True)).select_related('category', 'status')
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(AssetAuditList, self).get_context_data(**kwargs)
|
||||||
context['page_title'] = "Asset Audit List"
|
context['page_title'] = "Asset Audit List"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -213,7 +194,7 @@ class AssetAudit(AssetEdit):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["page_title"] = f"Audit Asset: {self.object.display_id}"
|
context["page_title"] = "Audit Asset: {}".format(self.object.display_id)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@@ -230,7 +211,7 @@ class SupplierList(GenericListView):
|
|||||||
ordering = ['name']
|
ordering = ['name']
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(SupplierList, self).get_context_data(**kwargs)
|
||||||
context['create'] = 'supplier_create'
|
context['create'] = 'supplier_create'
|
||||||
context['edit'] = 'supplier_update'
|
context['edit'] = 'supplier_update'
|
||||||
context['can_edit'] = self.request.user.has_perm('assets.change_supplier')
|
context['can_edit'] = self.request.user.has_perm('assets.change_supplier')
|
||||||
@@ -257,7 +238,7 @@ class SupplierDetail(GenericDetailView):
|
|||||||
model = models.Supplier
|
model = models.Supplier
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(SupplierDetail, self).get_context_data(**kwargs)
|
||||||
context['history_link'] = 'supplier_history'
|
context['history_link'] = 'supplier_history'
|
||||||
context['update_link'] = 'supplier_update'
|
context['update_link'] = 'supplier_update'
|
||||||
context['detail_link'] = 'supplier_detail'
|
context['detail_link'] = 'supplier_detail'
|
||||||
@@ -276,7 +257,7 @@ class SupplierCreate(GenericCreateView, ModalURLMixin):
|
|||||||
form_class = forms.SupplierForm
|
form_class = forms.SupplierForm
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(SupplierCreate, self).get_context_data(**kwargs)
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
else:
|
else:
|
||||||
@@ -322,8 +303,8 @@ class CableTypeDetail(generic.DetailView):
|
|||||||
template_name = 'cable_type_detail.html'
|
template_name = 'cable_type_detail.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(CableTypeDetail, self).get_context_data(**kwargs)
|
||||||
context["page_title"] = f"Cable Type {self.object}"
|
context["page_title"] = "Cable Type {}".format(str(self.object))
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
@@ -333,7 +314,7 @@ class CableTypeCreate(generic.CreateView):
|
|||||||
form_class = forms.CableTypeForm
|
form_class = forms.CableTypeForm
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(CableTypeCreate, self).get_context_data(**kwargs)
|
||||||
context["create"] = True
|
context["create"] = True
|
||||||
context["page_title"] = "Create Cable Type"
|
context["page_title"] = "Create Cable Type"
|
||||||
|
|
||||||
@@ -349,92 +330,11 @@ class CableTypeUpdate(generic.UpdateView):
|
|||||||
form_class = forms.CableTypeForm
|
form_class = forms.CableTypeForm
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super(CableTypeUpdate, self).get_context_data(**kwargs)
|
||||||
context["edit"] = True
|
context["edit"] = True
|
||||||
context["page_title"] = f"Edit Cable Type {self.object}"
|
context["page_title"] = "Edit Cable Type"
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse("cable_type_detail", kwargs={"pk": self.object.pk})
|
return reverse("cable_type_detail", kwargs={"pk": self.object.pk})
|
||||||
|
|
||||||
|
|
||||||
def generate_label(pk):
|
|
||||||
black = (0, 0, 0)
|
|
||||||
white = (255, 255, 255)
|
|
||||||
size = (700, 200)
|
|
||||||
font = ImageFont.truetype("static/fonts/OpenSans-Regular.tff", 20)
|
|
||||||
obj = get_object_or_404(models.Asset, asset_id=pk)
|
|
||||||
|
|
||||||
asset_id = f"Asset: {obj.asset_id}"
|
|
||||||
if obj.is_cable:
|
|
||||||
length = f"Length: {obj.length}m"
|
|
||||||
csa = f"CSA: {obj.csa}mm²"
|
|
||||||
|
|
||||||
image = Image.new("RGB", size, white)
|
|
||||||
logo = Image.open("static/imgs/square_logo.png")
|
|
||||||
draw = ImageDraw.Draw(image)
|
|
||||||
|
|
||||||
draw.text((210, 140), asset_id, fill=black, font=font)
|
|
||||||
if obj.is_cable:
|
|
||||||
draw.text((210, 170), length, fill=black, font=font)
|
|
||||||
draw.text((360, 170), csa, fill=black, font=font)
|
|
||||||
draw.multiline_text((500, 140), "TEC PA & Lighting\n(0115) 84 68720", fill=black, font=font)
|
|
||||||
|
|
||||||
barcode = Code39(str(obj.asset_id), writer=ImageWriter())
|
|
||||||
|
|
||||||
logo_size = (200, 200)
|
|
||||||
image.paste(logo.resize(logo_size, Image.ANTIALIAS))
|
|
||||||
barcode_image = barcode.render(writer_options={"quiet_zone": 0, "write_text": False})
|
|
||||||
width, height = barcode_image.size
|
|
||||||
image.paste(barcode_image.crop((0, 0, width, 135)), (int(((size[0] + logo_size[0]) - width) / 2), 0))
|
|
||||||
|
|
||||||
return image
|
|
||||||
|
|
||||||
|
|
||||||
class GenerateLabel(generic.View): # TODO Caching
|
|
||||||
def get(self, request, pk):
|
|
||||||
response = HttpResponse(content_type="image/png")
|
|
||||||
generate_label(pk).save(response, "PNG")
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
class GenerateLabels(generic.View):
|
|
||||||
def get(self, request, ids):
|
|
||||||
response = HttpResponse(content_type='application/pdf')
|
|
||||||
template = get_template('labels_print.xml')
|
|
||||||
|
|
||||||
images = []
|
|
||||||
|
|
||||||
for asset_id in ids:
|
|
||||||
image = generate_label(asset_id)
|
|
||||||
in_mem_file = BytesIO()
|
|
||||||
image.save(in_mem_file, format="PNG")
|
|
||||||
# reset file pointer to start
|
|
||||||
in_mem_file.seek(0)
|
|
||||||
img_bytes = in_mem_file.read()
|
|
||||||
|
|
||||||
base64_encoded_result_bytes = base64.b64encode(img_bytes)
|
|
||||||
base64_encoded_result_str = base64_encoded_result_bytes.decode('ascii')
|
|
||||||
images.append(base64_encoded_result_str)
|
|
||||||
|
|
||||||
context = {
|
|
||||||
'images0': images[::4],
|
|
||||||
'images1': images[1::4],
|
|
||||||
'images2': images[2::4],
|
|
||||||
'images3': images[3::4],
|
|
||||||
'filename': "Asset Label Sheet generated at {}".format(timezone.now())
|
|
||||||
}
|
|
||||||
merger = PdfFileMerger()
|
|
||||||
|
|
||||||
rml = template.render(context)
|
|
||||||
buffer = rml2pdf.parseString(rml)
|
|
||||||
merger.append(PdfFileReader(buffer))
|
|
||||||
buffer.close()
|
|
||||||
|
|
||||||
merged = BytesIO()
|
|
||||||
merger.write(merged)
|
|
||||||
|
|
||||||
response['Content-Disposition'] = 'filename="{}"'.format(context['filename'])
|
|
||||||
response.write(merged.getvalue())
|
|
||||||
return response
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ from django.conf import settings
|
|||||||
import django
|
import django
|
||||||
import pytest
|
import pytest
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
from RIGS.models import VatRate
|
from RIGS.models import VatRate, Profile
|
||||||
|
import random
|
||||||
|
from django.db import connection
|
||||||
from PyRIGS.tests import pages
|
from PyRIGS.tests import pages
|
||||||
import os
|
import os
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
|
|||||||
11
gulpfile.js
11
gulpfile.js
@@ -3,7 +3,7 @@
|
|||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
|
|
||||||
const terser = require('gulp-uglify');
|
const terser = require('gulp-uglify');
|
||||||
const sass = require('gulp-sass')(require('node-sass'));
|
const sass = require('gulp-sass');
|
||||||
const flatten = require('gulp-flatten');
|
const flatten = require('gulp-flatten');
|
||||||
const autoprefixer = require('autoprefixer')
|
const autoprefixer = require('autoprefixer')
|
||||||
const postcss = require('gulp-postcss')
|
const postcss = require('gulp-postcss')
|
||||||
@@ -15,6 +15,8 @@ const cssnano = require('cssnano');
|
|||||||
const con = require('gulp-concat');
|
const con = require('gulp-concat');
|
||||||
const gulpif = require('gulp-if');
|
const gulpif = require('gulp-if');
|
||||||
|
|
||||||
|
sass.compiler = require('node-sass');
|
||||||
|
|
||||||
function fonts(done) {
|
function fonts(done) {
|
||||||
return gulp.src('node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.*')
|
return gulp.src('node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.*')
|
||||||
.pipe(gulp.dest('pipeline/built_assets/fonts'))
|
.pipe(gulp.dest('pipeline/built_assets/fonts'))
|
||||||
@@ -27,9 +29,7 @@ function styles(done) {
|
|||||||
'node_modules/fullcalendar/main.css',
|
'node_modules/fullcalendar/main.css',
|
||||||
'node_modules/bootstrap-select/dist/css/bootstrap-select.css',
|
'node_modules/bootstrap-select/dist/css/bootstrap-select.css',
|
||||||
'node_modules/ajax-bootstrap-select/dist/css/ajax-bootstrap-select.css',
|
'node_modules/ajax-bootstrap-select/dist/css/ajax-bootstrap-select.css',
|
||||||
'node_modules/flatpickr/dist/flatpickr.css',
|
'node_modules/flatpickr/dist/flatpickr.css',])
|
||||||
'node_modules/simplemde/dist/simplemde.min.css'
|
|
||||||
])
|
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(sass().on('error', sass.logError))
|
.pipe(sass().on('error', sass.logError))
|
||||||
.pipe(gulpif(function(file) { return bs_select.includes(file.relative);}, con('selects.css')))
|
.pipe(gulpif(function(file) { return bs_select.includes(file.relative);}, con('selects.css')))
|
||||||
@@ -64,7 +64,6 @@ function scripts() {
|
|||||||
'node_modules/fullcalendar/main.js',
|
'node_modules/fullcalendar/main.js',
|
||||||
'node_modules/bootstrap-select/dist/js/bootstrap-select.js',
|
'node_modules/bootstrap-select/dist/js/bootstrap-select.js',
|
||||||
'node_modules/ajax-bootstrap-select/dist/js/ajax-bootstrap-select.js',
|
'node_modules/ajax-bootstrap-select/dist/js/ajax-bootstrap-select.js',
|
||||||
'node_modules/simplemde/dist/simplemde.min.js',
|
|
||||||
'node_modules/konami/konami.js',
|
'node_modules/konami/konami.js',
|
||||||
'pipeline/source_assets/js/**/*.js',])
|
'pipeline/source_assets/js/**/*.js',])
|
||||||
.pipe(gulpif(function(file) { return base_scripts.includes(file.relative);}, con('base.js')))
|
.pipe(gulpif(function(file) { return base_scripts.includes(file.relative);}, con('base.js')))
|
||||||
@@ -84,7 +83,7 @@ function browserSync(done) {
|
|||||||
notify: false,
|
notify: false,
|
||||||
open: false,
|
open: false,
|
||||||
port: 8001,
|
port: 8001,
|
||||||
proxy: '127.0.0.1:8000'
|
proxy: 'localhost:8000'
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
7776
package-lock.json
generated
7776
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
34
package.json
34
package.json
@@ -5,37 +5,35 @@
|
|||||||
"author": "Tom Price",
|
"author": "Tom Price",
|
||||||
"license": "Custom",
|
"license": "Custom",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@forevolve/bootstrap-dark": "^2.1.0",
|
"@forevolve/bootstrap-dark": "^1.0.0-alpha.1075",
|
||||||
"@fortawesome/fontawesome-free": "^5.15.4",
|
"@fortawesome/fontawesome-free": "^5.15.2",
|
||||||
"ajax-bootstrap-select": "^1.4.5",
|
"ajax-bootstrap-select": "^1.4.5",
|
||||||
"autocompleter": "^6.1.2",
|
"autocompleter": "^6.0.3",
|
||||||
"autoprefixer": "^10.4.0",
|
"autoprefixer": "^9.8.0",
|
||||||
"bootstrap": "^4.5.2",
|
"bootstrap": "^4.5.2",
|
||||||
"bootstrap-select": "^1.13.17",
|
"bootstrap-select": "^1.13.17",
|
||||||
"clipboard": "^2.0.8",
|
"clipboard": "^2.0.6",
|
||||||
"cssnano": "^5.0.13",
|
"cssnano": "^4.1.10",
|
||||||
"flatpickr": "^4.6.6",
|
"flatpickr": "^4.6.6",
|
||||||
"fullcalendar": "^5.10.1",
|
"fullcalendar": "^5.3.2",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
"gulp-flatten": "^0.4.0",
|
"gulp-flatten": "^0.4.0",
|
||||||
"gulp-if": "^3.0.0",
|
"gulp-if": "^3.0.0",
|
||||||
"gulp-postcss": "^9.0.1",
|
"gulp-postcss": "^8.0.0",
|
||||||
"gulp-sass": "^5.0.0",
|
"gulp-sass": "^4.1.0",
|
||||||
"gulp-sourcemaps": "^3.0.0",
|
"gulp-sourcemaps": "^2.6.5",
|
||||||
"gulp-uglify": "^3.0.2",
|
"gulp-uglify": "^3.0.2",
|
||||||
"html5sortable": "^0.13.3",
|
"html5sortable": "^0.10.0",
|
||||||
"jquery": "^3.6.0",
|
"jquery": "^3.5.1",
|
||||||
"konami": "^1.6.3",
|
"konami": "^1.6.2",
|
||||||
"moment": "^2.27.0",
|
"moment": "^2.27.0",
|
||||||
"node-sass": "^7.0.0",
|
"node-sass": "^5.0.0",
|
||||||
"popper.js": "^1.16.1",
|
"popper.js": "^1.16.1",
|
||||||
"postcss": "^8.4.5",
|
"uglify-js": "^3.12.6"
|
||||||
"simplemde": "^1.11.2",
|
|
||||||
"uglify-js": "^3.14.5"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"browser-sync": "^2.27.7"
|
"browser-sync": "^2.26.12"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"gulp": "gulp",
|
"gulp": "gulp",
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
marked.setOptions({
|
|
||||||
breaks: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
function setupItemTable(items_json) {
|
function setupItemTable(items_json) {
|
||||||
objectitems = JSON.parse(items_json)
|
objectitems = JSON.parse(items_json)
|
||||||
$.each(objectitems, function (key, val) {
|
$.each(objectitems, function (key, val) {
|
||||||
@@ -36,16 +32,6 @@ function updatePrices() {
|
|||||||
$('#total').text(parseFloat(sum + vat).toFixed(2));
|
$('#total').text(parseFloat(sum + vat).toFixed(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupMDE(selector) {
|
|
||||||
editor = new SimpleMDE({
|
|
||||||
element: $(selector)[0],
|
|
||||||
forceSync: true,
|
|
||||||
toolbar: ["bold", "italic", "strikethrough", "|", "unordered-list", "ordered-list", "|", "link", "|", "preview", "guide"],
|
|
||||||
status: true,
|
|
||||||
});
|
|
||||||
$(selector).data('mde_editor',editor);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#item-table').on('click', '.item-delete', function () {
|
$('#item-table').on('click', '.item-delete', function () {
|
||||||
delete objectitems[$(this).data('pk')]
|
delete objectitems[$(this).data('pk')]
|
||||||
$('#item-' + $(this).data('pk')).remove();
|
$('#item-' + $(this).data('pk')).remove();
|
||||||
@@ -120,7 +106,7 @@ $('body').on('submit', '#item-form', function (e) {
|
|||||||
// update the table
|
// update the table
|
||||||
$row = $('#item-' + pk);
|
$row = $('#item-' + pk);
|
||||||
$row.find('.name').html(escapeHtml(fields.name));
|
$row.find('.name').html(escapeHtml(fields.name));
|
||||||
$row.find('.description').html(marked(fields.description));
|
$row.find('.description').html(nl2br(escapeHtml(fields.description)));
|
||||||
$row.find('.cost').html(parseFloat(fields.cost).toFixed(2));
|
$row.find('.cost').html(parseFloat(fields.cost).toFixed(2));
|
||||||
$row.find('.quantity').html(fields.quantity);
|
$row.find('.quantity').html(fields.quantity);
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,6 @@
|
|||||||
color: $gray-100 !important;
|
color: $gray-100 !important;
|
||||||
border-color: $darktheme;
|
border-color: $darktheme;
|
||||||
}
|
}
|
||||||
.btn-link {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.bs-popover-right > .arrow::after {
|
.bs-popover-right > .arrow::after {
|
||||||
border-right-color: $darktheme;
|
border-right-color: $darktheme;
|
||||||
}
|
}
|
||||||
@@ -122,35 +119,4 @@
|
|||||||
background: #222;
|
background: #222;
|
||||||
color: $gray-100;
|
color: $gray-100;
|
||||||
}
|
}
|
||||||
input:-webkit-autofill,
|
|
||||||
input:-webkit-autofill:hover,
|
|
||||||
input:-webkit-autofill:focus,
|
|
||||||
textarea:-webkit-autofill,
|
|
||||||
textarea:-webkit-autofill:hover,
|
|
||||||
textarea:-webkit-autofill:focus,
|
|
||||||
select:-webkit-autofill,
|
|
||||||
select:-webkit-autofill:hover,
|
|
||||||
select:-webkit-autofill:focus {
|
|
||||||
border: 1px solid $info;
|
|
||||||
-webkit-text-fill-color: white;
|
|
||||||
-webkit-box-shadow: 0 0 0px 1000px rgba($info, .3) inset;
|
|
||||||
transition: background-color 5000s ease-in-out 0s;
|
|
||||||
}
|
|
||||||
.editor-toolbar > a {
|
|
||||||
color: white !important;
|
|
||||||
}
|
|
||||||
.editor-toolbar > a:hover {
|
|
||||||
background: transparent !important;
|
|
||||||
}
|
|
||||||
.editor-toolbar > a.active {
|
|
||||||
background: $info !important;
|
|
||||||
}
|
|
||||||
.cm-s-paper {
|
|
||||||
color: white;
|
|
||||||
background-color: $darktheme;
|
|
||||||
border-color: #bbb;
|
|
||||||
}
|
|
||||||
.CodeMirror-cursor {
|
|
||||||
border-color: white !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,11 +177,6 @@ svg {
|
|||||||
white-space: no-wrap;
|
white-space: no-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.fas {
|
|
||||||
padding-left: 0.1em !important;
|
|
||||||
padding-right: 0.1em !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html.embedded {
|
html.embedded {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -226,33 +221,3 @@ html.embedded {
|
|||||||
max-width: 3em;
|
max-width: 3em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown {
|
|
||||||
h1 {
|
|
||||||
font-size: $h1-font-size * 0.75;
|
|
||||||
}
|
|
||||||
h2 {
|
|
||||||
font-size: $h2-font-size * 0.8;
|
|
||||||
}
|
|
||||||
h3 {
|
|
||||||
font-size: $h3-font-size * 0.85;
|
|
||||||
}
|
|
||||||
h4 {
|
|
||||||
font-size: $h4-font-size * 0.9;
|
|
||||||
}
|
|
||||||
h5 {
|
|
||||||
font-size: $h5-font-size * 0.95;
|
|
||||||
}
|
|
||||||
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#rigboard {
|
|
||||||
.markdown {
|
|
||||||
img {
|
|
||||||
max-width: 30rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user