Compare commits
245 Commits
f775cee7dd
...
estates-co
| Author | SHA1 | Date | |
|---|---|---|---|
| cbe651957d | |||
| ef2826ab0a | |||
| 5a54092771 | |||
|
|
e8a8f2bf0d | ||
|
|
3984c17605 | ||
|
|
b2209eef4e | ||
|
e7c4f7f73d
|
|||
|
769d983e3d
|
|||
|
303005a32b
|
|||
|
c722773586
|
|||
|
|
0c2e677786 | ||
|
|
9719581977 | ||
|
|
b838dde30b | ||
|
387fa56442
|
|||
|
f35ce88acc
|
|||
|
ee5468fdd7
|
|||
|
1ce6ec3284
|
|||
|
677f352524
|
|||
|
8b3102b136
|
|||
|
e2b1dc1d05
|
|||
|
c9ba228bd2
|
|||
|
9f4cd41d23
|
|||
|
2049d0f76d
|
|||
|
29db3b5a0c
|
|||
|
53b09e47b8
|
|||
|
097e7c2481
|
|||
| 16874073e9 | |||
|
|
d03a4e115f | ||
| e1b87b412a | |||
| 54b44404ba | |||
|
|
26942b80dd | ||
|
|
888300490c | ||
| 9201f9d896 | |||
| 9fae129e26 | |||
|
|
8d45e260dd | ||
| 7d8dddb952 | |||
| 1104f10c91 | |||
| 3d5efba0af | |||
| 9a44aaf557 | |||
| 550eff83ee | |||
| bf3da5ae25 | |||
| 87aa87bc0f | |||
| 01a0b8f831 | |||
|
724762a1e8
|
|||
|
6ea5dc9698
|
|||
|
|
eb45db8950 | ||
|
b1a2859f1b
|
|||
|
dc71c2de62
|
|||
| 8863d86ed0 | |||
|
|
6550ed2318 | ||
|
|
c9759a6339 | ||
|
|
b637c4e452 | ||
|
|
8986b94b07 | ||
| 86c033ba97 | |||
| 52fd662340 | |||
| 9818ed995f | |||
| 5178614d71 | |||
| a7bf990666 | |||
|
a4a28a6130
|
|||
|
e3d8cf8978
|
|||
|
626779ef25
|
|||
| fa1dc31639 | |||
| d69543e309 | |||
|
|
a24e6d4495 | ||
|
|
fa5792914a | ||
| 0117091f3e | |||
|
37101d3340
|
|||
| de4bed92a4 | |||
|
|
3767923175 | ||
|
|
1d77cf95d3 | ||
|
|
1f21d0b265 | ||
| 7846a6d31e | |||
| d28b73a0b8 | |||
|
|
5c2e8b391c | ||
|
|
548bc1df81 | ||
|
|
c1d2bce8fb | ||
|
c71beab278
|
|||
|
259932a548
|
|||
|
7526485837
|
|||
| 39ed5aefb4 | |||
|
e7e760de2e
|
|||
| 9091197639 | |||
|
4f4baa62c1
|
|||
|
b9f8621e1a
|
|||
|
4b1dc37a7f
|
|||
|
|
9273ca35cf | ||
|
|
4a4b7fa30d | ||
| a44a532c7d | |||
| 3a2e5c943b | |||
| 426a9088cc | |||
|
|
1369a2f978 | ||
|
38eafbced3
|
|||
|
900002bf71
|
|||
|
2869c9fcc3
|
|||
|
00eb4e0e27
|
|||
|
23e17b0e34
|
|||
|
bf268a4566
|
|||
|
dedb8d81fe
|
|||
|
7d785f4f1b
|
|||
|
5eb113156b
|
|||
|
ab03ad081a
|
|||
| cd5889f60e | |||
| f18bf3b077 | |||
|
3d36d986a4
|
|||
|
41f5a23ef0
|
|||
|
09f48f740d
|
|||
|
805d77af20
|
|||
|
fabab87e23
|
|||
|
a95779e04e
|
|||
|
24e6ba540d
|
|||
|
14d3522b81
|
|||
|
e4cfaba57d
|
|||
|
d9664422c5
|
|||
|
27bb3f1d8e
|
|||
|
151ac8b3bd
|
|||
|
c2dcd86d5d
|
|||
|
6c14b30c13
|
|||
|
5215af349a
|
|||
|
a5e888fef5
|
|||
|
|
2ae4e4142c | ||
|
8799f822bb
|
|||
|
2dd3d306b4
|
|||
|
042004e1ae
|
|||
|
733ea69cc5
|
|||
|
bbea47e8ec
|
|||
|
c4aafbd7e5
|
|||
|
ccdc13df93
|
|||
|
aa19ceaf18
|
|||
|
05d280172d
|
|||
|
2f51b7b1d3
|
|||
|
8d1edb54ea
|
|||
| 54c90a7be4 | |||
|
3e1e0079d8
|
|||
|
b6952aeb52
|
|||
|
d33a4231fb
|
|||
|
8dea6aeab0
|
|||
|
34c03e379d
|
|||
|
988fb78b45
|
|||
|
eda314c092
|
|||
|
8ef520619a
|
|||
|
95931f86b4
|
|||
|
cc2cb5c4d1
|
|||
|
3ae507b469
|
|||
|
33754eed60
|
|||
|
15ab626593
|
|||
|
7bc47b446c
|
|||
|
83b287a418
|
|||
|
3b9848d457
|
|||
|
308d0c697e
|
|||
|
f243a589fa
|
|||
|
79c90ac92c
|
|||
|
8244287a64
|
|||
|
da4d62729b
|
|||
|
f8a48798de
|
|||
|
fc817fa9b5
|
|||
|
b04a168f01
|
|||
|
cc6992976e
|
|||
|
a556b17d2d
|
|||
|
f9e38338dc
|
|||
|
ce83ae6dd1
|
|||
|
9e1d54dc02
|
|||
| 375b0af2fd | |||
|
|
0354662864 | ||
|
c537118037
|
|||
|
466a9a9693
|
|||
| d25381b2de | |||
|
|
eaf891daf7 | ||
|
|
801d2e8a7d | ||
|
|
3d329219b8 | ||
|
2ddc8923ba
|
|||
|
276a86c5be
|
|||
|
484f155e43
|
|||
|
fdbdaab52e
|
|||
|
|
a01e351e89 | ||
|
|
708a387774 | ||
|
|
af6fe582e0 | ||
|
|
905a144e7d | ||
| 0e64021f01 | |||
| 2eb87a51f8 | |||
| 30fac1d1b9 | |||
|
c4fec483ae
|
|||
|
3028fb92d9
|
|||
| 215697ba64 | |||
|
d966bddfd7
|
|||
|
0d5e48b89c
|
|||
|
bd2c94d3e3
|
|||
|
21d09d951d
|
|||
|
014b00bc30
|
|||
|
3f8fc82260
|
|||
| 41c1c44754 | |||
|
8a2b107516
|
|||
|
f8c52803a5
|
|||
|
85d1850f08
|
|||
|
e146d9314a
|
|||
|
2c3dff79ba
|
|||
|
9ee8cd0f8b
|
|||
|
d3391d9e3e
|
|||
|
|
0086461d6c | ||
|
8bafeabe5f
|
|||
|
f214f9a835
|
|||
|
b31d53a3c5
|
|||
|
62a891c6ec
|
|||
|
8c0c0941c2
|
|||
|
abb0e35690
|
|||
|
bec0d4aee5
|
|||
|
f1e43b707e
|
|||
| 796f5b44b0 | |||
| 6458f016f0 | |||
| 9ca953423f | |||
|
|
4c5d958c6d | ||
| 85ca7b0880 | |||
|
44f9509eda
|
|||
|
a2be4cbe5e
|
|||
|
|
bb2f369ab5 | ||
|
2fdb2f260f
|
|||
|
6de3cb5d8c
|
|||
|
7c38af66f6
|
|||
|
f1a624ec8f
|
|||
|
ab01beb2cd
|
|||
|
11636809ca
|
|||
|
d7458f6366
|
|||
| febf9cf3ed | |||
| 3322a5ddf8 | |||
|
|
673bee4215 | ||
|
|
bab31107f7 | ||
|
|
2d8473b698 | ||
| d81ecd9015 | |||
| b42c583897 | |||
| 57e966826e | |||
|
6a5de4a9d6
|
|||
| 56bbf4c17c | |||
|
|
698f0be281 | ||
|
|
483f06e96f | ||
|
|
22193f3c39 | ||
|
|
59b63fe7aa | ||
| 5976ce9ea2 | |||
|
780d05e27c
|
|||
| 8cfa4bd79d | |||
|
36f83ee59b
|
|||
|
6d768832f4
|
|||
|
38da8642fa
|
|||
|
f75e1d5bfc
|
|||
|
3f959f8d56
|
|||
|
b63a01120b
|
|||
| 911336ceec |
@@ -1,3 +1,5 @@
|
|||||||
[run]
|
[run]
|
||||||
plugins = django_coverage_plugin
|
omit = */migrations/*
|
||||||
omit = */migrations/*, */tests/*
|
*/tests/*
|
||||||
|
*/site-packages/*
|
||||||
|
*/distutils/*
|
||||||
|
|||||||
151
.github/workflows/combine-prs.yml
vendored
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
name: 'Combine PRs'
|
||||||
|
|
||||||
|
# Controls when the action will run - in this case triggered manually
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
branchPrefix:
|
||||||
|
description: 'Branch prefix to find combinable PRs based on'
|
||||||
|
required: true
|
||||||
|
default: 'dependabot'
|
||||||
|
mustBeGreen:
|
||||||
|
description: 'Only combine PRs that are green (status is success)'
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
combineBranchName:
|
||||||
|
description: 'Name of the branch to combine PRs into'
|
||||||
|
required: true
|
||||||
|
default: 'combine-prs-branch'
|
||||||
|
ignoreLabel:
|
||||||
|
description: 'Exclude PRs with this label'
|
||||||
|
required: true
|
||||||
|
default: 'nocombine'
|
||||||
|
|
||||||
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
|
jobs:
|
||||||
|
# This workflow contains a single job called "combine-prs"
|
||||||
|
combine-prs:
|
||||||
|
# The type of runner that the job will run on
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||||
|
steps:
|
||||||
|
- uses: actions/github-script@v6
|
||||||
|
id: create-combined-pr
|
||||||
|
name: Create Combined PR
|
||||||
|
with:
|
||||||
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
script: |
|
||||||
|
const pulls = await github.paginate('GET /repos/:owner/:repo/pulls', {
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo
|
||||||
|
});
|
||||||
|
let branchesAndPRStrings = [];
|
||||||
|
let baseBranch = null;
|
||||||
|
let baseBranchSHA = null;
|
||||||
|
for (const pull of pulls) {
|
||||||
|
const branch = pull['head']['ref'];
|
||||||
|
console.log('Pull for branch: ' + branch);
|
||||||
|
if (branch.startsWith('${{ github.event.inputs.branchPrefix }}')) {
|
||||||
|
console.log('Branch matched prefix: ' + branch);
|
||||||
|
let statusOK = true;
|
||||||
|
if(${{ github.event.inputs.mustBeGreen }}) {
|
||||||
|
console.log('Checking green status: ' + branch);
|
||||||
|
const stateQuery = `query($owner: String!, $repo: String!, $pull_number: Int!) {
|
||||||
|
repository(owner: $owner, name: $repo) {
|
||||||
|
pullRequest(number:$pull_number) {
|
||||||
|
commits(last: 1) {
|
||||||
|
nodes {
|
||||||
|
commit {
|
||||||
|
statusCheckRollup {
|
||||||
|
state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
const vars = {
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
pull_number: pull['number']
|
||||||
|
};
|
||||||
|
const result = await github.graphql(stateQuery, vars);
|
||||||
|
const [{ commit }] = result.repository.pullRequest.commits.nodes;
|
||||||
|
const state = commit.statusCheckRollup.state
|
||||||
|
console.log('Validating status: ' + state);
|
||||||
|
if(state != 'SUCCESS') {
|
||||||
|
console.log('Discarding ' + branch + ' with status ' + state);
|
||||||
|
statusOK = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('Checking labels: ' + branch);
|
||||||
|
const labels = pull['labels'];
|
||||||
|
for(const label of labels) {
|
||||||
|
const labelName = label['name'];
|
||||||
|
console.log('Checking label: ' + labelName);
|
||||||
|
if(labelName == '${{ github.event.inputs.ignoreLabel }}') {
|
||||||
|
console.log('Discarding ' + branch + ' with label ' + labelName);
|
||||||
|
statusOK = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (statusOK) {
|
||||||
|
console.log('Adding branch to array: ' + branch);
|
||||||
|
const prString = '#' + pull['number'] + ' ' + pull['title'];
|
||||||
|
branchesAndPRStrings.push({ branch, prString });
|
||||||
|
baseBranch = pull['base']['ref'];
|
||||||
|
baseBranchSHA = pull['base']['sha'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (branchesAndPRStrings.length == 0) {
|
||||||
|
core.setFailed('No PRs/branches matched criteria');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await github.rest.git.createRef({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
ref: 'refs/heads/' + '${{ github.event.inputs.combineBranchName }}',
|
||||||
|
sha: baseBranchSHA
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
core.setFailed('Failed to create combined branch - maybe a branch by that name already exists?');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let combinedPRs = [];
|
||||||
|
let mergeFailedPRs = [];
|
||||||
|
for(const { branch, prString } of branchesAndPRStrings) {
|
||||||
|
try {
|
||||||
|
await github.rest.repos.merge({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
base: '${{ github.event.inputs.combineBranchName }}',
|
||||||
|
head: branch,
|
||||||
|
});
|
||||||
|
console.log('Merged branch ' + branch);
|
||||||
|
combinedPRs.push(prString);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Failed to merge branch ' + branch);
|
||||||
|
mergeFailedPRs.push(prString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Creating combined PR');
|
||||||
|
const combinedPRsString = combinedPRs.join('\n');
|
||||||
|
let body = '✅ This PR was created by the Combine PRs action by combining the following PRs:\n' + combinedPRsString;
|
||||||
|
if(mergeFailedPRs.length > 0) {
|
||||||
|
const mergeFailedPRsString = mergeFailedPRs.join('\n');
|
||||||
|
body += '\n\n⚠️ The following PRs were left out due to merge conflicts:\n' + mergeFailedPRsString
|
||||||
|
}
|
||||||
|
await github.rest.pulls.create({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
title: 'Combined PR',
|
||||||
|
head: '${{ github.event.inputs.combineBranchName }}',
|
||||||
|
base: baseBranch,
|
||||||
|
body: body
|
||||||
|
});
|
||||||
14
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: Manual Deploy
|
||||||
|
|
||||||
|
on: workflow_dispatch
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
|
||||||
|
with:
|
||||||
|
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
|
||||||
|
heroku_app_name: "pyrigs" #Must be unique in Heroku
|
||||||
|
heroku_email: "aj@aronajones.com"
|
||||||
47
.github/workflows/django.yml
vendored
@@ -10,43 +10,44 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# strategy:
|
|
||||||
# matrix:
|
|
||||||
# browser: ['chrome']
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# BROWSER: ${{ matrix.browser }}
|
PYTHONDONTWRITEBYTECODE: 1
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: bahmutov/npm-install@v1
|
|
||||||
- run: node node_modules/gulp/bin/gulp build
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
python-version: 3.9
|
||||||
- name: Cache python deps
|
cache: 'pipenv'
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ${{ env.pythonLocation }}
|
|
||||||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip pipenv
|
||||||
pip install pycodestyle coveralls django_coverage_plugin pytest-cov
|
pipenv install -d
|
||||||
pip install --upgrade --upgrade-strategy eager -r requirements.txt
|
# if: steps.pcache.outputs.cache-hit != 'true'
|
||||||
python manage.py collectstatic --noinput
|
- name: Cache Static Files
|
||||||
|
id: static-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: 'pipeline/built_assets'
|
||||||
|
key: ${{ hashFiles('package-lock.json') }}-${{ hashFiles('pipeline/source_assets') }}
|
||||||
|
- uses: bahmutov/npm-install@v1
|
||||||
|
if: steps.static-cache.outputs.cache-hit != 'true'
|
||||||
|
- run: node node_modules/gulp/bin/gulp build
|
||||||
|
if: steps.static-cache.outputs.cache-hit != 'true'
|
||||||
- name: Basic Checks
|
- name: Basic Checks
|
||||||
run: |
|
run: |
|
||||||
pycodestyle . --exclude=migrations,node_modules
|
pipenv run pycodestyle . --exclude=migrations,node_modules
|
||||||
python manage.py check
|
pipenv run python3 manage.py check
|
||||||
python manage.py makemigrations --check --dry-run
|
pipenv run python3 manage.py makemigrations --check --dry-run
|
||||||
|
pipenv run python3 manage.py collectstatic --noinput
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: pytest --cov -n 8
|
run: pipenv run pytest -n auto --cov
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v3
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: failure-screenshots ${{ matrix.test-group }}
|
name: failure-screenshots ${{ matrix.test-group }}
|
||||||
path: screenshots/
|
path: screenshots/
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
- name: Coveralls
|
- name: Coveralls
|
||||||
run: coveralls --service=github
|
run: pipenv run coveralls --service=github
|
||||||
|
|||||||
1
.gitignore
vendored
@@ -26,6 +26,7 @@ var/
|
|||||||
.installed.cfg
|
.installed.cfg
|
||||||
*.egg
|
*.egg
|
||||||
node_modules/
|
node_modules/
|
||||||
|
data/
|
||||||
|
|
||||||
# Continer extras
|
# Continer extras
|
||||||
.vagrant
|
.vagrant
|
||||||
|
|||||||
12
Dockerfile
@@ -1,12 +0,0 @@
|
|||||||
FROM python:3.6
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
ADD . /app
|
|
||||||
|
|
||||||
RUN pip install -r requirements.txt && \
|
|
||||||
python manage.py collectstatic --noinput
|
|
||||||
|
|
||||||
EXPOSE 8000
|
|
||||||
|
|
||||||
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
|
||||||
104
Pipfile
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
[[source]]
|
||||||
|
url = "https://pypi.python.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
name = "pypi"
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
ansicolors = "~=1.1.8"
|
||||||
|
asgiref = "~=3.3.1"
|
||||||
|
"backports.tempfile" = "~=1.0"
|
||||||
|
"backports.weakref" = "~=1.0.post1"
|
||||||
|
beautifulsoup4 = "~=4.9.3"
|
||||||
|
Brotli = "~=1.0.9"
|
||||||
|
cachetools = "~=4.2.1"
|
||||||
|
chardet = "~=4.0.0"
|
||||||
|
configparser = "~=5.0.1"
|
||||||
|
contextlib2 = "~=0.6.0.post1"
|
||||||
|
cssselect = "~=1.1.0"
|
||||||
|
cssutils = "~=1.0.2"
|
||||||
|
dj-database-url = "~=0.5.0"
|
||||||
|
dj-static = "~=0.0.6"
|
||||||
|
Django = "~=3.2"
|
||||||
|
django-debug-toolbar = "~=4.0.0"
|
||||||
|
django-filter = "~=2.4.0"
|
||||||
|
django-ical = "~=1.7.1"
|
||||||
|
django-recurrence = "~=1.10.3"
|
||||||
|
django-registration-redux = "~=2.9"
|
||||||
|
django-reversion = "~=3.0.9"
|
||||||
|
django-widget-tweaks = "~=1.4.8"
|
||||||
|
django-htmlmin = "~=0.11.0"
|
||||||
|
envparse = "*"
|
||||||
|
gunicorn = "~=20.0.4"
|
||||||
|
icalendar = "~=4.0.7"
|
||||||
|
idna = "~=2.10"
|
||||||
|
Markdown = "~=3.3.3"
|
||||||
|
msgpack = "~=1.0.2"
|
||||||
|
pep517 = "~=0.9.1"
|
||||||
|
Pillow = "~=9.3.0"
|
||||||
|
premailer = "~=3.7.0"
|
||||||
|
progress = "~=1.5"
|
||||||
|
psutil = "~=5.8.0"
|
||||||
|
psycopg2 = "~=2.8.6"
|
||||||
|
Pygments = "~=2.15.0"
|
||||||
|
pyparsing = "~=2.4.7"
|
||||||
|
PyPDF2 = "~=1.27.5"
|
||||||
|
PyPOM = "~=2.2.4"
|
||||||
|
python-dateutil = "~=2.8.1"
|
||||||
|
pytoml = "~=0.1.21"
|
||||||
|
pytz = "~=2020.5"
|
||||||
|
reportlab = "*"
|
||||||
|
requests = "~=2.31.0"
|
||||||
|
retrying = "~=1.3.3"
|
||||||
|
simplejson = "~=3.17.2"
|
||||||
|
six = "~=1.15.0"
|
||||||
|
soupsieve = "~=2.1"
|
||||||
|
sqlparse = "~=0.4.2"
|
||||||
|
static3 = "~=0.7.0"
|
||||||
|
svg2rlg = "~=0.3"
|
||||||
|
tini = "~=3.0.1"
|
||||||
|
tornado = "~=6.3"
|
||||||
|
urllib3 = "~=1.26.5"
|
||||||
|
whitenoise = "~=5.2.0"
|
||||||
|
yolk = "~=0.4.3"
|
||||||
|
zipp = "~=3.4.0"
|
||||||
|
"zope.component" = "~=4.6.2"
|
||||||
|
"zope.deferredimport" = "~=4.3.1"
|
||||||
|
"zope.deprecation" = "~=4.4.0"
|
||||||
|
"zope.event" = "~=4.5.0"
|
||||||
|
"zope.hookable" = "~=5.0.1"
|
||||||
|
"zope.interface" = "~=5.2.0"
|
||||||
|
"zope.proxy" = "~=4.3.5"
|
||||||
|
"zope.schema" = "~=6.0.1"
|
||||||
|
sentry-sdk = "*"
|
||||||
|
diff-match-patch = "*"
|
||||||
|
python-barcode = "*"
|
||||||
|
django-hCaptcha = "*"
|
||||||
|
importlib-metadata = "*"
|
||||||
|
django-hcaptcha = "*"
|
||||||
|
"z3c.rml" = "*"
|
||||||
|
pikepdf = "*"
|
||||||
|
django-queryable-properties = "*"
|
||||||
|
django-mass-edit = "*"
|
||||||
|
selenium = "~=4.9.1"
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
pycodestyle = "~=2.9.1"
|
||||||
|
coveralls = "*"
|
||||||
|
django-coverage-plugin = "*"
|
||||||
|
pytest-cov = "*"
|
||||||
|
pytest-django = "*"
|
||||||
|
pluggy = "*"
|
||||||
|
pytest-splinter = "*"
|
||||||
|
pytest = "*"
|
||||||
|
pytest-reverse = "*"
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.10"
|
||||||
|
|
||||||
|
[dev-packages.pytest-xdist]
|
||||||
|
extras = [ "psutil",]
|
||||||
|
version = "*"
|
||||||
|
|
||||||
|
[dev-packages.PyPOM]
|
||||||
|
extras = [ "splinter",]
|
||||||
|
version = "*"
|
||||||
2078
Pipfile.lock
generated
Normal file
@@ -9,9 +9,8 @@ from RIGS import models
|
|||||||
|
|
||||||
def get_oembed(login_url, request, oembed_view, kwargs):
|
def get_oembed(login_url, request, oembed_view, kwargs):
|
||||||
context = {}
|
context = {}
|
||||||
context['oembed_url'] = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'],
|
context['oembed_url'] = f"{request.scheme}://{request.META['HTTP_HOST']}{reverse(oembed_view, kwargs=kwargs)}"
|
||||||
reverse(oembed_view, kwargs=kwargs))
|
context['login_url'] = f"{login_url}?{REDIRECT_FIELD_NAME}={request.get_full_path()}"
|
||||||
context['login_url'] = "{0}?{1}={2}".format(login_url, REDIRECT_FIELD_NAME, request.get_full_path())
|
|
||||||
resp = render(request, 'login_redirect.html', context=context)
|
resp = render(request, 'login_redirect.html', context=context)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ def has_oembed(oembed_view, login_url=settings.LOGIN_URL):
|
|||||||
if oembed_view is not None:
|
if oembed_view is not None:
|
||||||
return get_oembed(login_url, request, oembed_view, kwargs)
|
return get_oembed(login_url, request, oembed_view, kwargs)
|
||||||
else:
|
else:
|
||||||
return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, request.get_full_path()))
|
return HttpResponseRedirect(f'{login_url}?{REDIRECT_FIELD_NAME}={request.get_full_path()}')
|
||||||
|
|
||||||
_checklogin.__doc__ = view_func.__doc__
|
_checklogin.__doc__ = view_func.__doc__
|
||||||
_checklogin.__dict__ = view_func.__dict__
|
_checklogin.__dict__ = view_func.__dict__
|
||||||
@@ -55,7 +54,7 @@ def user_passes_test_with_403(test_func, login_url=None, oembed_view=None):
|
|||||||
if oembed_view is not None:
|
if oembed_view is not None:
|
||||||
return get_oembed(login_url, request, oembed_view, kwargs)
|
return get_oembed(login_url, request, oembed_view, kwargs)
|
||||||
else:
|
else:
|
||||||
return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, request.get_full_path()))
|
return HttpResponseRedirect(f'{login_url}?{REDIRECT_FIELD_NAME}={request.get_full_path()}')
|
||||||
else:
|
else:
|
||||||
resp = render(request, '403.html')
|
resp = render(request, '403.html')
|
||||||
resp.status_code = 403
|
resp.status_code = 403
|
||||||
@@ -122,3 +121,7 @@ def nottinghamtec_address_required(function):
|
|||||||
return function(request, *args, **kwargs)
|
return function(request, *args, **kwargs)
|
||||||
|
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
|
|
||||||
|
def not_estates():
|
||||||
|
return user_passes_test_with_403(lambda u: not u.email.endswith('@nottingham.ac.uk'))
|
||||||
0
PyRIGS/management/commands/__init__.py
Normal file
@@ -9,27 +9,21 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
from pathlib import Path
|
||||||
import os
|
|
||||||
import secrets
|
import secrets
|
||||||
|
|
||||||
import raven
|
import sentry_sdk
|
||||||
|
from sentry_sdk.integrations.django import DjangoIntegration
|
||||||
from envparse import env
|
from envparse import env
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
|
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
|
||||||
# Quick-start development settings - unsuitable for production
|
|
||||||
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = env('SECRET_KEY', default='gxhy(a#5mhp289_=6xx$7jh=eh$ymxg^ymc+di*0c*geiu3p_e')
|
SECRET_KEY = env('SECRET_KEY', default='gxhy(a#5mhp289_=6xx$7jh=eh$ymxg^ymc+di*0c*geiu3p_e')
|
||||||
|
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = env('DEBUG', cast=bool, default=True)
|
DEBUG = env('DEBUG', cast=bool, default=True)
|
||||||
|
|
||||||
STAGING = env('STAGING', cast=bool, default=False)
|
STAGING = env('STAGING', cast=bool, default=False)
|
||||||
|
|
||||||
CI = env('CI', cast=bool, default=False)
|
CI = env('CI', cast=bool, default=False)
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['pyrigs.nottinghamtec.co.uk', 'rigs.nottinghamtec.co.uk', 'pyrigs.herokuapp.com']
|
ALLOWED_HOSTS = ['pyrigs.nottinghamtec.co.uk', 'rigs.nottinghamtec.co.uk', 'pyrigs.herokuapp.com']
|
||||||
@@ -41,6 +35,9 @@ if DEBUG:
|
|||||||
ALLOWED_HOSTS.append('localhost')
|
ALLOWED_HOSTS.append('localhost')
|
||||||
ALLOWED_HOSTS.append('example.com')
|
ALLOWED_HOSTS.append('example.com')
|
||||||
ALLOWED_HOSTS.append('127.0.0.1')
|
ALLOWED_HOSTS.append('127.0.0.1')
|
||||||
|
ALLOWED_HOSTS.append('.github.dev')
|
||||||
|
|
||||||
|
CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS
|
||||||
|
|
||||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
if not DEBUG:
|
if not DEBUG:
|
||||||
@@ -48,13 +45,15 @@ if not DEBUG:
|
|||||||
|
|
||||||
INTERNAL_IPS = ['127.0.0.1']
|
INTERNAL_IPS = ['127.0.0.1']
|
||||||
|
|
||||||
ADMINS = [('Tom Price', 'tomtom5152@gmail.com'), ('IT Manager', 'it@nottinghamtec.co.uk'),
|
DOMAIN = env('DOMAIN', default='example.com')
|
||||||
('Arona Jones', 'arona.jones@nottinghamtec.co.uk')]
|
|
||||||
|
ADMINS = [('IT Manager', f'it@{DOMAIN}'), ('Arona Jones', f'arona.jones@{DOMAIN}')]
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
ADMINS.append(('Testing Superuser', 'superuser@example.com'))
|
ADMINS.append(('Testing Superuser', 'superuser@example.com'))
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
|
'whitenoise.runserver_nostatic',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
@@ -66,20 +65,20 @@ INSTALLED_APPS = (
|
|||||||
'users',
|
'users',
|
||||||
'RIGS',
|
'RIGS',
|
||||||
'assets',
|
'assets',
|
||||||
|
'training',
|
||||||
|
|
||||||
'debug_toolbar',
|
# 'debug_toolbar',
|
||||||
'registration',
|
'registration',
|
||||||
'reversion',
|
'reversion',
|
||||||
'captcha',
|
|
||||||
'widget_tweaks',
|
'widget_tweaks',
|
||||||
'raven.contrib.django.raven_compat',
|
'hcaptcha',
|
||||||
|
'massadmin',
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE = (
|
MIDDLEWARE = (
|
||||||
'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||||
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||||
'reversion.middleware.RevisionMiddleware',
|
'reversion.middleware.RevisionMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
@@ -87,19 +86,19 @@ MIDDLEWARE = (
|
|||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
'htmlmin.middleware.HtmlMinifyMiddleware',
|
||||||
|
'htmlmin.middleware.MarkRequestMiddleware',
|
||||||
)
|
)
|
||||||
|
|
||||||
ROOT_URLCONF = 'PyRIGS.urls'
|
ROOT_URLCONF = 'PyRIGS.urls'
|
||||||
|
|
||||||
WSGI_APPLICATION = 'PyRIGS.wsgi.application'
|
WSGI_APPLICATION = 'PyRIGS.wsgi.application'
|
||||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
'NAME': str(BASE_DIR / 'db.sqlite3'),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,9 +176,12 @@ else:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RAVEN_CONFIG = {
|
# Error/performance monitoring
|
||||||
'dsn': env('RAVEN_DSN', default=""),
|
sentry_sdk.init(
|
||||||
}
|
dsn=env('SENTRY_DSN', default=""),
|
||||||
|
integrations=[DjangoIntegration()],
|
||||||
|
traces_sample_rate=1.0,
|
||||||
|
)
|
||||||
|
|
||||||
# User system
|
# User system
|
||||||
AUTH_USER_MODEL = 'RIGS.Profile'
|
AUTH_USER_MODEL = 'RIGS.Profile'
|
||||||
@@ -190,12 +192,9 @@ LOGOUT_URL = '/user/logout/'
|
|||||||
|
|
||||||
ACCOUNT_ACTIVATION_DAYS = 7
|
ACCOUNT_ACTIVATION_DAYS = 7
|
||||||
|
|
||||||
# reCAPTCHA settings
|
# CAPTCHA settings
|
||||||
RECAPTCHA_PUBLIC_KEY = env('RECAPTCHA_PUBLIC_KEY', default="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI") # If not set, use development key
|
HCAPTCHA_SITEKEY = env('HCAPTCHA_SITEKEY', '10000000-ffff-ffff-ffff-000000000001')
|
||||||
RECAPTCHA_PRIVATE_KEY = env('RECAPTCHA_PUBLIC_KEY', default="6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe") # If not set, use development key
|
HCAPTCHA_SECRET = env('HCAPTCHA_SECRET', '0x0000000000000000000000000000000000000000')
|
||||||
NOCAPTCHA = True
|
|
||||||
|
|
||||||
SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error']
|
|
||||||
|
|
||||||
# Email
|
# Email
|
||||||
EMAILER_TEST = False
|
EMAILER_TEST = False
|
||||||
@@ -222,8 +221,6 @@ TIME_ZONE = 'Europe/London'
|
|||||||
|
|
||||||
FORMAT_MODULE_PATH = 'PyRIGS.formats'
|
FORMAT_MODULE_PATH = 'PyRIGS.formats'
|
||||||
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
USE_L10N = True
|
USE_L10N = True
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
@@ -232,21 +229,18 @@ USE_TZ = True
|
|||||||
DATETIME_INPUT_FORMATS = ('%Y-%m-%dT%H:%M', '%Y-%m-%dT%H:%M:%S')
|
DATETIME_INPUT_FORMATS = ('%Y-%m-%dT%H:%M', '%Y-%m-%dT%H:%M:%S')
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
|
STATIC_ROOT = str(BASE_DIR / 'static/')
|
||||||
STATIC_DIRS = (
|
|
||||||
os.path.join(BASE_DIR, 'static/')
|
|
||||||
)
|
|
||||||
STATICFILES_DIRS = [
|
STATICFILES_DIRS = [
|
||||||
os.path.join(BASE_DIR, 'pipeline/built_assets/'),
|
str(BASE_DIR / 'pipeline/built_assets'),
|
||||||
]
|
]
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [
|
'DIRS': [
|
||||||
os.path.join(BASE_DIR, 'templates')
|
BASE_DIR / 'templates'
|
||||||
],
|
],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
@@ -269,3 +263,12 @@ 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'
|
||||||
|
|
||||||
|
SECURE_HSTS_SECONDS = 3600
|
||||||
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
||||||
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
||||||
|
SESSION_COOKIE_SECURE = env('SESSION_COOKIE_SECURE_ENABLED', True)
|
||||||
|
CSRF_COOKIE_SECURE = env('CSRF_COOKIE_SECURE_ENABLED', True)
|
||||||
|
SECURE_HSTS_PRELOAD = True
|
||||||
|
|||||||
@@ -11,30 +11,22 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|||||||
|
|
||||||
from RIGS import models as rigsmodels
|
from RIGS import models as rigsmodels
|
||||||
from . import pages
|
from . import pages
|
||||||
from envparse import env
|
|
||||||
|
from pytest_django.asserts import assertContains
|
||||||
|
|
||||||
|
|
||||||
def create_datetime(year, month, day, hour, min):
|
def create_datetime(year, month, day, hour, minute):
|
||||||
tz = pytz.timezone(settings.TIME_ZONE)
|
tz = pytz.timezone(settings.TIME_ZONE)
|
||||||
return tz.localize(datetime(year, month, day, hour, min)).astimezone(pytz.utc)
|
return tz.localize(datetime(year, month, day, hour, minute)).astimezone(tz)
|
||||||
|
|
||||||
|
|
||||||
def create_browser():
|
def create_browser():
|
||||||
browser = env('BROWSER', default="chrome")
|
options = webdriver.ChromeOptions()
|
||||||
if browser == "firefox":
|
options.add_argument("--window-size=1920,1080")
|
||||||
options = webdriver.FirefoxOptions()
|
options.add_argument("--headless")
|
||||||
options.headless = True
|
if settings.CI:
|
||||||
driver = webdriver.Firefox(options=options)
|
options.add_argument("--no-sandbox")
|
||||||
driver.set_window_position(0, 0)
|
driver = webdriver.Chrome(options=options)
|
||||||
# Firefox is pissy about out of bounds otherwise
|
|
||||||
driver.set_window_size(3840, 2160)
|
|
||||||
else:
|
|
||||||
options = webdriver.ChromeOptions()
|
|
||||||
options.add_argument("--window-size=1920,1080")
|
|
||||||
options.add_argument("--headless")
|
|
||||||
if settings.CI:
|
|
||||||
options.add_argument("--no-sandbox")
|
|
||||||
driver = webdriver.Chrome(options=options)
|
|
||||||
return driver
|
return driver
|
||||||
|
|
||||||
|
|
||||||
@@ -60,6 +52,7 @@ class AutoLoginTest(BaseTest):
|
|||||||
login_page.login("EventTest", "EventTestPassword")
|
login_page.login("EventTest", "EventTestPassword")
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME Refactor as a pytest fixture
|
||||||
def screenshot_failure(func):
|
def screenshot_failure(func):
|
||||||
def wrapper_func(self, *args, **kwargs):
|
def wrapper_func(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
@@ -70,7 +63,7 @@ def screenshot_failure(func):
|
|||||||
if not pathlib.Path("screenshots").is_dir():
|
if not pathlib.Path("screenshots").is_dir():
|
||||||
os.mkdir("screenshots")
|
os.mkdir("screenshots")
|
||||||
self.driver.save_screenshot(screenshot_file)
|
self.driver.save_screenshot(screenshot_file)
|
||||||
print("Error in test {} is at path {}".format(screenshot_name, screenshot_file), file=sys.stderr)
|
print(f"Error in test {screenshot_name} is at path {screenshot_file}", file=sys.stderr)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
return wrapper_func
|
return wrapper_func
|
||||||
@@ -83,5 +76,30 @@ def screenshot_failure_cls(cls):
|
|||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
||||||
def assert_times_equal(first_time, second_time):
|
def assert_times_almost_equal(first_time, second_time):
|
||||||
assert first_time.replace(microsecond=0, second=0) == second_time.replace(microsecond=0, second=0)
|
assert first_time.replace(microsecond=0, second=0) == second_time.replace(microsecond=0, second=0)
|
||||||
|
|
||||||
|
|
||||||
|
def assert_oembed(alt_event_embed_url, alt_oembed_url, client, event_embed_url, event_url, oembed_url):
|
||||||
|
# Test the meta tag is in place
|
||||||
|
response = client.get(event_url, follow=True, HTTP_HOST='example.com')
|
||||||
|
assertContains(response, 'application/json+oembed')
|
||||||
|
assertContains(response, oembed_url)
|
||||||
|
# Test that the JSON exists
|
||||||
|
response = client.get(oembed_url, follow=True, HTTP_HOST='example.com')
|
||||||
|
assert response.status_code == 200
|
||||||
|
assertContains(response, event_embed_url)
|
||||||
|
# Should also work for non-existant events
|
||||||
|
response = client.get(alt_oembed_url, follow=True, HTTP_HOST='example.com')
|
||||||
|
assert response.status_code == 200
|
||||||
|
assertContains(response, alt_event_embed_url)
|
||||||
|
|
||||||
|
|
||||||
|
def login(client, django_user_model):
|
||||||
|
pwd = 'testuser'
|
||||||
|
usr = 'TestUser'
|
||||||
|
user = django_user_model.objects.create_user(username=usr, email="TestUser@test.com", password=pwd,
|
||||||
|
is_superuser=True,
|
||||||
|
is_active=True, is_staff=True)
|
||||||
|
assert client.login(username=usr, password=pwd)
|
||||||
|
return user
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ class BootstrapSelectElement(Region):
|
|||||||
self.find_element(*self._deselect_all_locator).click()
|
self.find_element(*self._deselect_all_locator).click()
|
||||||
|
|
||||||
def search(self, query):
|
def search(self, query):
|
||||||
|
# self.wait.until(expected_conditions.visibility_of_element_located(self._status_locator))
|
||||||
search_box = self.find_element(*self._search_locator)
|
search_box = self.find_element(*self._search_locator)
|
||||||
self.open()
|
self.open()
|
||||||
search_box.clear()
|
search_box.clear()
|
||||||
@@ -83,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 = list((x for x in self.options if x.name == name))
|
options = [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)
|
||||||
|
|
||||||
@@ -116,6 +117,15 @@ class TextBox(Region):
|
|||||||
self.root.send_keys(value)
|
self.root.send_keys(value)
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleMDETextArea(Region):
|
||||||
|
@property
|
||||||
|
def value(self):
|
||||||
|
return self.driver.execute_script("return document.querySelector('#' + arguments[0]).nextSibling.children[1].CodeMirror.getDoc().getValue();", self.root.get_attribute("id"))
|
||||||
|
|
||||||
|
def set_value(self, value):
|
||||||
|
self.driver.execute_script("document.querySelector('#' + arguments[0]).nextSibling.children[1].CodeMirror.getDoc().setValue(arguments[1]);", self.root.get_attribute("id"), value)
|
||||||
|
|
||||||
|
|
||||||
class CheckBox(Region):
|
class CheckBox(Region):
|
||||||
def toggle(self):
|
def toggle(self):
|
||||||
self.root.click()
|
self.root.click()
|
||||||
@@ -135,7 +145,7 @@ class RadioSelect(Region): # Currently only works for yes/no radio selects
|
|||||||
value = "0"
|
value = "0"
|
||||||
else:
|
else:
|
||||||
value = "1"
|
value = "1"
|
||||||
self.find_element(By.XPATH, "//label[@for='{}_{}']".format(self.root.get_attribute("id"), value)).click()
|
self.find_element(By.XPATH, f"//label[@for='{self.root.get_attribute('id')}_{value}']").click()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self):
|
def value(self):
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
from PyRIGS import urls
|
|
||||||
from assets.tests.test_unit import create_asset_one
|
|
||||||
import pytest
|
import pytest
|
||||||
from django.urls import URLPattern, URLResolver, reverse
|
from django.core.management import call_command
|
||||||
|
from django.template.defaultfilters import striptags
|
||||||
|
from django.urls import URLPattern, URLResolver
|
||||||
|
from django.urls import reverse
|
||||||
from django.urls.exceptions import NoReverseMatch
|
from django.urls.exceptions import NoReverseMatch
|
||||||
from pytest_django.asserts import assertContains, assertRedirects, assertTemplateUsed, assertInHTML
|
from pytest_django.asserts import assertRedirects, assertContains, assertNotContains
|
||||||
|
from pytest_django.asserts import assertTemplateUsed, assertInHTML
|
||||||
|
|
||||||
pytestmark = pytest.mark.django_db
|
from PyRIGS import urls
|
||||||
|
from RIGS.models import Event, Profile
|
||||||
|
from assets.models import Asset
|
||||||
|
from training.tests.test_unit import get_response
|
||||||
|
from django.db import connection
|
||||||
|
from django.template.defaultfilters import striptags
|
||||||
|
from django.urls.exceptions import NoReverseMatch
|
||||||
|
|
||||||
|
from django.test import TestCase, TransactionTestCase
|
||||||
|
from django.test.utils import override_settings
|
||||||
|
|
||||||
|
|
||||||
def find_urls_recursive(patterns):
|
def find_urls_recursive(patterns):
|
||||||
@@ -14,7 +25,7 @@ def find_urls_recursive(patterns):
|
|||||||
if isinstance(url, URLResolver):
|
if isinstance(url, URLResolver):
|
||||||
urls_to_check += find_urls_recursive(url.url_patterns)
|
urls_to_check += find_urls_recursive(url.url_patterns)
|
||||||
elif isinstance(url, URLPattern):
|
elif isinstance(url, URLPattern):
|
||||||
# Skip some thinks that actually don't need auth (mainly OEmbed JSONs that are essentially just a redirect)
|
# Skip some things that actually don't need auth (mainly OEmbed JSONs that are essentially just a redirect)
|
||||||
if url.name is not None and url.name != "closemodal" and "json" not in str(url):
|
if url.name is not None and url.name != "closemodal" and "json" not in str(url):
|
||||||
urls_to_check.append(url)
|
urls_to_check.append(url)
|
||||||
return urls_to_check
|
return urls_to_check
|
||||||
@@ -22,7 +33,6 @@ def find_urls_recursive(patterns):
|
|||||||
|
|
||||||
def get_request_url(url):
|
def get_request_url(url):
|
||||||
pattern = str(url.pattern)
|
pattern = str(url.pattern)
|
||||||
request_url = ""
|
|
||||||
try:
|
try:
|
||||||
kwargz = {}
|
kwargz = {}
|
||||||
if ":pk>" in pattern:
|
if ":pk>" in pattern:
|
||||||
@@ -34,8 +44,29 @@ def get_request_url(url):
|
|||||||
print("Couldn't test url " + pattern)
|
print("Couldn't test url " + pattern)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("command", ['generateSampleAssetsData', 'generateSampleRIGSData', 'generateSampleUserData',
|
||||||
|
'deleteSampleData', 'generateSampleTrainingData', 'generate_sample_training_users'])
|
||||||
|
def test_production_exception(command):
|
||||||
|
from django.core.management.base import CommandError
|
||||||
|
with pytest.raises(CommandError, match=".*production"):
|
||||||
|
call_command(command)
|
||||||
|
|
||||||
|
|
||||||
|
class TestSampleDataGenerator(TestCase):
|
||||||
|
@override_settings(DEBUG=True)
|
||||||
|
def test_sample_data(self):
|
||||||
|
call_command('generateSampleData')
|
||||||
|
assert Asset.objects.all().count() > 50
|
||||||
|
assert Event.objects.all().count() > 100
|
||||||
|
call_command('deleteSampleData')
|
||||||
|
assert not Asset.objects.all().exists()
|
||||||
|
assert not Event.objects.all().exists()
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(DEBUG=True)
|
||||||
|
@pytest.mark.skip(reason="broken")
|
||||||
def test_unauthenticated(client): # Nothing should be available to the unauthenticated
|
def test_unauthenticated(client): # Nothing should be available to the unauthenticated
|
||||||
create_asset_one()
|
call_command('generateSampleData')
|
||||||
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
|
||||||
@@ -45,21 +76,71 @@ def test_unauthenticated(client): # Nothing should be available to the unauthen
|
|||||||
assertTemplateUsed(response, 'login_redirect.html')
|
assertTemplateUsed(response, 'login_redirect.html')
|
||||||
else:
|
else:
|
||||||
if "embed" in str(url):
|
if "embed" in str(url):
|
||||||
expected_url = "{0}?next={1}".format(reverse('login_embed'), request_url)
|
expected_url = f"{reverse('login_embed')}?next={request_url}"
|
||||||
else:
|
else:
|
||||||
expected_url = "{0}?next={1}".format(reverse('login'), request_url)
|
expected_url = f"{reverse('login')}?next={request_url}"
|
||||||
assertRedirects(response, expected_url)
|
assertRedirects(response, expected_url)
|
||||||
|
call_command('deleteSampleData')
|
||||||
|
|
||||||
|
|
||||||
def test_page_titles(admin_client):
|
@override_settings(DEBUG=True)
|
||||||
create_asset_one()
|
@pytest.mark.skip(reason="broken")
|
||||||
for url in filter((lambda u: "embed" not in u.name), find_urls_recursive(urls.urlpatterns)):
|
def test_basic_access(client):
|
||||||
request_url = get_request_url(url)
|
call_command('generateSampleData')
|
||||||
response = admin_client.get(request_url)
|
assert client.login(username="basic", password="basic")
|
||||||
if hasattr(response, "context_data") and "page_title" in response.context_data:
|
|
||||||
expected_title = response.context_data["page_title"]
|
url = reverse('asset_list')
|
||||||
# try:
|
response = client.get(url)
|
||||||
assertInHTML('<title>{} | Rig Information Gathering System'.format(expected_title), response.content.decode())
|
# Check edit and duplicate buttons NOT shown in list
|
||||||
print("{} | {}".format(request_url, expected_title)) # If test fails, tell me where!
|
assertNotContains(response, 'Edit')
|
||||||
# except:
|
assertNotContains(response,
|
||||||
# print(response.content.decode(), file=open('output.html', 'w'))
|
'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})
|
||||||
|
response = client.get(url)
|
||||||
|
assertNotContains(response, 'Purchase Details')
|
||||||
|
assertNotContains(response, 'View Revision History')
|
||||||
|
|
||||||
|
urlz = {'asset_history', 'asset_update', 'asset_duplicate'}
|
||||||
|
for url_name in urlz:
|
||||||
|
request_url = reverse(url_name, kwargs={'pk': Asset.objects.first().asset_id})
|
||||||
|
response = client.get(request_url, follow=True)
|
||||||
|
assert response.status_code == 403
|
||||||
|
|
||||||
|
request_url = reverse('supplier_create')
|
||||||
|
response = client.get(request_url, follow=True)
|
||||||
|
assert response.status_code == 403
|
||||||
|
|
||||||
|
request_url = reverse('supplier_update', kwargs={'pk': 1})
|
||||||
|
response = client.get(request_url, follow=True)
|
||||||
|
assert response.status_code == 403
|
||||||
|
client.logout()
|
||||||
|
call_command('deleteSampleData')
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(DEBUG=True)
|
||||||
|
@pytest.mark.skip(reason="broken")
|
||||||
|
def test_keyholder_access(client):
|
||||||
|
call_command('generateSampleData')
|
||||||
|
assert client.login(username="keyholder", password="keyholder")
|
||||||
|
|
||||||
|
url = reverse('asset_list')
|
||||||
|
response = client.get(url)
|
||||||
|
# Check edit and duplicate buttons shown in list
|
||||||
|
assertContains(response, 'Edit')
|
||||||
|
assertContains(response, 'Duplicate')
|
||||||
|
|
||||||
|
url = reverse('asset_detail', kwargs={'pk': Asset.objects.first().asset_id})
|
||||||
|
response = client.get(url)
|
||||||
|
assertContains(response, 'Purchase Details')
|
||||||
|
assertContains(response, 'View Revision History')
|
||||||
|
client.logout()
|
||||||
|
call_command('deleteSampleData')
|
||||||
|
|
||||||
|
|
||||||
|
def test_search(admin_client, admin_user):
|
||||||
|
url = reverse('search')
|
||||||
|
response = admin_client.get(url, {'q': "Definetelynothingfoundifwesearchthis"})
|
||||||
|
assertContains(response, "No results found")
|
||||||
|
response = admin_client.get(url, {'q': admin_user.first_name})
|
||||||
|
assertContains(response, admin_user.first_name)
|
||||||
|
|||||||
@@ -6,34 +6,40 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
from PyRIGS.decorators import not_estates
|
||||||
|
|
||||||
from PyRIGS import views
|
from PyRIGS import views
|
||||||
|
|
||||||
urlpatterns = [
|
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('', not_estates()(views.Index.as_view()), name='index'),
|
||||||
|
|
||||||
# API
|
# API
|
||||||
path('api/<str:model>/', login_required(views.SecureAPIRequest.as_view()),
|
path('api/<str:model>/', not_estates()(views.SecureAPIRequest.as_view()),
|
||||||
name="api_secure"),
|
name="api_secure"),
|
||||||
path('api/<str:model>/<int:pk>/', login_required(views.SecureAPIRequest.as_view()),
|
path('api/<str:model>/<int:pk>/', not_estates()(views.SecureAPIRequest.as_view()),
|
||||||
name="api_secure"),
|
name="api_secure"),
|
||||||
|
|
||||||
path('closemodal/', views.CloseModal.as_view(), name='closemodal'),
|
path('closemodal/', views.CloseModal.as_view(), name='closemodal'),
|
||||||
path('search_help/', login_required(views.SearchHelp.as_view()), name='search_help'),
|
path('search/', not_estates()(views.Search.as_view()), name='search'),
|
||||||
|
path('search_help/', not_estates()(views.SearchHelp.as_view()), name='search_help'),
|
||||||
|
|
||||||
path('', include('users.urls')),
|
path('', include('users.urls')),
|
||||||
|
|
||||||
|
path('admin/', include('massadmin.urls')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path("robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += staticfiles_urlpatterns()
|
urlpatterns += staticfiles_urlpatterns()
|
||||||
|
|
||||||
import debug_toolbar
|
import debug_toolbar
|
||||||
urlpatterns = [
|
urlpatterns += [
|
||||||
path('__debug__/', include(debug_toolbar.urls)),
|
path('__debug__/', include(debug_toolbar.urls)),
|
||||||
path('bootstrap/', TemplateView.as_view(template_name="bootstrap.html")),
|
path('bootstrap/', TemplateView.as_view(template_name="bootstrap.html")),
|
||||||
] + urlpatterns
|
]
|
||||||
|
|||||||
227
PyRIGS/views.py
@@ -1,33 +1,54 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import operator
|
import operator
|
||||||
from functools import reduce
|
import re
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
import simplejson
|
from functools import reduce
|
||||||
|
from itertools import chain
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
from PyPDF2 import PdfFileMerger, PdfFileReader
|
||||||
|
from z3c.rml import rml2pdf
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.urls import reverse_lazy, reverse, NoReverseMatch
|
from django.urls import reverse_lazy, reverse, NoReverseMatch
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
|
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||||
|
from django.template.loader import get_template
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
from assets import models as asset_models
|
from assets import models as asset_models
|
||||||
|
from training import models as training_models
|
||||||
|
|
||||||
|
|
||||||
def is_ajax(request):
|
def is_ajax(request):
|
||||||
return request.headers.get('x-requested-with') == 'XMLHttpRequest'
|
return request.headers.get('x-requested-with') == 'XMLHttpRequest'
|
||||||
|
|
||||||
# Displays the current rig count along with a few other bits and pieces
|
|
||||||
|
def get_related(form, context): # Get some other objects to include in the form. Used when there are errors but also nice and quick.
|
||||||
|
for field, model in form.related_models.items():
|
||||||
|
value = form[field].value()
|
||||||
|
if value is not None and value != '':
|
||||||
|
context[field] = model.objects.get(pk=value)
|
||||||
|
|
||||||
|
|
||||||
class Index(generic.TemplateView):
|
class Index(generic.TemplateView): # Displays the current rig count along with a few other bits and pieces
|
||||||
template_name = 'index.html'
|
template_name = 'index.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(Index, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['rig_count'] = models.Event.objects.rig_count()
|
context['rig_count'] = models.Event.objects.rig_count()
|
||||||
|
context['now'] = models.Event.objects.events_in_bounds(timezone.now(), timezone.now()).exclude(status=models.Event.CANCELLED).filter(is_rig=True, dry_hire=False)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +59,9 @@ 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
|
'asset': asset_models.Asset,
|
||||||
|
'supplier': asset_models.Supplier,
|
||||||
|
'training_item': training_models.TrainingItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
perms = {
|
perms = {
|
||||||
@@ -47,7 +70,9 @@ class SecureAPIRequest(generic.View):
|
|||||||
'organisation': 'RIGS.view_organisation',
|
'organisation': 'RIGS.view_organisation',
|
||||||
'profile': 'RIGS.view_profile',
|
'profile': 'RIGS.view_profile',
|
||||||
'event': None,
|
'event': None,
|
||||||
'supplier': None
|
'asset': None,
|
||||||
|
'supplier': None,
|
||||||
|
'training_item': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@@ -75,6 +100,9 @@ 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:
|
||||||
@@ -95,27 +123,35 @@ 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)
|
||||||
objects = self.models[model].objects.filter(query)
|
objects = self.models[model].objects.filter(query)
|
||||||
|
# Returning unactivated or unapproved users when they are elsewhere filtered out of the default queryset leads to some *very* unexpected results
|
||||||
|
if model == "profile":
|
||||||
|
objects = objects.filter(is_active=True, is_approved=True)
|
||||||
for o in objects:
|
for o in objects:
|
||||||
|
name = o.display_name if hasattr(o, 'display_name') else o.name
|
||||||
data = {
|
data = {
|
||||||
'pk': o.pk,
|
'pk': o.pk,
|
||||||
'value': o.pk,
|
'value': o.pk,
|
||||||
'text': o.name,
|
'text': name,
|
||||||
}
|
}
|
||||||
try: # See if there is a valid update URL
|
try: # See if there is a valid update URL
|
||||||
data['update'] = reverse("%s_update" % model, kwargs={'pk': o.pk})
|
data['update'] = reverse(f"{model}_update", kwargs={'pk': o.pk})
|
||||||
except NoReverseMatch:
|
except NoReverseMatch:
|
||||||
pass
|
pass
|
||||||
results.append(data)
|
results.append(data)
|
||||||
|
|
||||||
# return a data response
|
# return a data response
|
||||||
json = simplejson.dumps(results)
|
return JsonResponse(results, safe=False)
|
||||||
return HttpResponse(json, content_type="application/json") # Always json
|
|
||||||
|
|
||||||
start = request.GET.get('start', None)
|
start = request.GET.get('start', None)
|
||||||
end = request.GET.get('end', None)
|
end = request.GET.get('end', None)
|
||||||
@@ -140,8 +176,7 @@ class SecureAPIRequest(generic.View):
|
|||||||
}
|
}
|
||||||
|
|
||||||
results.append(data)
|
results.append(data)
|
||||||
json = simplejson.dumps(results)
|
return JsonResponse(results, safe=False)
|
||||||
return HttpResponse(json, content_type="application/json") # Always json
|
|
||||||
|
|
||||||
return HttpResponse(model)
|
return HttpResponse(model)
|
||||||
|
|
||||||
@@ -152,7 +187,7 @@ class ModalURLMixin:
|
|||||||
url = reverse_lazy('closemodal')
|
url = reverse_lazy('closemodal')
|
||||||
update_url = str(reverse_lazy(update, kwargs={'pk': self.object.pk}))
|
update_url = str(reverse_lazy(update, kwargs={'pk': self.object.pk}))
|
||||||
messages.info(self.request, "modalobject=" + serializers.serialize("json", [self.object]))
|
messages.info(self.request, "modalobject=" + serializers.serialize("json", [self.object]))
|
||||||
messages.info(self.request, "modalobject[0]['update_url']='" + update_url + "'")
|
messages.info(self.request, f"modalobject[0]['update_url']='{update_url}'")
|
||||||
else:
|
else:
|
||||||
url = reverse_lazy(detail, kwargs={
|
url = reverse_lazy(detail, kwargs={
|
||||||
'pk': self.object.pk,
|
'pk': self.object.pk,
|
||||||
@@ -165,27 +200,14 @@ class GenericListView(generic.ListView):
|
|||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GenericListView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['page_title'] = self.model.__name__ + "s"
|
context['page_title'] = self.model.__name__ + "s"
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
q = self.request.GET.get('q', "")
|
object_list = self.model.objects.search(query=self.request.GET.get('q', ""))
|
||||||
|
|
||||||
filter = Q(name__icontains=q) | Q(email__icontains=q) | Q(address__icontains=q) | Q(notes__icontains=q) | Q(
|
|
||||||
phone__startswith=q) | Q(phone__endswith=q)
|
|
||||||
|
|
||||||
# try and parse an int
|
|
||||||
try:
|
|
||||||
val = int(q)
|
|
||||||
filter = filter | Q(pk=val)
|
|
||||||
except: # noqa
|
|
||||||
# not an integer
|
|
||||||
pass
|
|
||||||
|
|
||||||
object_list = self.model.objects.filter(filter)
|
|
||||||
|
|
||||||
orderBy = self.request.GET.get('orderBy', "name")
|
orderBy = self.request.GET.get('orderBy', "name")
|
||||||
if orderBy != "":
|
if orderBy != "":
|
||||||
@@ -197,8 +219,8 @@ class GenericDetailView(generic.DetailView):
|
|||||||
template_name = "generic_detail.html"
|
template_name = "generic_detail.html"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GenericDetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['page_title'] = "{} | {}".format(self.model.__name__, self.object.name)
|
context['page_title'] = f"{self.model.__name__} | {self.object.name}"
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
return context
|
return context
|
||||||
@@ -208,8 +230,8 @@ class GenericUpdateView(generic.UpdateView):
|
|||||||
template_name = "generic_form.html"
|
template_name = "generic_form.html"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GenericUpdateView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['page_title'] = "Edit {}".format(self.model.__name__)
|
context['page_title'] = f"Edit {self.model.__name__}"
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
return context
|
return context
|
||||||
@@ -219,26 +241,145 @@ class GenericCreateView(generic.CreateView):
|
|||||||
template_name = "generic_form.html"
|
template_name = "generic_form.html"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GenericCreateView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['page_title'] = "Create {}".format(self.model.__name__)
|
context['page_title'] = f"Create {self.model.__name__}"
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
context['override'] = "base_ajax.html"
|
context['override'] = "base_ajax.html"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class Search(generic.ListView):
|
||||||
|
template_name = 'search_results.html'
|
||||||
|
paginate_by = 20
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
def get_context_data(self, *args, **kwargs):
|
||||||
|
context = super().get_context_data(*args, **kwargs)
|
||||||
|
context['count'] = self.count or 0
|
||||||
|
context['query'] = self.request.GET.get('q')
|
||||||
|
context['page_title'] = f"{context['count']} search results for <b>{context['query']}</b>"
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
request = self.request
|
||||||
|
query = request.GET.get('q', None)
|
||||||
|
|
||||||
|
if query is not None:
|
||||||
|
event_results = models.Event.objects.search(query)
|
||||||
|
person_results = models.Person.objects.search(query)
|
||||||
|
organisation_results = models.Organisation.objects.search(query)
|
||||||
|
venue_results = models.Venue.objects.search(query)
|
||||||
|
invoice_results = models.Invoice.objects.search(query)
|
||||||
|
asset_results = asset_models.Asset.objects.search(query)
|
||||||
|
supplier_results = asset_models.Supplier.objects.search(query)
|
||||||
|
trainee_results = training_models.Trainee.objects.search(query)
|
||||||
|
training_item_results = training_models.TrainingItem.objects.search(query)
|
||||||
|
|
||||||
|
# combine querysets
|
||||||
|
queryset_chain = chain(
|
||||||
|
event_results,
|
||||||
|
person_results,
|
||||||
|
organisation_results,
|
||||||
|
venue_results,
|
||||||
|
invoice_results,
|
||||||
|
asset_results,
|
||||||
|
supplier_results,
|
||||||
|
trainee_results,
|
||||||
|
training_item_results,
|
||||||
|
)
|
||||||
|
qs = sorted(queryset_chain,
|
||||||
|
key=lambda instance: instance.pk,
|
||||||
|
reverse=True)
|
||||||
|
self.count = len(qs) # since qs is actually a list
|
||||||
|
return qs
|
||||||
|
return models.Event.objects.none() # just an empty queryset as default
|
||||||
|
|
||||||
|
|
||||||
class SearchHelp(generic.TemplateView):
|
class SearchHelp(generic.TemplateView):
|
||||||
template_name = 'search_help.html'
|
template_name = 'search_help.html'
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
Called from a modal window (e.g. when an item is submitted to an event/invoice).
|
|
||||||
May optionally also include some javascript in a success message to cause a load of
|
|
||||||
the new information onto the page.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class CloseModal(generic.TemplateView):
|
class CloseModal(generic.TemplateView):
|
||||||
|
"""
|
||||||
|
Called from a modal window (e.g. when an item is submitted to an event/invoice).
|
||||||
|
May optionally also include some javascript in a success message to cause a load of
|
||||||
|
the new information onto the page.
|
||||||
|
"""
|
||||||
template_name = 'closemodal.html'
|
template_name = 'closemodal.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
return {'messages': messages.get_messages(self.request)}
|
return {'messages': messages.get_messages(self.request)}
|
||||||
|
|
||||||
|
|
||||||
|
class OEmbedView(generic.View):
|
||||||
|
def get(self, request, pk=None):
|
||||||
|
embed_url = reverse(self.url_name, args=[pk])
|
||||||
|
full_url = f"{request.scheme}://{request.META['HTTP_HOST']}{embed_url}"
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'html': f'<iframe src="{full_url}" frameborder="0" width="100%" height="250"></iframe>',
|
||||||
|
'version': '1.0',
|
||||||
|
'type': 'rich',
|
||||||
|
'height': '250'
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonResponse(data)
|
||||||
|
|
||||||
|
|
||||||
|
def get_info_string(user):
|
||||||
|
user_str = f"by {user.name} " if user else ""
|
||||||
|
time = timezone.now().strftime('%d/%m/%Y %H:%I')
|
||||||
|
return f"[Paperwork generated {user_str}on {time}"
|
||||||
|
|
||||||
|
|
||||||
|
def render_pdf_response(template, context, append_terms):
|
||||||
|
merger = PdfFileMerger()
|
||||||
|
rml = template.render(context)
|
||||||
|
buffer = rml2pdf.parseString(rml)
|
||||||
|
merger.append(PdfFileReader(buffer))
|
||||||
|
buffer.close()
|
||||||
|
|
||||||
|
if append_terms:
|
||||||
|
terms = urllib.request.urlopen(settings.TERMS_OF_HIRE_URL)
|
||||||
|
merger.append(BytesIO(terms.read()))
|
||||||
|
|
||||||
|
merged = BytesIO()
|
||||||
|
merger.write(merged)
|
||||||
|
|
||||||
|
response = HttpResponse(content_type='application/pdf')
|
||||||
|
f = context['filename']
|
||||||
|
response['Content-Disposition'] = f'filename="{f}"'
|
||||||
|
response.write(merged.getvalue())
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
class PrintView(generic.View):
|
||||||
|
append_terms = False
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
obj = get_object_or_404(self.model, pk=self.kwargs['pk'])
|
||||||
|
object_name = re.sub(r'[^a-zA-Z0-9 \n\.]', '', obj.name)
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'object': obj,
|
||||||
|
'current_user': self.request.user,
|
||||||
|
'object_name': object_name,
|
||||||
|
'info_string': get_info_string(self.request.user) + f"- {obj.current_version_id}]",
|
||||||
|
}
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get(self, request, pk):
|
||||||
|
return render_pdf_response(get_template(self.template_name), self.get_context_data(), self.append_terms)
|
||||||
|
|
||||||
|
|
||||||
|
class PrintListView(generic.ListView):
|
||||||
|
def get_context_data(self, *args, **kwargs):
|
||||||
|
context = super().get_context_data(*args, **kwargs)
|
||||||
|
context['current_user'] = self.request.user
|
||||||
|
context['info_string'] = get_info_string(self.request.user) + "]"
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
self.object_list = self.get_queryset()
|
||||||
|
return render_pdf_response(get_template(self.template_name), self.get_context_data(), False)
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ For setup information and other such helpful stuff check the [Wiki](https://gith
|
|||||||
- PyRIGS: Base app, stores 'global' information
|
- PyRIGS: Base app, stores 'global' information
|
||||||
- RIGS: Rigboard stuff - event calendar etc
|
- RIGS: Rigboard stuff - event calendar etc
|
||||||
- assets: Database of our kit, testing data etc
|
- assets: Database of our kit, testing data etc
|
||||||
|
- training: Logs in-house training within various "departments" (sound, lighting etc).
|
||||||
- versioning: Our custom logic built on top of django-reversion. Semi-modular.
|
- versioning: Our custom logic built on top of django-reversion. Semi-modular.
|
||||||
- users: Our custom logic for registration and profiles. Semi-modular.
|
- users: Our custom logic for registration and profiles. Semi-modular.
|
||||||
- training: SoonTM
|
|
||||||
|
|
||||||
[](https://forthebadge.com) [](https://forthebadge.com)
|
[](https://forthebadge.com) [](https://forthebadge.com)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
default_app_config = 'RIGS.apps.RIGSAppConfig'
|
|
||||||
|
|||||||
202
RIGS/admin.py
@@ -8,30 +8,155 @@ from django.db.models import Count
|
|||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.db import IntegrityError
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from reversion.admin import VersionAdmin
|
from reversion.admin import VersionAdmin
|
||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
from users import forms as user_forms
|
from users import forms as user_forms
|
||||||
|
|
||||||
# Register your models here.
|
|
||||||
admin.site.register(models.VatRate, VersionAdmin)
|
admin.site.register(models.VatRate, VersionAdmin)
|
||||||
admin.site.register(models.Event, VersionAdmin)
|
admin.site.register(models.Event, VersionAdmin)
|
||||||
admin.site.register(models.EventItem, VersionAdmin)
|
admin.site.register(models.EventItem, VersionAdmin)
|
||||||
admin.site.register(models.Invoice, VersionAdmin)
|
admin.site.register(models.Invoice, VersionAdmin)
|
||||||
|
admin.site.register(models.EventCheckIn)
|
||||||
|
|
||||||
|
|
||||||
def approve_user(modeladmin, request, queryset):
|
@transaction.atomic() # Copied from django-extensions. GenericForeignKey support removed as unnecessary.
|
||||||
queryset.update(is_approved=True)
|
def merge_model_instances(primary_object, alias_objects):
|
||||||
|
"""
|
||||||
|
Merge several model instances into one, the `primary_object`.
|
||||||
|
Use this function to merge model objects and migrate all of the related
|
||||||
|
fields from the alias objects the primary object.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# get related fields
|
||||||
|
related_fields = list(filter(
|
||||||
|
lambda x: x.is_relation is True,
|
||||||
|
primary_object._meta.get_fields()))
|
||||||
|
|
||||||
|
many_to_many_fields = list(filter(
|
||||||
|
lambda x: x.many_to_many is True, related_fields))
|
||||||
|
|
||||||
|
related_fields = list(filter(
|
||||||
|
lambda x: x.many_to_many is False, related_fields))
|
||||||
|
|
||||||
|
# Loop through all alias objects and migrate their references to the
|
||||||
|
# primary object
|
||||||
|
deleted_objects = []
|
||||||
|
deleted_objects_count = 0
|
||||||
|
for alias_object in alias_objects:
|
||||||
|
# Migrate all foreign key references from alias object to primary
|
||||||
|
# object.
|
||||||
|
for many_to_many_field in many_to_many_fields:
|
||||||
|
alias_varname = many_to_many_field.name
|
||||||
|
related_objects = getattr(alias_object, alias_varname)
|
||||||
|
for obj in related_objects.all():
|
||||||
|
try:
|
||||||
|
# Handle regular M2M relationships.
|
||||||
|
getattr(alias_object, alias_varname).remove(obj)
|
||||||
|
getattr(primary_object, alias_varname).add(obj)
|
||||||
|
except AttributeError:
|
||||||
|
# Handle M2M relationships with a 'through' model.
|
||||||
|
# This does not delete the 'through model.
|
||||||
|
# TODO: Allow the user to delete a duplicate 'through' model.
|
||||||
|
through_model = getattr(alias_object, alias_varname).through
|
||||||
|
kwargs = {
|
||||||
|
many_to_many_field.m2m_reverse_field_name(): obj,
|
||||||
|
many_to_many_field.m2m_field_name(): alias_object,
|
||||||
|
}
|
||||||
|
through_model_instances = through_model.objects.filter(**kwargs)
|
||||||
|
for instance in through_model_instances:
|
||||||
|
# Re-attach the through model to the primary_object
|
||||||
|
setattr(
|
||||||
|
instance,
|
||||||
|
many_to_many_field.m2m_field_name(),
|
||||||
|
primary_object)
|
||||||
|
instance.save()
|
||||||
|
# TODO: Here, try to delete duplicate instances that are
|
||||||
|
# disallowed by a unique_together constraint
|
||||||
|
|
||||||
|
for related_field in related_fields:
|
||||||
|
if related_field.one_to_many:
|
||||||
|
with transaction.atomic():
|
||||||
|
try:
|
||||||
|
alias_varname = related_field.get_accessor_name()
|
||||||
|
related_objects = getattr(alias_object, alias_varname)
|
||||||
|
for obj in related_objects.all():
|
||||||
|
field_name = related_field.field.name
|
||||||
|
setattr(obj, field_name, primary_object)
|
||||||
|
obj.save()
|
||||||
|
except IntegrityError:
|
||||||
|
pass # Skip to avoid integrity error from unique_together
|
||||||
|
elif related_field.one_to_one or related_field.many_to_one:
|
||||||
|
alias_varname = related_field.name
|
||||||
|
if hasattr(alias_object, alias_varname):
|
||||||
|
related_object = getattr(alias_object, alias_varname)
|
||||||
|
primary_related_object = getattr(primary_object, alias_varname)
|
||||||
|
if primary_related_object is None:
|
||||||
|
setattr(primary_object, alias_varname, related_object)
|
||||||
|
primary_object.save()
|
||||||
|
elif related_field.one_to_one:
|
||||||
|
related_object.delete()
|
||||||
|
|
||||||
|
if alias_object.id:
|
||||||
|
deleted_objects += [alias_object]
|
||||||
|
alias_object.delete()
|
||||||
|
deleted_objects_count += 1
|
||||||
|
|
||||||
|
return primary_object, deleted_objects, deleted_objects_count
|
||||||
|
|
||||||
|
|
||||||
approve_user.short_description = "Approve selected users"
|
class AssociateAdmin(VersionAdmin):
|
||||||
|
search_fields = ['id', 'name']
|
||||||
|
list_display_links = ['id', 'name']
|
||||||
|
actions = ['merge']
|
||||||
|
|
||||||
|
def get_queryset(self, request):
|
||||||
|
return super().get_queryset(request).annotate(event_count=Count('event'))
|
||||||
|
|
||||||
|
def number_of_events(self, obj):
|
||||||
|
return obj.latest_events.count()
|
||||||
|
|
||||||
|
number_of_events.admin_order_field = 'event_count'
|
||||||
|
|
||||||
|
def merge(self, request, queryset):
|
||||||
|
if request.POST.get('post'): # Has the user confirmed which is the master record?
|
||||||
|
try:
|
||||||
|
master_object_pk = request.POST.get('master')
|
||||||
|
master_object = queryset.get(pk=master_object_pk)
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
self.message_user(request, "An error occured. Did you select a 'master' record?", level=messages.ERROR)
|
||||||
|
return
|
||||||
|
|
||||||
|
primary_object, deleted_objects, deleted_objects_count = merge_model_instances(master_object, queryset.exclude(pk=master_object_pk).all())
|
||||||
|
reversion.set_comment('Merging Objects')
|
||||||
|
self.message_user(request, f"Objects successfully merged. {deleted_objects_count} old objects deleted.")
|
||||||
|
else: # Present the confirmation screen
|
||||||
|
class TempForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = queryset.model
|
||||||
|
fields = self.merge_fields
|
||||||
|
|
||||||
|
forms = []
|
||||||
|
for obj in queryset:
|
||||||
|
forms.append(TempForm(instance=obj))
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'title': _("Are you sure?"),
|
||||||
|
'queryset': queryset,
|
||||||
|
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
|
||||||
|
'forms': forms
|
||||||
|
}
|
||||||
|
return TemplateResponse(request, 'admin_associate_merge.html', context)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(models.Profile)
|
@admin.register(models.Profile)
|
||||||
class ProfileAdmin(UserAdmin):
|
class ProfileAdmin(UserAdmin, AssociateAdmin):
|
||||||
# Don't know how to add 'is_approved' whilst preserving the default list...
|
list_display = ('username', 'name', 'is_approved', 'is_superuser', 'is_supervisor', 'number_of_events', 'last_login')
|
||||||
list_filter = ('is_approved', 'is_active', 'is_staff', 'is_superuser', 'groups')
|
list_display_links = ['username']
|
||||||
|
list_filter = UserAdmin.list_filter + ('is_approved',)
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, {'fields': ('username', 'password')}),
|
(None, {'fields': ('username', 'password')}),
|
||||||
(_('Personal info'), {
|
(_('Personal info'), {
|
||||||
@@ -49,62 +174,12 @@ class ProfileAdmin(UserAdmin):
|
|||||||
)
|
)
|
||||||
form = user_forms.ProfileChangeForm
|
form = user_forms.ProfileChangeForm
|
||||||
add_form = user_forms.ProfileCreationForm
|
add_form = user_forms.ProfileCreationForm
|
||||||
actions = [approve_user]
|
actions = ['approve_user', 'merge']
|
||||||
|
|
||||||
|
merge_fields = ['username', 'first_name', 'last_name', 'initials', 'email', 'phone', 'is_supervisor']
|
||||||
|
|
||||||
class AssociateAdmin(VersionAdmin):
|
def approve_user(modeladmin, request, queryset):
|
||||||
list_display = ('id', 'name', 'number_of_events')
|
queryset.update(is_approved=True)
|
||||||
search_fields = ['id', 'name']
|
|
||||||
list_display_links = ['id', 'name']
|
|
||||||
actions = ['merge']
|
|
||||||
|
|
||||||
merge_fields = ['name']
|
|
||||||
|
|
||||||
def get_queryset(self, request):
|
|
||||||
return super(AssociateAdmin, self).get_queryset(request).annotate(event_count=Count('event'))
|
|
||||||
|
|
||||||
def number_of_events(self, obj):
|
|
||||||
return obj.latest_events.count()
|
|
||||||
|
|
||||||
number_of_events.admin_order_field = 'event_count'
|
|
||||||
|
|
||||||
def merge(self, request, queryset):
|
|
||||||
if request.POST.get('post'): # Has the user confirmed which is the master record?
|
|
||||||
try:
|
|
||||||
masterObjectPk = request.POST.get('master')
|
|
||||||
masterObject = queryset.get(pk=masterObjectPk)
|
|
||||||
except ObjectDoesNotExist:
|
|
||||||
self.message_user(request, "An error occured. Did you select a 'master' record?", level=messages.ERROR)
|
|
||||||
return
|
|
||||||
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
for obj in queryset.exclude(pk=masterObjectPk):
|
|
||||||
events = obj.event_set.all()
|
|
||||||
for event in events:
|
|
||||||
masterObject.event_set.add(event)
|
|
||||||
obj.delete()
|
|
||||||
reversion.set_comment('Merging Objects')
|
|
||||||
|
|
||||||
self.message_user(request, "Objects successfully merged.")
|
|
||||||
return
|
|
||||||
else: # Present the confirmation screen
|
|
||||||
|
|
||||||
class TempForm(ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = queryset.model
|
|
||||||
fields = self.merge_fields
|
|
||||||
|
|
||||||
forms = []
|
|
||||||
for obj in queryset:
|
|
||||||
forms.append(TempForm(instance=obj))
|
|
||||||
|
|
||||||
context = {
|
|
||||||
'title': _("Are you sure?"),
|
|
||||||
'queryset': queryset,
|
|
||||||
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
|
|
||||||
'forms': forms
|
|
||||||
}
|
|
||||||
return TemplateResponse(request, 'admin_associate_merge.html', context)
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(models.Person)
|
@admin.register(models.Person)
|
||||||
@@ -133,3 +208,8 @@ class RiskAssessmentAdmin(VersionAdmin):
|
|||||||
@admin.register(models.EventChecklist)
|
@admin.register(models.EventChecklist)
|
||||||
class EventChecklistAdmin(VersionAdmin):
|
class EventChecklistAdmin(VersionAdmin):
|
||||||
list_display = ('id', 'event', 'reviewed_at', 'reviewed_by')
|
list_display = ('id', 'event', 'reviewed_at', 'reviewed_by')
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(models.PowerTestRecord)
|
||||||
|
class EventChecklistAdmin(VersionAdmin):
|
||||||
|
list_display = ('id', 'event', 'reviewed_at', 'reviewed_by')
|
||||||
|
|||||||
146
RIGS/forms.py
@@ -8,6 +8,7 @@ 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'})
|
||||||
@@ -43,7 +44,7 @@ class EventForm(forms.ModelForm):
|
|||||||
return simplejson.dumps(items)
|
return simplejson.dumps(items)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(EventForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.fields['items_json'].initial = self._get_items_json
|
self.fields['items_json'].initial = self._get_items_json
|
||||||
self.fields['start_date'].widget.format = '%Y-%m-%d'
|
self.fields['start_date'].widget.format = '%Y-%m-%d'
|
||||||
@@ -96,10 +97,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(EventForm, self).clean()
|
return super().clean()
|
||||||
|
|
||||||
def save(self, commit=True):
|
def save(self, commit=True):
|
||||||
m = super(EventForm, self).save(commit=False)
|
m = super().save(commit=False)
|
||||||
|
|
||||||
if (commit):
|
if (commit):
|
||||||
m.save()
|
m.save()
|
||||||
@@ -120,7 +121,7 @@ class EventForm(forms.ModelForm):
|
|||||||
fields = ['is_rig', 'name', 'venue', 'start_time', 'end_date', 'start_date',
|
fields = ['is_rig', 'name', 'venue', 'start_time', 'end_date', 'start_date',
|
||||||
'end_time', 'meet_at', 'access_at', 'description', 'notes', 'mic',
|
'end_time', 'meet_at', 'access_at', 'description', 'notes', 'mic',
|
||||||
'person', 'organisation', 'dry_hire', 'checked_in_by', 'status',
|
'person', 'organisation', 'dry_hire', 'checked_in_by', 'status',
|
||||||
'purchase_order', 'collector']
|
'purchase_order', 'collector', 'forum_url']
|
||||||
|
|
||||||
|
|
||||||
class BaseClientEventAuthorisationForm(forms.ModelForm):
|
class BaseClientEventAuthorisationForm(forms.ModelForm):
|
||||||
@@ -130,7 +131,7 @@ class BaseClientEventAuthorisationForm(forms.ModelForm):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
if self.cleaned_data.get('amount') != self.instance.event.total:
|
if self.cleaned_data.get('amount') != self.instance.event.total:
|
||||||
self.add_error('amount', 'The amount authorised must equal the total for the event (inc VAT).')
|
self.add_error('amount', 'The amount authorised must equal the total for the event (inc VAT).')
|
||||||
return super(BaseClientEventAuthorisationForm, self).clean()
|
return super().clean()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
@@ -138,7 +139,7 @@ class BaseClientEventAuthorisationForm(forms.ModelForm):
|
|||||||
|
|
||||||
class InternalClientEventAuthorisationForm(BaseClientEventAuthorisationForm):
|
class InternalClientEventAuthorisationForm(BaseClientEventAuthorisationForm):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(InternalClientEventAuthorisationForm, self).__init__(**kwargs)
|
super().__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
|
||||||
|
|
||||||
@@ -152,8 +153,12 @@ class EventAuthorisationRequestForm(forms.Form):
|
|||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentForm(forms.ModelForm):
|
class EventRiskAssessmentForm(forms.ModelForm):
|
||||||
|
related_models = {
|
||||||
|
'power_mic': models.Profile,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(EventRiskAssessmentForm, self).__init__(*args, **kwargs)
|
super().__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()
|
||||||
@@ -164,14 +169,17 @@ class EventRiskAssessmentForm(forms.ModelForm):
|
|||||||
], attrs={'class': 'custom-control-input', 'required': 'true'})
|
], attrs={'class': 'custom-control-input', 'required': 'true'})
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
if self.cleaned_data.get('big_power'):
|
||||||
|
if not self.cleaned_data.get('power_mic').level_qualifications.filter(level__department=TrainingLevel.POWER).exists():
|
||||||
|
self.add_error('power_mic', forms.ValidationError("Your Power MIC must be a Power Technician.", code="power_tech_required"))
|
||||||
# Check expected values
|
# Check expected values
|
||||||
unexpected_values = []
|
unexpected_values = []
|
||||||
for field, value in models.RiskAssessment.expected_values.items():
|
for field, value in models.RiskAssessment.expected_values.items():
|
||||||
if self.cleaned_data.get(field) != value:
|
if self.cleaned_data.get(field) != value:
|
||||||
unexpected_values.append("<li>{}</li>".format(self._meta.model._meta.get_field(field).help_text))
|
unexpected_values.append(f"<li>{self._meta.model._meta.get_field(field).help_text}</li>")
|
||||||
if len(unexpected_values) > 0 and not self.cleaned_data.get('supervisor_consulted'):
|
if len(unexpected_values) > 0 and not self.cleaned_data.get('supervisor_consulted'):
|
||||||
raise forms.ValidationError("Your answers to these questions: <ul>{}</ul> require consulting with a supervisor.".format(''.join([str(elem) for elem in unexpected_values])), code='unusual_answers')
|
raise forms.ValidationError(f"Your answers to these questions: <ul>{''.join([str(elem) for elem in unexpected_values])}</ul> require consulting with a supervisor.", code='unusual_answers')
|
||||||
return super(EventRiskAssessmentForm, self).clean()
|
return super().clean()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.RiskAssessment
|
model = models.RiskAssessment
|
||||||
@@ -181,97 +189,55 @@ class EventRiskAssessmentForm(forms.ModelForm):
|
|||||||
|
|
||||||
class EventChecklistForm(forms.ModelForm):
|
class EventChecklistForm(forms.ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(EventChecklistForm, self).__init__(*args, **kwargs)
|
super().__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:
|
||||||
# Only display yes/no to user, the 'none' is only ever set in the background
|
# Only display yes/no to user, the 'none' is only ever set in the background
|
||||||
field.widget = forms.CheckboxInput()
|
field.widget = forms.CheckboxInput()
|
||||||
# Parsed from incoming form data by clean, then saved into models when the form is saved
|
|
||||||
items = {}
|
related_models = {
|
||||||
|
'venue': models.Venue,
|
||||||
|
}
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.EventChecklist
|
||||||
|
fields = '__all__'
|
||||||
|
exclude = ['reviewed_at', 'reviewed_by']
|
||||||
|
|
||||||
|
|
||||||
|
class PowerTestRecordForm(forms.ModelForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
for name, field in self.fields.items():
|
||||||
|
if field.__class__ == forms.NullBooleanField:
|
||||||
|
# Only display yes/no to user, the 'none' is only ever set in the background
|
||||||
|
field.widget = forms.CheckboxInput()
|
||||||
|
|
||||||
related_models = {
|
related_models = {
|
||||||
'venue': models.Venue,
|
'venue': models.Venue,
|
||||||
'power_mic': models.Profile,
|
'power_mic': models.Profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Two possible formats
|
|
||||||
def parsedatetime(self, date_string):
|
|
||||||
try:
|
|
||||||
return timezone.make_aware(datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S'))
|
|
||||||
except ValueError:
|
|
||||||
return timezone.make_aware(datetime.strptime(date_string, '%Y-%m-%dT%H:%M'))
|
|
||||||
|
|
||||||
# There's probably a thousand better ways to do this, but this one is mine
|
|
||||||
def clean(self):
|
|
||||||
vehicles = {key: val for key, val in self.data.items()
|
|
||||||
if key.startswith('vehicle')}
|
|
||||||
for key in vehicles:
|
|
||||||
pk = int(key.split('_')[1])
|
|
||||||
driver_key = 'driver_' + str(pk)
|
|
||||||
if(self.data[driver_key] == ''):
|
|
||||||
raise forms.ValidationError('Add a driver to vehicle ' + str(pk), code='vehicle_mismatch')
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
item = models.EventChecklistVehicle.objects.get(pk=pk)
|
|
||||||
except models.EventChecklistVehicle.DoesNotExist:
|
|
||||||
item = models.EventChecklistVehicle()
|
|
||||||
|
|
||||||
item.vehicle = vehicles['vehicle_' + str(pk)]
|
|
||||||
item.driver = models.Profile.objects.get(pk=self.data[driver_key])
|
|
||||||
item.full_clean('checklist')
|
|
||||||
|
|
||||||
# item does not have a database pk yet as it isn't saved
|
|
||||||
self.items['v' + str(pk)] = item
|
|
||||||
|
|
||||||
crewmembers = {key: val for key, val in self.data.items()
|
|
||||||
if key.startswith('crewmember')}
|
|
||||||
other_fields = ['start', 'role', 'end']
|
|
||||||
for key in crewmembers:
|
|
||||||
pk = int(key.split('_')[1])
|
|
||||||
|
|
||||||
for field in other_fields:
|
|
||||||
value = self.data['{}_{}'.format(field, pk)]
|
|
||||||
if value == '':
|
|
||||||
raise forms.ValidationError('Add a {} to crewmember {}'.format(field, pk), code='{}_mismatch'.format(field))
|
|
||||||
|
|
||||||
try:
|
|
||||||
item = models.EventChecklistCrew.objects.get(pk=pk)
|
|
||||||
except models.EventChecklistCrew.DoesNotExist:
|
|
||||||
item = models.EventChecklistCrew()
|
|
||||||
|
|
||||||
item.crewmember = models.Profile.objects.get(pk=self.data['crewmember_' + str(pk)])
|
|
||||||
item.start = self.parsedatetime(self.data['start_' + str(pk)])
|
|
||||||
item.role = self.data['role_' + str(pk)]
|
|
||||||
item.end = self.parsedatetime(self.data['end_' + str(pk)])
|
|
||||||
item.full_clean('checklist')
|
|
||||||
|
|
||||||
# item does not have a database pk yet as it isn't saved
|
|
||||||
self.items['c' + str(pk)] = item
|
|
||||||
|
|
||||||
return super(EventChecklistForm, self).clean()
|
|
||||||
|
|
||||||
def save(self, commit=True):
|
|
||||||
checklist = super(EventChecklistForm, self).save(commit=False)
|
|
||||||
if (commit):
|
|
||||||
# Remove all existing, to be recreated from the form
|
|
||||||
checklist.vehicles.all().delete()
|
|
||||||
checklist.crew.all().delete()
|
|
||||||
checklist.save()
|
|
||||||
|
|
||||||
for key in self.items:
|
|
||||||
item = self.items[key]
|
|
||||||
reversion.add_to_revision(item)
|
|
||||||
# finish and save new database items
|
|
||||||
item.checklist = checklist
|
|
||||||
item.full_clean()
|
|
||||||
item.save()
|
|
||||||
|
|
||||||
self.items.clear()
|
|
||||||
|
|
||||||
return checklist
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.EventChecklist
|
model = models.PowerTestRecord
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
exclude = ['reviewed_at', 'reviewed_by']
|
exclude = ['reviewed_at', 'reviewed_by']
|
||||||
|
|
||||||
|
|
||||||
|
class EventCheckInForm(forms.ModelForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['time'].initial = timezone.now()
|
||||||
|
self.fields['role'].initial = "Crew"
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.EventCheckIn
|
||||||
|
fields = '__all__'
|
||||||
|
exclude = ['end_time']
|
||||||
|
|
||||||
|
|
||||||
|
class EditCheckInForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = models.EventCheckIn
|
||||||
|
fields = '__all__'
|
||||||
|
|||||||
217
RIGS/hs.py
@@ -1,217 +0,0 @@
|
|||||||
from django.contrib import messages
|
|
||||||
from django.http import HttpResponseRedirect
|
|
||||||
from django.urls import reverse_lazy
|
|
||||||
from django.utils import timezone
|
|
||||||
from django.views import generic
|
|
||||||
from reversion import revisions as reversion
|
|
||||||
|
|
||||||
from RIGS import models, forms
|
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentCreate(generic.CreateView):
|
|
||||||
model = models.RiskAssessment
|
|
||||||
template_name = 'risk_assessment_form.html'
|
|
||||||
form_class = forms.EventRiskAssessmentForm
|
|
||||||
|
|
||||||
def get(self, *args, **kwargs):
|
|
||||||
epk = kwargs.get('pk')
|
|
||||||
event = models.Event.objects.get(pk=epk)
|
|
||||||
|
|
||||||
# Check if RA exists
|
|
||||||
ra = models.RiskAssessment.objects.filter(event=event).first()
|
|
||||||
|
|
||||||
if ra is not None:
|
|
||||||
return HttpResponseRedirect(reverse_lazy('ra_edit', kwargs={'pk': ra.pk}))
|
|
||||||
|
|
||||||
return super(EventRiskAssessmentCreate, self).get(self)
|
|
||||||
|
|
||||||
def get_form(self, **kwargs):
|
|
||||||
form = super(EventRiskAssessmentCreate, self).get_form(**kwargs)
|
|
||||||
epk = self.kwargs.get('pk')
|
|
||||||
event = models.Event.objects.get(pk=epk)
|
|
||||||
form.instance.event = event
|
|
||||||
return form
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(EventRiskAssessmentCreate, self).get_context_data(**kwargs)
|
|
||||||
epk = self.kwargs.get('pk')
|
|
||||||
event = models.Event.objects.get(pk=epk)
|
|
||||||
context['event'] = event
|
|
||||||
context['page_title'] = 'Create Risk Assessment for Event {}'.format(event.display_id)
|
|
||||||
return context
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
return reverse_lazy('ra_detail', kwargs={'pk': self.object.pk})
|
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentEdit(generic.UpdateView):
|
|
||||||
model = models.RiskAssessment
|
|
||||||
template_name = 'risk_assessment_form.html'
|
|
||||||
form_class = forms.EventRiskAssessmentForm
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
ra = self.get_object()
|
|
||||||
ra.reviewed_by = None
|
|
||||||
ra.reviewed_at = None
|
|
||||||
ra.save()
|
|
||||||
return reverse_lazy('ra_detail', kwargs={'pk': self.object.pk})
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(EventRiskAssessmentEdit, self).get_context_data(**kwargs)
|
|
||||||
rpk = self.kwargs.get('pk')
|
|
||||||
ra = models.RiskAssessment.objects.get(pk=rpk)
|
|
||||||
context['event'] = ra.event
|
|
||||||
context['edit'] = True
|
|
||||||
context['page_title'] = 'Edit Risk Assessment for Event {}'.format(ra.event.display_id)
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentDetail(generic.DetailView):
|
|
||||||
model = models.RiskAssessment
|
|
||||||
template_name = 'risk_assessment_detail.html'
|
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentList(generic.ListView):
|
|
||||||
paginate_by = 20
|
|
||||||
model = models.RiskAssessment
|
|
||||||
template_name = 'hs_object_list.html'
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(EventRiskAssessmentList, self).get_context_data(**kwargs)
|
|
||||||
context['title'] = 'Risk Assessment'
|
|
||||||
context['view'] = 'ra_detail'
|
|
||||||
context['edit'] = 'ra_edit'
|
|
||||||
context['review'] = 'ra_review'
|
|
||||||
context['perm'] = 'perms.RIGS.review_riskassessment'
|
|
||||||
context['fields'] = [n.name for n in list(self.model._meta.get_fields()) if n.name != 'reviewed_at' and n.name != 'reviewed_by' and not n.is_relation and not n.auto_created]
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class EventRiskAssessmentReview(generic.View):
|
|
||||||
def get(self, *args, **kwargs):
|
|
||||||
rpk = kwargs.get('pk')
|
|
||||||
ra = models.RiskAssessment.objects.get(pk=rpk)
|
|
||||||
with reversion.create_revision():
|
|
||||||
reversion.set_user(self.request.user)
|
|
||||||
ra.reviewed_by = self.request.user
|
|
||||||
ra.reviewed_at = timezone.now()
|
|
||||||
ra.save()
|
|
||||||
return HttpResponseRedirect(reverse_lazy('ra_list'))
|
|
||||||
|
|
||||||
|
|
||||||
class EventChecklistDetail(generic.DetailView):
|
|
||||||
model = models.EventChecklist
|
|
||||||
template_name = 'event_checklist_detail.html'
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(EventChecklistDetail, self).get_context_data(**kwargs)
|
|
||||||
context['page_title'] = "Event Checklist for Event {} {}".format(self.object.event.display_id, self.object.event.name)
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class EventChecklistEdit(generic.UpdateView):
|
|
||||||
model = models.EventChecklist
|
|
||||||
template_name = 'event_checklist_form.html'
|
|
||||||
form_class = forms.EventChecklistForm
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
ec = self.get_object()
|
|
||||||
ec.reviewed_by = None
|
|
||||||
ec.reviewed_at = None
|
|
||||||
ec.save()
|
|
||||||
return reverse_lazy('ec_detail', kwargs={'pk': self.object.pk})
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(EventChecklistEdit, self).get_context_data(**kwargs)
|
|
||||||
pk = self.kwargs.get('pk')
|
|
||||||
ec = models.EventChecklist.objects.get(pk=pk)
|
|
||||||
context['event'] = ec.event
|
|
||||||
context['edit'] = True
|
|
||||||
context['page_title'] = 'Edit Event Checklist for Event {}'.format(ec.event.display_id)
|
|
||||||
form = context['form']
|
|
||||||
# Get some other objects to include in the form. Used when there are errors but also nice and quick.
|
|
||||||
for field, model in form.related_models.items():
|
|
||||||
value = form[field].value()
|
|
||||||
if value is not None and value != '':
|
|
||||||
context[field] = model.objects.get(pk=value)
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class EventChecklistCreate(generic.CreateView):
|
|
||||||
model = models.EventChecklist
|
|
||||||
template_name = 'event_checklist_form.html'
|
|
||||||
form_class = forms.EventChecklistForm
|
|
||||||
|
|
||||||
# From both business logic and programming POVs, RAs must exist before ECs!
|
|
||||||
def get(self, *args, **kwargs):
|
|
||||||
epk = kwargs.get('pk')
|
|
||||||
event = models.Event.objects.get(pk=epk)
|
|
||||||
|
|
||||||
# Check if RA exists
|
|
||||||
ra = models.RiskAssessment.objects.filter(event=event).first()
|
|
||||||
|
|
||||||
if ra is None:
|
|
||||||
messages.error(self.request, 'A Risk Assessment must exist prior to creating any Event Checklists for {}! Please create one now.'.format(event))
|
|
||||||
return HttpResponseRedirect(reverse_lazy('event_ra', kwargs={'pk': epk}))
|
|
||||||
|
|
||||||
return super(EventChecklistCreate, self).get(self)
|
|
||||||
|
|
||||||
def get_form(self, **kwargs):
|
|
||||||
form = super(EventChecklistCreate, self).get_form(**kwargs)
|
|
||||||
epk = self.kwargs.get('pk')
|
|
||||||
event = models.Event.objects.get(pk=epk)
|
|
||||||
form.instance.event = event
|
|
||||||
return form
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(EventChecklistCreate, self).get_context_data(**kwargs)
|
|
||||||
epk = self.kwargs.get('pk')
|
|
||||||
event = models.Event.objects.get(pk=epk)
|
|
||||||
context['event'] = event
|
|
||||||
context['page_title'] = 'Create Event Checklist for Event {}'.format(event.display_id)
|
|
||||||
return context
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
return reverse_lazy('ec_detail', kwargs={'pk': self.object.pk})
|
|
||||||
|
|
||||||
|
|
||||||
class EventChecklistList(generic.ListView):
|
|
||||||
paginate_by = 20
|
|
||||||
model = models.EventChecklist
|
|
||||||
template_name = 'hs_object_list.html'
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(EventChecklistList, self).get_context_data(**kwargs)
|
|
||||||
context['title'] = 'Event Checklist'
|
|
||||||
context['view'] = 'ec_detail'
|
|
||||||
context['edit'] = 'ec_edit'
|
|
||||||
context['review'] = 'ec_review'
|
|
||||||
context['perm'] = 'perms.RIGS.review_eventchecklist'
|
|
||||||
context['fields'] = [n.name for n in list(self.model._meta.get_fields()) if n.name != 'reviewed_at' and n.name != 'reviewed_by' and not n.is_relation and not n.auto_created]
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class EventChecklistReview(generic.View):
|
|
||||||
def get(self, *args, **kwargs):
|
|
||||||
rpk = kwargs.get('pk')
|
|
||||||
ec = models.EventChecklist.objects.get(pk=rpk)
|
|
||||||
with reversion.create_revision():
|
|
||||||
reversion.set_user(self.request.user)
|
|
||||||
ec.reviewed_by = self.request.user
|
|
||||||
ec.reviewed_at = timezone.now()
|
|
||||||
ec.save()
|
|
||||||
return HttpResponseRedirect(reverse_lazy('ec_list'))
|
|
||||||
|
|
||||||
|
|
||||||
class HSList(generic.ListView):
|
|
||||||
paginate_by = 20
|
|
||||||
model = models.Event
|
|
||||||
template_name = 'hs_list.html'
|
|
||||||
|
|
||||||
def get_queryset(self):
|
|
||||||
return models.Event.objects.all().order_by('-start_date')
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(HSList, self).get_context_data(**kwargs)
|
|
||||||
context['page_title'] = 'H&S Overview'
|
|
||||||
return context
|
|
||||||
43
RIGS/management/commands/deleteSampleData.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
|
||||||
|
from django.contrib.auth.models import Group
|
||||||
|
from assets import models
|
||||||
|
from RIGS import models as rigsmodels
|
||||||
|
from training import models as tmodels
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Deletes testing sample data'
|
||||||
|
|
||||||
|
def handle(self, *args, **kwargs):
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
if not settings.DEBUG:
|
||||||
|
raise CommandError('You cannot run this command in production')
|
||||||
|
|
||||||
|
self.delete_objects(models.AssetCategory)
|
||||||
|
self.delete_objects(models.AssetStatus)
|
||||||
|
self.delete_objects(models.Supplier)
|
||||||
|
self.delete_objects(models.Connector)
|
||||||
|
self.delete_objects(models.Asset)
|
||||||
|
self.delete_objects(rigsmodels.VatRate)
|
||||||
|
self.delete_objects(rigsmodels.Profile)
|
||||||
|
self.delete_objects(rigsmodels.Person)
|
||||||
|
self.delete_objects(rigsmodels.Organisation)
|
||||||
|
self.delete_objects(rigsmodels.Venue)
|
||||||
|
self.delete_objects(Group)
|
||||||
|
self.delete_objects(rigsmodels.Event)
|
||||||
|
self.delete_objects(rigsmodels.EventItem)
|
||||||
|
self.delete_objects(rigsmodels.Invoice)
|
||||||
|
self.delete_objects(rigsmodels.Payment)
|
||||||
|
self.delete_objects(rigsmodels.RiskAssessment)
|
||||||
|
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):
|
||||||
|
for obj in model.objects.all():
|
||||||
|
obj.delete()
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
|
from RIGS import models
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'Adds sample data to use for testing'
|
help = 'Adds sample data to use for testing'
|
||||||
can_import_settings = True
|
can_import_settings = True
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
|
call_command('generateSampleUserData')
|
||||||
call_command('generateSampleRIGSData')
|
call_command('generateSampleRIGSData')
|
||||||
call_command('generateSampleAssetsData')
|
call_command('generateSampleAssetsData')
|
||||||
|
call_command('generateSampleTrainingData')
|
||||||
|
|||||||
@@ -17,13 +17,11 @@ class Command(BaseCommand):
|
|||||||
people = []
|
people = []
|
||||||
organisations = []
|
organisations = []
|
||||||
venues = []
|
venues = []
|
||||||
profiles = []
|
events = []
|
||||||
|
profiles = models.Profile.objects.all()
|
||||||
keyholder_group = None
|
|
||||||
finance_group = None
|
|
||||||
hs_group = None
|
|
||||||
|
|
||||||
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):
|
||||||
@@ -34,20 +32,13 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
models.VatRate.objects.create(start_at='2014-03-05', rate=0.20, comment='test1')
|
models.VatRate.objects.create(start_at='2014-03-05', rate=0.20, comment='test1')
|
||||||
|
self.setup_people()
|
||||||
|
self.setup_organisations()
|
||||||
|
self.setup_venues()
|
||||||
|
self.setup_events()
|
||||||
|
print("Done generating rigboard data")
|
||||||
|
|
||||||
self.setupGenericProfiles()
|
def setup_people(self):
|
||||||
|
|
||||||
self.setupPeople()
|
|
||||||
self.setupOrganisations()
|
|
||||||
self.setupVenues()
|
|
||||||
|
|
||||||
self.setupGroups()
|
|
||||||
|
|
||||||
self.setupEvents()
|
|
||||||
|
|
||||||
self.setupUsefulProfiles()
|
|
||||||
|
|
||||||
def setupPeople(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",
|
||||||
"Bartemius Crouch", "Fleur Delacour", "Cedric Diggory", "Alberforth Dumbledore", "Albus Dumbledore",
|
"Bartemius Crouch", "Fleur Delacour", "Cedric Diggory", "Alberforth Dumbledore", "Albus Dumbledore",
|
||||||
"Dudley Dursley", "Petunia Dursley", "Vernon Dursley", "Argus Filch", "Seamus Finnigan",
|
"Dudley Dursley", "Petunia Dursley", "Vernon Dursley", "Argus Filch", "Seamus Finnigan",
|
||||||
@@ -62,25 +53,25 @@ class Command(BaseCommand):
|
|||||||
"Ron Weasley", "Dobby", "Fluffy", "Hedwig", "Moaning Myrtle", "Aragog", "Grawp"] # noqa
|
"Ron Weasley", "Dobby", "Fluffy", "Hedwig", "Moaning Myrtle", "Aragog", "Grawp"] # noqa
|
||||||
for i, name in enumerate(names):
|
for i, name in enumerate(names):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
reversion.set_user(random.choice(self.profiles))
|
reversion.set_user(random.choice(models.Profile.objects.all()))
|
||||||
|
person = models.Person.objects.create(name=name)
|
||||||
|
|
||||||
newPerson = models.Person.objects.create(name=name)
|
|
||||||
if i % 3 == 0:
|
if i % 3 == 0:
|
||||||
newPerson.email = "address@person.com"
|
person.email = "address@person.com"
|
||||||
|
|
||||||
if i % 5 == 0:
|
if i % 5 == 0:
|
||||||
newPerson.notes = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
|
person.notes = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
|
||||||
|
|
||||||
if i % 7 == 0:
|
if i % 7 == 0:
|
||||||
newPerson.address = "1 Person Test Street \n Demoton \n United States of TEC \n RMRF 567"
|
person.address = "1 Person Test Street \n Demoton \n United States of TEC \n RMRF 567"
|
||||||
|
|
||||||
if i % 9 == 0:
|
if i % 9 == 0:
|
||||||
newPerson.phone = "01234 567894"
|
person.phone = "01234 567894"
|
||||||
|
|
||||||
newPerson.save()
|
person.save()
|
||||||
self.people.append(newPerson)
|
self.people.append(person)
|
||||||
|
|
||||||
def setupOrganisations(self):
|
def setup_organisations(self):
|
||||||
names = ["Acme, inc.", "Widget Corp", "123 Warehousing", "Demo Company", "Smith and Co.", "Foo Bars",
|
names = ["Acme, inc.", "Widget Corp", "123 Warehousing", "Demo Company", "Smith and Co.", "Foo Bars",
|
||||||
"ABC Telecom", "Fake Brothers", "QWERTY Logistics", "Demo, inc.", "Sample Company", "Sample, inc",
|
"ABC Telecom", "Fake Brothers", "QWERTY Logistics", "Demo, inc.", "Sample Company", "Sample, inc",
|
||||||
"Acme Corp", "Allied Biscuit", "Ankh-Sto Associates", "Extensive Enterprise", "Galaxy Corp",
|
"Acme Corp", "Allied Biscuit", "Ankh-Sto Associates", "Extensive Enterprise", "Galaxy Corp",
|
||||||
@@ -109,27 +100,28 @@ class Command(BaseCommand):
|
|||||||
"Tip Top Cafe", "Moes Tavern", "Central Perk", "Chasers"] # noqa
|
"Tip Top Cafe", "Moes Tavern", "Central Perk", "Chasers"] # noqa
|
||||||
for i, name in enumerate(names):
|
for i, name in enumerate(names):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
reversion.set_user(random.choice(self.profiles))
|
reversion.set_user(random.choice(models.Profile.objects.all()))
|
||||||
newOrganisation = models.Organisation.objects.create(name=name)
|
new_organisation = models.Organisation.objects.create(name=name)
|
||||||
|
|
||||||
if i % 2 == 0:
|
if i % 2 == 0:
|
||||||
newOrganisation.has_su_account = True
|
new_organisation.has_su_account = True
|
||||||
|
|
||||||
if i % 3 == 0:
|
if i % 3 == 0:
|
||||||
newOrganisation.email = "address@organisation.com"
|
new_organisation.email = "address@organisation.com"
|
||||||
|
|
||||||
if i % 5 == 0:
|
if i % 5 == 0:
|
||||||
newOrganisation.notes = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
|
new_organisation.notes = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
|
||||||
|
|
||||||
if i % 7 == 0:
|
if i % 7 == 0:
|
||||||
newOrganisation.address = "1 Organisation Test Street \n Demoton \n United States of TEC \n RMRF 567"
|
new_organisation.address = "1 Organisation Test Street \n Demoton \n United States of TEC \n RMRF 567"
|
||||||
|
|
||||||
if i % 9 == 0:
|
if i % 9 == 0:
|
||||||
newOrganisation.phone = "01234 567894"
|
new_organisation.phone = "01234 567894"
|
||||||
|
|
||||||
newOrganisation.save()
|
new_organisation.save()
|
||||||
self.organisations.append(newOrganisation)
|
self.organisations.append(new_organisation)
|
||||||
|
|
||||||
def setupVenues(self):
|
def setup_venues(self):
|
||||||
names = ["Bear Island", "Crossroads Inn", "Deepwood Motte", "The Dreadfort", "The Eyrie", "Greywater Watch",
|
names = ["Bear Island", "Crossroads Inn", "Deepwood Motte", "The Dreadfort", "The Eyrie", "Greywater Watch",
|
||||||
"The Iron Islands", "Karhold", "Moat Cailin", "Oldstones", "Raventree Hall", "Riverlands",
|
"The Iron Islands", "Karhold", "Moat Cailin", "Oldstones", "Raventree Hall", "Riverlands",
|
||||||
"The Ruby Ford", "Saltpans", "Seagard", "Torrhen's Square", "The Trident", "The Twins",
|
"The Ruby Ford", "Saltpans", "Seagard", "Torrhen's Square", "The Trident", "The Twins",
|
||||||
@@ -145,108 +137,27 @@ class Command(BaseCommand):
|
|||||||
for i, name in enumerate(names):
|
for i, name in enumerate(names):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
reversion.set_user(random.choice(self.profiles))
|
reversion.set_user(random.choice(self.profiles))
|
||||||
newVenue = models.Venue.objects.create(name=name)
|
new_venue = models.Venue.objects.create(name=name)
|
||||||
|
|
||||||
if i % 2 == 0:
|
if i % 2 == 0:
|
||||||
newVenue.three_phase_available = True
|
new_venue.three_phase_available = True
|
||||||
|
|
||||||
if i % 3 == 0:
|
if i % 3 == 0:
|
||||||
newVenue.email = "address@venue.com"
|
new_venue.email = "address@venue.com"
|
||||||
|
|
||||||
if i % 5 == 0:
|
if i % 5 == 0:
|
||||||
newVenue.notes = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
|
new_venue.notes = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
|
||||||
|
|
||||||
if i % 7 == 0:
|
if i % 7 == 0:
|
||||||
newVenue.address = "1 Venue Test Street \n Demoton \n United States of TEC \n RMRF 567"
|
new_venue.address = "1 Venue Test Street \n Demoton \n United States of TEC \n RMRF 567"
|
||||||
|
|
||||||
if i % 9 == 0:
|
if i % 9 == 0:
|
||||||
newVenue.phone = "01234 567894"
|
new_venue.phone = "01234 567894"
|
||||||
|
|
||||||
newVenue.save()
|
new_venue.save()
|
||||||
self.venues.append(newVenue)
|
self.venues.append(new_venue)
|
||||||
|
|
||||||
def setupGroups(self):
|
def setup_events(self):
|
||||||
self.keyholder_group = Group.objects.create(name='Keyholders')
|
|
||||||
self.finance_group = Group.objects.create(name='Finance')
|
|
||||||
self.hs_group = Group.objects.create(name='H&S')
|
|
||||||
|
|
||||||
keyholderPerms = ["add_event", "change_event", "view_event",
|
|
||||||
"add_eventitem", "change_eventitem", "delete_eventitem",
|
|
||||||
"add_organisation", "change_organisation", "view_organisation",
|
|
||||||
"add_person", "change_person", "view_person", "view_profile",
|
|
||||||
"add_venue", "change_venue", "view_venue",
|
|
||||||
"add_asset", "change_asset", "delete_asset",
|
|
||||||
"view_asset", "view_supplier", "change_supplier", "asset_finance",
|
|
||||||
"add_supplier", "view_cabletype", "change_cabletype",
|
|
||||||
"add_cabletype", "view_eventchecklist", "change_eventchecklist",
|
|
||||||
"add_eventchecklist", "view_riskassessment", "change_riskassessment",
|
|
||||||
"add_riskassessment", "add_eventchecklistcrew", "change_eventchecklistcrew",
|
|
||||||
"delete_eventchecklistcrew", "view_eventchecklistcrew", "add_eventchecklistvehicle",
|
|
||||||
"change_eventchecklistvehicle",
|
|
||||||
"delete_eventchecklistvehicle", "view_eventchecklistvehicle", ]
|
|
||||||
financePerms = keyholderPerms + ["add_invoice", "change_invoice", "view_invoice",
|
|
||||||
"add_payment", "change_payment", "delete_payment"]
|
|
||||||
hsPerms = keyholderPerms + ["review_riskassessment", "review_eventchecklist"]
|
|
||||||
|
|
||||||
for permId in keyholderPerms:
|
|
||||||
self.keyholder_group.permissions.add(Permission.objects.get(codename=permId))
|
|
||||||
|
|
||||||
for permId in financePerms:
|
|
||||||
self.finance_group.permissions.add(Permission.objects.get(codename=permId))
|
|
||||||
|
|
||||||
for permId in hsPerms:
|
|
||||||
self.hs_group.permissions.add(Permission.objects.get(codename=permId))
|
|
||||||
|
|
||||||
def setupGenericProfiles(self):
|
|
||||||
names = ["Clara Oswin Oswald", "Rory Williams", "Amy Pond", "River Song", "Martha Jones", "Donna Noble",
|
|
||||||
"Jack Harkness", "Mickey Smith", "Rose Tyler"]
|
|
||||||
for i, name in enumerate(names):
|
|
||||||
newProfile = models.Profile.objects.create(username=name.replace(" ", ""), first_name=name.split(" ")[0],
|
|
||||||
last_name=name.split(" ")[-1],
|
|
||||||
email=name.replace(" ", "") + "@example.com",
|
|
||||||
initials="".join([j[0].upper() for j in name.split()]))
|
|
||||||
if i % 2 == 0:
|
|
||||||
newProfile.phone = "01234 567894"
|
|
||||||
|
|
||||||
newProfile.save()
|
|
||||||
self.profiles.append(newProfile)
|
|
||||||
|
|
||||||
def setupUsefulProfiles(self):
|
|
||||||
superUser = models.Profile.objects.create(username="superuser", first_name="Super", last_name="User",
|
|
||||||
initials="SU",
|
|
||||||
email="superuser@example.com", is_superuser=True, is_active=True,
|
|
||||||
is_staff=True)
|
|
||||||
superUser.set_password('superuser')
|
|
||||||
superUser.save()
|
|
||||||
|
|
||||||
financeUser = models.Profile.objects.create(username="finance", first_name="Finance", last_name="User",
|
|
||||||
initials="FU",
|
|
||||||
email="financeuser@example.com", is_active=True, is_approved=True)
|
|
||||||
financeUser.groups.add(self.finance_group)
|
|
||||||
financeUser.groups.add(self.keyholder_group)
|
|
||||||
financeUser.set_password('finance')
|
|
||||||
financeUser.save()
|
|
||||||
|
|
||||||
hsUser = models.Profile.objects.create(username="hs", first_name="HS", last_name="User",
|
|
||||||
initials="HSU",
|
|
||||||
email="hsuser@example.com", is_active=True, is_approved=True)
|
|
||||||
hsUser.groups.add(self.hs_group)
|
|
||||||
hsUser.groups.add(self.keyholder_group)
|
|
||||||
hsUser.set_password('hs')
|
|
||||||
hsUser.save()
|
|
||||||
|
|
||||||
keyholderUser = models.Profile.objects.create(username="keyholder", first_name="Keyholder", last_name="User",
|
|
||||||
initials="KU",
|
|
||||||
email="keyholderuser@example.com", is_active=True, is_approved=True)
|
|
||||||
keyholderUser.groups.add(self.keyholder_group)
|
|
||||||
keyholderUser.set_password('keyholder')
|
|
||||||
keyholderUser.save()
|
|
||||||
|
|
||||||
basicUser = models.Profile.objects.create(username="basic", first_name="Basic", last_name="User", initials="BU",
|
|
||||||
email="basicuser@example.com", is_active=True, is_approved=True)
|
|
||||||
basicUser.set_password('basic')
|
|
||||||
basicUser.save()
|
|
||||||
|
|
||||||
def setupEvents(self):
|
|
||||||
names = ["Outdoor Concert", "Hall Open Mic Night", "Festival", "Weekend Event", "Magic Show", "Society Ball",
|
names = ["Outdoor Concert", "Hall Open Mic Night", "Festival", "Weekend Event", "Magic Show", "Society Ball",
|
||||||
"Evening Show", "Talent Show", "Acoustic Evening", "Hire of Things", "SU Event",
|
"Evening Show", "Talent Show", "Acoustic Evening", "Hire of Things", "SU Event",
|
||||||
"End of Term Show", "Theatre Show", "Outdoor Fun Day", "Summer Carnival", "Open Days", "Magic Show",
|
"End of Term Show", "Theatre Show", "Outdoor Fun Day", "Summer Carnival", "Open Days", "Magic Show",
|
||||||
@@ -257,7 +168,7 @@ class Command(BaseCommand):
|
|||||||
notes = ["The client came into the office at some point", "Who knows if this will happen",
|
notes = ["The client came into the office at some point", "Who knows if this will happen",
|
||||||
"Probably should check this event", "Maybe not happening", "Run away!"]
|
"Probably should check this event", "Maybe not happening", "Run away!"]
|
||||||
|
|
||||||
itemOptions = [
|
item_options = [
|
||||||
{'name': 'Speakers', 'description': 'Some really really big speakers \n these are very loud', 'quantity': 2,
|
{'name': 'Speakers', 'description': 'Some really really big speakers \n these are very loud', 'quantity': 2,
|
||||||
'cost': 200.00},
|
'cost': 200.00},
|
||||||
{'name': 'Projector',
|
{'name': 'Projector',
|
||||||
@@ -274,7 +185,7 @@ class Command(BaseCommand):
|
|||||||
{'name': 'Crew', 'description': 'Costs nothing, because reasons', 'quantity': 1, 'cost': 0.00},
|
{'name': 'Crew', 'description': 'Costs nothing, because reasons', 'quantity': 1, 'cost': 0.00},
|
||||||
{'name': 'Loyalty Discount', 'description': 'Have some negative moneys', 'quantity': 1, 'cost': -50.00}]
|
{'name': 'Loyalty Discount', 'description': 'Have some negative moneys', 'quantity': 1, 'cost': -50.00}]
|
||||||
|
|
||||||
dayDelta = -120 # start adding events from 4 months ago
|
day_delta = -120 # start adding events from 4 months ago
|
||||||
|
|
||||||
for i in range(150): # Let's add 100 events
|
for i in range(150): # Let's add 100 events
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
@@ -282,70 +193,71 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
name = names[i % len(names)]
|
name = names[i % len(names)]
|
||||||
|
|
||||||
startDate = datetime.date.today() + datetime.timedelta(days=dayDelta)
|
start_date = datetime.date.today() + datetime.timedelta(days=day_delta)
|
||||||
dayDelta = dayDelta + random.randint(0, 3)
|
day_delta = day_delta + random.randint(0, 3)
|
||||||
|
|
||||||
newEvent = models.Event.objects.create(name=name, start_date=startDate)
|
new_event = models.Event.objects.create(name=name, start_date=start_date)
|
||||||
|
|
||||||
if random.randint(0, 2) > 1: # 1 in 3 have a start time
|
if random.randint(0, 2) > 1: # 1 in 3 have a start time
|
||||||
newEvent.start_time = datetime.time(random.randint(15, 20))
|
new_event.start_time = datetime.time(random.randint(15, 20))
|
||||||
if random.randint(0, 2) > 1: # of those, 1 in 3 have an end time on the same day
|
if random.randint(0, 2) > 1: # of those, 1 in 3 have an end time on the same day
|
||||||
newEvent.end_time = datetime.time(random.randint(21, 23))
|
new_event.end_time = datetime.time(random.randint(21, 23))
|
||||||
elif random.randint(0, 1) > 0: # half of the others finish early the next day
|
elif random.randint(0, 1) > 0: # half of the others finish early the next day
|
||||||
newEvent.end_date = newEvent.start_date + datetime.timedelta(days=1)
|
new_event.end_date = new_event.start_date + datetime.timedelta(days=1)
|
||||||
newEvent.end_time = datetime.time(random.randint(0, 5))
|
new_event.end_time = datetime.time(random.randint(0, 5))
|
||||||
elif random.randint(0, 2) > 1: # 1 in 3 of the others finish a few days ahead
|
elif random.randint(0, 2) > 1: # 1 in 3 of the others finish a few days ahead
|
||||||
newEvent.end_date = newEvent.start_date + datetime.timedelta(days=random.randint(1, 4))
|
new_event.end_date = new_event.start_date + datetime.timedelta(days=random.randint(1, 4))
|
||||||
|
|
||||||
if random.randint(0, 6) > 0: # 5 in 6 have MIC
|
if random.randint(0, 6) > 0: # 5 in 6 have MIC
|
||||||
newEvent.mic = random.choice(self.profiles)
|
new_event.mic = random.choice(self.profiles)
|
||||||
|
|
||||||
if random.randint(0, 6) > 0: # 5 in 6 have organisation
|
if random.randint(0, 6) > 0: # 5 in 6 have organisation
|
||||||
newEvent.organisation = random.choice(self.organisations)
|
new_event.organisation = random.choice(self.organisations)
|
||||||
|
|
||||||
if random.randint(0, 6) > 0: # 5 in 6 have person
|
if random.randint(0, 6) > 0: # 5 in 6 have person
|
||||||
newEvent.person = random.choice(self.people)
|
new_event.person = random.choice(self.people)
|
||||||
|
|
||||||
if random.randint(0, 6) > 0: # 5 in 6 have venue
|
if random.randint(0, 6) > 0: # 5 in 6 have venue
|
||||||
newEvent.venue = random.choice(self.venues)
|
new_event.venue = random.choice(self.venues)
|
||||||
|
|
||||||
# Could have any status, equally weighted
|
# Could have any status, equally weighted
|
||||||
newEvent.status = random.choice(
|
new_event.status = random.choice(
|
||||||
[models.Event.BOOKED, models.Event.CONFIRMED, models.Event.PROVISIONAL, models.Event.CANCELLED])
|
[models.Event.BOOKED, models.Event.CONFIRMED, models.Event.PROVISIONAL, models.Event.CANCELLED])
|
||||||
|
|
||||||
newEvent.dry_hire = (random.randint(0, 7) == 0) # 1 in 7 are dry hire
|
new_event.dry_hire = (random.randint(0, 7) == 0) # 1 in 7 are dry hire
|
||||||
|
|
||||||
if random.randint(0, 1) > 0: # 1 in 2 have description
|
if random.randint(0, 1) > 0: # 1 in 2 have description
|
||||||
newEvent.description = random.choice(descriptions)
|
new_event.description = random.choice(descriptions)
|
||||||
|
|
||||||
if random.randint(0, 1) > 0: # 1 in 2 have notes
|
if random.randint(0, 1) > 0: # 1 in 2 have notes
|
||||||
newEvent.notes = random.choice(notes)
|
new_event.notes = random.choice(notes)
|
||||||
|
|
||||||
newEvent.save()
|
new_event.save()
|
||||||
|
|
||||||
# Now add some items
|
# Now add some items
|
||||||
for j in range(random.randint(1, 5)):
|
for j in range(random.randint(1, 5)):
|
||||||
itemData = itemOptions[random.randint(0, len(itemOptions) - 1)]
|
item_data = item_options[random.randint(0, len(item_options) - 1)]
|
||||||
newItem = models.EventItem.objects.create(event=newEvent, order=j, **itemData)
|
new_item = models.EventItem.objects.create(event=new_event, order=j, **item_data)
|
||||||
newItem.save()
|
new_item.save()
|
||||||
|
|
||||||
while newEvent.sum_total < 0:
|
while new_event.sum_total < 0:
|
||||||
itemData = itemOptions[random.randint(0, len(itemOptions) - 1)]
|
item_data = item_options[random.randint(0, len(item_options) - 1)]
|
||||||
newItem = models.EventItem.objects.create(event=newEvent, order=j, **itemData)
|
new_item = models.EventItem.objects.create(event=new_event, order=j, **item_data)
|
||||||
newItem.save()
|
new_item.save()
|
||||||
|
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
reversion.set_user(random.choice(self.profiles))
|
reversion.set_user(random.choice(self.profiles))
|
||||||
if newEvent.start_date < datetime.date.today(): # think about adding an invoice
|
if new_event.start_date < datetime.date.today(): # think about adding an invoice
|
||||||
if random.randint(0, 2) > 0: # 2 in 3 have had paperwork sent to treasury
|
if random.randint(0, 2) > 0: # 2 in 3 have had paperwork sent to treasury
|
||||||
newInvoice = models.Invoice.objects.create(event=newEvent)
|
new_invoice = models.Invoice.objects.create(event=new_event)
|
||||||
if newEvent.status is models.Event.CANCELLED: # void cancelled events
|
if new_event.status is models.Event.CANCELLED: # void cancelled events
|
||||||
newInvoice.void = True
|
new_invoice.void = True
|
||||||
elif random.randint(0, 2) > 1: # 1 in 3 have been paid
|
elif random.randint(0, 2) > 1: # 1 in 3 have been paid
|
||||||
models.Payment.objects.create(invoice=newInvoice, amount=newInvoice.balance,
|
models.Payment.objects.create(invoice=new_invoice, amount=new_invoice.balance,
|
||||||
date=datetime.date.today())
|
date=datetime.date.today())
|
||||||
if i == 1 or random.randint(0, 5) > 0: # Event 1 and 1 in 5 have a RA
|
if i == 1 or random.randint(0, 5) > 0: # Event 1 and 1 in 5 have a RA
|
||||||
models.RiskAssessment.objects.create(event=newEvent, supervisor_consulted=bool(random.getrandbits(1)), nonstandard_equipment=bool(random.getrandbits(1)),
|
models.RiskAssessment.objects.create(event=new_event, supervisor_consulted=bool(random.getrandbits(1)),
|
||||||
|
nonstandard_equipment=bool(random.getrandbits(1)),
|
||||||
nonstandard_use=bool(random.getrandbits(1)),
|
nonstandard_use=bool(random.getrandbits(1)),
|
||||||
contractors=bool(random.getrandbits(1)),
|
contractors=bool(random.getrandbits(1)),
|
||||||
other_companies=bool(random.getrandbits(1)),
|
other_companies=bool(random.getrandbits(1)),
|
||||||
@@ -366,8 +278,13 @@ class Command(BaseCommand):
|
|||||||
suspended_structures=bool(random.getrandbits(1)),
|
suspended_structures=bool(random.getrandbits(1)),
|
||||||
outside=bool(random.getrandbits(1)))
|
outside=bool(random.getrandbits(1)))
|
||||||
if i == 0 or random.randint(0, 1) > 0: # Event 1 and 1 in 10 have a Checklist
|
if i == 0 or random.randint(0, 1) > 0: # Event 1 and 1 in 10 have a Checklist
|
||||||
models.EventChecklist.objects.create(event=newEvent, power_mic=random.choice(self.profiles), safe_parking=bool(random.getrandbits(1)),
|
models.EventChecklist.objects.create(event=new_event,
|
||||||
safe_packing=bool(random.getrandbits(1)), exits=bool(random.getrandbits(1)), trip_hazard=bool(random.getrandbits(1)), warning_signs=bool(random.getrandbits(1)),
|
safe_parking=bool(random.getrandbits(1)),
|
||||||
ear_plugs=bool(random.getrandbits(1)), hs_location="Locked away safely",
|
safe_packing=bool(random.getrandbits(1)),
|
||||||
extinguishers_location="Somewhere, I forgot", earthing=bool(random.getrandbits(1)), pat=bool(random.getrandbits(1)),
|
exits=bool(random.getrandbits(1)),
|
||||||
|
trip_hazard=bool(random.getrandbits(1)),
|
||||||
|
warning_signs=bool(random.getrandbits(1)),
|
||||||
|
ear_plugs=bool(random.getrandbits(1)),
|
||||||
|
hs_location="Locked away safely",
|
||||||
|
extinguishers_location="Somewhere, I forgot",
|
||||||
date=timezone.now(), venue=random.choice(self.venues))
|
date=timezone.now(), venue=random.choice(self.venues))
|
||||||
|
|||||||
38
RIGS/management/commands/send_reminders.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import premailer
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from django.template.loader import get_template
|
||||||
|
from django.contrib.staticfiles import finders
|
||||||
|
from django.conf import settings
|
||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
from django.core.mail import EmailMultiAlternatives
|
||||||
|
from django.utils import timezone
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
from RIGS import models
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Sends email reminders as required. Triggered daily through heroku-scheduler in production.'
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
events = models.Event.objects.current_events().select_related('riskassessment')
|
||||||
|
for event in events:
|
||||||
|
earliest_time = event.earliest_time if isinstance(event.earliest_time, datetime.datetime) else timezone.make_aware(datetime.datetime.combine(event.earliest_time, datetime.time(00, 00)))
|
||||||
|
# 48 hours = 172800 seconds
|
||||||
|
if event.is_rig and not event.cancelled and not event.dry_hire and (earliest_time - timezone.now()).total_seconds() <= 172800 and not hasattr(event, 'riskassessment'):
|
||||||
|
context = {
|
||||||
|
"event": event,
|
||||||
|
"url": "https://" + settings.DOMAIN + reverse('event_ra', kwargs={'pk': event.pk})
|
||||||
|
}
|
||||||
|
target = event.mic.email if event.mic else f"productions@{settings.DOMAIN}"
|
||||||
|
msg = EmailMultiAlternatives(
|
||||||
|
f"{event} - Risk Assessment Incomplete",
|
||||||
|
get_template("email/ra_reminder.txt").render(context),
|
||||||
|
to=[target],
|
||||||
|
reply_to=[f"h.s.manager@{settings.DOMAIN}"],
|
||||||
|
)
|
||||||
|
css = finders.find('css/email.css')
|
||||||
|
html = premailer.Premailer(get_template("email/ra_reminder.html").render(context), external_styles=css).transform()
|
||||||
|
msg.attach_alternative(html, 'text/html')
|
||||||
|
msg.send()
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
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):
|
||||||
@@ -25,6 +26,6 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
bases=(models.Model, RIGS.models.RevisionMixin),
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
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):
|
||||||
@@ -21,6 +22,6 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
bases=(models.Model, RIGS.models.RevisionMixin),
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
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):
|
||||||
@@ -41,7 +42,7 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
bases=(models.Model, RIGS.models.RevisionMixin),
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='EventItem',
|
name='EventItem',
|
||||||
@@ -70,7 +71,7 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
bases=(models.Model, RIGS.models.RevisionMixin),
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Generated by Django 2.0.13 on 2020-01-11 18:29
|
# Generated by Django 2.0.13 on 2020-01-11 18:29
|
||||||
# This migration ensures that legacy Profiles from before approvals were implemented are automatically approved
|
# This migration ensures that legacy Profiles from before approvals were implemented are automatically approved
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
def approve_legacy(apps, schema_editor):
|
def approve_legacy(apps, schema_editor):
|
||||||
@@ -15,5 +15,5 @@ class Migration(migrations.Migration):
|
|||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(approve_legacy)
|
migrations.RunPython(approve_legacy, migrations.RunPython.noop)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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):
|
||||||
@@ -58,7 +59,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, RIGS.models.RevisionMixin),
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='EventChecklistCrew',
|
name='EventChecklistCrew',
|
||||||
@@ -69,7 +70,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, RIGS.models.RevisionMixin),
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='EventChecklistVehicle',
|
name='EventChecklistVehicle',
|
||||||
@@ -78,7 +79,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, RIGS.models.RevisionMixin),
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='RiskAssessment',
|
name='RiskAssessment',
|
||||||
@@ -117,7 +118,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, RIGS.models.RevisionMixin),
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
),
|
),
|
||||||
migrations.RemoveField(
|
migrations.RemoveField(
|
||||||
model_name='eventcrew',
|
model_name='eventcrew',
|
||||||
|
|||||||
67
RIGS/migrations/0040_auto_20210302_1148.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# 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)
|
||||||
|
]
|
||||||
201
RIGS/migrations/0041_auto_20210302_1204.py
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
# Generated by Django 3.1.7 on 2021-03-02 12:04
|
||||||
|
|
||||||
|
import RIGS.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0040_auto_20210302_1148'),
|
||||||
|
]
|
||||||
|
|
||||||
|
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(
|
||||||
|
model_name='event',
|
||||||
|
name='auth_request_to',
|
||||||
|
field=models.EmailField(blank=True, default='', max_length=254),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='collector',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=255, verbose_name='collected by'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='notes',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='purchase_order',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=255, verbose_name='PO'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventauthorisation',
|
||||||
|
name='account_code',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=50),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventauthorisation',
|
||||||
|
name='uni_id',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=10, verbose_name='University ID'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='extinguishers_location',
|
||||||
|
field=models.CharField(blank=True, default='', help_text='Location of fire extinguishers', max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='hs_location',
|
||||||
|
field=models.CharField(blank=True, default='', help_text='Location of Safety Bag/Box', max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w1_description',
|
||||||
|
field=models.CharField(blank=True, default='', help_text='Description', max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w2_description',
|
||||||
|
field=models.CharField(blank=True, default='', help_text='Description', max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w3_description',
|
||||||
|
field=models.CharField(blank=True, default='', help_text='Description', max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventitem',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='organisation',
|
||||||
|
name='address',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='organisation',
|
||||||
|
name='email',
|
||||||
|
field=models.EmailField(blank=True, default='', max_length=254),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='organisation',
|
||||||
|
name='notes',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='organisation',
|
||||||
|
name='phone',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=15),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='payment',
|
||||||
|
name='method',
|
||||||
|
field=models.CharField(blank=True, choices=[('C', 'Cash'), ('I', 'Internal'), ('E', 'External'), ('SU', 'SU Core'), ('T', 'TEC Adjustment')], default='', max_length=2),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='person',
|
||||||
|
name='address',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='person',
|
||||||
|
name='email',
|
||||||
|
field=models.EmailField(blank=True, default='', max_length=254),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='person',
|
||||||
|
name='notes',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='person',
|
||||||
|
name='phone',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=15),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='profile',
|
||||||
|
name='api_key',
|
||||||
|
field=models.CharField(blank=True, default='', editable=False, max_length=40),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='profile',
|
||||||
|
name='phone',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=13),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='riskassessment',
|
||||||
|
name='general_notes',
|
||||||
|
field=models.TextField(blank=True, default='', help_text='Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='riskassessment',
|
||||||
|
name='persons_responsible_structures',
|
||||||
|
field=models.TextField(blank=True, default='', help_text='Who are the persons on site responsible for their use?'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='riskassessment',
|
||||||
|
name='power_notes',
|
||||||
|
field=models.TextField(blank=True, default='', help_text='Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='riskassessment',
|
||||||
|
name='power_plan',
|
||||||
|
field=models.URLField(blank=True, default='', help_text="Upload your power plan to the <a href='https://nottinghamtec.sharepoint.com/'>Sharepoint</a> and submit a link", validators=[RIGS.models.validate_url]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='riskassessment',
|
||||||
|
name='rigging_plan',
|
||||||
|
field=models.URLField(blank=True, default='', help_text="Upload your rigging plan to the <a href='https://nottinghamtec.sharepoint.com/'>Sharepoint</a> and submit a link", validators=[RIGS.models.validate_url]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='riskassessment',
|
||||||
|
name='sound_notes',
|
||||||
|
field=models.TextField(blank=True, default='', help_text='Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='venue',
|
||||||
|
name='address',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='venue',
|
||||||
|
name='email',
|
||||||
|
field=models.EmailField(blank=True, default='', max_length=254),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='venue',
|
||||||
|
name='notes',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='venue',
|
||||||
|
name='phone',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=15),
|
||||||
|
),
|
||||||
|
]
|
||||||
34
RIGS/migrations/0042_auto_20211007_2338.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# 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'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
18
RIGS/migrations/0043_auto_20211027_1519.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.1.13 on 2021-10-27 14:19
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0042_auto_20211007_2338'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='profile',
|
||||||
|
name='initials',
|
||||||
|
field=models.CharField(max_length=5, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
RIGS/migrations/0044_profile_is_supervisor.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.11 on 2022-01-09 14:56
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0043_auto_20211027_1519'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='profile',
|
||||||
|
name='is_supervisor',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
RIGS/migrations/0045_alter_profile_is_approved.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.12 on 2022-10-20 23:02
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0044_profile_is_supervisor'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='profile',
|
||||||
|
name='is_approved',
|
||||||
|
field=models.BooleanField(default=False, help_text='Designates whether a staff member has approved this user.', verbose_name='Approval Status'),
|
||||||
|
),
|
||||||
|
]
|
||||||
71
RIGS/migrations/0046_create_powertests.py
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# Generated by Django 3.2.16 on 2023-05-08 15:58
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import versioning.versioning
|
||||||
|
|
||||||
|
def migrate_old_data(apps, schema_editor):
|
||||||
|
EventChecklist = apps.get_model('RIGS', 'EventChecklist')
|
||||||
|
PowerTestRecord = apps.get_model('RIGS', 'PowerTestRecord')
|
||||||
|
for ec in EventChecklist.objects.all():
|
||||||
|
# New highscore for the most pythonic BS I've ever written.
|
||||||
|
PowerTestRecord.objects.create(event=ec.event, venue=ec.venue, reviewed_by=ec.reviewed_by, **{i.name:getattr(ec, i.attname) for i in PowerTestRecord._meta.get_fields() if not (i.is_relation or i.auto_created or i.name == "notes")})
|
||||||
|
|
||||||
|
|
||||||
|
def revert(apps, schema_editor):
|
||||||
|
apps.get_model('RIGS', 'PowerTestRecord').objects.all().delete()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0045_alter_profile_is_approved'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='PowerTestRecord',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='power_tests', to='RIGS.event')),
|
||||||
|
('notes', models.TextField(blank=True, default='')),
|
||||||
|
('venue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='RIGS.venue')),
|
||||||
|
('reviewed_at', models.DateTimeField(null=True)),
|
||||||
|
('rcds', models.BooleanField(blank=True, help_text='RCDs installed where needed and tested?', null=True)),
|
||||||
|
('supply_test', models.BooleanField(blank=True, help_text='Electrical supplies tested?<br><small>(using socket tester)</small>', null=True)),
|
||||||
|
('earthing', models.BooleanField(blank=True, help_text='Equipment appropriately earthed?<br><small>(truss, stage, generators etc)</small>', null=True)),
|
||||||
|
('pat', models.BooleanField(blank=True, help_text='All equipment in PAT period?', null=True)),
|
||||||
|
('source_rcd', models.BooleanField(blank=True, help_text='Source RCD protected?<br><small>(if cable is more than 3m long) </small>', null=True)),
|
||||||
|
('labelling', models.BooleanField(blank=True, help_text='Appropriate and clear labelling on distribution and cabling?', null=True)),
|
||||||
|
('fd_voltage_l1', models.IntegerField(blank=True, help_text='L1 - N', null=True, verbose_name='First Distro Voltage L1-N')),
|
||||||
|
('fd_voltage_l2', models.IntegerField(blank=True, help_text='L2 - N', null=True, verbose_name='First Distro Voltage L2-N')),
|
||||||
|
('fd_voltage_l3', models.IntegerField(blank=True, help_text='L3 - N', null=True, verbose_name='First Distro Voltage L3-N')),
|
||||||
|
('fd_phase_rotation', models.BooleanField(blank=True, help_text='Phase Rotation<br><small>(if required)</small>', null=True, verbose_name='Phase Rotation')),
|
||||||
|
('fd_earth_fault', 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')),
|
||||||
|
('fd_pssc', models.IntegerField(blank=True, help_text='Prospective Short Circuit Current', null=True, verbose_name='PSCC')),
|
||||||
|
('w1_description', models.CharField(blank=True, default='', help_text='Description', max_length=255)),
|
||||||
|
('w1_polarity', models.BooleanField(blank=True, help_text='Polarity Checked?', null=True)),
|
||||||
|
('w1_voltage', models.IntegerField(blank=True, help_text='Voltage', null=True)),
|
||||||
|
('w1_earth_fault', 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')),
|
||||||
|
('w2_description', models.CharField(blank=True, default='', help_text='Description', max_length=255)),
|
||||||
|
('w2_polarity', models.BooleanField(blank=True, help_text='Polarity Checked?', null=True)),
|
||||||
|
('w2_voltage', models.IntegerField(blank=True, help_text='Voltage', null=True)),
|
||||||
|
('w2_earth_fault', 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')),
|
||||||
|
('w3_description', models.CharField(blank=True, default='', help_text='Description', max_length=255)),
|
||||||
|
('w3_polarity', models.BooleanField(blank=True, help_text='Polarity Checked?', null=True)),
|
||||||
|
('w3_voltage', models.IntegerField(blank=True, help_text='Voltage', null=True)),
|
||||||
|
('w3_earth_fault', 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')),
|
||||||
|
('all_rcds_tested', models.BooleanField(blank=True, help_text='All circuit RCDs tested?<br><small>(using test button)</small>', null=True)),
|
||||||
|
('public_sockets_tested', models.BooleanField(blank=True, help_text='Public/Performer accessible circuits tested?<br><small>(using socket tester)</small>', null=True)),
|
||||||
|
('reviewed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Reviewer')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
'ordering': ['event'],
|
||||||
|
'permissions': [('review_power', 'Can review Power Test Records')],
|
||||||
|
},
|
||||||
|
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||||
|
),
|
||||||
|
migrations.RunPython(migrate_old_data, reverse_code=revert),
|
||||||
|
]
|
||||||
44
RIGS/migrations/0047_auto_20230517_0944.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Generated by Django 3.2.19 on 2023-05-17 08:44
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_old_data(apps, schema_editor):
|
||||||
|
EventChecklist = apps.get_model('RIGS', 'EventChecklist')
|
||||||
|
EventCheckIn = apps.get_model('RIGS', 'EventCheckIn')
|
||||||
|
for ec in EventChecklist.objects.all():
|
||||||
|
for crew in ec.crew.all():
|
||||||
|
try:
|
||||||
|
EventCheckIn.objects.create(event=ec.event, person=crew.crewmember, role=crew.role, time=crew.start, end_time=crew.end, vehicle=ec.vehicles.get(driver=crew.crewmember).vehicle)
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
EventCheckIn.objects.create(event=ec.event, person=crew.crewmember, role=crew.role, time=crew.start, end_time=crew.end)
|
||||||
|
|
||||||
|
|
||||||
|
def revert(apps, schema_editor):
|
||||||
|
apps.get_model('RIGS', 'EventCheckIn').objects.all().delete()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0046_create_powertests'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='EventCheckIn',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('time', models.DateTimeField()),
|
||||||
|
('role', models.CharField(blank=True, max_length=50)),
|
||||||
|
('vehicle', models.CharField(blank=True, max_length=100)),
|
||||||
|
('end_time', models.DateTimeField(blank=True, null=True)),
|
||||||
|
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='crew', to='RIGS.event')),
|
||||||
|
('person', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='checkins', to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.RunPython(migrate_old_data, reverse_code=revert),
|
||||||
|
]
|
||||||
156
RIGS/migrations/0048_auto_20230518_1256.py
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
# Generated by Django 3.2.19 on 2023-05-18 11:56
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0047_auto_20230517_0944'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklistvehicle',
|
||||||
|
name='checklist',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklistvehicle',
|
||||||
|
name='driver',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='all_rcds_tested',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='earthing',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='fd_earth_fault',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='fd_phase_rotation',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='fd_pssc',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='fd_voltage_l1',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='fd_voltage_l2',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='fd_voltage_l3',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='labelling',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='pat',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='power_mic',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='public_sockets_tested',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='rcds',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='source_rcd',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='supply_test',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w1_description',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w1_earth_fault',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w1_polarity',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w1_voltage',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w2_description',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w2_earth_fault',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w2_polarity',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w2_voltage',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w3_description',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w3_earth_fault',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w3_polarity',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='w3_voltage',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='power_mic',
|
||||||
|
field=models.ForeignKey(blank=True, help_text='Who is the Power MIC?', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='checklists', to=settings.AUTH_USER_MODEL, verbose_name='Power MIC'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventchecklist',
|
||||||
|
name='reviewed_at',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='reviewed_at',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='riskassessment',
|
||||||
|
name='reviewed_at',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='EventChecklistCrew',
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='EventChecklistVehicle',
|
||||||
|
),
|
||||||
|
]
|
||||||
53
RIGS/migrations/0049_auto_20230529_1123.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Generated by Django 3.2.19 on 2023-05-29 10:23
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0048_auto_20230518_1256'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='fd_earth_fault',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>) / Ω', max_digits=6, null=True, verbose_name='Earth Fault Loop Impedance'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='fd_pssc',
|
||||||
|
field=models.IntegerField(blank=True, help_text='Prospective Short Circuit Current / A', null=True, verbose_name='PSCC'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='w1_earth_fault',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>) / Ω', max_digits=6, null=True, verbose_name='Earth Fault Loop Impedance'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='w1_voltage',
|
||||||
|
field=models.IntegerField(blank=True, help_text='Voltage / V', null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='w2_earth_fault',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>) / Ω', max_digits=6, null=True, verbose_name='Earth Fault Loop Impedance'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='w2_voltage',
|
||||||
|
field=models.IntegerField(blank=True, help_text='Voltage / V', null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='w3_earth_fault',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>) / Ω', max_digits=6, null=True, verbose_name='Earth Fault Loop Impedance'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='powertestrecord',
|
||||||
|
name='w3_voltage',
|
||||||
|
field=models.IntegerField(blank=True, help_text='Voltage / V', null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
19
RIGS/migrations/0050_event_forum_url.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 3.2.19 on 2023-06-27 11:28
|
||||||
|
|
||||||
|
import RIGS.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0049_auto_20230529_1123'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='event',
|
||||||
|
name='forum_url',
|
||||||
|
field=models.URLField(blank=True, default='', validators=[RIGS.models.validate_forum_url]),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
RIGS/migrations/0051_alter_payment_method.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.19 on 2023-07-09 21:23
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0050_event_forum_url'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='payment',
|
||||||
|
name='method',
|
||||||
|
field=models.CharField(blank=True, choices=[('C', 'Cash'), ('I', 'Internal'), ('E', 'External'), ('T', 'TEC Adjustment')], default='', max_length=2),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
RIGS/migrations/0052_venue_on_campus.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.21 on 2023-09-05 22:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0051_alter_payment_method'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='venue',
|
||||||
|
name='on_campus',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='Is this venue on a UoN campus?'),
|
||||||
|
),
|
||||||
|
]
|
||||||
479
RIGS/models.py
@@ -8,24 +8,41 @@ from urllib.parse import urlparse
|
|||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.db.models import Q, F
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import AbstractUser
|
from django.contrib.auth.models import AbstractUser
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from reversion.models import Version
|
from reversion.models import Version
|
||||||
|
from versioning.versioning import RevisionMixin
|
||||||
|
|
||||||
|
|
||||||
|
def filter_by_pk(filt, query):
|
||||||
|
# try and parse an int
|
||||||
|
try:
|
||||||
|
val = int(query)
|
||||||
|
filt = filt | Q(pk=val)
|
||||||
|
except: # noqa
|
||||||
|
# not an integer
|
||||||
|
pass
|
||||||
|
return filt
|
||||||
|
|
||||||
|
|
||||||
class Profile(AbstractUser):
|
class Profile(AbstractUser):
|
||||||
initials = models.CharField(max_length=5, unique=True, null=True, blank=False)
|
initials = models.CharField(max_length=5, null=True, blank=False)
|
||||||
phone = models.CharField(max_length=13, null=True, blank=True)
|
phone = models.CharField(max_length=13, blank=True, default='')
|
||||||
api_key = models.CharField(max_length=40, blank=True, editable=False, null=True)
|
api_key = models.CharField(max_length=40, blank=True, editable=False, default='')
|
||||||
is_approved = models.BooleanField(default=False)
|
is_approved = models.BooleanField(default=False, verbose_name="Approval Status", help_text="Designates whether a staff member has approved this user.")
|
||||||
last_emailed = models.DateTimeField(blank=True,
|
# Currently only populated by the admin approval email. TODO: Populate it each time we send any email, might need that...
|
||||||
null=True) # 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)
|
||||||
|
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):
|
||||||
@@ -46,12 +63,12 @@ class Profile(AbstractUser):
|
|||||||
def name(self):
|
def name(self):
|
||||||
name = self.get_full_name()
|
name = self.get_full_name()
|
||||||
if self.initials:
|
if self.initials:
|
||||||
name += ' "{}"'.format(self.initials)
|
name += f' "{self.initials}"'
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def latest_events(self):
|
def latest_events(self):
|
||||||
return self.event_mic.order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic')
|
return self.event_mic.order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic', 'riskassessment', 'invoice').prefetch_related('checklists')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def admins(cls):
|
def admins(cls):
|
||||||
@@ -59,55 +76,38 @@ class Profile(AbstractUser):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def users_awaiting_approval_count(cls):
|
def users_awaiting_approval_count(cls):
|
||||||
return Profile.objects.filter(models.Q(is_approved=False)).count()
|
# last_login = None ensures we only pick up genuinely new users, not those that have been deactivated for inactivity
|
||||||
|
return Profile.objects.filter(is_approved=False, last_login=None).count()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
# TODO move to versioning - currently get import errors with that
|
def current_event(self):
|
||||||
|
q = EventCheckIn.objects.filter(person=self, end_time=None)
|
||||||
|
return q.latest('time') if q.exists() else None
|
||||||
|
|
||||||
|
|
||||||
class RevisionMixin(object):
|
class ContactableManager(models.Manager):
|
||||||
@property
|
def search(self, query=None):
|
||||||
def is_first_version(self):
|
qs = self.get_queryset()
|
||||||
versions = Version.objects.get_for_object(self)
|
if query is not None:
|
||||||
return len(versions) == 1
|
or_lookup = Q(name__icontains=query) | Q(email__icontains=query) | Q(address__icontains=query) | Q(notes__icontains=query) | Q(
|
||||||
|
phone__startswith=query) | Q(phone__endswith=query)
|
||||||
|
|
||||||
@property
|
or_lookup = filter_by_pk(or_lookup, query)
|
||||||
def current_version(self):
|
|
||||||
version = Version.objects.get_for_object(self).select_related('revision').first()
|
|
||||||
return version
|
|
||||||
|
|
||||||
@property
|
qs = qs.filter(or_lookup).distinct() # distinct() is often necessary with Q lookups
|
||||||
def last_edited_at(self):
|
return qs
|
||||||
version = self.current_version
|
|
||||||
if version is None:
|
|
||||||
return None
|
|
||||||
return version.revision.date_created
|
|
||||||
|
|
||||||
@property
|
|
||||||
def last_edited_by(self):
|
|
||||||
version = self.current_version
|
|
||||||
if version is None:
|
|
||||||
return None
|
|
||||||
return version.revision.user
|
|
||||||
|
|
||||||
@property
|
|
||||||
def current_version_id(self):
|
|
||||||
version = self.current_version
|
|
||||||
if version is None:
|
|
||||||
return None
|
|
||||||
return "V{0} | R{1}".format(version.pk, version.revision.pk)
|
|
||||||
|
|
||||||
|
|
||||||
class Person(models.Model, RevisionMixin):
|
class Person(models.Model, RevisionMixin):
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
phone = models.CharField(max_length=15, blank=True, null=True)
|
phone = models.CharField(max_length=15, blank=True, default='')
|
||||||
email = models.EmailField(blank=True, null=True)
|
email = models.EmailField(blank=True, default='')
|
||||||
|
address = models.TextField(blank=True, default='')
|
||||||
|
notes = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
address = models.TextField(blank=True, null=True)
|
objects = ContactableManager()
|
||||||
|
|
||||||
notes = models.TextField(blank=True, null=True)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
@@ -133,19 +133,19 @@ class Person(models.Model, RevisionMixin):
|
|||||||
return self.event_set.order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic')
|
return self.event_set.order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic')
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse_lazy('person_detail', kwargs={'pk': self.pk})
|
return reverse('person_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
|
|
||||||
class Organisation(models.Model, RevisionMixin):
|
class Organisation(models.Model, RevisionMixin):
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
phone = models.CharField(max_length=15, blank=True, null=True)
|
phone = models.CharField(max_length=15, blank=True, default='')
|
||||||
email = models.EmailField(blank=True, null=True)
|
email = models.EmailField(blank=True, default='')
|
||||||
|
address = models.TextField(blank=True, default='')
|
||||||
address = models.TextField(blank=True, null=True)
|
notes = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
notes = models.TextField(blank=True, null=True)
|
|
||||||
union_account = models.BooleanField(default=False)
|
union_account = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
objects = ContactableManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
if self.notes is not None:
|
if self.notes is not None:
|
||||||
@@ -170,7 +170,7 @@ class Organisation(models.Model, RevisionMixin):
|
|||||||
return self.event_set.order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic')
|
return self.event_set.order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic')
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse_lazy('organisation_detail', kwargs={'pk': self.pk})
|
return reverse('organisation_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
|
|
||||||
class VatManager(models.Manager):
|
class VatManager(models.Manager):
|
||||||
@@ -178,7 +178,6 @@ class VatManager(models.Manager):
|
|||||||
return self.find_rate(timezone.now())
|
return self.find_rate(timezone.now())
|
||||||
|
|
||||||
def find_rate(self, date):
|
def find_rate(self, date):
|
||||||
# return self.filter(startAt__lte=date).latest()
|
|
||||||
try:
|
try:
|
||||||
return self.filter(start_at__lte=date).latest()
|
return self.filter(start_at__lte=date).latest()
|
||||||
except VatRate.DoesNotExist:
|
except VatRate.DoesNotExist:
|
||||||
@@ -206,17 +205,19 @@ class VatRate(models.Model, RevisionMixin):
|
|||||||
get_latest_by = 'start_at'
|
get_latest_by = 'start_at'
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.comment + " " + str(self.start_at) + " @ " + str(self.as_percent) + "%"
|
return f"{self.comment} {self.start_at} @ {self.as_percent}%"
|
||||||
|
|
||||||
|
|
||||||
class Venue(models.Model, RevisionMixin):
|
class Venue(models.Model, RevisionMixin):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
phone = models.CharField(max_length=15, blank=True, null=True)
|
phone = models.CharField(max_length=15, blank=True, default='')
|
||||||
email = models.EmailField(blank=True, null=True)
|
email = models.EmailField(blank=True, default='')
|
||||||
three_phase_available = models.BooleanField(default=False)
|
three_phase_available = models.BooleanField(default=False)
|
||||||
notes = models.TextField(blank=True, null=True)
|
on_campus = models.BooleanField(default=False, verbose_name="Is this venue on a UoN campus?")
|
||||||
|
notes = models.TextField(blank=True, default='')
|
||||||
|
address = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
address = models.TextField(blank=True, null=True)
|
objects = ContactableManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
@@ -229,24 +230,23 @@ class Venue(models.Model, RevisionMixin):
|
|||||||
return self.event_set.order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic')
|
return self.event_set.order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic')
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse_lazy('venue_detail', kwargs={'pk': self.pk})
|
return reverse('venue_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
|
|
||||||
class EventManager(models.Manager):
|
class EventManager(models.Manager):
|
||||||
def current_events(self):
|
def current_events(self):
|
||||||
events = self.filter(
|
events = self.filter(
|
||||||
(models.Q(start_date__gte=timezone.now().date(), end_date__isnull=True, dry_hire=False) & ~models.Q(
|
(models.Q(start_date__gte=timezone.now(), end_date__isnull=True, dry_hire=False) & ~models.Q(
|
||||||
status=Event.CANCELLED)) | # Starts after with no end
|
status=Event.CANCELLED)) | # Starts after with no end
|
||||||
(models.Q(end_date__gte=timezone.now().date(), dry_hire=False) & ~models.Q(
|
(models.Q(end_date__gte=timezone.now().date(), dry_hire=False) & ~models.Q(
|
||||||
status=Event.CANCELLED)) | # Ends after
|
status=Event.CANCELLED)) | # Ends after
|
||||||
(models.Q(dry_hire=True, start_date__gte=timezone.now().date()) & ~models.Q(
|
(models.Q(dry_hire=True, start_date__gte=timezone.now()) & ~models.Q(
|
||||||
status=Event.CANCELLED)) | # Active dry hire
|
status=Event.CANCELLED)) | # Active dry hire
|
||||||
(models.Q(dry_hire=True, checked_in_by__isnull=True) & (
|
(models.Q(dry_hire=True, checked_in_by__isnull=True) & (
|
||||||
models.Q(status=Event.BOOKED) | models.Q(status=Event.CONFIRMED))) | # Active dry hire GT
|
models.Q(status=Event.BOOKED) | models.Q(status=Event.CONFIRMED))) | # Active dry hire GT
|
||||||
models.Q(status=Event.CANCELLED, start_date__gte=timezone.now().date()) # Canceled but not started
|
models.Q(status=Event.CANCELLED, start_date__gte=timezone.now()) # Canceled but not started
|
||||||
).order_by('start_date', 'end_date', 'start_time', 'end_time', 'meet_at').select_related('person',
|
).order_by('start_date', 'end_date', 'start_time', 'end_time', 'meet_at').select_related('person', 'organisation', 'venue', 'mic')
|
||||||
'organisation',
|
|
||||||
'venue', 'mic')
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
def events_in_bounds(self, start, end):
|
def events_in_bounds(self, start, end):
|
||||||
@@ -269,16 +269,54 @@ class EventManager(models.Manager):
|
|||||||
|
|
||||||
def rig_count(self):
|
def rig_count(self):
|
||||||
event_count = self.filter(
|
event_count = self.filter(
|
||||||
(models.Q(start_date__gte=timezone.now().date(), end_date__isnull=True, dry_hire=False,
|
(models.Q(start_date__gte=timezone.now(), end_date__isnull=True, dry_hire=False,
|
||||||
is_rig=True) & ~models.Q(
|
is_rig=True) & ~models.Q(
|
||||||
status=Event.CANCELLED)) | # Starts after with no end
|
status=Event.CANCELLED)) | # Starts after with no end
|
||||||
(models.Q(end_date__gte=timezone.now().date(), dry_hire=False, is_rig=True) & ~models.Q(
|
(models.Q(end_date__gte=timezone.now(), dry_hire=False, is_rig=True) & ~models.Q(
|
||||||
status=Event.CANCELLED)) | # Ends after
|
status=Event.CANCELLED)) | # Ends after
|
||||||
(models.Q(dry_hire=True, start_date__gte=timezone.now().date(), is_rig=True) & ~models.Q(
|
(models.Q(dry_hire=True, start_date__gte=timezone.now(), is_rig=True) & ~models.Q(
|
||||||
status=Event.CANCELLED)) # Active dry hire
|
status=Event.CANCELLED)) # Active dry hire
|
||||||
).count()
|
).count()
|
||||||
return event_count
|
return event_count
|
||||||
|
|
||||||
|
def waiting_invoices(self):
|
||||||
|
events = self.filter(
|
||||||
|
(
|
||||||
|
models.Q(start_date__lte=datetime.date.today(), end_date__isnull=True) | # Starts before with no end
|
||||||
|
models.Q(end_date__lte=datetime.date.today()) # Or has end date, finishes before
|
||||||
|
) & models.Q(invoice__isnull=True) & # Has not already been invoiced
|
||||||
|
models.Q(is_rig=True) # Is a rig (not non-rig)
|
||||||
|
).order_by('start_date') \
|
||||||
|
.select_related('person', 'organisation', 'venue', 'mic') \
|
||||||
|
.prefetch_related('items')
|
||||||
|
|
||||||
|
return events
|
||||||
|
|
||||||
|
def search(self, query=None):
|
||||||
|
qs = self.get_queryset()
|
||||||
|
if query is not None:
|
||||||
|
or_lookup = Q(name__icontains=query) | Q(description__icontains=query) | Q(notes__icontains=query)
|
||||||
|
|
||||||
|
or_lookup = filter_by_pk(or_lookup, query)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if query[0] == "N":
|
||||||
|
val = int(query[1:])
|
||||||
|
or_lookup = Q(pk=val) # If string is N###### then do a simple PK filter
|
||||||
|
except: # noqa
|
||||||
|
pass
|
||||||
|
|
||||||
|
qs = qs.filter(or_lookup).distinct() # distinct() is often necessary with Q lookups
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
def validate_forum_url(value):
|
||||||
|
if not value:
|
||||||
|
return # Required error is done the field
|
||||||
|
obj = urlparse(value)
|
||||||
|
if obj.hostname not in ('forum.nottinghamtec.co.uk'):
|
||||||
|
raise ValidationError('URL must point to a location on the TEC Forum')
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(follow=['items'])
|
@reversion.register(follow=['items'])
|
||||||
class Event(models.Model, RevisionMixin):
|
class Event(models.Model, RevisionMixin):
|
||||||
@@ -298,8 +336,8 @@ class Event(models.Model, RevisionMixin):
|
|||||||
person = models.ForeignKey('Person', null=True, blank=True, on_delete=models.CASCADE)
|
person = models.ForeignKey('Person', null=True, blank=True, on_delete=models.CASCADE)
|
||||||
organisation = models.ForeignKey('Organisation', blank=True, null=True, on_delete=models.CASCADE)
|
organisation = models.ForeignKey('Organisation', blank=True, null=True, on_delete=models.CASCADE)
|
||||||
venue = models.ForeignKey('Venue', blank=True, null=True, on_delete=models.CASCADE)
|
venue = models.ForeignKey('Venue', blank=True, null=True, on_delete=models.CASCADE)
|
||||||
description = models.TextField(blank=True, null=True)
|
description = models.TextField(blank=True, default='')
|
||||||
notes = models.TextField(blank=True, null=True)
|
notes = models.TextField(blank=True, default='')
|
||||||
status = models.IntegerField(choices=EVENT_STATUS_CHOICES, default=PROVISIONAL)
|
status = models.IntegerField(choices=EVENT_STATUS_CHOICES, default=PROVISIONAL)
|
||||||
dry_hire = models.BooleanField(default=False)
|
dry_hire = models.BooleanField(default=False)
|
||||||
is_rig = models.BooleanField(default=True)
|
is_rig = models.BooleanField(default=True)
|
||||||
@@ -313,7 +351,6 @@ 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, null=True)
|
|
||||||
|
|
||||||
# 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,
|
||||||
@@ -322,22 +359,23 @@ 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, null=True)
|
purchase_order = models.CharField(max_length=255, blank=True, default='', verbose_name='PO')
|
||||||
payment_received = models.CharField(max_length=255, blank=True, null=True)
|
collector = models.CharField(max_length=255, blank=True, default='', verbose_name='collected by')
|
||||||
purchase_order = models.CharField(max_length=255, blank=True, null=True, verbose_name='PO')
|
|
||||||
collector = models.CharField(max_length=255, blank=True, null=True, verbose_name='collected by')
|
|
||||||
|
|
||||||
# Authorisation request details
|
# Authorisation request details
|
||||||
auth_request_by = models.ForeignKey('Profile', null=True, blank=True, on_delete=models.CASCADE)
|
auth_request_by = models.ForeignKey('Profile', null=True, blank=True, on_delete=models.CASCADE)
|
||||||
auth_request_at = models.DateTimeField(null=True, blank=True)
|
auth_request_at = models.DateTimeField(null=True, blank=True)
|
||||||
auth_request_to = models.EmailField(null=True, blank=True)
|
auth_request_to = models.EmailField(blank=True, default='')
|
||||||
|
|
||||||
|
forum_url = models.URLField(default='', blank=True, validators=[validate_forum_url])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def display_id(self):
|
def display_id(self):
|
||||||
if self.is_rig:
|
if self.pk:
|
||||||
return str("N%05d" % self.pk)
|
if self.is_rig:
|
||||||
else:
|
return f"N{self.pk:05d}"
|
||||||
return self.pk
|
return self.pk
|
||||||
|
return "????"
|
||||||
|
|
||||||
# Calculated values
|
# Calculated values
|
||||||
"""
|
"""
|
||||||
@@ -346,7 +384,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def sum_total(self):
|
def sum_total(self):
|
||||||
total = EventItem.objects.filter(event=self).aggregate(
|
total = self.items.aggregate(
|
||||||
sum_total=models.Sum(models.F('cost') * models.F('quantity'),
|
sum_total=models.Sum(models.F('cost') * models.F('quantity'),
|
||||||
output_field=models.DecimalField(max_digits=10, decimal_places=2))
|
output_field=models.DecimalField(max_digits=10, decimal_places=2))
|
||||||
)['sum_total']
|
)['sum_total']
|
||||||
@@ -360,6 +398,9 @@ 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'))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -380,7 +421,15 @@ class Event(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def hs_done(self):
|
def hs_done(self):
|
||||||
return self.riskassessment is not None and len(self.checklists.all()) > 0
|
return self.riskassessment is not None and self.has_checklist and self.has_power
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_checklist(self):
|
||||||
|
return self.checklists.exists()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_power(self):
|
||||||
|
return self.power_tests.exists()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_start_time(self):
|
def has_start_time(self):
|
||||||
@@ -453,13 +502,22 @@ class Event(models.Model, RevisionMixin):
|
|||||||
else:
|
else:
|
||||||
return bool(self.purchase_order)
|
return bool(self.purchase_order)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_check_in(self):
|
||||||
|
earliest = self.earliest_time
|
||||||
|
if isinstance(self.earliest_time, datetime.date):
|
||||||
|
earliest = datetime.datetime.combine(self.start_date, datetime.time(00, 00))
|
||||||
|
tz = pytz.timezone(settings.TIME_ZONE)
|
||||||
|
earliest = tz.localize(earliest)
|
||||||
|
return not self.dry_hire and not self.status == Event.CANCELLED and earliest <= timezone.now()
|
||||||
|
|
||||||
objects = EventManager()
|
objects = EventManager()
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse_lazy('event_detail', kwargs={'pk': self.pk})
|
return reverse('event_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{}: {}".format(self.display_id, self.name)
|
return f"{self.display_id} | {self.name}"
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
errdict = {}
|
errdict = {}
|
||||||
@@ -490,7 +548,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
class EventItem(models.Model, RevisionMixin):
|
class EventItem(models.Model, RevisionMixin):
|
||||||
event = models.ForeignKey('Event', related_name='items', blank=True, on_delete=models.CASCADE)
|
event = models.ForeignKey('Event', related_name='items', blank=True, on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
description = models.TextField(blank=True, null=True)
|
description = models.TextField(blank=True, default='')
|
||||||
quantity = models.IntegerField()
|
quantity = models.IntegerField()
|
||||||
cost = models.DecimalField(max_digits=10, decimal_places=2)
|
cost = models.DecimalField(max_digits=10, decimal_places=2)
|
||||||
order = models.IntegerField()
|
order = models.IntegerField()
|
||||||
@@ -505,11 +563,11 @@ class EventItem(models.Model, RevisionMixin):
|
|||||||
ordering = ['order']
|
ordering = ['order']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.event.pk) + "." + str(self.order) + ": " + self.event.name + " | " + self.name
|
return f"{self.event_id}.{self.order}: {self.event.name} | {self.name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return str("item {}".format(self.name))
|
return f"item {self.name}"
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
@@ -517,17 +575,62 @@ class EventAuthorisation(models.Model, RevisionMixin):
|
|||||||
event = models.OneToOneField('Event', related_name='authorisation', on_delete=models.CASCADE)
|
event = models.OneToOneField('Event', related_name='authorisation', on_delete=models.CASCADE)
|
||||||
email = models.EmailField()
|
email = models.EmailField()
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
uni_id = models.CharField(max_length=10, blank=True, null=True, verbose_name="University ID")
|
uni_id = models.CharField(max_length=10, blank=True, default='', verbose_name="University ID")
|
||||||
account_code = models.CharField(max_length=50, blank=True, null=True)
|
account_code = models.CharField(max_length=50, default='', blank=True)
|
||||||
amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="authorisation amount")
|
amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="authorisation amount")
|
||||||
sent_by = models.ForeignKey('Profile', on_delete=models.CASCADE)
|
sent_by = models.ForeignKey('Profile', on_delete=models.CASCADE)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse_lazy('event_detail', kwargs={'pk': self.event.pk})
|
return reverse('event_detail', kwargs={'pk': self.event_id})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return "{} (requested by {})".format(self.event.display_id, self.sent_by.initials)
|
return f"{self.event.display_id} (requested by {self.sent_by.initials})"
|
||||||
|
|
||||||
|
|
||||||
|
class InvoiceManager(models.Manager):
|
||||||
|
def outstanding_invoices(self):
|
||||||
|
# Manual query is the only way I have found to do this efficiently. Not ideal but needs must
|
||||||
|
sql = "SELECT * FROM " \
|
||||||
|
"(SELECT " \
|
||||||
|
"(SELECT COUNT(p.amount) FROM \"RIGS_payment\" AS p WHERE p.invoice_id=\"RIGS_invoice\".id) AS \"payment_count\", " \
|
||||||
|
"(SELECT SUM(ei.cost * ei.quantity) FROM \"RIGS_eventitem\" AS ei WHERE ei.event_id=\"RIGS_invoice\".event_id) AS \"cost\", " \
|
||||||
|
"(SELECT SUM(p.amount) FROM \"RIGS_payment\" AS p WHERE p.invoice_id=\"RIGS_invoice\".id) AS \"payments\", " \
|
||||||
|
"\"RIGS_invoice\".\"id\", \"RIGS_invoice\".\"event_id\", \"RIGS_invoice\".\"invoice_date\", \"RIGS_invoice\".\"void\" FROM \"RIGS_invoice\") " \
|
||||||
|
"AS sub " \
|
||||||
|
"WHERE (((cost > 0.0) AND (payment_count=0)) OR (cost - payments) <> 0.0) AND void = '0'" \
|
||||||
|
"ORDER BY invoice_date"
|
||||||
|
|
||||||
|
query = self.raw(sql)
|
||||||
|
return query
|
||||||
|
|
||||||
|
def search(self, query=None):
|
||||||
|
qs = self.get_queryset()
|
||||||
|
if query is not None:
|
||||||
|
or_lookup = Q(event__name__icontains=query)
|
||||||
|
|
||||||
|
or_lookup = filter_by_pk(or_lookup, query)
|
||||||
|
|
||||||
|
# try and parse an int
|
||||||
|
try:
|
||||||
|
val = int(query)
|
||||||
|
or_lookup = or_lookup | Q(event__pk=val)
|
||||||
|
except: # noqa
|
||||||
|
# not an integer
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
if query[0] == "N":
|
||||||
|
val = int(query[1:])
|
||||||
|
or_lookup = Q(event__pk=val) # If string is Nxxxxx then filter by event number
|
||||||
|
elif query[0] == "#":
|
||||||
|
val = int(query[1:])
|
||||||
|
or_lookup = Q(pk=val) # If string is #xxxxx then filter by invoice number
|
||||||
|
except: # noqa
|
||||||
|
pass
|
||||||
|
|
||||||
|
qs = qs.filter(or_lookup).distinct() # distinct() is often necessary with Q lookups
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(follow=['payment_set'])
|
@reversion.register(follow=['payment_set'])
|
||||||
@@ -538,6 +641,8 @@ 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
|
||||||
@@ -562,18 +667,18 @@ class Invoice(models.Model, RevisionMixin):
|
|||||||
return self.balance == 0 or self.void
|
return self.balance == 0 or self.void
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse_lazy('invoice_detail', kwargs={'pk': self.pk})
|
return reverse('invoice_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return "#{} for Event {}".format(self.display_id, "N%05d" % self.event.pk)
|
return f"{self.display_id} for Event {self.event.display_id}"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%i: %s (%.2f)" % (self.pk, self.event, self.balance)
|
return f"{self.display_id}: {self.event} (£{self.balance:.2f})"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def display_id(self):
|
def display_id(self):
|
||||||
return "{:05d}".format(self.pk)
|
return f"#{self.pk:05d}"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-invoice_date']
|
ordering = ['-invoice_date']
|
||||||
@@ -584,29 +689,27 @@ class Payment(models.Model, RevisionMixin):
|
|||||||
CASH = 'C'
|
CASH = 'C'
|
||||||
INTERNAL = 'I'
|
INTERNAL = 'I'
|
||||||
EXTERNAL = 'E'
|
EXTERNAL = 'E'
|
||||||
SUCORE = 'SU'
|
|
||||||
ADJUSTMENT = 'T'
|
ADJUSTMENT = 'T'
|
||||||
METHODS = (
|
METHODS = (
|
||||||
(CASH, 'Cash'),
|
(CASH, 'Cash'),
|
||||||
(INTERNAL, 'Internal'),
|
(INTERNAL, 'Internal'),
|
||||||
(EXTERNAL, 'External'),
|
(EXTERNAL, 'External'),
|
||||||
(SUCORE, 'SU Core'),
|
|
||||||
(ADJUSTMENT, 'TEC Adjustment'),
|
(ADJUSTMENT, 'TEC Adjustment'),
|
||||||
)
|
)
|
||||||
|
|
||||||
invoice = models.ForeignKey('Invoice', on_delete=models.CASCADE)
|
invoice = models.ForeignKey('Invoice', on_delete=models.CASCADE)
|
||||||
date = models.DateField()
|
date = models.DateField()
|
||||||
amount = models.DecimalField(max_digits=10, decimal_places=2, help_text='Please use ex. VAT')
|
amount = models.DecimalField(max_digits=10, decimal_places=2, help_text='Please use ex. VAT')
|
||||||
method = models.CharField(max_length=2, choices=METHODS, null=True, blank=True)
|
method = models.CharField(max_length=2, choices=METHODS, default='', blank=True)
|
||||||
|
|
||||||
reversion_hide = True
|
reversion_hide = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s: %d" % (self.get_method_display(), self.amount)
|
return f"{self.get_method_display()}: {self.amount}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return str("payment of £{}".format(self.amount))
|
return f"payment of £{self.amount}"
|
||||||
|
|
||||||
|
|
||||||
def validate_url(value):
|
def validate_url(value):
|
||||||
@@ -617,8 +720,21 @@ def validate_url(value):
|
|||||||
raise ValidationError('URL must point to a location on the TEC Sharepoint')
|
raise ValidationError('URL must point to a location on the TEC Sharepoint')
|
||||||
|
|
||||||
|
|
||||||
|
class ReviewableModel(models.Model):
|
||||||
|
reviewed_at = models.DateTimeField(null=True, blank=True)
|
||||||
|
reviewed_by = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True,
|
||||||
|
verbose_name="Reviewer", on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def fieldz(self):
|
||||||
|
return [n.name for n in list(self._meta.get_fields()) if n.name != 'reviewed_at' and n.name != 'reviewed_by' and not n.is_relation and not n.auto_created]
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
class RiskAssessment(models.Model, RevisionMixin):
|
class RiskAssessment(ReviewableModel, RevisionMixin):
|
||||||
SMALL = (0, 'Small')
|
SMALL = (0, 'Small')
|
||||||
MEDIUM = (1, 'Medium')
|
MEDIUM = (1, 'Medium')
|
||||||
LARGE = (2, 'Large')
|
LARGE = (2, 'Large')
|
||||||
@@ -632,12 +748,10 @@ class RiskAssessment(models.Model, RevisionMixin):
|
|||||||
contractors = models.BooleanField(help_text="Are you using any external contractors?<br><small>i.e. Freelancers/Crewing Companies</small>")
|
contractors = models.BooleanField(help_text="Are you using any external contractors?<br><small>i.e. Freelancers/Crewing Companies</small>")
|
||||||
other_companies = models.BooleanField(help_text="Are TEC working with any other companies on site?<br><small>e.g. TEC is providing the lighting while another company does sound</small>")
|
other_companies = models.BooleanField(help_text="Are TEC working with any other companies on site?<br><small>e.g. TEC is providing the lighting while another company does sound</small>")
|
||||||
crew_fatigue = models.BooleanField(help_text="Is crew fatigue likely to be a risk at any point during this event?")
|
crew_fatigue = models.BooleanField(help_text="Is crew fatigue likely to be a risk at any point during this event?")
|
||||||
general_notes = models.TextField(blank=True, null=True, help_text="Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?")
|
general_notes = models.TextField(blank=True, default='', help_text="Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?")
|
||||||
|
|
||||||
# Power
|
# Power
|
||||||
# event_size = models.IntegerField(blank=True, null=True, choices=SIZES)
|
|
||||||
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?")
|
||||||
@@ -645,12 +759,12 @@ class RiskAssessment(models.Model, RevisionMixin):
|
|||||||
other_companies_power = models.BooleanField(help_text="Will TEC be supplying power to any other companies?")
|
other_companies_power = models.BooleanField(help_text="Will TEC be supplying power to any other companies?")
|
||||||
nonstandard_equipment_power = models.BooleanField(help_text="Does the power plan require the use of any power equipment (distros, dimmers, motor controllers, etc.) that does not belong to TEC?")
|
nonstandard_equipment_power = models.BooleanField(help_text="Does the power plan require the use of any power equipment (distros, dimmers, motor controllers, etc.) that does not belong to TEC?")
|
||||||
multiple_electrical_environments = models.BooleanField(help_text="Will the electrical installation occupy more than one electrical environment?")
|
multiple_electrical_environments = models.BooleanField(help_text="Will the electrical installation occupy more than one electrical environment?")
|
||||||
power_notes = models.TextField(blank=True, null=True, help_text="Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?")
|
power_notes = models.TextField(blank=True, default='', help_text="Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?")
|
||||||
power_plan = models.URLField(blank=True, null=True, help_text="Upload your power plan to the <a href='https://nottinghamtec.sharepoint.com/'>Sharepoint</a> and submit a link", validators=[validate_url])
|
power_plan = models.URLField(blank=True, default='', help_text="Upload your power plan to the <a href='https://nottinghamtec.sharepoint.com/'>Sharepoint</a> and submit a link", validators=[validate_url])
|
||||||
|
|
||||||
# Sound
|
# Sound
|
||||||
noise_monitoring = models.BooleanField(help_text="Does the event require noise monitoring or any non-standard procedures in order to comply with health and safety legislation or site rules?")
|
noise_monitoring = models.BooleanField(help_text="Does the event require noise monitoring or any non-standard procedures in order to comply with health and safety legislation or site rules?")
|
||||||
sound_notes = models.TextField(blank=True, null=True, help_text="Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?")
|
sound_notes = models.TextField(blank=True, default='', help_text="Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?")
|
||||||
|
|
||||||
# Site
|
# Site
|
||||||
known_venue = models.BooleanField(help_text="Is this venue new to you (the MIC) or new to TEC?")
|
known_venue = models.BooleanField(help_text="Is this venue new to you (the MIC) or new to TEC?")
|
||||||
@@ -663,15 +777,11 @@ class RiskAssessment(models.Model, RevisionMixin):
|
|||||||
# Structures
|
# Structures
|
||||||
special_structures = models.BooleanField(help_text="Does the event require use of winch stands, motors, MPT Towers, or staging?")
|
special_structures = models.BooleanField(help_text="Does the event require use of winch stands, motors, MPT Towers, or staging?")
|
||||||
suspended_structures = models.BooleanField(help_text="Are any structures (excluding projector screens and IWBs) being suspended from TEC's structures?")
|
suspended_structures = models.BooleanField(help_text="Are any structures (excluding projector screens and IWBs) being suspended from TEC's structures?")
|
||||||
persons_responsible_structures = models.TextField(blank=True, null=True, help_text="Who are the persons on site responsible for their use?")
|
persons_responsible_structures = models.TextField(blank=True, default='', help_text="Who are the persons on site responsible for their use?")
|
||||||
rigging_plan = models.URLField(blank=True, null=True, help_text="Upload your rigging plan to the <a href='https://nottinghamtec.sharepoint.com/'>Sharepoint</a> and submit a link", validators=[validate_url])
|
rigging_plan = models.URLField(blank=True, default='', help_text="Upload your rigging plan to the <a href='https://nottinghamtec.sharepoint.com/'>Sharepoint</a> and submit a link", validators=[validate_url])
|
||||||
|
|
||||||
# Blimey that was a lot of options
|
# Blimey that was a lot of options
|
||||||
|
|
||||||
reviewed_at = models.DateTimeField(null=True)
|
|
||||||
reviewed_by = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True,
|
|
||||||
verbose_name="Reviewer", on_delete=models.CASCADE)
|
|
||||||
|
|
||||||
supervisor_consulted = models.BooleanField(null=True)
|
supervisor_consulted = models.BooleanField(null=True)
|
||||||
|
|
||||||
expected_values = {
|
expected_values = {
|
||||||
@@ -680,7 +790,7 @@ class RiskAssessment(models.Model, RevisionMixin):
|
|||||||
'contractors': False,
|
'contractors': False,
|
||||||
'other_companies': False,
|
'other_companies': False,
|
||||||
'crew_fatigue': False,
|
'crew_fatigue': False,
|
||||||
'big_power': False,
|
# 'big_power': False Doesn't require checking with a super either way
|
||||||
'generators': False,
|
'generators': False,
|
||||||
'other_companies_power': False,
|
'other_companies_power': False,
|
||||||
'nonstandard_equipment_power': False,
|
'nonstandard_equipment_power': False,
|
||||||
@@ -718,24 +828,29 @@ class RiskAssessment(models.Model, RevisionMixin):
|
|||||||
else:
|
else:
|
||||||
return self.SMALL[0]
|
return self.SMALL[0]
|
||||||
|
|
||||||
|
def get_event_size_display(self):
|
||||||
|
return self.SIZES[self.event_size][1] + " Event"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.pk} | {self.event}"
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('ra_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return str(self.event)
|
return str(self.event)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
@property
|
||||||
return reverse_lazy('ra_detail', kwargs={'pk': self.pk})
|
def name(self):
|
||||||
|
return str(self)
|
||||||
def __str__(self):
|
|
||||||
return "%i - %s" % (self.pk, self.event)
|
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(follow=['vehicles', 'crew'])
|
@reversion.register
|
||||||
class EventChecklist(models.Model, RevisionMixin):
|
class EventChecklist(ReviewableModel, RevisionMixin):
|
||||||
event = models.ForeignKey('Event', related_name='checklists', on_delete=models.CASCADE)
|
event = models.ForeignKey('Event', related_name='checklists', on_delete=models.CASCADE)
|
||||||
|
|
||||||
# General
|
# General
|
||||||
power_mic = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='checklists',
|
|
||||||
verbose_name="Power MIC", on_delete=models.CASCADE, help_text="Who is the Power MIC?")
|
|
||||||
venue = models.ForeignKey('Venue', on_delete=models.CASCADE)
|
venue = models.ForeignKey('Venue', on_delete=models.CASCADE)
|
||||||
date = models.DateField()
|
date = models.DateField()
|
||||||
|
|
||||||
@@ -746,9 +861,38 @@ class EventChecklist(models.Model, RevisionMixin):
|
|||||||
trip_hazard = models.BooleanField(blank=True, null=True, help_text="Appropriate barriers around kit and cabling secured?")
|
trip_hazard = models.BooleanField(blank=True, null=True, help_text="Appropriate barriers around kit and cabling secured?")
|
||||||
warning_signs = models.BooleanField(blank=True, help_text="Warning signs in place?<br><small>(strobe, smoke, power etc.)</small>")
|
warning_signs = models.BooleanField(blank=True, help_text="Warning signs in place?<br><small>(strobe, smoke, power etc.)</small>")
|
||||||
ear_plugs = models.BooleanField(blank=True, null=True, help_text="Ear plugs issued to crew where needed?")
|
ear_plugs = models.BooleanField(blank=True, null=True, help_text="Ear plugs issued to crew where needed?")
|
||||||
hs_location = models.CharField(blank=True, null=True, max_length=255, help_text="Location of Safety Bag/Box")
|
hs_location = models.CharField(blank=True, default='', max_length=255, help_text="Location of Safety Bag/Box")
|
||||||
extinguishers_location = models.CharField(blank=True, null=True, max_length=255, help_text="Location of fire extinguishers")
|
extinguishers_location = models.CharField(blank=True, default='', max_length=255, help_text="Location of fire extinguishers")
|
||||||
|
|
||||||
|
inverted_fields = []
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ['event']
|
||||||
|
permissions = [
|
||||||
|
('review_eventchecklist', 'Can review Event Checklists')
|
||||||
|
]
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.pk} - {self.event}"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def activity_feed_string(self):
|
||||||
|
return str(self.event)
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('ec_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
|
|
||||||
|
@reversion.register
|
||||||
|
class PowerTestRecord(ReviewableModel, RevisionMixin):
|
||||||
|
earth_fault_text = "Earth Fault Loop Impedance (Z<small>S</small>) / Ω"
|
||||||
|
pssc_text = "Prospective Short Circuit Current / A"
|
||||||
|
|
||||||
|
event = models.ForeignKey('Event', related_name='power_tests', on_delete=models.CASCADE)
|
||||||
|
power_mic = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='checklists',
|
||||||
|
verbose_name="Power MIC", on_delete=models.CASCADE, help_text="Who is the Power MIC?")
|
||||||
|
venue = models.ForeignKey('Venue', on_delete=models.CASCADE)
|
||||||
|
notes = models.TextField(blank=True, default='')
|
||||||
# Small Electrical Checks
|
# Small Electrical Checks
|
||||||
rcds = models.BooleanField(blank=True, null=True, help_text="RCDs installed where needed and tested?")
|
rcds = models.BooleanField(blank=True, null=True, help_text="RCDs installed where needed and tested?")
|
||||||
supply_test = models.BooleanField(blank=True, null=True, help_text="Electrical supplies tested?<br><small>(using socket tester)</small>")
|
supply_test = models.BooleanField(blank=True, null=True, help_text="Electrical supplies tested?<br><small>(using socket tester)</small>")
|
||||||
@@ -765,73 +909,62 @@ 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.IntegerField(blank=True, null=True, verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
fd_earth_fault = models.DecimalField(blank=True, null=True, max_digits=6, decimal_places=2, verbose_name="Earth Fault Loop Impedance", help_text=earth_fault_text)
|
||||||
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=pssc_text)
|
||||||
# Worst case points
|
# Worst case points
|
||||||
w1_description = models.CharField(blank=True, null=True, 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 / V")
|
||||||
w1_earth_fault = models.IntegerField(blank=True, null=True, help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
w1_earth_fault = models.DecimalField(blank=True, null=True, max_digits=6, decimal_places=2, verbose_name="Earth Fault Loop Impedance", help_text=earth_fault_text)
|
||||||
w2_description = models.CharField(blank=True, null=True, 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 / V")
|
||||||
w2_earth_fault = models.IntegerField(blank=True, null=True, help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
w2_earth_fault = models.DecimalField(blank=True, null=True, max_digits=6, decimal_places=2, verbose_name="Earth Fault Loop Impedance", help_text=earth_fault_text)
|
||||||
w3_description = models.CharField(blank=True, null=True, 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 / V")
|
||||||
w3_earth_fault = models.IntegerField(blank=True, null=True, help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
w3_earth_fault = models.DecimalField(blank=True, null=True, max_digits=6, decimal_places=2, verbose_name="Earth Fault Loop Impedance", help_text=earth_fault_text)
|
||||||
|
|
||||||
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>")
|
||||||
|
|
||||||
reviewed_at = models.DateTimeField(null=True)
|
|
||||||
reviewed_by = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True,
|
|
||||||
verbose_name="Reviewer", on_delete=models.CASCADE)
|
|
||||||
|
|
||||||
inverted_fields = []
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['event']
|
ordering = ['event']
|
||||||
permissions = [
|
permissions = [
|
||||||
('review_eventchecklist', 'Can review Event Checklists')
|
('review_power', 'Can review Power Test Records')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.pk} - {self.event}"
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('pt_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
def activity_feed_string(self):
|
||||||
return str(self.event)
|
return str(self.event)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return reverse_lazy('ec_detail', kwargs={'pk': self.pk})
|
class EventCheckIn(models.Model):
|
||||||
|
event = models.ForeignKey('Event', related_name='crew', on_delete=models.CASCADE)
|
||||||
|
person = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='checkins', on_delete=models.CASCADE)
|
||||||
|
time = models.DateTimeField()
|
||||||
|
role = models.CharField(max_length=50, blank=True)
|
||||||
|
vehicle = models.CharField(max_length=100, blank=True)
|
||||||
|
end_time = models.DateTimeField(null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%i - %s" % (self.pk, self.event)
|
return f"{self.person} on {self.event}"
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
|
||||||
class EventChecklistVehicle(models.Model, RevisionMixin):
|
|
||||||
checklist = models.ForeignKey('EventChecklist', related_name='vehicles', blank=True, on_delete=models.CASCADE)
|
|
||||||
vehicle = models.CharField(max_length=255)
|
|
||||||
driver = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='vehicles', on_delete=models.CASCADE)
|
|
||||||
|
|
||||||
reversion_hide = True
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "{} driven by {}".format(self.vehicle, str(self.driver))
|
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
|
||||||
class EventChecklistCrew(models.Model, RevisionMixin):
|
|
||||||
checklist = models.ForeignKey('EventChecklist', related_name='crew', blank=True, on_delete=models.CASCADE)
|
|
||||||
crewmember = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='crewed', on_delete=models.CASCADE)
|
|
||||||
role = models.CharField(max_length=255)
|
|
||||||
start = models.DateTimeField()
|
|
||||||
end = models.DateTimeField()
|
|
||||||
|
|
||||||
reversion_hide = True
|
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if self.start > self.end:
|
sass = " Please invent time travel and retry."
|
||||||
raise ValidationError('Unless you\'ve invented time travel, crew can\'t finish before they have started.')
|
if self.time > timezone.now():
|
||||||
|
raise ValidationError("May not check in in the future." + sass)
|
||||||
|
if self.end_time and self.end_time < self.time:
|
||||||
|
raise ValidationError("May not check out before you've checked in." + sass)
|
||||||
|
|
||||||
def __str__(self):
|
def get_absolute_url(self):
|
||||||
return "{} ({})".format(str(self.crewmember), self.role)
|
return reverse('event_detail', kwargs={'pk': self.event_id})
|
||||||
|
|
||||||
|
def active(self):
|
||||||
|
return end_time is not None
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from io import BytesIO
|
|||||||
|
|
||||||
from PyPDF2 import PdfFileReader, PdfFileMerger
|
from PyPDF2 import PdfFileReader, PdfFileMerger
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
from django.contrib.staticfiles import finders
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.core.mail import EmailMessage, EmailMultiAlternatives
|
from django.core.mail import EmailMessage, EmailMultiAlternatives
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
@@ -25,12 +25,6 @@ def send_eventauthorisation_success_email(instance):
|
|||||||
# Generate PDF first to prevent context conflicts
|
# Generate PDF first to prevent context conflicts
|
||||||
context = {
|
context = {
|
||||||
'object': instance.event,
|
'object': instance.event,
|
||||||
'fonts': {
|
|
||||||
'opensans': {
|
|
||||||
'regular': 'RIGS/static/fonts/OPENSANS-REGULAR.TTF',
|
|
||||||
'bold': 'RIGS/static/fonts/OPENSANS-BOLD.TTF',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'receipt': True,
|
'receipt': True,
|
||||||
'current_user': False,
|
'current_user': False,
|
||||||
}
|
}
|
||||||
@@ -60,23 +54,23 @@ def send_eventauthorisation_success_email(instance):
|
|||||||
elif instance.event.organisation is not None and instance.email == instance.event.organisation.email:
|
elif instance.event.organisation is not None and instance.email == instance.event.organisation.email:
|
||||||
context['to_name'] = instance.event.organisation.name
|
context['to_name'] = instance.event.organisation.name
|
||||||
|
|
||||||
subject = "N%05d | %s - Event Authorised" % (instance.event.pk, instance.event.name)
|
subject = f"{instance.event.display_id} | {instance.event.name} - Event Authorised"
|
||||||
|
|
||||||
client_email = EmailMultiAlternatives(
|
client_email = EmailMultiAlternatives(
|
||||||
subject,
|
subject,
|
||||||
get_template("eventauthorisation_client_success.txt").render(context),
|
get_template("email/eventauthorisation_client_success.txt").render(context),
|
||||||
to=[instance.email],
|
to=[instance.email],
|
||||||
reply_to=[settings.AUTHORISATION_NOTIFICATION_ADDRESS],
|
reply_to=[settings.AUTHORISATION_NOTIFICATION_ADDRESS],
|
||||||
)
|
)
|
||||||
|
|
||||||
css = staticfiles_storage.path('css/email.css')
|
css = finders.find('css/email.css')
|
||||||
html = Premailer(get_template("eventauthorisation_client_success.html").render(context),
|
html = Premailer(get_template("email/eventauthorisation_client_success.html").render(context),
|
||||||
external_styles=css).transform()
|
external_styles=css).transform()
|
||||||
client_email.attach_alternative(html, 'text/html')
|
client_email.attach_alternative(html, 'text/html')
|
||||||
|
|
||||||
escapedEventName = re.sub(r'[^a-zA-Z0-9 \n\.]', '', instance.event.name)
|
escapedEventName = re.sub(r'[^a-zA-Z0-9 \n\.]', '', instance.event.name)
|
||||||
|
|
||||||
client_email.attach('N%05d - %s - CONFIRMATION.pdf' % (instance.event.pk, escapedEventName),
|
client_email.attach(f'{instance.event.display_id} - {escapedEventName} - CONFIRMATION.pdf',
|
||||||
merged.getvalue(),
|
merged.getvalue(),
|
||||||
'application/pdf'
|
'application/pdf'
|
||||||
)
|
)
|
||||||
@@ -88,7 +82,7 @@ def send_eventauthorisation_success_email(instance):
|
|||||||
|
|
||||||
mic_email = EmailMessage(
|
mic_email = EmailMessage(
|
||||||
subject,
|
subject,
|
||||||
get_template("eventauthorisation_mic_success.txt").render(context),
|
get_template("email/eventauthorisation_mic_success.txt").render(context),
|
||||||
to=[mic_email_address]
|
to=[mic_email_address]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -122,13 +116,13 @@ def send_admin_awaiting_approval_email(user, request, **kwargs):
|
|||||||
}
|
}
|
||||||
|
|
||||||
email = EmailMultiAlternatives(
|
email = EmailMultiAlternatives(
|
||||||
"%s new users awaiting approval on RIGS" % (context['number_of_users']),
|
f"{context['number_of_users']} new users awaiting approval on RIGS",
|
||||||
get_template("admin_awaiting_approval.txt").render(context),
|
get_template("email/admin_awaiting_approval.txt").render(context),
|
||||||
to=[admin.email],
|
to=[admin.email],
|
||||||
reply_to=[user.email],
|
reply_to=[user.email],
|
||||||
)
|
)
|
||||||
css = staticfiles_storage.path('css/email.css')
|
css = finders.find('css/email.css')
|
||||||
html = Premailer(get_template("admin_awaiting_approval.html").render(context),
|
html = Premailer(get_template("email/admin_awaiting_approval.html").render(context),
|
||||||
external_styles=css).transform()
|
external_styles=css).transform()
|
||||||
email.attach_alternative(html, 'text/html')
|
email.attach_alternative(html, 'text/html')
|
||||||
email.send()
|
email.send()
|
||||||
|
|||||||
BIN
RIGS/static/imgs/assets.jpg
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
RIGS/static/imgs/logo.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
RIGS/static/imgs/logo.webp
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 63 KiB |
BIN
RIGS/static/imgs/rigs.jpg
Normal file
|
After Width: | Height: | Size: 278 KiB |
BIN
RIGS/static/imgs/tappytaptap.gif
Normal file
|
After Width: | Height: | Size: 5.4 MiB |
BIN
RIGS/static/imgs/training.jpg
Normal file
|
After Width: | Height: | Size: 852 KiB |
BIN
RIGS/static/imgs/wof2014-1-small.jpg
Normal file
|
After Width: | Height: | Size: 164 KiB |
6
RIGS/static/js/marked.min.js
vendored
Normal file
142
RIGS/templates/base_print.xml
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE document SYSTEM "rml.dtd">
|
||||||
|
<document filename="{{filename}}">
|
||||||
|
<docinit>
|
||||||
|
<registerTTFont faceName="OpenSans" fileName="static/fonts/OpenSans-Regular.tff"/>
|
||||||
|
<registerTTFont faceName="OpenSans-Bold" fileName="static/fonts/OpenSans-Bold.tff"/>
|
||||||
|
<registerFontFamily name="OpenSans" bold="OpenSans-Bold" boldItalic="OpenSans-Bold"/>
|
||||||
|
</docinit>
|
||||||
|
|
||||||
|
<stylesheet>
|
||||||
|
<initialize>
|
||||||
|
<color id="LightGray" RGB="#D3D3D3"/>
|
||||||
|
<color id="DarkGray" RGB="#707070"/>
|
||||||
|
<color id="Brand" RGB="#3853a4"/>
|
||||||
|
</initialize>
|
||||||
|
|
||||||
|
<paraStyle name="style.para" fontName="OpenSans" />
|
||||||
|
<paraStyle name="blockPara" spaceAfter="5" spaceBefore="5"/>
|
||||||
|
<paraStyle name="style.Heading1" fontName="OpenSans" fontSize="16" leading="18" spaceAfter="0"/>
|
||||||
|
<paraStyle name="style.Heading2" fontName="OpenSans-Bold" fontSize="10" spaceAfter="2"/>
|
||||||
|
<paraStyle name="style.Heading3" fontName="OpenSans" fontSize="10" spaceAfter="0"/>
|
||||||
|
<paraStyle name="center" alignment="center"/>
|
||||||
|
<paraStyle name="page-head" alignment="center" fontName="OpenSans-Bold" fontSize="16" leading="18" spaceAfter="0"/>
|
||||||
|
|
||||||
|
<paraStyle name="style.event_description" fontName="OpenSans" textColor="DarkGray" />
|
||||||
|
<paraStyle name="style.item_description" fontName="OpenSans" textColor="DarkGray" leftIndent="10" />
|
||||||
|
<paraStyle name="style.specific_description" fontName="OpenSans" textColor="DarkGray" fontSize="10" />
|
||||||
|
<paraStyle name="style.times" fontName="OpenSans" fontSize="10" />
|
||||||
|
<paraStyle name="style.head_titles" fontName="OpenSans-Bold" fontSize="10" />
|
||||||
|
<paraStyle name="style.head_numbers" fontName="OpenSans" fontSize="10" />
|
||||||
|
<paraStyle name="style.emheader" fontName="OpenSans" textColor="White" fontSize="12" backColor="Brand" leading="20" borderPadding="4"/>
|
||||||
|
<paraStyle name="style.breakbefore" parent="emheader" pageBreakBefore="1"/>
|
||||||
|
|
||||||
|
<blockTableStyle id="eventSpecifics">
|
||||||
|
<blockValign value="top"/>
|
||||||
|
<lineStyle kind="LINEAFTER" colorName="LightGrey" start="0,0" stop="1,0" thickness="1"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="headLayout">
|
||||||
|
<blockValign value="top"/>
|
||||||
|
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="eventDetails">
|
||||||
|
<blockValign value="top"/>
|
||||||
|
<blockTopPadding start="0,0" stop="-1,0" length="0"/>
|
||||||
|
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="itemTable">
|
||||||
|
<blockValign value="top"/>
|
||||||
|
<lineStyle kind="LINEBELOW" colorName="LightGrey" start="0,0" stop="-1,-1" thickness="1"/>
|
||||||
|
{#<lineStyle kind="box" colorName="black" thickness="1" start="0,0" stop="-1,-1"/>#}
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="totalTable">
|
||||||
|
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
||||||
|
<lineStyle kind="LINEBELOW" colorName="LightGrey" start="-2,0" stop="-1,-1" thickness="1"/>
|
||||||
|
{# <lineStyle cap="default" kind="grid" colorName="black" thickness="1" start="1,0" stop="-1,-1"/> #}
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="infoTable" keepWithNext="true">
|
||||||
|
<blockLeftPadding start="0,0" stop="-1,-1" length="0"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="paymentTable">
|
||||||
|
<blockBackground colorName="LightGray" start="0,1" stop="3,1"/>
|
||||||
|
<blockFont name="OpenSans-Bold" start="0,1" stop="0,1"/>
|
||||||
|
<blockFont name="OpenSans-Bold" start="2,1" stop="2,1"/>
|
||||||
|
<lineStyle kind="outline" colorName="black" thickness="1" start="0,1" stop="3,1"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<blockTableStyle id="signatureTable">
|
||||||
|
<blockTopPadding length="20" />
|
||||||
|
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
||||||
|
<lineStyle kind="linebelow" start="1,0" stop="1,0" colorName="black"/>
|
||||||
|
<lineStyle kind="linebelow" start="3,0" stop="3,0" colorName="black"/>
|
||||||
|
<lineStyle kind="linebelow" start="5,0" stop="5,0" colorName="black"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
|
||||||
|
<listStyle name="ol"
|
||||||
|
bulletFormat="%s."
|
||||||
|
bulletFontSize="10" />
|
||||||
|
|
||||||
|
<listStyle name="ul"
|
||||||
|
start="bulletchar"
|
||||||
|
bulletFontSize="10"/>
|
||||||
|
</stylesheet>
|
||||||
|
|
||||||
|
<template title="{{filename}}"> {# Note: page is 595x842 points (1 point=1/72in) #}
|
||||||
|
<pageTemplate id="Headed" >
|
||||||
|
<pageGraphics>
|
||||||
|
<image file="static/imgs/paperwork/corner-tr-su.jpg" x="395" y="642" height="200" width="200"/>
|
||||||
|
<image file="static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
||||||
|
|
||||||
|
{# logo positioned 42 from left, 33 from top #}
|
||||||
|
<image file="static/imgs/paperwork/tec-logo.jpg" x="42" y="719" height="90" width="84"/>
|
||||||
|
|
||||||
|
<setFont name="OpenSans-Bold" size="22.5" leading="10"/>
|
||||||
|
<drawString x="137" y="780">TEC PA & Lighting</drawString>
|
||||||
|
|
||||||
|
<setFont name="OpenSans" size="9"/>
|
||||||
|
<drawString x="137" y="760">Portland Building, University Park, Nottingham, NG7 2RD</drawString>
|
||||||
|
<drawString x="137" y="746">www.nottinghamtec.co.uk</drawString>
|
||||||
|
<drawString x="265" y="746">info@nottinghamtec.co.uk</drawString>
|
||||||
|
<drawString x="137" y="732">Phone: (0115) 846 8720</drawString>
|
||||||
|
|
||||||
|
<setFont name="OpenSans" size="10" />
|
||||||
|
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
||||||
|
<setFont name="OpenSans" size="7" />
|
||||||
|
<drawCenteredString x="302.5" y="26">
|
||||||
|
{{info_string}}
|
||||||
|
</drawCenteredString>
|
||||||
|
</pageGraphics>
|
||||||
|
|
||||||
|
<frame id="main" x1="50" y1="65" width="495" height="645"/>
|
||||||
|
</pageTemplate>
|
||||||
|
|
||||||
|
<pageTemplate id="Main">
|
||||||
|
<pageGraphics>
|
||||||
|
<image file="static/imgs/paperwork/corner-tr.jpg" x="395" y="642" height="200" width="200"/>
|
||||||
|
<image file="static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
||||||
|
|
||||||
|
<setFont name="OpenSans" size="10"/>
|
||||||
|
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
||||||
|
<setFont name="OpenSans" size="7" />
|
||||||
|
<drawCenteredString x="302.5" y="26">
|
||||||
|
{{info_string}}
|
||||||
|
</drawCenteredString>
|
||||||
|
</pageGraphics>
|
||||||
|
<frame id="main" x1="50" y1="65" width="495" height="727"/>
|
||||||
|
</pageTemplate>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<story firstPageTemplate="Headed">
|
||||||
|
<setNextFrame name="main"/>
|
||||||
|
<nextFrame/>
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
</story>
|
||||||
|
|
||||||
|
</document>
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
{% 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" href="/">RIGS</a>
|
<a class="navbar-brand" style="margin-left: auto; margin-right: auto;" href="/">RIGS</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block titleelements %}
|
{% block titleelements %}
|
||||||
@@ -31,27 +34,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% if perms.RIGS.view_riskassessment %}
|
{% if perms.RIGS.view_riskassessment %}
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item"><a class="nav-link" href="{% url 'hs_list' %}">H&S</a></li>
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownHS" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
H&S
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdownHS">
|
|
||||||
<a class="dropdown-item" href="{% url 'hs_list' %}"><span class="fas fa-eye"></span> Overview</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'ra_list' %}"><span class="fas fa-file-medical"></span> Risk Assessments</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'ec_list' %}"><span class="fas fa-tasks"></span> Event Checklists</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{% 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
|
Invoices <span class="badge {% if todo == 0 %}badge-success{% else %}badge-danger{% endif %} badge-pill">{{ todo }}</span>
|
||||||
</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" href="{% url 'invoice_waiting' %}"><span class="fas fa-briefcase text-danger"></span> Waiting</a>
|
<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>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<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_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_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>
|
||||||
@@ -74,6 +71,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
<script src="{% static 'js/popover.js' %}"></script>
|
<script src="{% static 'js/popover.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
{% block title %}Calendar{% endblock %}
|
{% block title %}Calendar{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
<link href="{% static 'css/main.min.css' %}" rel='stylesheet' />
|
<link href="{% static 'css/main.css' %}" rel='stylesheet' />
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="{% static 'js/moment.js' %}"></script>
|
<script src="{% static 'js/moment.js' %}"></script>
|
||||||
<script src="{% static 'js/main.min.js' %}"></script>
|
<script src="{% static 'js/main.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
viewToUrl = {
|
viewToUrl = {
|
||||||
'timeGridWeek':'week',
|
'timeGridWeek':'week',
|
||||||
@@ -27,15 +27,12 @@
|
|||||||
|
|
||||||
calendar = new FullCalendar.Calendar(calendarEl, {
|
calendar = new FullCalendar.Calendar(calendarEl, {
|
||||||
themeSystem: 'bootstrap',
|
themeSystem: 'bootstrap',
|
||||||
//defaultView: 'dayGridMonth', This is now default
|
|
||||||
aspectRatio: 1.5,
|
aspectRatio: 1.5,
|
||||||
eventTimeFormat: {
|
eventTimeFormat: {
|
||||||
'hour': '2-digit',
|
'hour': '2-digit',
|
||||||
'minute': '2-digit',
|
'minute': '2-digit',
|
||||||
'hour12': false
|
'hour12': false
|
||||||
},
|
},
|
||||||
//nowIndicator: true,
|
|
||||||
//firstDay: 1,
|
|
||||||
headerToolbar: false,
|
headerToolbar: false,
|
||||||
editable: false,
|
editable: false,
|
||||||
dayMaxEventRows: true, // allow "more" link when too many events
|
dayMaxEventRows: true, // allow "more" link when too many events
|
||||||
@@ -58,8 +55,10 @@
|
|||||||
};
|
};
|
||||||
$(doc).each(function() {
|
$(doc).each(function() {
|
||||||
end = $(this).attr('latest')
|
end = $(this).attr('latest')
|
||||||
|
allDay = false
|
||||||
if(end.indexOf("T") < 0){ //If latest does not contain a time
|
if(end.indexOf("T") < 0){ //If latest does not contain a time
|
||||||
end = moment(end).add(1, 'days') //End date is non-inclusive, so add a day
|
end = moment(end + " 23:59").format("YYYY-MM-DD[T]HH:mm:ss")
|
||||||
|
allDay = true
|
||||||
}
|
}
|
||||||
|
|
||||||
thisEvent = {
|
thisEvent = {
|
||||||
@@ -67,7 +66,8 @@
|
|||||||
'end': end,
|
'end': end,
|
||||||
'className': 'modal-href',
|
'className': 'modal-href',
|
||||||
'title': $(this).attr('title'),
|
'title': $(this).attr('title'),
|
||||||
'url': $(this).attr('url')
|
'url': $(this).attr('url'),
|
||||||
|
'allDay': allDay
|
||||||
}
|
}
|
||||||
|
|
||||||
if($(this).attr('is_rig')===true || $(this).attr('status') === "Cancelled"){
|
if($(this).attr('is_rig')===true || $(this).attr('status') === "Cancelled"){
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
{% extends 'base_client_email.html' %}
|
{% extends 'base_client_email.html' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<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>N{{ object.pk|stringformat:"05d" }}
|
<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>{{ object.person.name }}</b>{% endif %}.</p>
|
| {{ 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>
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
|
|
||||||
@@ -23,7 +21,7 @@
|
|||||||
<table border="0" cellspacing="0" cellpadding="0">
|
<table border="0" cellspacing="0" cellpadding="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="button" align="center">
|
<td class="button" align="center">
|
||||||
<a href="{{ request.scheme }}://{{ request.get_host }}{% url 'event_authorise' object.pk hmac %}">
|
<a href="{{ request.scheme }}://{{ request.get_host }}{% url target|default:'event_authorise' object.pk hmac %}">
|
||||||
Complete Authorisation Form
|
Complete Authorisation Form
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -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 {{ object.person.name }}{% 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 {% if object.person %}{{ object.person.name }}{% else %}{{ object.organisation.name }}{% endif %}{% 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 #}
|
||||||
5
RIGS/templates/email/eventauthorisation_mic_success.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Hi {{object.event.mic.get_full_name|default_if_none:"somebody"}},
|
||||||
|
|
||||||
|
Just to let you know your event N{{object.eventdisplay_id}} has been successfully authorised for £{{object.amount}} by {{object.name}} as of {{object.event.last_edited_at}}.
|
||||||
|
|
||||||
|
The TEC Rig Information Gathering System
|
||||||
16
RIGS/templates/email/ra_reminder.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{% extends 'base_client_email.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>Hi {{event.mic.get_full_name|default_if_none:"Productions Manager"}},</p>
|
||||||
|
|
||||||
|
{% if event.mic %}
|
||||||
|
<p>Just to let you know your event {{event.display_id}} <em>requires<em> a pre-event risk assessment completing prior to the event. Please do so as soon as possible.</p>
|
||||||
|
{% else %}
|
||||||
|
<p>This is a reminder that event {{event.display_id}} requires a MIC assigning and a risk assessment completing.</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<p>Fill it out here:</p>
|
||||||
|
<a href="{{url}}" class="btn btn-info"><span class="fas fa-paperclip"></span> Create Risk Assessment</a>
|
||||||
|
|
||||||
|
<p>TEC PA & Lighting</p>
|
||||||
|
{% endblock %}
|
||||||
9
RIGS/templates/email/ra_reminder.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Hi {{event.mic.get_full_name|default_if_none:"Productions Manager"}},
|
||||||
|
|
||||||
|
{% if event.mic %}
|
||||||
|
Just to let you know your event {{event.display_id}} requires a risk assessment completing prior to the event. Please do so as soon as possible.
|
||||||
|
{% else %}
|
||||||
|
This is a reminder that event {{event.display_id}} requires a MIC assigning and a risk assessment completing.
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
The TEC Rig Information Gathering System
|
||||||
5
RIGS/templates/estates/estates_event_list.html
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{% extends 'base_client.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% include 'estates/estates_event_table.html' %}
|
||||||
|
{% endblock %}
|
||||||
78
RIGS/templates/estates/estates_event_table.html
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
{% load namewithnotes from filters %}
|
||||||
|
{% load markdown_tags %}
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table mb-0" id="event_table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Dates & Times</th>
|
||||||
|
<th scope="col">Event Details</th>
|
||||||
|
<th scope="col">Status</th>
|
||||||
|
<th scope="col">Member In Charge</th>
|
||||||
|
<th scope="col">Power Plan</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for event in events %}
|
||||||
|
<tr {% if event.cancelled %}style="opacity: 50% !important;"{% endif %} id="event_row">
|
||||||
|
<!---Number-->
|
||||||
|
<th scope="row" id="event_number">{{ event.display_id }}</th>
|
||||||
|
<!--Dates & Times-->
|
||||||
|
<td id="event_dates" style="text-align: justify;">
|
||||||
|
<span class="text-nowrap">Start: <strong>{{ event.start_date|date:"D d/m/Y" }}
|
||||||
|
{% if event.has_start_time %}
|
||||||
|
{{ event.start_time|date:"H:i" }}
|
||||||
|
{% endif %}</strong>
|
||||||
|
</span>
|
||||||
|
{% if event.end_date %}
|
||||||
|
<br>
|
||||||
|
<span class="text-nowrap">End: {% if event.end_date != event.start_date %}<strong>{{ event.end_date|date:"D d/m/Y" }}{% endif %}
|
||||||
|
{% if event.has_end_time %}
|
||||||
|
{{ event.end_time|date:"H:i" }}
|
||||||
|
{% endif %}</strong>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<!---Details-->
|
||||||
|
<td id="event_details" class="w-100">
|
||||||
|
<h4>
|
||||||
|
{{ event.name }}
|
||||||
|
{% if event.venue %}
|
||||||
|
<small>at {{ event.venue }}</small>
|
||||||
|
{% endif %}
|
||||||
|
</h4>
|
||||||
|
{% if event.is_rig and not event.cancelled %}
|
||||||
|
<h5>
|
||||||
|
{{ event.person.name }}
|
||||||
|
{% if event.organisation %}
|
||||||
|
for {{ event.organisation.name }}
|
||||||
|
{% endif %}
|
||||||
|
</h5>
|
||||||
|
{% endif %}
|
||||||
|
{% if not event.cancelled and event.description %}
|
||||||
|
<p>{{ event.description|markdown }}</p>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ event.get_status_display }}
|
||||||
|
</td>
|
||||||
|
<!---MIC-->
|
||||||
|
<td id="event_mic" class="text-nowrap">
|
||||||
|
{% if event.mic %}
|
||||||
|
{{ event.mic }}
|
||||||
|
{% elif event.is_rig %}
|
||||||
|
<span class="fas fa-user-slash"></span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ event.riskassessment.power_plan|default:"Pending" }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% empty %}
|
||||||
|
<tr class="bg-warning">
|
||||||
|
<td colspan="4">No events found</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
@@ -5,11 +5,13 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
<link rel="stylesheet" href="{% static 'css/bootstrap-select.css' %}"/>
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" href="{% static 'css/selects.css' %}"/>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block preload_js %}
|
{% block preload_js %}
|
||||||
<script src="{% static 'js/bootstrap-select.js' %}"></script>
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/selects.js' %}" async></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -1,367 +0,0 @@
|
|||||||
{% extends request.is_ajax|yesno:'base_ajax.html,base_rigs.html' %}
|
|
||||||
{% load widget_tweaks %}
|
|
||||||
{% load static %}
|
|
||||||
{% load help_text from filters %}
|
|
||||||
{% load profile_by_index from filters %}
|
|
||||||
{% load button from filters %}
|
|
||||||
|
|
||||||
{% block css %}
|
|
||||||
{{ block.super }}
|
|
||||||
<link rel="stylesheet" href="{% static 'css/bootstrap-select.css' %}"/>
|
|
||||||
<link rel="stylesheet" href="{% static 'css/ajax-bootstrap-select.css' %}"/>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block preload_js %}
|
|
||||||
{{ block.super }}
|
|
||||||
<script src="{% static 'js/bootstrap-select.js' %}"></script>
|
|
||||||
<script src="{% static 'js/ajax-bootstrap-select.js' %}"></script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block js %}
|
|
||||||
{{ block.super }}
|
|
||||||
<script src="{% static 'js/jquery-ui.js' %}"></script><!--TODO optimise-->
|
|
||||||
<script src="{% static 'js/interaction.js' %}"></script>
|
|
||||||
<script src="{% static 'js/modal.js' %}"></script>
|
|
||||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
|
||||||
|
|
||||||
<script src="{% static 'js/autocompleter.js' %}"></script>
|
|
||||||
|
|
||||||
{% include 'partials/datetime-fix.html' %}
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
$('button[data-action=add]').on('click', function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
let target = $($(this).attr('data-target'));
|
|
||||||
let newID = Number(target.attr('data-pk'));
|
|
||||||
let newRow = $($(this).attr('data-clone'))
|
|
||||||
.clone().attr('style', "")
|
|
||||||
.attr('id', function(i, val){
|
|
||||||
return val.split("_")[0] + '_' + newID;
|
|
||||||
})
|
|
||||||
.appendTo(target);
|
|
||||||
newRow.find('select,input').attr('name', function(i, val){
|
|
||||||
return val.split("_")[0] + '_' + newID;
|
|
||||||
})//Disabled is to prevent the hidden row being sent to the form
|
|
||||||
.removeAttr('disabled');
|
|
||||||
newRow.find('button[data-action=delete]').attr('data-id', newID);
|
|
||||||
newRow.find('select').addClass('selectpicker');
|
|
||||||
newRow.find('.selectpicker').selectpicker('refresh');
|
|
||||||
$(".selectpicker").each(function(){initPicker($(this))});
|
|
||||||
initDatetime();
|
|
||||||
$(target).attr('data-pk', newID - 1);
|
|
||||||
});
|
|
||||||
$(document).on('click', 'button[data-action=delete]', function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
$(this).closest('tr').remove();
|
|
||||||
});
|
|
||||||
//Somewhat rudimentary way of ensuring people fill in completely (if it hits the database validation the whole table row disappears when the page reloads...)
|
|
||||||
//the not is to avoid adding it to some of bootstrap-selects extra crap
|
|
||||||
$('#vehiclest,#crewmemberst').on('change', 'select,input', function () {
|
|
||||||
$(this).closest('tr').find("select,input").not(':input[type=search]').attr('required', 'true');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="col-12">
|
|
||||||
{% include 'form_errors.html' %}
|
|
||||||
{% if edit %}
|
|
||||||
<form role="form" method="POST" action="{% url 'ec_edit' pk=object.pk %}">
|
|
||||||
{% else %}
|
|
||||||
<form role="form" method="POST" action="{% url 'event_ec' pk=event.pk %}">
|
|
||||||
{% endif %}
|
|
||||||
<input type="hidden" name="{{ form.event.name }}" id="{{ form.event.id_for_label }}"
|
|
||||||
value="{{event.pk}}"/>
|
|
||||||
{% csrf_token %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">Event Information</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<dl class="row">
|
|
||||||
<dt class="col-4">Event Date</dt>
|
|
||||||
<dd class="col-8">{{ event.start_date}}{%if event.end_date %}-{{ event.end_date}}{%endif%}</dd>
|
|
||||||
<dt class="col-4">Event Name</dt>
|
|
||||||
<dd class="col-8">{{ event.name }}</dd>
|
|
||||||
<dt class="col-4">Client</dt>
|
|
||||||
<dd class="col-8">{{ event.person }}</dd>
|
|
||||||
<dt class="col-4">Event Size</dt>
|
|
||||||
<dd class="col-8">{% include 'partials/event_size.html' with object=event.riskassessment %}</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="form-group form-row">
|
|
||||||
<label for="{{ form.date.id_for_label }}"
|
|
||||||
class="col-4 col-form-label">{{ form.date.label }}</label>
|
|
||||||
{% if not form.date.value %}
|
|
||||||
{% render_field form.date class+="form-control col-8" value=event.start_date %}
|
|
||||||
{% else %}
|
|
||||||
{% render_field form.date class+="form-control col-8" %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div class="form-group form-row" id="{{ form.venue.id_for_label }}-group">
|
|
||||||
<label for="{{ form.venue.id_for_label }}"
|
|
||||||
class="col-4 col-form-label">{{ form.venue.label }}</label>
|
|
||||||
<select id="{{ form.venue.id_for_label }}" name="{{ form.venue.name }}" class="form-control selectpicker col-8" data-live-search="true" data-sourceurl="{% url 'api_secure' model='venue' %}">
|
|
||||||
{% if venue %}
|
|
||||||
<option value="{{venue.pk}}" selected="selected">{{ venue.name }}</option>
|
|
||||||
{% elif event.venue %}
|
|
||||||
<option value="{{event.venue.pk}}" selected="selected">{{ event.venue.name }}</option>
|
|
||||||
{% endif %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group form-row" id="{{ form.power_mic.id_for_label }}-group">
|
|
||||||
<label for="{{ form.power_mic.id_for_label }}"
|
|
||||||
class="col-4 col-form-label">{{ form.power_mic.help_text }}</label>
|
|
||||||
<select id="{{ form.power_mic.id_for_label }}" name="{{ form.power_mic.name }}" class="form-control selectpicker col-8" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" required="true">
|
|
||||||
{% if power_mic %}
|
|
||||||
<option value="{{power_mic.pk}}" selected="selected">{{ power_mic.name }}</option>
|
|
||||||
{% elif event.riskassessment.power_mic %}
|
|
||||||
<option value="{{event.riskassessment.power_mic.pk}}" selected="selected">{{ event.riskassessment.power_mic.name }}</option>
|
|
||||||
{% endif %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<p class="pt-3 font-weight-bold">List vehicles and their drivers</p>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-sm">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Vehicle</th>
|
|
||||||
<th scope="col">Driver</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="vehiclest" data-pk="-1">
|
|
||||||
<tr id="vehicles_new" style="display: none;">
|
|
||||||
<td><input type="text" class="form-control" name="vehicle_new" disabled="true"/></td>
|
|
||||||
<td><select class="form-control" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" name="driver_new" disabled="true"></select></td>
|
|
||||||
<td><button type="button" class="btn btn-danger btn-sm mt-1" data-action='delete' data-target='#vehicle'><span class="fas fa-times"></span></button></td>
|
|
||||||
</tr>
|
|
||||||
{% for i in object.vehicles.all %}
|
|
||||||
<tr id="vehicles_{{i.pk}}">
|
|
||||||
<td><input name="vehicle_{{i.pk}}" type="text" class="form-control" value="{{ i.vehicle }}"/></td>
|
|
||||||
<td>
|
|
||||||
<select name="driver_{{i.pk}}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
|
||||||
{% if i.driver != '' %}
|
|
||||||
<option value="{{i.driver.pk}}" selected="selected">{{ i.driver.name }}</option>
|
|
||||||
{% endif %}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td><button type="button" class="btn btn-danger btn-sm mt-1" data-id='{{i.pk}}' data-action='delete' data-target='#vehicle'><span class="fas fa-times"></span></button></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="text-right">
|
|
||||||
<button type="button" class="btn btn-secondary" id="vehicle-add" data-action='add' data-target='#vehiclest' data-clone='#vehicles_new'><span class="fas fa-plus"></span> Add Vehicle</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row my-3">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">Safety Checks</div>
|
|
||||||
<div class="card-body">
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.safe_parking %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.safe_packing %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.exits %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.trip_hazard %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.warning_signs %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.ear_plugs %}
|
|
||||||
<div class="row pt-3">
|
|
||||||
<label class="col-5" for="{{ form.hs_location.id_for_label }}">{{ form.hs_location.help_text }}</label>
|
|
||||||
{% render_field form.hs_location class+="form-control col-7 col-md-4" %}
|
|
||||||
</div>
|
|
||||||
<div class="row pt-1">
|
|
||||||
<label class="col-5" for="{{ form.extinguishers_location.id_for_label }}">{{ form.extinguishers_location.help_text }}</label>
|
|
||||||
{% render_field form.extinguishers_location class+="form-control col-7 col-md-4" %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row my-3">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">Crew Record</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-sm">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Person</th>
|
|
||||||
<th scope="col">Start Time</th>
|
|
||||||
<th scope="col">Role</th>
|
|
||||||
<th scope="col">End Time</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="crewmemberst" data-pk="-1">
|
|
||||||
<tr id="crew_new" style="display: none;">
|
|
||||||
<td>
|
|
||||||
<select name="crewmember_new" class="form-control" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" disabled="true"></select>
|
|
||||||
</td>
|
|
||||||
<td style="min-width: 15ch"><input name="start_new" type="datetime-local" class="form-control" value="{{ i.start }}" disabled=""/></td>
|
|
||||||
<td style="min-width: 15ch"><input name="role_new" type="text" class="form-control" value="{{ i.role }}" disabled="true"/></td>
|
|
||||||
<td style="min-width: 15ch"><input name="end_new" type="datetime-local" class="form-control" value="{{ i.end }}" disabled="true" /></td>
|
|
||||||
<td><button type="button" class="btn btn-danger btn-sm mt-1" data-id='{{crew.pk}}' data-action='delete' data-target='#crewmember'><span class="fas fa-times"></span></button></td>
|
|
||||||
</tr>
|
|
||||||
{% for crew in object.crew.all %}
|
|
||||||
<tr id="crew_{{crew.pk}}">
|
|
||||||
<td>
|
|
||||||
<select name="crewmember_{{crew.pk}}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
|
||||||
{% if crew.crewmember != '' %}
|
|
||||||
<option value="{{crew.crewmember.pk}}" selected="selected">{{ crew.crewmember.name }}</option>
|
|
||||||
{% endif %}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td><input name="start_{{crew.pk}}" type="datetime-local" class="form-control" value="{{ crew.start|date:'Y-m-d' }}T{{ crew.start|date:'H:i:s' }}"/></td>
|
|
||||||
<td><input name="role_{{crew.pk}}" type="text" class="form-control" value="{{ crew.role }}"/></td>
|
|
||||||
<td><input name="end_{{crew.pk}}" type="datetime-local" class="form-control" value="{{ crew.end|date:'Y-m-d' }}T{{ crew.end|date:'H:i:s' }}"/></td>
|
|
||||||
<td><button type="button" class="btn btn-danger btn-sm mt-1" data-id='{{crew.pk}}' data-action='delete' data-target='#crewmember'><span class="fas fa-times"></span></button></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
<div class="text-right">
|
|
||||||
<button type="button" class="btn btn-secondary" data-action='add' data-target='#crewmemberst' data-clone='#crew_new'><span class="fas fa-plus"></span> Add Crewmember</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% if event.riskassessment.event_size == 0 %}
|
|
||||||
<div class="row my-3" id="size-0">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="card border-success">
|
|
||||||
<div class="card-header">Electrical Checks <small>for ‘Small’ TEC Events <6kVA (approx. 26A)</small></div>
|
|
||||||
<div class="card-body">
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.rcds %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.supply_test %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.earthing %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.pat %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% elif event.riskassessment.event_size == 1 %}
|
|
||||||
<div class="row my-3" id="size-1">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="card border-warning">
|
|
||||||
<div class="card-header">Electrical Checks <small>for ‘Medium’ TEC Events </small></div>
|
|
||||||
<div class="card-body">
|
|
||||||
{% 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.earthing %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.pat %}
|
|
||||||
<hr>
|
|
||||||
<p>Tests at first distro</p>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-bordered table-sm">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" class="text-center">Test</th>
|
|
||||||
<th scope="col" colspan="3" class="text-center">Value</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th scope="row" rowspan="2">Voltage<br><small>(cube meter)</small></th>
|
|
||||||
<th class="text-center">{{ form.fd_voltage_l1.help_text }}</th>
|
|
||||||
<th class="text-center">{{ form.fd_voltage_l2.help_text }}</th>
|
|
||||||
<th class="text-center">{{ form.fd_voltage_l3.help_text }}</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>{% render_field form.fd_voltage_l1 class+="form-control" style="min-width: 5rem;" %}</td>
|
|
||||||
<td>{% render_field form.fd_voltage_l2 class+="form-control" style="min-width: 5rem;" %}</td>
|
|
||||||
<td>{% render_field form.fd_voltage_l3 class+="form-control" style="min-width: 5rem;" %}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{form.fd_phase_rotation.help_text|safe}}</th>
|
|
||||||
<td colspan="3">{% include 'partials/checklist_checkbox.html' with formitem=form.fd_phase_rotation %}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{form.fd_earth_fault.help_text|safe}}</th>
|
|
||||||
<td colspan="3">{% render_field form.fd_earth_fault class+="form-control" %}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{form.fd_pssc.help_text|safe}}</th>
|
|
||||||
<td colspan="3">{% render_field form.fd_pssc class+="form-control" %}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
<p>Tests at 'Worst Case' points (at least 1 point required)</p>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-bordered">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" class="text-center">Test</th>
|
|
||||||
<th scope="col" class="text-center">Point 1</th>
|
|
||||||
<th scope="col" class="text-center">Point 2</th>
|
|
||||||
<th scope="col" class="text-center">Point 3</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{form.w1_description.help_text|safe}}</th>
|
|
||||||
<td>{% render_field form.w1_description class+="form-control" style="min-width: 5rem;" %}</td>
|
|
||||||
<td>{% render_field form.w2_description class+="form-control" style="min-width: 5rem;" %}</td>
|
|
||||||
<td>{% render_field form.w3_description class+="form-control" style="min-width: 5rem;" %}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{form.w1_polarity.help_text|safe}}</th>
|
|
||||||
<td>{% render_field form.w1_polarity %}</td>
|
|
||||||
<td>{% render_field form.w2_polarity %}</td>
|
|
||||||
<td>{% render_field form.w3_polarity %}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{form.w1_voltage.help_text|safe}}</th>
|
|
||||||
<td>{% render_field form.w1_voltage class+="form-control" %}</td>
|
|
||||||
<td>{% render_field form.w2_voltage class+="form-control" %}</td>
|
|
||||||
<td>{% render_field form.w3_voltage class+="form-control" %}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{form.w1_earth_fault.help_text|safe}}</th>
|
|
||||||
<td>{% render_field form.w1_earth_fault class+="form-control" %}</td>
|
|
||||||
<td>{% render_field form.w2_earth_fault class+="form-control" %}</td>
|
|
||||||
<td>{% render_field form.w3_earth_fault class+="form-control" %}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.all_rcds_tested %}
|
|
||||||
{% include 'partials/checklist_checkbox.html' with formitem=form.public_sockets_tested %}
|
|
||||||
{% include 'partials/ec_power_info.html' %}
|
|
||||||
</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 %}
|
|
||||||
<div class="row mt-3">
|
|
||||||
<div class="col-sm-12 text-right">
|
|
||||||
{% button 'submit' %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,71 +1,22 @@
|
|||||||
{% 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 namewithnotes from filters %}
|
|
||||||
|
|
||||||
{% block title %}{% if object.is_rig %}N{{ object.pk|stringformat:"05d" }}{% else %}{{ object.pk }}{% endif %} | {{object.name}}{% endblock %}
|
{% load markdown_tags %}
|
||||||
|
{% load button from filters %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row my-3 py-3">
|
<div class="row my-3 py-3">
|
||||||
{% if not request.is_ajax %}
|
{% if not request.is_ajax %}
|
||||||
<div class="col-sm-12">
|
|
||||||
<h1>
|
|
||||||
{% if object.is_rig %}N{{ object.pk|stringformat:"05d" }}{% else %}{{ object.pk }}{% endif %}
|
|
||||||
| {{ object.name }} {% if event.dry_hire %}<span class="badge badge-secondary">Dry Hire</span>{% endif %}
|
|
||||||
</h1>
|
|
||||||
</div>
|
|
||||||
{% if perms.RIGS.view_event %}
|
{% if perms.RIGS.view_event %}
|
||||||
<div class="col-sm-12 text-right">
|
<div class="col-sm-12 text-right">
|
||||||
{% include 'event_detail_buttons.html' %}
|
{% include 'partials/event_detail_buttons.html' %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% 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">
|
||||||
{% if event.person %}
|
{% include 'partials/contact_details.html' %}
|
||||||
<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">
|
||||||
@@ -85,7 +36,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not request.is_ajax and perms.RIGS.view_event %}
|
{% if not request.is_ajax and perms.RIGS.view_event %}
|
||||||
<div class="col-sm-12 text-right">
|
<div class="col-sm-12 text-right">
|
||||||
{% include 'event_detail_buttons.html' %}
|
{% include 'partials/event_detail_buttons.html' %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if event.is_rig %}
|
{% if event.is_rig %}
|
||||||
@@ -96,16 +47,53 @@
|
|||||||
{% 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|linebreaksbr }}</p>
|
<p class="dont-break-out">{{ event.notes|markdown }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br>
|
<br>
|
||||||
{% include 'item_table.html' %}
|
{% include 'partials/item_table.html' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if event.can_check_in %}
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="card mt-3">
|
||||||
|
<div class="card-header">Crew Record</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-sm">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Name</th>
|
||||||
|
<th scope="col">Vehicle</th>
|
||||||
|
<th scope="col">Start Time</th>
|
||||||
|
<th scope="col">Role</th>
|
||||||
|
<th scope="col">End Time</th>
|
||||||
|
<th scope="col">{% if request.user.pk is event.mic.pk %}<a href="{% url 'event_checkin_override' event.pk %}" class="btn btn-sm btn-success"><span class="fas fa-plus"></span> Add</a>{% endif %}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="crewmembers">
|
||||||
|
{% for crew in object.crew.all %}
|
||||||
|
<tr>
|
||||||
|
<td>{{crew.person}}</td>
|
||||||
|
<td>{{crew.vehicle|default:"None"}}</td>
|
||||||
|
<td>{{crew.time}}</td>
|
||||||
|
<td>{{crew.role}}</td>
|
||||||
|
<td>{% if crew.end_time %}{{crew.end_time}}{% else %}<span class="text-success fas fa-clock" data-toggle="tooltip" title="This person is currently checked into this event"></span>{% endif %}</td>
|
||||||
|
<td>{% if crew.end_time %}{% if crew.person.pk == request.user.pk or event.mic.pk == request.user.pk %}{% button 'edit' 'edit_checkin' crew.pk clazz='btn-sm modal-href' %}{% endif %}{%endif%}</td>
|
||||||
|
</tr>
|
||||||
|
{% empty %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="text-center bg-warning">Apparently this event happened by magic...</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% if not request.is_ajax and perms.RIGS.view_event %}
|
{% if not request.is_ajax and perms.RIGS.view_event %}
|
||||||
<div class="col-sm-12 text-right">
|
<div class="col-sm-12 text-right">
|
||||||
{% include 'event_detail_buttons.html' %}
|
{% include 'partials/event_detail_buttons.html' %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -1,100 +1,89 @@
|
|||||||
{% extends 'base_embed.html' %}
|
{% extends 'base_embed.html' %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% block content %}
|
{% block extra-head %}
|
||||||
<div class="row">
|
<link href="{% static 'fontawesome_free/css/fontawesome.css' %}" rel="stylesheet" type="text/css">
|
||||||
<div class="col-sm-12">
|
<link href="{% static 'fontawesome_free/css/solid.css' %}" rel="stylesheet" type="text/css">
|
||||||
<a href="/">
|
{% endblock %}
|
||||||
<span class="source"> R<small>ig</small> I<small>nformation</small> G<small>athering</small> S<small>ystem</small></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-sm-12">
|
{% block content %}
|
||||||
<span class="pull-right">
|
<span class="float-right">
|
||||||
{% if object.mic %}
|
{% if object.mic %}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<img src="{{ object.mic.profile_picture }}" class="event-mic-photo rounded"/>
|
<img src="{{ object.mic.profile_picture }}" class="event-mic-photo rounded"/>
|
||||||
</div>
|
</div>
|
||||||
{% elif object.is_rig %}
|
{% elif object.is_rig %}
|
||||||
<span class="fas fa-exclamation-sign"></span>
|
<span class="fas fa-exclamation-sign"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<h3>
|
<h3>
|
||||||
<a href="{% url 'event_detail' object.pk %}">
|
<a href="{% url 'event_detail' object.pk %}">{{ object.display_id }} | {{ object.name }}</a>
|
||||||
{% if object.is_rig %}N{{ object.pk|stringformat:"05d" }}{% else %}{{ object.pk }}{% endif %}
|
{% if object.venue %}
|
||||||
| {{ object.name }} </a>
|
<small>at {{ object.venue }}</small>
|
||||||
{% if object.venue %}
|
{% endif %}
|
||||||
<small>at {{ object.venue }}</small>
|
<br/><small>
|
||||||
{% endif %}
|
|
||||||
<br/><small>
|
|
||||||
{{ object.start_date|date:"D d/m/Y" }}
|
{{ object.start_date|date:"D d/m/Y" }}
|
||||||
{% if object.has_start_time %}
|
{% if object.has_start_time %}
|
||||||
{{ object.start_time|date:"H:i" }}
|
{{ object.start_time|date:"H:i" }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if object.end_date or object.has_end_time %}
|
{% if object.end_date or object.has_end_time %}
|
||||||
–
|
–
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if object.end_date and object.end_date != object.start_date %}
|
{% if object.end_date and object.end_date != object.start_date %}
|
||||||
{{ object.end_date|date:"D d/m/Y" }}
|
{{ object.end_date|date:"D d/m/Y" }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if object.has_end_time %}
|
{% if object.has_end_time %}
|
||||||
{{ object.end_time|date:"H:i" }}
|
{{ object.end_time|date:"H:i" }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</small>
|
</small>
|
||||||
</h3>
|
</h3>
|
||||||
|
{% include 'partials/event_status.html' %}
|
||||||
<div class="row">
|
<div class="row ml-2">
|
||||||
<div class="col-xs-6">
|
<div class="col-xs-6 pr-2">
|
||||||
<p>
|
|
||||||
<strong>Status:</strong>
|
|
||||||
{{ object.get_status_display }}
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
{% if object.is_rig %}
|
|
||||||
<strong>Client:</strong> {{ object.person.name }}
|
|
||||||
{% if object.organisation %}
|
|
||||||
for {{ object.organisation.name }}
|
|
||||||
{% endif %}
|
|
||||||
{% if object.dry_hire %}(Dry Hire){% endif %}
|
|
||||||
{% else %}
|
|
||||||
<strong>Non-Rig</strong>
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<strong>MIC:</strong>
|
|
||||||
{% if object.mic %}
|
|
||||||
{{object.mic.name}}
|
|
||||||
{% else %}
|
|
||||||
None
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="col-xs-6">
|
|
||||||
{% if object.meet_at %}
|
|
||||||
<p>
|
|
||||||
<strong>Crew meet:</strong>
|
|
||||||
{{ object.meet_at|date:"H:i" }} {{ object.meet_at|date:"(Y-m-d)" }}
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
{% if object.access_at %}
|
|
||||||
<p>
|
|
||||||
<strong>Access at:</strong>
|
|
||||||
{{ object.access_at|date:"H:i" }} {{ object.access_at|date:"(Y-m-d)" }}
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
<p>
|
|
||||||
<strong>Last updated:</strong>
|
|
||||||
{{ object.last_edited_at }} by "{{ object.last_edited_by.initials }}"
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% if object.description %}
|
|
||||||
<p>
|
<p>
|
||||||
<strong>Description: </strong>
|
{% if object.is_rig %}
|
||||||
{{ object.description|linebreaksbr }}
|
<strong>Client:</strong> {{ object.person.name }}
|
||||||
|
{% if object.organisation %}
|
||||||
|
for {{ object.organisation.name }}
|
||||||
|
{% endif %}
|
||||||
|
{% if object.dry_hire %}(Dry Hire){% endif %}
|
||||||
|
{% else %}
|
||||||
|
<strong>Non-Rig</strong>
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
<p>
|
||||||
|
<strong>MIC:</strong>
|
||||||
|
{% if object.mic %}
|
||||||
|
{{object.mic.name}}
|
||||||
|
{% else %}
|
||||||
|
None
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-6 px-2">
|
||||||
|
{% if object.meet_at %}
|
||||||
|
<p>
|
||||||
|
<strong>Crew meet:</strong>
|
||||||
|
{{ object.meet_at|date:"H:i" }} {{ object.meet_at|date:"(Y-m-d)" }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if object.access_at %}
|
||||||
|
<p>
|
||||||
|
<strong>Access at:</strong>
|
||||||
|
{{ object.access_at|date:"H:i" }} {{ object.access_at|date:"(Y-m-d)" }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
<p>
|
||||||
|
<strong>Last updated:</strong>
|
||||||
|
{{ object.last_edited_at }} by "{{ object.last_edited_by.initials }}"
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% if object.description %}
|
||||||
|
<p>
|
||||||
|
<strong>Description: </strong>
|
||||||
|
{{ object.description|linebreaksbr }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -7,44 +7,46 @@
|
|||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<link rel="stylesheet" href="{% static 'css/bootstrap-select.css' %}"/>
|
<link rel="stylesheet" type="text/css" href="{% static 'css/selects.css' %}"/>
|
||||||
<link rel="stylesheet" href="{% static 'css/ajax-bootstrap-select.css' %}"/>
|
<link rel="stylesheet" type="text/css" href="{% static 'css/easymde.min.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'css/flatpickr.css' %}"/>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block preload_js %}
|
{% block preload_js %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script src="{% static 'js/bootstrap-select.js' %}"></script>
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
<script src="{% static 'js/ajax-bootstrap-select.js' %}"></script>
|
<script src="{% static 'js/easymde.min.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script src="{% static 'js/jquery-ui.js' %}"></script><!--TODO optimise--->
|
|
||||||
<script src="{% static 'js/interaction.js' %}"></script>
|
|
||||||
<script src="{% static 'js/modal.js' %}"></script>
|
|
||||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
|
||||||
|
|
||||||
<script src="{% static 'js/autocompleter.js' %}"></script>
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
|
<script src="{% static 'js/interaction.js' %}"></script>
|
||||||
{% include 'partials/datetime-fix.html' %}
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const matches = window.matchMedia("(prefers-reduced-motion: reduce)").matches || window.matchMedia("(update: slow)").matches;
|
const matches = window.matchMedia("(prefers-reduced-motion: reduce)").matches || window.matchMedia("(update: slow)").matches;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
dur = matches ? 0 : 500;
|
dur = matches ? 0 : 500;
|
||||||
{% if not object.pk and not form.errors %}
|
{% if object.pk %}
|
||||||
$('.form-hws').slideUp(dur, function () {
|
// Editing
|
||||||
$('.form-is_rig').slideUp(dur);
|
{% if not object.is_rig %}
|
||||||
});
|
|
||||||
{% elif not object.pk and form.errors %}
|
|
||||||
if ($('#{{form.is_rig.auto_id}}').attr('checked') !== 'checked') {
|
|
||||||
$('.form-is_rig').hide();
|
$('.form-is_rig').hide();
|
||||||
}
|
{% endif %}
|
||||||
{% endif %}
|
//Creation
|
||||||
{% if not object.pk %}
|
{% 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') {
|
||||||
|
$('.form-is_rig').hide();
|
||||||
|
}
|
||||||
|
{% else %}
|
||||||
|
//Initial hide
|
||||||
|
$('.form-hws').slideUp(dur);
|
||||||
|
{% endif %}
|
||||||
|
//Button handling
|
||||||
$('#is_rig-selector button').on('click', function () {
|
$('#is_rig-selector button').on('click', function () {
|
||||||
$('.form-non_rig').slideDown(dur);
|
$('.form-non_rig').slideDown(dur); //Non rig stuff also needed for rig, so always slide down
|
||||||
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')) {
|
||||||
@@ -54,7 +56,6 @@
|
|||||||
}
|
}
|
||||||
$('.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);
|
||||||
}
|
}
|
||||||
@@ -62,24 +63,27 @@
|
|||||||
{% 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 'item_modal.html' %}
|
{% include 'partials/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">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@@ -118,7 +122,7 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-9 col-md-7 col-lg-8">
|
<div class="col-sm-9 col-md-7 col-lg-8">
|
||||||
<select id="{{ form.person.id_for_label }}" name="{{ form.person.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='person' %}">
|
<select id="{{ form.person.id_for_label }}" name="{{ form.person.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='person' %}">
|
||||||
{% if person %}
|
{% if person %}
|
||||||
<option value="{{form.person.value}}" selected="selected" data-update_url="{% url 'person_update' form.person.value %}">{{ person }}</option>
|
<option value="{{form.person.value}}" selected="selected" data-update_url="{% url 'person_update' form.person.value %}">{{ person }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -145,7 +149,7 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-9 col-md-7 col-lg-8">
|
<div class="col-sm-9 col-md-7 col-lg-8">
|
||||||
<select id="{{ form.organisation.id_for_label }}" name="{{ form.organisation.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='organisation' %}" >
|
<select id="{{ form.organisation.id_for_label }}" name="{{ form.organisation.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='organisation' %}" >
|
||||||
{% if organisation %}
|
{% if organisation %}
|
||||||
<option value="{{form.organisation.value}}" selected="selected" data-update_url="{% url 'organisation_update' form.organisation.value %}">{{ organisation }}</option>
|
<option value="{{form.organisation.value}}" selected="selected" data-update_url="{% url 'organisation_update' form.organisation.value %}">{{ organisation }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -174,7 +178,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-8">
|
<div class="col-sm-12">
|
||||||
{% render_field form.description class+="form-control" %}
|
{% render_field form.description class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -203,9 +207,9 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-9 col-md-7 col-lg-8">
|
<div class="col-sm-9 col-md-7 col-lg-8">
|
||||||
<select id="{{ form.venue.id_for_label }}" name="{{ form.venue.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='venue' %}">
|
<select id="{{ form.venue.id_for_label }}" name="{{ form.venue.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='venue' %}">
|
||||||
{% if venue %}
|
{% if venue %}
|
||||||
<option value="{{form.venue.value}}" selected="selected" data-update_url="{% url 'venue_update' form.venue.value %}">{{ venue }}</option>
|
<option value="{{venue.id}}" selected="selected" data-update_url="{% url 'venue_update' venue.id %}">{{ venue }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -227,7 +231,7 @@
|
|||||||
<label for="{{ form.start_date.id_for_label }}"
|
<label for="{{ form.start_date.id_for_label }}"
|
||||||
class="col-sm-4 col-form-label">{{ form.start_date.label }}</label>
|
class="col-sm-4 col-form-label">{{ form.start_date.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-10">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="Start date for event, required">
|
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="Start date for event, required">
|
||||||
{% render_field form.start_date class+="form-control" %}
|
{% render_field form.start_date class+="form-control" %}
|
||||||
@@ -242,7 +246,7 @@
|
|||||||
<label for="{{ form.end_date.id_for_label }}"
|
<label for="{{ form.end_date.id_for_label }}"
|
||||||
class="col-sm-4 col-form-label">{{ form.end_date.label }}</label>
|
class="col-sm-4 col-form-label">{{ form.end_date.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-10">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="End date of event, leave blank if unknown or same as start date">
|
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="End date of event, leave blank if unknown or same as start date">
|
||||||
{% render_field form.end_date class+="form-control" %}
|
{% render_field form.end_date class+="form-control" %}
|
||||||
@@ -273,10 +277,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-4 col-sm-8">
|
<div class="col-sm-offset-4 col-sm-8">
|
||||||
<div class="checkbox">
|
|
||||||
<label data-toggle="tooltip" title="Mark this event as a dry-hire, so it needs to be checked in at the end">
|
<label data-toggle="tooltip" title="Mark this event as a dry-hire, so it needs to be checked in at the end">
|
||||||
{% render_field form.dry_hire %}{{ form.dry_hire.label }}
|
{{ form.dry_hire.label }} {% render_field form.dry_hire %}
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -298,7 +300,7 @@
|
|||||||
class="col-sm-4 col-form-label">{{ form.mic.label }}</label>
|
class="col-sm-4 col-form-label">{{ form.mic.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select id="{{ form.mic.id_for_label }}" name="{{ form.mic.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
<select id="{{ form.mic.id_for_label }}" name="{{ form.mic.name }}" class="px-0 selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
{% if mic %}
|
{% if mic %}
|
||||||
<option value="{{form.mic.value}}" selected="selected" >{{ mic.name }}</option>
|
<option value="{{form.mic.value}}" selected="selected" >{{ mic.name }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -312,7 +314,7 @@
|
|||||||
class="col-sm-4 col-form-label">{{ form.checked_in_by.label }}</label>
|
class="col-sm-4 col-form-label">{{ form.checked_in_by.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select id="{{ form.checked_in_by.id_for_label }}" name="{{ form.checked_in_by.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
<select id="{{ form.checked_in_by.id_for_label }}" name="{{ form.checked_in_by.name }}" class="px-0 selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
{% if checked_in_by %}
|
{% if checked_in_by %}
|
||||||
<option value="{{form.checked_in_by.value}}" selected="selected" >{{ checked_in_by.name }}</option>
|
<option value="{{form.checked_in_by.value}}" selected="selected" >{{ checked_in_by.name }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -338,6 +340,20 @@
|
|||||||
{% render_field form.purchase_order class+="form-control" %}
|
{% render_field form.purchase_order class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group" data-toggle="tooltip" title="The thread for this event on the TEC Forum">
|
||||||
|
<label for="{{ form.forum_url.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">Forum Thread</label>
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<p class="small mb-0">Paste URL</p>
|
||||||
|
{% render_field form.forum_url class+="form-control" %}
|
||||||
|
{% if object.pk %}
|
||||||
|
<p class="small mb-0">or</p>
|
||||||
|
<a href="{% url 'event_thread' object.pk %}" class="btn btn-primary" title="Create Forum Thread" target="_blank">
|
||||||
|
<span class="fas fa-plus"></span> <span class="hidden-xs">Create Forum Thread</span></a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -351,10 +367,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" %}
|
{% render_field form.notes class+="form-control md-enabled" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% include 'item_table.html' %}
|
{% include 'partials/item_table.html' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,131 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
{% extends 'base_print.xml' %}
|
||||||
{% load multiply from filters %}
|
|
||||||
{% load static %}
|
|
||||||
<!DOCTYPE document SYSTEM "rml.dtd">
|
|
||||||
|
|
||||||
<document filename="{{filename}}">
|
{% block content %}
|
||||||
<docinit>
|
{% include "event_print_page.xml" %}
|
||||||
<registerTTFont faceName="OpenSans" fileName="{{ fonts.opensans.regular }}"/>
|
{% endblock %}
|
||||||
<registerTTFont faceName="OpenSans-Bold" fileName="{{ fonts.opensans.bold }}"/>
|
|
||||||
<registerFontFamily name="OpenSans" bold="OpenSans-Bold" boldItalic="OpenSans-Bold"/>
|
|
||||||
</docinit>
|
|
||||||
|
|
||||||
<stylesheet>
|
|
||||||
<initialize>
|
|
||||||
<color id="LightGray" RGB="#D3D3D3"/>
|
|
||||||
<color id="DarkGray" RGB="#707070"/>
|
|
||||||
</initialize>
|
|
||||||
|
|
||||||
<paraStyle name="style.para" fontName="OpenSans" />
|
|
||||||
<paraStyle name="blockPara" spaceAfter="5" spaceBefore="5"/>
|
|
||||||
<paraStyle name="style.Heading1" fontName="OpenSans" fontSize="16" leading="18" spaceAfter="0"/>
|
|
||||||
<paraStyle name="style.Heading2" fontName="OpenSans-Bold" fontSize="10" spaceAfter="2"/>
|
|
||||||
<paraStyle name="style.Heading3" fontName="OpenSans" fontSize="10" spaceAfter="0"/>
|
|
||||||
<paraStyle name="center" alignment="center"/>
|
|
||||||
<paraStyle name="page-head" alignment="center" fontName="OpenSans-Bold" fontSize="16" leading="18" spaceAfter="0"/>
|
|
||||||
|
|
||||||
<paraStyle name="style.event_description" fontName="OpenSans" textColor="DarkGray" />
|
|
||||||
<paraStyle name="style.item_description" fontName="OpenSans" textColor="DarkGray" leftIndent="10" />
|
|
||||||
<paraStyle name="style.specific_description" fontName="OpenSans" textColor="DarkGray" fontSize="10" />
|
|
||||||
<paraStyle name="style.times" fontName="OpenSans" fontSize="10" />
|
|
||||||
<paraStyle name="style.head_titles" fontName="OpenSans-Bold" fontSize="10" />
|
|
||||||
<paraStyle name="style.head_numbers" fontName="OpenSans" fontSize="10" />
|
|
||||||
|
|
||||||
<blockTableStyle id="eventSpecifics">
|
|
||||||
<blockValign value="top"/>
|
|
||||||
<lineStyle kind="LINEAFTER" colorName="LightGrey" start="0,0" stop="1,0" thickness="1"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="headLayout">
|
|
||||||
<blockValign value="top"/>
|
|
||||||
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="eventDetails">
|
|
||||||
<blockValign value="top"/>
|
|
||||||
<blockTopPadding start="0,0" stop="-1,0" length="0"/>
|
|
||||||
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="itemTable">
|
|
||||||
<blockValign value="top"/>
|
|
||||||
<lineStyle kind="LINEBELOW" colorName="LightGrey" start="0,0" stop="-1,-1" thickness="1"/>
|
|
||||||
{#<lineStyle kind="box" colorName="black" thickness="1" start="0,0" stop="-1,-1"/>#}
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="totalTable">
|
|
||||||
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
|
||||||
<lineStyle kind="LINEBELOW" colorName="LightGrey" start="-2,0" stop="-1,-1" thickness="1"/>
|
|
||||||
{# <lineStyle cap="default" kind="grid" colorName="black" thickness="1" start="1,0" stop="-1,-1"/> #}
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="infoTable" keepWithNext="true">
|
|
||||||
<blockLeftPadding start="0,0" stop="-1,-1" length="0"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="paymentTable">
|
|
||||||
<blockBackground colorName="LightGray" start="0,1" stop="3,1"/>
|
|
||||||
<blockFont name="OpenSans-Bold" start="0,1" stop="0,1"/>
|
|
||||||
<blockFont name="OpenSans-Bold" start="2,1" stop="2,1"/>
|
|
||||||
<lineStyle kind="outline" colorName="black" thickness="1" start="0,1" stop="3,1"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
|
|
||||||
<blockTableStyle id="signatureTable">
|
|
||||||
<blockTopPadding length="20" />
|
|
||||||
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
|
||||||
<lineStyle kind="linebelow" start="1,0" stop="1,0" colorName="black"/>
|
|
||||||
<lineStyle kind="linebelow" start="3,0" stop="3,0" colorName="black"/>
|
|
||||||
<lineStyle kind="linebelow" start="5,0" stop="5,0" colorName="black"/>
|
|
||||||
</blockTableStyle>
|
|
||||||
</stylesheet>
|
|
||||||
|
|
||||||
<template > {# Note: page is 595x842 points (1 point=1/72in) #}
|
|
||||||
<pageTemplate id="Headed" >
|
|
||||||
<pageGraphics>
|
|
||||||
<image file="RIGS/static/imgs/paperwork/corner-tr-su.jpg" x="395" y="642" height="200" width="200"/>
|
|
||||||
<image file="RIGS/static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
|
||||||
|
|
||||||
{# logo positioned 42 from left, 33 from top #}
|
|
||||||
<image file="RIGS/static/imgs/paperwork/tec-logo.jpg" x="42" y="719" height="90" width="84"/>
|
|
||||||
|
|
||||||
<setFont name="OpenSans-Bold" size="22.5" leading="10"/>
|
|
||||||
<drawString x="137" y="780">TEC PA & Lighting</drawString>
|
|
||||||
|
|
||||||
<setFont name="OpenSans" size="9"/>
|
|
||||||
<drawString x="137" y="760">Portland Building, University Park, Nottingham, NG7 2RD</drawString>
|
|
||||||
<drawString x="137" y="746">www.nottinghamtec.co.uk</drawString>
|
|
||||||
<drawString x="265" y="746">info@nottinghamtec.co.uk</drawString>
|
|
||||||
<drawString x="137" y="732">Phone: (0115) 846 8720</drawString>
|
|
||||||
|
|
||||||
<setFont name="OpenSans" size="10" />
|
|
||||||
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
|
||||||
<setFont name="OpenSans" size="7" />
|
|
||||||
<drawCenteredString x="302.5" y="26">
|
|
||||||
[Paperwork generated{% if current_user %} by {{current_user.name}} |{% endif %} {% now "d/m/Y H:i" %} | {{object.current_version_id}}]
|
|
||||||
</drawCenteredString>
|
|
||||||
</pageGraphics>
|
|
||||||
|
|
||||||
<frame id="main" x1="50" y1="65" width="495" height="645"/>
|
|
||||||
</pageTemplate>
|
|
||||||
|
|
||||||
<pageTemplate id="Main">
|
|
||||||
<pageGraphics>
|
|
||||||
<image file="RIGS/static/imgs/paperwork/corner-tr.jpg" x="395" y="642" height="200" width="200"/>
|
|
||||||
<image file="RIGS/static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
|
||||||
|
|
||||||
<setFont name="OpenSans" size="10"/>
|
|
||||||
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
|
||||||
<setFont name="OpenSans" size="7" />
|
|
||||||
<drawCenteredString x="302.5" y="26">
|
|
||||||
[Paperwork generated{% if current_user %} by {{current_user.name}} |{% endif %} {% now "d/m/Y H:i" %} | {{object.current_version_id}}]
|
|
||||||
</drawCenteredString>
|
|
||||||
</pageGraphics>
|
|
||||||
<frame id="main" x1="50" y1="65" width="495" height="727"/>
|
|
||||||
</pageTemplate>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<story firstPageTemplate="Headed">
|
|
||||||
{% include "event_print_page.xml" %}
|
|
||||||
</story>
|
|
||||||
|
|
||||||
</document>
|
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
|
{% load markdown_tags %}
|
||||||
{% load filters %}
|
{% load filters %}
|
||||||
<setNextFrame name="main"/>
|
|
||||||
<nextFrame/>
|
|
||||||
<blockTable style="headLayout" colWidths="330,165">
|
<blockTable style="headLayout" colWidths="330,165">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h1><b>N{{ object.pk|stringformat:"05d" }}:</b> '{{ object.name }}'<small></small></h1>
|
<h1><b>N{{ object.pk|stringformat:"05d" }}:</b> '{{ object.name }}'</h1>
|
||||||
|
|
||||||
<para style="style.event_description">
|
<para style="style.event_description">
|
||||||
<b>{{object.start_date|date:"D jS N Y"}}</b>
|
<b>{{object.start_date|date:"D jS N Y"}}</b>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<keepInFrame>
|
<keepInFrame maxHeight="500" onOverflow="shrink">
|
||||||
<para style="style.event_description">
|
{{ object.description|default_if_none:""|markdown:"rml" }}
|
||||||
{{ object.description|default_if_none:""|linebreaksxml }}
|
|
||||||
</para>
|
|
||||||
</keepInFrame>
|
</keepInFrame>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -180,39 +178,36 @@
|
|||||||
{% for item in object.items.all %}
|
{% for item in object.items.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<para>{{ item.name }}
|
<para><b>{{ item.name }}</b></para>
|
||||||
{% if item.description %}
|
{% if item.description %}
|
||||||
</para>
|
{{ item.description|markdown:"rml" }}
|
||||||
<para style="item_description">
|
{% endif %}
|
||||||
<em>{{ item.description|linebreaksxml }}</em>
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
{% endif %}
|
|
||||||
</para>
|
|
||||||
</td>
|
</td>
|
||||||
<td>£ {{ item.cost|floatformat:2 }}</td>
|
<td>£{{ item.cost|floatformat:2 }}</td>
|
||||||
<td>{{ item.quantity }}</td>
|
<td>{{ item.quantity }}</td>
|
||||||
<td>£ {{ item.total_cost|floatformat:2 }}</td>
|
<td>£{{ item.total_cost|floatformat:2 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</blockTable>
|
</blockTable>
|
||||||
<keepTogether>
|
<keepTogether>
|
||||||
<blockTable style="totalTable" colWidths="300,115,80">
|
<blockTable style="totalTable" colWidths="300,115,80">
|
||||||
|
{% if object.vat > 0 %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% if quote %}VAT Registration Number: 170734807{% endif %}</td>
|
<td>{% if quote %}VAT Registration Number: 170734807</td>
|
||||||
<td>Total (ex. VAT)</td>
|
<td>Total (ex. VAT){% endif %}</td>
|
||||||
<td>£ {{ object.sum_total|floatformat:2 }}</td>
|
<td>£ {{ object.sum_total|floatformat:2 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if quote %}
|
{% if quote %}
|
||||||
<para>
|
<para>This quote is valid for 30 days unless otherwise arranged.</para>
|
||||||
This quote is valid for 30 days unless otherwise arranged.
|
|
||||||
</para>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
{% if object.vat > 0 %}
|
||||||
<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>
|
||||||
@@ -224,7 +219,7 @@
|
|||||||
</td>
|
</td>
|
||||||
{% if invoice %}
|
{% if invoice %}
|
||||||
<td>Total</td>
|
<td>Total</td>
|
||||||
<td>£ {{ object.total|floatformat:2 }}</td>
|
<td>£{{ object.total|floatformat:2 }}</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>
|
<td>
|
||||||
<para>
|
<para>
|
||||||
@@ -233,7 +228,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<para>
|
<para>
|
||||||
<b>£ {{ object.total|floatformat:2 }}</b>
|
<b>£{{ object.total|floatformat:2 }}</b>
|
||||||
</para>
|
</para>
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -267,7 +262,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{ payment.get_method_display }}</td>
|
<td>{{ payment.get_method_display }}</td>
|
||||||
<td>{{ payment.date }}</td>
|
<td>{{ payment.date }}</td>
|
||||||
<td>£ {{ payment.amount|floatformat:2 }}</td>
|
<td>£{{ payment.amount|floatformat:2 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</blockTable>
|
</blockTable>
|
||||||
@@ -275,18 +270,18 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Payment Total</td>
|
<td>Payment Total</td>
|
||||||
<td>£ {{ object.invoice.payment_total|floatformat:2 }}</td>
|
<td>£{{ object.invoice.payment_total|floatformat:2 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<para>
|
<para>
|
||||||
<b>Balance</b> (ex. VAT)
|
<b>Balance</b> {% if object.vat > 0 %}(ex. VAT){% endif %}
|
||||||
</para>
|
</para>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<para>
|
<para>
|
||||||
<b>£ {{ object.invoice.balance|floatformat:2 }}</b>
|
<b>£{{ object.invoice.balance|floatformat:2 }}</b>
|
||||||
</para>
|
</para>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -316,7 +311,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>
|
||||||
{% else %}
|
{% elif object.vat > 0 %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<para>VAT Registration Number: 170734807</para>
|
<para>VAT Registration Number: 170734807</para>
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
<blockTable style="signatureTable" colWidths="50,120,60,120,35,110">
|
|
||||||
<tr>
|
|
||||||
<td>Signature</td>
|
|
||||||
<td></td>
|
|
||||||
<td>Print Name</td>
|
|
||||||
<td></td>
|
|
||||||
<td>Date</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</blockTable>
|
|
||||||
@@ -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 'item_table.html' %}
|
{% include 'partials/item_table.html' %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
{% extends 'eventauthorisation.html' %}
|
{% extends 'eventauthorisation.html' %}
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
{% block js %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block authorisation %}
|
{% block authorisation %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
@@ -86,7 +83,7 @@
|
|||||||
|
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-primary btn-lg" type="submit">Authorise</button>
|
<button class="btn btn-primary btn-lg" type="submit" {% if preview %}disabled="" data-toggle="tooltip" title="This is only a preview!"{%endif%}>Authorise</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
Hi {{object.event.mic.get_full_name|default_if_none:"somebody"}},
|
|
||||||
|
|
||||||
Just to let you know your event N{{object.event.pk|stringformat:"05d"}} has been successfully authorised for £{{object.amount}} by {{object.name}} as of {{object.event.last_edited_at}}.
|
|
||||||
|
|
||||||
The TEC Rig Information Gathering System
|
|
||||||
@@ -1,24 +1,33 @@
|
|||||||
{% 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 content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning pb-0">
|
||||||
<h1>Send authorisation request email.</h1>
|
<h1>Send authorisation request email.</h1>
|
||||||
<p>Pressing send will email the address provided. Please triple check everything before continuing.</p>
|
<p>Pressing send will email the address provided. <strong>Please triple check everything before continuing.</strong></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info pb-0">
|
||||||
|
{% 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>{{ object.person.email }}</dd>
|
<dd><span id="person-email" class="pr-1">{{ object.person.email }}</span> {% button 'copy' id='#person-email' %}</dd>
|
||||||
|
{% endif %}
|
||||||
|
{% if object.organisation.email %}
|
||||||
<dt>Organisation Email</dt>
|
<dt>Organisation Email</dt>
|
||||||
<dd>{{ object.organisation.email }}</dd>
|
<dd><span id="org-email" class="pr-1">{{ object.organisation.email }}</span> {% button 'copy' id='#org-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 %}
|
||||||
@@ -30,21 +39,33 @@
|
|||||||
{% render_field form.email type="email" class+="form-control" %}
|
{% render_field form.email type="email" class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right col-sm-3 offset-sm-9">
|
|
||||||
<div class="form-group">
|
|
||||||
<button type="submit" class="form-control btn btn-primary">
|
|
||||||
<i class="fas fa-paper-plane"></i>
|
|
||||||
Send
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
<script src="{% static 'js/popover.js' %}"></script>
|
||||||
|
<script src="{% static 'js/clipboard.min.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
$('#auth-request-form').on('submit', function () {
|
$('#auth-request-form').on('submit', function () {
|
||||||
$('#auth-request-form button').attr('disabled', true);
|
$('#auth-request-form button').attr('disabled', true);
|
||||||
});
|
});
|
||||||
|
var clipboard = new ClipboardJS('.btn');
|
||||||
|
|
||||||
|
clipboard.on('success', function(e) {
|
||||||
|
$(e.trigger).popover('show');
|
||||||
|
window.setTimeout(function () {$(e.trigger).popover('hide')}, 3000);
|
||||||
|
e.clearSelection();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block footer %}
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="btn-group" role="group">
|
||||||
|
<a type="button" target="_blank" href="{% url 'event_authorise_preview' object.pk %}" class="btn btn-info text-nowrap"><span class="fas fa-drafting-compass"></span> Preview</a>
|
||||||
|
<button type="submit" class="form-control btn btn-primary" form="auth-request-form">
|
||||||
|
<span class="fas fa-paper-plane"></span> Send
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|||||||
83
RIGS/templates/hs/event_checklist_detail.html
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
||||||
|
{% load help_text from filters %}
|
||||||
|
{% load profile_by_index from filters %}
|
||||||
|
{% load yesnoi from filters %}
|
||||||
|
{% load button from filters %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 text-right my-3">
|
||||||
|
{% button 'edit' url='ec_edit' pk=object.pk %}
|
||||||
|
{% button 'view' url='event_detail' pk=object.event.pk text="Event" %}
|
||||||
|
<a href="{% url 'event_pt' object.event.pk %}" class="btn btn-info"><span class="fas fa-paperclip"></span> <span
|
||||||
|
class="hidden-xs">Create Power Test</span></a>
|
||||||
|
{% include 'partials/review_status.html' with perm=perms.RIGS.review_eventchecklist review='ec_review' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 col-sm-12">
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header">General</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-6">Date</dt>
|
||||||
|
<dd class="col-6">
|
||||||
|
{{ object.date }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-6">Venue</dt>
|
||||||
|
<dd class="col-6">
|
||||||
|
{% if object.venue %}
|
||||||
|
<a href="{% url 'venue_detail' object.venue.pk %}" class="modal-href">
|
||||||
|
{{ object.venue }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-sm-12">
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header">Safety Checks</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-10">{{ object|help_text:'safe_parking'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.safe_parking|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-10">{{ object|help_text:'safe_packing'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.safe_packing|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-10">{{ object|help_text:'exits'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.exits|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-10">{{ object|help_text:'trip_hazard'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.trip_hazard|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-10">{{ object|help_text:'warning_signs'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.warning_signs|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-10">{{ object|help_text:'ear_plugs'|safe }}</dt>
|
||||||
|
<dd class="col-2">
|
||||||
|
{{ object.ear_plugs|yesnoi }}
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 text-right">
|
||||||
|
{% button 'edit' url='ec_edit' pk=object.pk %}
|
||||||
|
{% button 'view' url='event_detail' pk=object.pk text="Event" %}
|
||||||
|
<a href="{% url 'event_pt' object.event.pk %}" class="btn btn-info"><span class="fas fa-paperclip"></span> <span
|
||||||
|
class="hidden-xs">Create Power Test</span></a>
|
||||||
|
{% include 'partials/review_status.html' with perm=perms.RIGS.review_eventchecklist review='ec_review' %}
|
||||||
|
</div>
|
||||||
|
<div class="col-12 text-right">
|
||||||
|
{% include 'partials/last_edited.html' with target="eventchecklist_history" %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
99
RIGS/templates/hs/event_checklist_form.html
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
{% extends request.is_ajax|yesno:'base_ajax.html,base_rigs.html' %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
{% load static %}
|
||||||
|
{% load help_text from filters %}
|
||||||
|
{% load profile_by_index from filters %}
|
||||||
|
{% load button from filters %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" href="{% static 'css/selects.css' %}"/>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block preload_js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
|
<script src="{% static 'js/interaction.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="col-12">
|
||||||
|
{% include 'form_errors.html' %}
|
||||||
|
|
||||||
|
<form role="form" method="POST" action="{% if edit %}{% url 'ec_edit' pk=object.pk %}{% else %}{% url 'event_ec' pk=event.pk %}{% endif %}">
|
||||||
|
<input type="hidden" name="{{ form.event.name }}" id="{{ form.event.id_for_label }}"
|
||||||
|
value="{{event.pk}}"/>
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Event Information</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-4">Event Date</dt>
|
||||||
|
<dd class="col-8">{{ event.start_date}}{%if event.end_date %}-{{ event.end_date}}{%endif%}</dd>
|
||||||
|
<dt class="col-4">Event Name</dt>
|
||||||
|
<dd class="col-8">{{ event.name }}</dd>
|
||||||
|
<dt class="col-4">Client</dt>
|
||||||
|
<dd class="col-8">{{ event.person }}</dd>
|
||||||
|
<dt class="col-4">Event Size</dt>
|
||||||
|
<dd class="col-8">{% include 'partials/event_size.html' with object=event.riskassessment %}</dd>
|
||||||
|
</dl>
|
||||||
|
<div class="form-group form-row">
|
||||||
|
<label for="{{ form.date.id_for_label }}"
|
||||||
|
class="col-4 col-form-label">{{ form.date.label }}</label>
|
||||||
|
{% if not form.date.value %}
|
||||||
|
{% render_field form.date class+="form-control col-8" value=event.start_date %}
|
||||||
|
{% else %}
|
||||||
|
{% render_field form.date class+="form-control col-8" %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-row" id="{{ form.venue.id_for_label }}-group">
|
||||||
|
<label for="{{ form.venue.id_for_label }}"
|
||||||
|
class="col-4 col-form-label">{{ form.venue.label }}</label>
|
||||||
|
<select id="{{ form.venue.id_for_label }}" name="{{ form.venue.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='venue' %}">
|
||||||
|
{% if venue %}
|
||||||
|
<option value="{{venue.pk}}" selected="selected">{{ venue.name }}</option>
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row my-3">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Safety Checks</div>
|
||||||
|
<div class="card-body">
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.safe_parking %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.safe_packing %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.exits %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.trip_hazard %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.warning_signs %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.ear_plugs %}
|
||||||
|
<div class="row pt-3">
|
||||||
|
<label class="col-5" for="{{ form.hs_location.id_for_label }}">{{ form.hs_location.help_text }}</label>
|
||||||
|
{% render_field form.hs_location class+="form-control col-7 col-md-4" %}
|
||||||
|
</div>
|
||||||
|
<div class="row pt-1">
|
||||||
|
<label class="col-5" for="{{ form.extinguishers_location.id_for_label }}">{{ form.extinguishers_location.help_text }}</label>
|
||||||
|
{% render_field form.extinguishers_location class+="form-control col-7 col-md-4" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-sm-12 text-right">
|
||||||
|
{% button 'submit' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
105
RIGS/templates/hs/eventcheckin_form.html
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
{% extends request.is_ajax|yesno:'base_ajax.html,base_rigs.html' %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
{% load static %}
|
||||||
|
{% load button from filters %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'css/selects.css' %}"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'css/easymde.min.css' %}">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block preload_js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
|
<script src="{% static 'js/easymde.min.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
|
<script src="{% static 'js/interaction.js' %}"></script>
|
||||||
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="col-12">
|
||||||
|
{% include 'form_errors.html' %}
|
||||||
|
<form id="checkin" role="form" method="POST" action="{{ form.action|default:request.path }}">
|
||||||
|
<input type="hidden" name="{{ form.event.name }}" id="{{ form.event.id_for_label }}"
|
||||||
|
value="{{event.pk}}"/>
|
||||||
|
{% if not request.is_ajax and self.request.user.pk is form.event.mic.pk %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.person.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">{{ form.person.label }}</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select id="{{ form.person.id_for_label }}" name="{{ form.person.name }}" class="px-0 selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
|
{% if person %}
|
||||||
|
<option value="{{form.person.value}}" selected="selected" >{{ person.name }}</option>
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<input type="hidden" name="{{ form.person.name }}" id="{{ form.person.id_for_label }}"
|
||||||
|
value="{{request.user.pk}}"/>
|
||||||
|
{% endif %}
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.time.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">Start Time</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.time class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.role.id_for_label }}" class="col col-form-label">Role</label>
|
||||||
|
<div class="row pl-3">
|
||||||
|
<div class="col-md-6 col-sm-12">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="document.getElementById('id_role').value='MIC'">MIC</button>
|
||||||
|
<button type="button" class="btn btn-danger" onclick="document.getElementById('id_role').value='Power MIC'">Power MIC</button>
|
||||||
|
<button type="button" class="btn btn-info" onclick="document.getElementById('id_role').value='Crew'">Crew</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mt-2">
|
||||||
|
{% render_field form.role class+="form-control" placeholder="Other (enter text)" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.vehicle.id_for_label }}" class="col col-form-label">Vehicle (if applicable)</label>
|
||||||
|
<div class="row pl-3">
|
||||||
|
<div class="col-md-6 col-sm-12">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="document.getElementById('id_vehicle').value='Virgil'"><span class="fas fa-truck-moving"></span> Virgil</button>
|
||||||
|
<button type="button" class="btn btn-secondary" onclick="document.getElementById('id_vehicle').value='Virgil + Erms'"><span class="fas fa-trailer"></span><span class="fas fa-truck-moving"></span> Virgil + Erms</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mt-2">
|
||||||
|
{% render_field form.vehicle class+="form-control" placeholder="Other (enter text)" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% if edit or manual %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.end_time.id_for_label }}"
|
||||||
|
class="col-sm-4 col-form-label">End Time</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.end_time class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if not request.is_ajax %}
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-sm-12 text-right">
|
||||||
|
{% button 'submit' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block footer %}
|
||||||
|
<div class="col-sm-12 text-right pr-0">
|
||||||
|
<button type="submit" class="btn btn-primary" title="Save" form="checkin"
|
||||||
|
><span class="fas fa-save align-middle"></span> <span class="d-none d-sm-inline align-middle">Save</span></button>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -4,19 +4,22 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table mb-0">
|
<table class="table mb-0 table-sm">
|
||||||
<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>
|
||||||
|
<th scope="col">Power Records</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<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></th>
|
<th scope="row" id="event_number"><a href="{% url 'event_detail' event.pk %}">{{ event }}</a><br><small>{{ event.get_status_display }}</small></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>
|
||||||
@@ -33,6 +36,14 @@
|
|||||||
<a href="{% url 'event_ec' event.pk %}" class="btn btn-info"><span class="fas fa-paperclip"></span> <span
|
<a href="{% url 'event_ec' event.pk %}" class="btn btn-info"><span class="fas fa-paperclip"></span> <span
|
||||||
class="d-none d-sm-inline">Create</span></a>
|
class="d-none d-sm-inline">Create</span></a>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{% for record in event.power_tests.all %}
|
||||||
|
{% include 'partials/hs_status.html' with event=event object=record view='pt_detail' edit='pt_edit' create='event_pt' review='pt_review' perm=perms.RIGS.review_power %}
|
||||||
|
<br/>
|
||||||
|
{% endfor %}
|
||||||
|
<a href="{% url 'event_pt' event.pk %}" class="btn btn-info"><span class="fas fa-paperclip"></span> <span
|
||||||
|
class="hidden-xs">Create</span></a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr class="bg-warning text-dark">
|
<tr class="bg-warning text-dark">
|
||||||
@@ -7,20 +7,22 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<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='pt_edit' pk=object.pk %}
|
||||||
{% button 'view' url='event_detail' pk=object.pk text="Event" %}
|
{% button 'view' url='event_detail' pk=object.event.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_power review='pt_review' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="card mb-3">
|
||||||
<div class="col-md-6 col-sm-12">
|
<div class="card-header">{% include 'partials/event_size.html' with object=object.event.riskassessment %}</div>
|
||||||
<div class="card mb-3">
|
<div class="card-body">
|
||||||
<div class="card-header">General</div>
|
<dl class="row">
|
||||||
<div class="card-body">
|
<dt class="col-6">{{ object|help_text:'power_mic' }}</dt>
|
||||||
<dl class="row">
|
|
||||||
<dt class="col-6">Date</dt>
|
|
||||||
<dd class="col-6">
|
<dd class="col-6">
|
||||||
{{ object.date }}
|
{% if object.power_mic %}
|
||||||
|
<a href="{% url 'profile_detail' object.power_mic.pk %}">{{ object.power_mic.name }}</a>
|
||||||
|
{% else %}
|
||||||
|
None
|
||||||
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-6">Venue</dt>
|
<dt class="col-6">Venue</dt>
|
||||||
<dd class="col-6">
|
<dd class="col-6">
|
||||||
@@ -30,84 +32,31 @@
|
|||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-6">{{ object|help_text:'power_mic' }}</dt>
|
<dt class="col-6">Notes</dt>
|
||||||
<dd class="col-6">
|
<dd class="col-6">
|
||||||
<a href="{% url 'profile_detail' object.power_mic.pk %}">{{ object.power_mic.name }}</a>
|
{{ object.notes }}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<p>List vehicles and their drivers</p>
|
{% if object.event.riskassessment.event_size == 0 %}
|
||||||
<ul>
|
<dl class="row">
|
||||||
{% for i in object.vehicles.all %}
|
<dt class="col-10">{{ object|help_text:'rcds'|safe }}</dt>
|
||||||
<li>{{i}}</li>
|
<dd class="col-2">
|
||||||
{% endfor %}
|
{{ object.rcds|yesnoi }}
|
||||||
</ul>
|
</dd>
|
||||||
</div>
|
<dt class="col-10">{{ object|help_text:'supply_test'|safe }}</dt>
|
||||||
</div>
|
<dd class="col-2">
|
||||||
</div>
|
{{ object.supply_test|yesnoi }}
|
||||||
<div class="col-md-6 col-sm-12">
|
</dd>
|
||||||
<div class="card mb-3">
|
<dt class="col-10">{{ object|help_text:'earthing'|safe }}</dt>
|
||||||
<div class="card-header">Safety Checks</div>
|
<dd class="col-2">
|
||||||
<div class="card-body">
|
{{ object.earthing|yesnoi }}
|
||||||
<dl class="row">
|
</dd>
|
||||||
<dt class="col-10">{{ object|help_text:'safe_parking'|safe }}</dt>
|
<dt class="col-10">{{ object|help_text:'pat'|safe }}</dt>
|
||||||
<dd class="col-2">
|
<dd class="col-2">
|
||||||
{{ object.safe_parking|yesnoi }}
|
{{ object.pat|yesnoi }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-10">{{ object|help_text:'safe_packing'|safe }}</dt>
|
</dl>
|
||||||
<dd class="col-2">
|
{% else %}
|
||||||
{{ object.safe_packing|yesnoi }}
|
|
||||||
</dd>
|
|
||||||
<dt class="col-10">{{ object|help_text:'exits'|safe }}</dt>
|
|
||||||
<dd class="col-2">
|
|
||||||
{{ object.exits|yesnoi }}
|
|
||||||
</dd>
|
|
||||||
<dt class="col-10">{{ object|help_text:'trip_hazard'|safe }}</dt>
|
|
||||||
<dd class="col-2">
|
|
||||||
{{ object.trip_hazard|yesnoi }}
|
|
||||||
</dd>
|
|
||||||
<dt class="col-10">{{ object|help_text:'warning_signs'|safe }}</dt>
|
|
||||||
<dd class="col-2">
|
|
||||||
{{ object.warning_signs|yesnoi }}
|
|
||||||
</dd>
|
|
||||||
<dt class="col-10">{{ object|help_text:'ear_plugs'|safe }}</dt>
|
|
||||||
<dd class="col-2">
|
|
||||||
{{ object.ear_plugs|yesnoi }}
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card mb-3">
|
|
||||||
<div class="card-header">Crew Record</div>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-sm">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Crewmember</th>
|
|
||||||
<th scope="col">Start Time</th>
|
|
||||||
<th scope="col">Role</th>
|
|
||||||
<th scope="col">End Time</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="crewmemberst">
|
|
||||||
{% for crew in object.crew.all %}
|
|
||||||
<tr>
|
|
||||||
<td>{{crew.crewmember}}</td>
|
|
||||||
<td>{{crew.start}}</td>
|
|
||||||
<td>{{crew.role}}</td>
|
|
||||||
<td>{{crew.end}}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card mb-3">
|
|
||||||
<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">
|
|
||||||
{% if object.event.riskassessment.event_size == 1 %}
|
|
||||||
<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">
|
||||||
@@ -137,7 +86,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row" rowspan="2">Voltage<br><small>(cube meter)</small></th>
|
<th scope="row" rowspan="2">Voltage<br><small>(cube meter)</small> / V</th>
|
||||||
<th>{{ object|help_text:'fd_voltage_l1' }}</th>
|
<th>{{ object|help_text:'fd_voltage_l1' }}</th>
|
||||||
<th>{{ object|help_text:'fd_voltage_l2' }}</th>
|
<th>{{ object|help_text:'fd_voltage_l2' }}</th>
|
||||||
<th>{{ object|help_text:'fd_voltage_l3' }}</th>
|
<th>{{ object|help_text:'fd_voltage_l3' }}</th>
|
||||||
@@ -212,35 +161,15 @@
|
|||||||
</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='pt_edit' pk=object.pk %}
|
||||||
{% button 'view' url='event_detail' pk=object.pk text="Event" %}
|
{% button 'view' url='event_detail' pk=object.event.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_power review='pt_review' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 text-right">
|
<div class="col-12 text-right">
|
||||||
{% include 'partials/last_edited.html' with target="eventchecklist_history" %}
|
{% include 'partials/last_edited.html' with target="powertestrecord_history" %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
199
RIGS/templates/hs/power_form.html
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
{% extends request.is_ajax|yesno:'base_ajax.html,base_rigs.html' %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
{% load static %}
|
||||||
|
{% load help_text from filters %}
|
||||||
|
{% load profile_by_index from filters %}
|
||||||
|
{% load button from filters %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" href="{% static 'css/selects.css' %}"/>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block preload_js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="col-12">
|
||||||
|
{% include 'form_errors.html' %}
|
||||||
|
{% if edit %}
|
||||||
|
<form role="form" method="POST" action="{% url 'pt_edit' pk=object.pk %}">
|
||||||
|
{% else %}
|
||||||
|
<form role="form" method="POST" action="{% url 'event_pt' pk=event.pk %}">
|
||||||
|
{% endif %}
|
||||||
|
<input type="hidden" name="{{ form.event.name }}" id="{{ form.event.id_for_label }}"
|
||||||
|
value="{{event.pk}}"/>
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Event Information</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-4">Event Date</dt>
|
||||||
|
<dd class="col-8">{{ event.start_date}}{%if event.end_date %}-{{ event.end_date}}{%endif%}</dd>
|
||||||
|
<dt class="col-4">Event Name</dt>
|
||||||
|
<dd class="col-8">{{ event.name }}</dd>
|
||||||
|
<dt class="col-4">Client</dt>
|
||||||
|
<dd class="col-8">{{ event.person }}</dd>
|
||||||
|
<dt class="col-4">Event Size</dt>
|
||||||
|
<dd class="col-8">{% include 'partials/event_size.html' with object=event.riskassessment %}</dd>
|
||||||
|
</dl>
|
||||||
|
<hr>
|
||||||
|
<div class="form-group form-row" id="{{ form.power_mic.id_for_label }}-group">
|
||||||
|
<label for="{{ form.power_mic.id_for_label }}"
|
||||||
|
class="col-4 col-form-label">{{ form.power_mic.help_text }}</label>
|
||||||
|
<select id="{{ form.power_mic.id_for_label }}" name="{{ form.power_mic.name }}" class="selectpicker col-8" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" required="true">
|
||||||
|
{% if power_mic %}
|
||||||
|
<option value="{{power_mic.pk}}" selected="selected">{{ power_mic.name }}</option>
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-row" id="{{ form.venue.id_for_label }}-group">
|
||||||
|
<label for="{{ form.venue.id_for_label }}"
|
||||||
|
class="col-4 col-form-label">{{ form.venue.label }}</label>
|
||||||
|
<select id="{{ form.venue.id_for_label }}" name="{{ form.venue.name }}" class="selectpicker col-8" data-live-search="true" data-sourceurl="{% url 'api_secure' model='venue' %}">
|
||||||
|
{% if venue %}
|
||||||
|
<option value="{{venue.pk}}" selected="selected">{{ venue.name }}</option>
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<label for="{{ form.notes.id_for_label }}">Notes</label>
|
||||||
|
{% render_field form.notes class+="form-control" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% if event.riskassessment.event_size == 0 %}
|
||||||
|
<div class="row my-3" id="size-0">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card border-success">
|
||||||
|
<div class="card-header">Electrical Checks <small>for ‘Small’ TEC Events <6kVA (approx. 26A)</small></div>
|
||||||
|
<div class="card-body">
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.rcds %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.supply_test %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.earthing %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.pat %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="row my-3" id="size-1">
|
||||||
|
<div class="col-12">
|
||||||
|
{% if event.riskassessment.event_size == 1 %}
|
||||||
|
<div class="card border-warning">
|
||||||
|
<div class="card-header">Electrical Checks <small>for ‘Medium’ TEC Events </small></div>
|
||||||
|
<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.labelling %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.earthing %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.pat %}
|
||||||
|
<hr>
|
||||||
|
<p>Tests at first distro</p>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered table-sm">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="text-center">Test</th>
|
||||||
|
<th scope="col" colspan="3" class="text-center">Value</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row" rowspan="2">Voltage<br><small>(cube meter)</small> / V</th>
|
||||||
|
<th class="text-center">{{ form.fd_voltage_l1.help_text }}</th>
|
||||||
|
<th class="text-center">{{ form.fd_voltage_l2.help_text }}</th>
|
||||||
|
<th class="text-center">{{ form.fd_voltage_l3.help_text }}</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{% render_field form.fd_voltage_l1 class+="form-control" style="min-width: 5rem;" %}</td>
|
||||||
|
<td>{% render_field form.fd_voltage_l2 class+="form-control" style="min-width: 5rem;" %}</td>
|
||||||
|
<td>{% render_field form.fd_voltage_l3 class+="form-control" style="min-width: 5rem;" %}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{form.fd_phase_rotation.help_text|safe}}</th>
|
||||||
|
<td colspan="3">{% include 'partials/checklist_checkbox.html' with formitem=form.fd_phase_rotation %}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{form.fd_earth_fault.help_text|safe}}</th>
|
||||||
|
<td colspan="3">{% render_field form.fd_earth_fault class+="form-control" %}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{form.fd_pssc.help_text|safe}}</th>
|
||||||
|
<td colspan="3">{% render_field form.fd_pssc class+="form-control" %}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<p>Tests at 'Worst Case' points (at least 1 point required)</p>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="text-center">Test</th>
|
||||||
|
<th scope="col" class="text-center">Point 1</th>
|
||||||
|
<th scope="col" class="text-center">Point 2</th>
|
||||||
|
<th scope="col" class="text-center">Point 3</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{form.w1_description.help_text|safe}}</th>
|
||||||
|
<td>{% render_field form.w1_description class+="form-control" style="min-width: 5rem;" %}</td>
|
||||||
|
<td>{% render_field form.w2_description class+="form-control" style="min-width: 5rem;" %}</td>
|
||||||
|
<td>{% render_field form.w3_description class+="form-control" style="min-width: 5rem;" %}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{form.w1_polarity.help_text|safe}}</th>
|
||||||
|
<td>{% render_field form.w1_polarity %}</td>
|
||||||
|
<td>{% render_field form.w2_polarity %}</td>
|
||||||
|
<td>{% render_field form.w3_polarity %}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{form.w1_voltage.help_text|safe}}</th>
|
||||||
|
<td>{% render_field form.w1_voltage class+="form-control" %}</td>
|
||||||
|
<td>{% render_field form.w2_voltage class+="form-control" %}</td>
|
||||||
|
<td>{% render_field form.w3_voltage class+="form-control" %}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{form.w1_earth_fault.help_text|safe}}</th>
|
||||||
|
<td>{% render_field form.w1_earth_fault class+="form-control" %}</td>
|
||||||
|
<td>{% render_field form.w2_earth_fault class+="form-control" %}</td>
|
||||||
|
<td>{% render_field form.w3_earth_fault class+="form-control" %}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<hr/>
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.all_rcds_tested %}
|
||||||
|
{% include 'partials/checklist_checkbox.html' with formitem=form.public_sockets_tested %}
|
||||||
|
{% include 'partials/ec_power_info.html' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-sm-12 text-right">
|
||||||
|
{% button 'submit' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
135
RIGS/templates/hs/ra_print.xml
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
{% extends 'base_print.xml' %}
|
||||||
|
{% load filters %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<spacer length="15"/>
|
||||||
|
<h1>Event Specific Risk Assessment for <strong>{{ object.event }}</strong></h1>
|
||||||
|
<spacer length="15"/>
|
||||||
|
<h2>Client: {{ object.event.person|default:object.event.organisation }} | Venue: {{ object.event.venue }} | MIC: {{ object.event.mic }}</h2>
|
||||||
|
<spacer length="15"/>
|
||||||
|
<hr/>
|
||||||
|
<blockTable colWidths="425,100" spaceAfter="15">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>General</strong></h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'nonstandard_equipment'|striptags }}</para></td>
|
||||||
|
<td>{{ object.nonstandard_equipment|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'nonstandard_use'|striptags }}</para></td>
|
||||||
|
<td>{{ object.nonstandard_use|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'contractors'|striptags }}</para></td>
|
||||||
|
<td>{{ object.contractors|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'other_companies'|striptags }}</para></td>
|
||||||
|
<td>{{ object.other_companies|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'crew_fatigue'|striptags }}</para></td>
|
||||||
|
<td>{{ object.crew_fatigue|yesno|capfirst }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'general_notes'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.general_notes|default:'No' }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>Power</strong></h3><spacer length="4"/><para textColor="white" backColor={% if object.event_size == 0 %}"green"{% elif object.event_size == 1 %}"yellow"{% else %}"red"{% endif %} borderPadding="3">{{ object.get_event_size_display }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'big_power'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.big_power|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'power_mic'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.power_mic|default:object.event.mic }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'outside'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.outside|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'generators'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.generators|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'other_companies_power'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.other_companies_power|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'nonstandard_equipment_power'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.nonstandard_equipment_power|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'multiple_electrical_environments'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.multiple_electrical_environments|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'power_notes'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.power_notes|default:'No' }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>Sound</strong></h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'noise_monitoring'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.noise_monitoring|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'sound_notes'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.sound_notes|default:'No' }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>Site Details</strong></h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'known_venue'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.known_venue|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'safe_loading'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.safe_loading|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'safe_storage'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.safe_storage|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'area_outside_of_control'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.area_outside_of_control|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'barrier_required'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.barrier_required|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'nonstandard_emergency_procedure'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.nonstandard_emergency_procedure|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3><strong>Structures</strong></h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'special_structures'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.special_structures|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'suspended_structures'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.suspended_structures|yesno|capfirst }}</para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><para>{{ object|help_text:'persons_responsible_structures'|striptags }}</para></td>
|
||||||
|
<td><para>{{ object.persons_responsible_structures|default:'N/A' }}</para></td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
<spacer length="15"/>\
|
||||||
|
<hr/>
|
||||||
|
<spacer length="15"/>
|
||||||
|
<para><em>Assessment completed by {{ object.last_edited_by }} on {{ object.last_edited_at }}</em></para>
|
||||||
|
{% if object.reviewed_by %}
|
||||||
|
<para><em>Reviewed by {{ object.reviewed_by }} on {{ object.reviewed.at }}</em></para>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
{% 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 filters %}
|
||||||
{% load help_text from filters %}
|
|
||||||
{% load yesnoi from filters %}
|
|
||||||
{% load linkornone from filters %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row py-3">
|
<div class="row py-3">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h3>Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}</h3>
|
|
||||||
<div class="card card-default mb-3">
|
<div class="card card-default mb-3">
|
||||||
<div class="card-header">General</div>
|
<div class="card-header">General</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -47,15 +43,15 @@
|
|||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
{{ object.big_power|yesnoi:'invert' }}
|
{{ object.big_power|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-6">{{ object|help_text:'power_mic' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'power_mic'|safe }}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
{{ object.power_mic.name|default:'None' }}
|
{{ object.power_mic.name|default:object.event.mic }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-6">{{ object|help_text:'generators' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'outside' }}</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:'outside' }}</dt>
|
<dt class="col-sm-6">{{ object|help_text:'generators' }}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
{{ object.generators|yesnoi:'invert' }}
|
{{ object.generators|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
@@ -97,62 +93,69 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card card-default mb-3">
|
<div class="row">
|
||||||
<div class="card-header">Site Details</div>
|
<div class="col-lg-6 col-12">
|
||||||
<div class="card-body">
|
<div class="card card-default mb-3">
|
||||||
<dl class="row">
|
<div class="card-header">Site Details</div>
|
||||||
<dt class="col-sm-6">{{ object|help_text:'known_venue' }}</dt>
|
<div class="card-body">
|
||||||
<dd class="col-sm-6">
|
<dl class="row">
|
||||||
{{ object.known_venue|yesnoi:'invert' }}
|
<dt class="col-10">{{ object|help_text:'known_venue' }}</dt>
|
||||||
</dd>
|
<dd class="col-2">
|
||||||
<dt class="col-sm-6">{{ object|help_text:'safe_loading'|safe }}</dt>
|
{{ object.known_venue|yesnoi:'invert' }}
|
||||||
<dd class="col-sm-6">
|
</dd>
|
||||||
{{ object.safe_loading|yesnoi:'invert' }}
|
<dt class="col-10">{{ object|help_text:'safe_loading'|safe }}</dt>
|
||||||
</dd>
|
<dd class="col-2">
|
||||||
<dt class="col-sm-6">{{ object|help_text:'safe_storage' }}</dt>
|
{{ object.safe_loading|yesnoi:'invert' }}
|
||||||
<dd class="col-sm-6">
|
</dd>
|
||||||
{{ object.safe_storage|yesnoi:'invert' }}
|
<dt class="col-10">{{ object|help_text:'safe_storage' }}</dt>
|
||||||
</dd>
|
<dd class="col-2">
|
||||||
<dt class="col-sm-6">{{ object|help_text:'area_outside_of_control' }}</dt>
|
{{ object.safe_storage|yesnoi:'invert' }}
|
||||||
<dd class="col-sm-6">
|
</dd>
|
||||||
{{ object.area_outside_of_control|yesnoi:'invert' }}
|
<dt class="col-10">{{ object|help_text:'area_outside_of_control' }}</dt>
|
||||||
</dd>
|
<dd class="col-2">
|
||||||
<dt class="col-sm-6">{{ object|help_text:'barrier_required' }}</dt>
|
{{ object.area_outside_of_control|yesnoi:'invert' }}
|
||||||
<dd class="col-sm-6">
|
</dd>
|
||||||
{{ object.barrier_required|yesnoi:'invert' }}
|
<dt class="col-10">{{ object|help_text:'barrier_required' }}</dt>
|
||||||
</dd>
|
<dd class="col-2">
|
||||||
<dt class="col-sm-6">{{ object|help_text:'nonstandard_emergency_procedure' }}</dt>
|
{{ object.barrier_required|yesnoi:'invert' }}
|
||||||
<dd class="col-sm-6">
|
</dd>
|
||||||
{{ object.nonstandard_emergency_procedure|yesnoi:'invert' }}
|
<dt class="col-10">{{ object|help_text:'nonstandard_emergency_procedure' }}</dt>
|
||||||
</dd>
|
<dd class="col-2">
|
||||||
</dl>
|
{{ object.nonstandard_emergency_procedure|yesnoi:'invert' }}
|
||||||
|
</dd>
|
||||||
|
</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-sm-6">{{ object|help_text:'special_structures' }}</dt>
|
<dt class="col-10">{{ object|help_text:'special_structures' }}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-2">
|
||||||
{{ object.special_structures|yesnoi:'invert' }}
|
{{ object.special_structures|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-6">{{ object|help_text:'suspended_structures' }}</dt>
|
<dt class="col-10">{{ object|help_text:'suspended_structures' }}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-2">
|
||||||
{{ object.suspended_structures|yesnoi:'invert' }}
|
{{ object.suspended_structures|yesnoi:'invert' }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-6">{{ object|help_text:'persons_responsible_structures' }}</dt>
|
<dt class="col-12">{{ object|help_text:'persons_responsible_structures' }}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-12">
|
||||||
{{ object.persons_responsible_structures.name|default:'N/A'|linebreaks }}
|
{{ object.persons_responsible_structures|default:'N/A'|linebreaks }}
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-6">{{ object|help_text:'rigging_plan'|safe }}</dt>
|
<dt class="col-12">{{ object|help_text:'rigging_plan'|safe }}</dt>
|
||||||
<dd class="col-6">
|
<dd class="col-12">
|
||||||
{{ object.rigging_plan|linkornone }}
|
{{ object.rigging_plan|linkornone|default:'N/A' }}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 text-right">
|
<div class="col-12 text-right">
|
||||||
|
{% button 'print' 'ra_print' object.pk %}
|
||||||
<a href="{% url 'ra_edit' object.pk %}" class="btn btn-warning my-3"><span class="fas fa-edit"></span> <span
|
<a href="{% url 'ra_edit' object.pk %}" class="btn btn-warning my-3"><span class="fas fa-edit"></span> <span
|
||||||
class="d-none d-sm-inline">Edit</span></a>
|
class="d-none d-sm-inline">Edit</span></a>
|
||||||
<a href="{% url 'event_detail' object.event.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> View Event</a>
|
<a href="{% url 'event_detail' object.event.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> View Event</a>
|
||||||
@@ -5,25 +5,16 @@
|
|||||||
{% 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/bootstrap-select.css' %}"/>
|
|
||||||
<link rel="stylesheet" href="{% static 'css/ajax-bootstrap-select.css' %}"/>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block preload_js %}
|
{% block preload_js %}
|
||||||
{{ block.super }}
|
<script src="{% static 'js/selects.js' %}" async></script>
|
||||||
<script src="{% static 'js/bootstrap-select.js' %}"></script>
|
|
||||||
<script src="{% static 'js/ajax-bootstrap-select.js' %}"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ block.super }}
|
|
||||||
<script src="{% static 'js/jquery-ui.js' %}"></script><!--TODO optimise--->
|
|
||||||
<script src="{% static 'js/interaction.js' %}"></script>
|
|
||||||
<script src="{% static 'js/modal.js' %}"></script>
|
|
||||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
|
||||||
|
|
||||||
<script src="{% static 'js/autocompleter.js' %}"></script>
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function parseBool(str) {
|
function parseBool(str) {
|
||||||
@@ -34,7 +25,7 @@
|
|||||||
});
|
});
|
||||||
$('input[type=radio][name=outside], input[type=radio][name=generators], input[type=radio][name=other_companies_power], input[type=radio][name=nonstandard_equipment_power], input[type=radio][name=multiple_electrical_environments]').change(function() {
|
$('input[type=radio][name=outside], input[type=radio][name=generators], input[type=radio][name=other_companies_power], input[type=radio][name=nonstandard_equipment_power], input[type=radio][name=multiple_electrical_environments]').change(function() {
|
||||||
$('#{{ form.power_notes.id_for_label }}').prop('required', parseBool(this.value));
|
$('#{{ form.power_notes.id_for_label }}').prop('required', parseBool(this.value));
|
||||||
$('#{{ form.power_plan.id_for_label }}').prop('required', parseBool(this.value));
|
//$('#{{ form.power_plan.id_for_label }}').prop('required', parseBool(this.value));
|
||||||
});
|
});
|
||||||
$('input[type=radio][name=special_structures]').change(function() {
|
$('input[type=radio][name=special_structures]').change(function() {
|
||||||
$('#{{ form.persons_responsible_structures.id_for_label }}').prop('hidden', !parseBool(this.value)).prop('required', parseBool(this.value));
|
$('#{{ form.persons_responsible_structures.id_for_label }}').prop('hidden', !parseBool(this.value)).prop('required', parseBool(this.value));
|
||||||
@@ -107,9 +98,9 @@
|
|||||||
<label for="{{ form.power_mic.id_for_label }}"
|
<label for="{{ form.power_mic.id_for_label }}"
|
||||||
class="col col-form-label">{{ form.power_mic.help_text|safe }}</label>
|
class="col col-form-label">{{ form.power_mic.help_text|safe }}</label>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<select id="{{ form.power_mic.id_for_label }}" name="{{ form.power_mic.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
<select id="{{ form.power_mic.id_for_label }}" name="{{ form.power_mic.name }}" class="selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
{% if object.power_mic %}
|
{% if power_mic %}
|
||||||
<option value="{{object.power_mic.pk}}" selected="selected">{{ object.power_mic.name }}</option>
|
<option value="{{form.power_mic.value}}" selected="selected">{{ power_mic }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
{% extends 'base_rigs.html' %}
|
|
||||||
{% load paginator from filters %}
|
|
||||||
{% load help_text from filters %}
|
|
||||||
{% load verbose_name from filters %}
|
|
||||||
{% load get_field from filters %}
|
|
||||||
|
|
||||||
{% block title %}{{ title }} List{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h2>{{title}} List</h2>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table mb-0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Event</th>
|
|
||||||
{# mmm hax #}
|
|
||||||
{% if object_list.0 != None %}
|
|
||||||
{% for field in fields %}
|
|
||||||
<th scope="col">{{ object_list.0|verbose_name:field|title }}</th>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for object in object_list %}
|
|
||||||
<tr class="{% if object.reviewed_by %}table-success{%endif%}">
|
|
||||||
{# General #}
|
|
||||||
<th scope="row"><a href="{% url 'event_detail' object.event.pk %}">{{ object.event }}</a></th>
|
|
||||||
{% for field in fields %}
|
|
||||||
<td>{{ object|get_field:field }}</td>
|
|
||||||
{% endfor %}
|
|
||||||
{# Buttons #}
|
|
||||||
<td>
|
|
||||||
{% include 'partials/hs_status.html' %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% empty %}
|
|
||||||
<tr class="bg-warning">
|
|
||||||
<td colspan="6">Nothing found</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% if is_paginated %}
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
{% paginator %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
@@ -2,102 +2,88 @@
|
|||||||
{% load button from filters %}
|
{% load button from filters %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="col-sm-12">
|
<div class="row py-4">
|
||||||
<div class="row justify-content-end py-3">
|
<div class="col-sm-12 text-right px-0">
|
||||||
<div class="col-sm-4 text-right">
|
<div class="btn-group">
|
||||||
<div class="btn-group btn-page">
|
<a href="{% url 'event_detail' object.event.pk %}" class="btn btn-primary">Open Event Page <span class="fas fa-eye"></span></a>
|
||||||
<a href="{% url 'invoice_delete' object.pk %}" class="btn btn-danger" title="Delete Invoice">
|
<a href="{% url 'invoice_delete' object.pk %}" class="btn btn-danger" title="Delete Invoice">
|
||||||
<span class="fas fa-times"></span> <span
|
<span class="fas fa-times"></span> <span
|
||||||
class="d-none d-sm-inline">Delete</span>
|
class="d-none d-sm-inline">Delete</span>
|
||||||
</a>
|
</a>
|
||||||
<a href="{% url 'invoice_void' object.pk %}" class="btn btn-warning" title="Void Invoice">
|
<a href="{% url 'invoice_void' object.pk %}" class="btn btn-warning" title="Void Invoice">
|
||||||
<span class="fas fa-ban"></span> <span
|
<span class="fas fa-ban"></span> <span
|
||||||
class="d-none d-sm-inline">Void</span>
|
class="d-none d-sm-inline">Void</span>
|
||||||
</a>
|
</a>
|
||||||
{% button 'print' url='invoice_print' pk=object.pk %}
|
{% button 'print' url='invoice_print' pk=object.pk %}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<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 class="col-sm-6">
|
|
||||||
{% include 'partials/event_details.html' %}
|
|
||||||
</div>
|
|
||||||
{% if object.event.internal %}
|
|
||||||
<div class="col-sm-6">
|
|
||||||
{% include 'partials/auth_details.html' %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row py-4">
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="card card-default">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="text-right py-3">
|
|
||||||
<a href="{% url 'payment_create' %}?invoice={{ object.pk }}"
|
|
||||||
class="btn btn-success modal-href"
|
|
||||||
data-target="#{{ form.person.id_for_label }}">
|
|
||||||
<span class="fas fa-plus"></span> Add
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<table class="table table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Date</th>
|
|
||||||
<th scope="col">Amount</th>
|
|
||||||
<th scope="col">Method</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for payment in object.payment_set.all %}
|
|
||||||
<tr>
|
|
||||||
<th scope="row">{{ payment.date }}</th>
|
|
||||||
<td>{{ payment.amount|floatformat:2 }}</td>
|
|
||||||
<td>{{ payment.get_method_display }}</td>
|
|
||||||
<td>
|
|
||||||
<a href="{% url 'payment_delete' payment.pk %}" class="btn btn-small btn-danger"><span class="fas fa-times"></span></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
<tr>
|
|
||||||
<td class="text-right"><strong>Balance:</strong></td>
|
|
||||||
<td>{{ object.balance|floatformat:2 }}</td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="card">
|
|
||||||
{% with object.event as object %}
|
|
||||||
{% include 'item_table.html' %}
|
|
||||||
{% endwith %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 text-right">
|
|
||||||
{% include 'partials/last_edited.html' with target="invoice_history" %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="row py-4">
|
||||||
|
{% with object.event as object %}
|
||||||
|
<div class="col-sm-6">
|
||||||
|
{% include 'partials/contact_details.html' %}
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
{% include 'partials/event_details.html' %}
|
||||||
|
</div>
|
||||||
|
{% if object.event.internal %}
|
||||||
|
<div class="col-sm-6">
|
||||||
|
{% include 'partials/auth_details.html' %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
</div>
|
||||||
|
<div class="row py-4">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="card card-default">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="text-right py-3">
|
||||||
|
<a href="{% url 'payment_create' %}?invoice={{ object.pk }}"
|
||||||
|
class="btn btn-success modal-href"
|
||||||
|
data-target="#{{ form.person.id_for_label }}">
|
||||||
|
<span class="fas fa-plus"></span> Add
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Date</th>
|
||||||
|
<th scope="col">Amount</th>
|
||||||
|
<th scope="col">Method</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for payment in object.payment_set.all %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{ payment.date }}</th>
|
||||||
|
<td>{{ payment.amount|floatformat:2 }}</td>
|
||||||
|
<td>{{ payment.get_method_display }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{% url 'payment_delete' payment.pk %}" class="btn btn-small btn-danger"><span class="fas fa-times"></span></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-right"><strong>Balance:</strong></td>
|
||||||
|
<td>{{ object.balance|floatformat:2 }}</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="card">
|
||||||
|
{% with object.event as object %}
|
||||||
|
{% include 'partials/item_table.html' %}
|
||||||
|
{% endwith %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 text-right">
|
||||||
|
{% include 'partials/last_edited.html' with target="invoice_history" %}
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<td>{{ invoice.event.start_date }}</td>
|
<td>{{ invoice.event.start_date }}</td>
|
||||||
<td>{{ invoice.invoice_date }}</td>
|
<td>{{ invoice.invoice_date }}</td>
|
||||||
<td>
|
<td>
|
||||||
{{ invoice.balance|floatformat:2 }}
|
£{{ invoice.balance|floatformat:2 }}
|
||||||
{% if not invoice.event.internal %}
|
{% if not invoice.event.internal %}
|
||||||
<br />
|
<br />
|
||||||
<span class="text-muted">{{ invoice.event.purchase_order }}</span>
|
<span class="text-muted">{{ invoice.event.purchase_order }}</span>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ event.sum_total|floatformat:2 }}
|
£{{ event.sum_total|floatformat:2 }}
|
||||||
<br />
|
<br />
|
||||||
<span class="text-muted">{% if not event.internal %}{{ event.purchase_order }}{% endif %}</span>
|
<span class="text-muted">{% if not event.internal %}{{ event.purchase_order }}{% endif %}</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<div class="card card-default
|
<div class="card card-default
|
||||||
{% if object.authorised %}
|
{% if event.authorised %}
|
||||||
card-success
|
border-success
|
||||||
{% elif event.authorisation and event.authorisation.amount != event.total and event.authorisation.last_edited_at > event.auth_request_at %}
|
{% elif event.authorisation and event.authorisation.amount != event.total and event.authorisation.last_edited_at > event.auth_request_at %}
|
||||||
card-warning
|
border-warning
|
||||||
{% elif event.auth_request_to %}
|
{% elif event.auth_request_to %}
|
||||||
card-info
|
border-info
|
||||||
{% endif %}
|
{% endif %}
|
||||||
">
|
">
|
||||||
<div class="card-header">Client Authorisation</div>
|
<div class="card-header">Client Authorisation</div>
|
||||||
<div class="card-body row">
|
<div class="card-body row">
|
||||||
<dl class="col-md-6">
|
<dl class="col-sm-6">
|
||||||
<dt>Authorisation Request</dt>
|
<dt>Authorisation Request</dt>
|
||||||
<dd>{{ object.auth_request_to|yesno:"Yes,No" }}</dd>
|
<dd>{{ object.auth_request_to|yesno:"Yes,No" }}</dd>
|
||||||
|
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
<dt>To</dt>
|
<dt>To</dt>
|
||||||
<dd>{{ object.auth_request_to }}</dd>
|
<dd>{{ object.auth_request_to }}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dd class="d-block d-sm-none"> </dd>
|
<dl class="col-sm-6">
|
||||||
<dl class="col-md-6">
|
<hr class="d-block d-sm-none">
|
||||||
<dt>Authorised</dt>
|
<dt>Authorised</dt>
|
||||||
<dd>{{ object.authorised|yesno:"Yes,No" }}</dd>
|
<dd>{{ object.authorised|yesno:"Yes,No" }}</dd>
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,29 @@
|
|||||||
<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 mt-3">
|
<div class="card">
|
||||||
<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">
|
||||||
@@ -29,9 +31,10 @@
|
|||||||
<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">{{ object.organisation.phone }}</dd>
|
<dd class="col-sm-7">{{ event.organisation.phone }}</dd>
|
||||||
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -43,15 +46,12 @@
|
|||||||
<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">
|
||||||
{% if object.venue %}
|
{{ event.venue }}
|
||||||
<a href="{% url 'venue_detail' object.venue.pk %}" class="modal-href">
|
|
||||||
{{ object.venue }}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</dd>
|
</dd>
|
||||||
|
{% endif %}
|
||||||
<dt class="col-sm-5">Status</dt>
|
<dt class="col-sm-5">Status</dt>
|
||||||
<dd class="col-sm-7">{{ event.get_status_display }}</dd>
|
<dd class="col-sm-7">{{ event.get_status_display }}</dd>
|
||||||
|
|
||||||
|
|||||||