Compare commits
303 Commits
feature/su
...
heroku-upg
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
458059fd06 | ||
|
|
1a49bb50e5 | ||
|
|
86b349f60e | ||
|
|
35997aa882 | ||
|
|
faa4573f6d | ||
|
|
7babaee44c | ||
|
|
c0fe176495 | ||
|
|
b269069b6a | ||
|
|
7e06b5a162 | ||
|
|
a18bb07d78 | ||
|
|
bd28d2054e | ||
|
|
14836f135c | ||
|
|
5f8a77586a | ||
|
|
e5b7fdbae1 | ||
|
|
f1c8dca8c4 | ||
|
|
843b76d8ea | ||
|
|
e81af9e479 | ||
|
|
efab8c8cef | ||
|
|
3f7531e157 | ||
|
|
988f3dced4 | ||
|
|
bd3240c2bc | ||
|
|
7fbbe2871f | ||
|
|
109ece508b | ||
|
|
971144c2e6 | ||
|
|
a3c6edda0b | ||
|
|
71bb4696b8 | ||
|
|
2a3ed0b763 | ||
|
|
632fa56353 | ||
|
|
f3020fc783 | ||
|
|
9fdf5e674e | ||
|
|
cfe03a8628 | ||
|
|
eccf224b63 | ||
|
|
0b2c86ebb5 | ||
|
|
f616857131 | ||
|
|
60fb90a50c | ||
|
|
66f024e961 | ||
|
|
06daacf611 | ||
|
|
c74bc945b6 | ||
|
|
3c605d2976 | ||
|
|
9720066fd7 | ||
|
|
b157e3b187 | ||
|
|
19030fdf2f | ||
|
|
42450b5a22 | ||
|
|
ce11df9bbc | ||
|
|
82e664c5e0 | ||
|
|
8098b33698 | ||
|
|
9c2603557c | ||
|
|
f4209f21dc | ||
|
|
1e3c021a76 | ||
|
|
d8f9256252 | ||
|
|
014bab6c1f | ||
|
|
8872084cab | ||
|
|
76ceb15000 | ||
|
|
7dff951f28 | ||
|
|
05feb7df1c | ||
|
|
ad3b38d222 | ||
|
|
a26e65073c | ||
|
|
7f3d628d01 | ||
|
|
abdf785723 | ||
|
|
85edba03a2 | ||
|
|
d61b21df0a | ||
|
|
7e68dfb851 | ||
|
|
69cbac31e7 | ||
|
|
ce4e0f5630 | ||
|
|
c99c5d573f | ||
|
|
221ef739b9 | ||
|
|
aa98039c35 | ||
|
|
7ef923b89f | ||
|
|
9ac86a6ad0 | ||
|
|
c0c143a166 | ||
|
|
0abfa2fd0c | ||
|
|
3333b29f24 | ||
|
|
880509d611 | ||
|
|
387f5b0d8e | ||
|
|
27b12d6bf4 | ||
|
|
c511f2f528 | ||
|
|
a61165f301 | ||
|
|
98245939fe | ||
|
|
b203832f79 | ||
|
|
c6846b85c7 | ||
|
|
0c15718d31 | ||
|
|
0f1db22452 | ||
|
|
e3970929e4 | ||
|
|
a64bf8e16f | ||
|
|
cf8edc8a1c | ||
|
|
ca9e309b1b | ||
|
|
0ccb669019 | ||
|
|
92acd17e64 | ||
|
|
ff83bcc14a | ||
|
|
f17e0e199c | ||
|
|
7b3b05677c | ||
|
|
403549f449 | ||
|
|
aee4ccb5a2 | ||
|
|
f8c2551eeb | ||
|
|
1bab3464b7 | ||
|
|
2b863b91b3 | ||
|
|
5c4181a5cc | ||
|
|
f9389e3996 | ||
|
|
131ff3e612 | ||
|
|
7dd7378e6c | ||
|
|
4d0da2fdc1 | ||
|
|
ddbc0699ee | ||
|
|
5f14001d01 | ||
|
|
91f1e6d290 | ||
|
|
00d46274f1 | ||
|
|
0aec836b1a | ||
|
|
ee930aa86a | ||
|
|
a88f4d0cb2 | ||
|
|
50c997b568 | ||
|
|
3035320e82 | ||
|
|
98182143ec | ||
|
|
bffbaeb4c6 | ||
|
|
8f1c640bea | ||
|
|
827a2cdd25 | ||
|
|
3202981fbe | ||
|
|
f0edd5020e | ||
|
|
cf1c7ae725 | ||
|
|
1ac637bfd7 | ||
|
|
37933650d3 | ||
|
|
1266dd419c | ||
|
|
74747e8700 | ||
|
|
34ffd62436 | ||
|
|
22c520e841 | ||
|
|
3fa9191150 | ||
|
|
ae4f05a661 | ||
|
|
c178a293a1 | ||
|
|
aebaa16311 | ||
|
|
175807f664 | ||
|
|
abb56af222 | ||
|
|
48139b29cf | ||
|
|
7ec09fb774 | ||
|
|
e37d1c663b | ||
|
|
bdd7f02fe2 | ||
|
|
b4ea818992 | ||
|
|
7cb9e97ecb | ||
|
|
7fdafd854e | ||
|
|
d85ebb63a1 | ||
|
|
c6b7bbc219 | ||
|
|
4d316c7a4a | ||
|
|
75a3059c88 | ||
|
|
b6e4c0ed14 | ||
|
|
0a45b047a2 | ||
|
|
4e79f00551 | ||
|
|
b4ab29393e | ||
|
|
703fb8561a | ||
|
|
f3c020b613 | ||
|
|
4b87b0a196 | ||
|
|
7cc715cedc | ||
|
|
4b032944ac | ||
|
|
cb23fd183e | ||
|
|
fbc039c274 | ||
|
|
b3156dbb0d | ||
|
|
fdce2fa53d | ||
|
|
55d24e96cb | ||
|
|
36d258253f | ||
|
|
865bb131a5 | ||
|
|
eb1e8935f4 | ||
|
|
f8aaf9f36e | ||
|
|
7a4f5ba8bf | ||
|
|
16a993123b | ||
|
|
e547e3e858 | ||
|
|
ea26823fec | ||
|
|
1f4e53ad27 | ||
|
|
374c31e8b4 | ||
|
|
0d726b2b60 | ||
|
|
38a8ac1eb4 | ||
|
|
872e5e72f3 | ||
|
|
d916c1ca19 | ||
|
|
9b1cc965c7 | ||
|
|
83028418fe | ||
|
|
7f680dcffb | ||
|
|
e573088c5e | ||
|
|
7ac9eef7a2 | ||
|
|
286e4314f5 | ||
|
|
6b05938953 | ||
|
|
602ba1d051 | ||
|
|
1710c3f01f | ||
|
|
f57ac3acb1 | ||
|
|
331dab20f7 | ||
|
|
d9076a4f5f | ||
|
|
56d4e438b6 | ||
|
|
430862b24d | ||
|
|
e12367bde7 | ||
|
|
c0f4884242 | ||
|
|
36638e4df6 | ||
|
|
a0440e1587 | ||
|
|
6e78f16c33 | ||
|
|
82b6f1cbf8 | ||
|
|
5be3842aea | ||
|
|
067e03b757 | ||
|
|
391d9ef28f | ||
|
|
5d17d642ec | ||
|
|
22119a3d08 | ||
|
|
306c11bb2f | ||
|
|
3fa9795cde | ||
|
|
7fd0c50146 | ||
|
|
97b11eabbd | ||
|
|
3b2aa02ae5 | ||
|
|
cf11e8235f | ||
|
|
1670b190c2 | ||
|
|
e65e97b1a3 | ||
|
|
c2787d54b0 | ||
|
|
9b7c84cf08 | ||
|
|
3269e92ef2 | ||
|
|
0ae7bcaf7c | ||
|
|
9694d407ae | ||
|
|
82aa2785ea | ||
|
|
337dbd74fd | ||
|
|
caa55fe89a | ||
|
|
289b30e823 | ||
|
|
b939bc5a64 | ||
|
|
5e8f2312d3 | ||
|
|
90c8b19915 | ||
|
|
d82ef3f8d1 | ||
|
|
fc006dc53e | ||
|
|
3ce191aaf2 | ||
|
|
6fc89727f2 | ||
|
|
b235ac540f | ||
|
|
97decf8c52 | ||
|
|
97cdf34c18 | ||
|
|
92c77c07e0 | ||
|
|
0541a70cec | ||
|
|
e0cb2f4925 | ||
|
|
68a46af1a8 | ||
|
|
f61158b9c0 | ||
|
|
88954eca5c | ||
|
|
3fc04616b3 | ||
|
|
2d5f768523 | ||
|
|
5949ff74ec | ||
|
|
879ecd1f6d | ||
|
|
0e72c3f896 | ||
|
|
b93a716a3b | ||
|
|
0d92c3812a | ||
|
|
fc110a0bff | ||
|
|
008edd8bee | ||
|
|
ac7e85c24a | ||
|
|
73b8ce4add | ||
|
|
511ce554b1 | ||
|
|
536842971d | ||
|
|
3e224a33a7 | ||
|
|
3f4c362bfa | ||
|
|
8a838aa4bd | ||
|
|
7e379b33db | ||
|
|
5e9f7e2c63 | ||
|
|
3f752cd7b7 | ||
|
|
25a3ef3f0c | ||
|
|
1b28efb6af | ||
|
|
441a2be0b8 | ||
|
|
1bdc4bd293 | ||
|
|
f0bb4c5b02 | ||
|
|
4660322964 | ||
|
|
59efc2c485 | ||
|
|
69b0ff9fae | ||
|
|
4b94ea7ef2 | ||
|
|
0244f5cfca | ||
|
|
17c7a3c524 | ||
|
|
a02087bf2a | ||
|
|
585f909d3f | ||
|
|
eb10c8e21f | ||
|
|
f7ea0cb834 | ||
|
|
64f3842a13 | ||
|
|
6370679b62 | ||
|
|
e77728c52c | ||
|
|
92f4e26883 | ||
|
|
024f08562b | ||
|
|
b4246fe170 | ||
|
|
fc6db5bff2 | ||
|
|
c5d3e7c0f2 | ||
|
|
10b57adb37 | ||
|
|
4f839d05f9 | ||
|
|
84393e9e4a | ||
|
|
b94cef92d2 | ||
|
|
10c04be051 | ||
|
|
7ecd6212ac | ||
|
|
11180e507c | ||
|
|
1c90ce5b41 | ||
|
|
11dd9ad02f | ||
|
|
27c0deaba3 | ||
|
|
4c09258566 | ||
|
|
7d14429d84 | ||
|
|
190825f5ef | ||
|
|
021edfd39d | ||
|
|
3052f28329 | ||
|
|
4cec20e357 | ||
|
|
8a0cbe32bd | ||
|
|
8a3a52a21b | ||
|
|
98a9b22e0e | ||
|
|
9178cf6062 | ||
|
|
abbb20e49e | ||
|
|
01d2eae7bc | ||
|
|
39d27d2730 | ||
|
|
05b2de561e | ||
|
|
667b0c80ca | ||
|
|
67624eea6f | ||
|
|
8cfda69717 | ||
|
|
463c4d147c | ||
|
|
6da688cc9e | ||
|
|
c1d164bd73 | ||
|
|
d43e4b2465 | ||
|
|
98ee9bb0db | ||
|
|
cd2aed00d7 | ||
|
|
0ee37b1cd3 | ||
|
|
486c66b198 |
32
.codeclimate.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
engines:
|
||||||
|
csslint:
|
||||||
|
enabled: true
|
||||||
|
duplication:
|
||||||
|
enabled: true
|
||||||
|
config:
|
||||||
|
languages:
|
||||||
|
- ruby
|
||||||
|
- javascript
|
||||||
|
- python
|
||||||
|
- php
|
||||||
|
eslint:
|
||||||
|
enabled: true
|
||||||
|
fixme:
|
||||||
|
enabled: true
|
||||||
|
radon:
|
||||||
|
enabled: true
|
||||||
|
rubocop:
|
||||||
|
enabled: true
|
||||||
|
ratings:
|
||||||
|
paths:
|
||||||
|
- "**.css"
|
||||||
|
- "**.inc"
|
||||||
|
- "**.js"
|
||||||
|
- "**.jsx"
|
||||||
|
- "**.module"
|
||||||
|
- "**.php"
|
||||||
|
- "**.py"
|
||||||
|
- "**.rb"
|
||||||
|
exclude_paths:
|
||||||
|
- config/
|
||||||
6
.coveragerc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[run]
|
||||||
|
source =
|
||||||
|
./
|
||||||
|
|
||||||
|
omit =
|
||||||
|
*/migrations/*
|
||||||
2
.csslintrc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
--exclude-exts=.min.css
|
||||||
|
--ignore=adjoining-classes,box-model,ids,order-alphabetical,unqualified-attributes
|
||||||
1
.eslintignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
**/*{.,-}min.js
|
||||||
213
.eslintrc
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
ecmaFeatures:
|
||||||
|
modules: true
|
||||||
|
jsx: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
amd: true
|
||||||
|
browser: true
|
||||||
|
es6: true
|
||||||
|
jquery: true
|
||||||
|
node: true
|
||||||
|
|
||||||
|
# http://eslint.org/docs/rules/
|
||||||
|
rules:
|
||||||
|
# Possible Errors
|
||||||
|
comma-dangle: [2, never]
|
||||||
|
no-cond-assign: 2
|
||||||
|
no-console: 0
|
||||||
|
no-constant-condition: 2
|
||||||
|
no-control-regex: 2
|
||||||
|
no-debugger: 2
|
||||||
|
no-dupe-args: 2
|
||||||
|
no-dupe-keys: 2
|
||||||
|
no-duplicate-case: 2
|
||||||
|
no-empty: 2
|
||||||
|
no-empty-character-class: 2
|
||||||
|
no-ex-assign: 2
|
||||||
|
no-extra-boolean-cast: 2
|
||||||
|
no-extra-parens: 0
|
||||||
|
no-extra-semi: 2
|
||||||
|
no-func-assign: 2
|
||||||
|
no-inner-declarations: [2, functions]
|
||||||
|
no-invalid-regexp: 2
|
||||||
|
no-irregular-whitespace: 2
|
||||||
|
no-negated-in-lhs: 2
|
||||||
|
no-obj-calls: 2
|
||||||
|
no-regex-spaces: 2
|
||||||
|
no-sparse-arrays: 2
|
||||||
|
no-unexpected-multiline: 2
|
||||||
|
no-unreachable: 2
|
||||||
|
use-isnan: 2
|
||||||
|
valid-jsdoc: 0
|
||||||
|
valid-typeof: 2
|
||||||
|
|
||||||
|
# Best Practices
|
||||||
|
accessor-pairs: 2
|
||||||
|
block-scoped-var: 0
|
||||||
|
complexity: [2, 6]
|
||||||
|
consistent-return: 0
|
||||||
|
curly: 0
|
||||||
|
default-case: 0
|
||||||
|
dot-location: 0
|
||||||
|
dot-notation: 0
|
||||||
|
eqeqeq: 2
|
||||||
|
guard-for-in: 2
|
||||||
|
no-alert: 2
|
||||||
|
no-caller: 2
|
||||||
|
no-case-declarations: 2
|
||||||
|
no-div-regex: 2
|
||||||
|
no-else-return: 0
|
||||||
|
no-empty-label: 2
|
||||||
|
no-empty-pattern: 2
|
||||||
|
no-eq-null: 2
|
||||||
|
no-eval: 2
|
||||||
|
no-extend-native: 2
|
||||||
|
no-extra-bind: 2
|
||||||
|
no-fallthrough: 2
|
||||||
|
no-floating-decimal: 0
|
||||||
|
no-implicit-coercion: 0
|
||||||
|
no-implied-eval: 2
|
||||||
|
no-invalid-this: 0
|
||||||
|
no-iterator: 2
|
||||||
|
no-labels: 0
|
||||||
|
no-lone-blocks: 2
|
||||||
|
no-loop-func: 2
|
||||||
|
no-magic-number: 0
|
||||||
|
no-multi-spaces: 0
|
||||||
|
no-multi-str: 0
|
||||||
|
no-native-reassign: 2
|
||||||
|
no-new-func: 2
|
||||||
|
no-new-wrappers: 2
|
||||||
|
no-new: 2
|
||||||
|
no-octal-escape: 2
|
||||||
|
no-octal: 2
|
||||||
|
no-proto: 2
|
||||||
|
no-redeclare: 2
|
||||||
|
no-return-assign: 2
|
||||||
|
no-script-url: 2
|
||||||
|
no-self-compare: 2
|
||||||
|
no-sequences: 0
|
||||||
|
no-throw-literal: 0
|
||||||
|
no-unused-expressions: 2
|
||||||
|
no-useless-call: 2
|
||||||
|
no-useless-concat: 2
|
||||||
|
no-void: 2
|
||||||
|
no-warning-comments: 0
|
||||||
|
no-with: 2
|
||||||
|
radix: 2
|
||||||
|
vars-on-top: 0
|
||||||
|
wrap-iife: 2
|
||||||
|
yoda: 0
|
||||||
|
|
||||||
|
# Strict
|
||||||
|
strict: 0
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
init-declarations: 0
|
||||||
|
no-catch-shadow: 2
|
||||||
|
no-delete-var: 2
|
||||||
|
no-label-var: 2
|
||||||
|
no-shadow-restricted-names: 2
|
||||||
|
no-shadow: 0
|
||||||
|
no-undef-init: 2
|
||||||
|
no-undef: 0
|
||||||
|
no-undefined: 0
|
||||||
|
no-unused-vars: 0
|
||||||
|
no-use-before-define: 0
|
||||||
|
|
||||||
|
# Node.js and CommonJS
|
||||||
|
callback-return: 2
|
||||||
|
global-require: 2
|
||||||
|
handle-callback-err: 2
|
||||||
|
no-mixed-requires: 0
|
||||||
|
no-new-require: 0
|
||||||
|
no-path-concat: 2
|
||||||
|
no-process-exit: 2
|
||||||
|
no-restricted-modules: 0
|
||||||
|
no-sync: 0
|
||||||
|
|
||||||
|
# Stylistic Issues
|
||||||
|
array-bracket-spacing: 0
|
||||||
|
block-spacing: 0
|
||||||
|
brace-style: 0
|
||||||
|
camelcase: 0
|
||||||
|
comma-spacing: 0
|
||||||
|
comma-style: 0
|
||||||
|
computed-property-spacing: 0
|
||||||
|
consistent-this: 0
|
||||||
|
eol-last: 0
|
||||||
|
func-names: 0
|
||||||
|
func-style: 0
|
||||||
|
id-length: 0
|
||||||
|
id-match: 0
|
||||||
|
indent: 0
|
||||||
|
jsx-quotes: 0
|
||||||
|
key-spacing: 0
|
||||||
|
linebreak-style: 0
|
||||||
|
lines-around-comment: 0
|
||||||
|
max-depth: 0
|
||||||
|
max-len: 0
|
||||||
|
max-nested-callbacks: 0
|
||||||
|
max-params: 0
|
||||||
|
max-statements: [2, 30]
|
||||||
|
new-cap: 0
|
||||||
|
new-parens: 0
|
||||||
|
newline-after-var: 0
|
||||||
|
no-array-constructor: 0
|
||||||
|
no-bitwise: 0
|
||||||
|
no-continue: 0
|
||||||
|
no-inline-comments: 0
|
||||||
|
no-lonely-if: 0
|
||||||
|
no-mixed-spaces-and-tabs: 0
|
||||||
|
no-multiple-empty-lines: 0
|
||||||
|
no-negated-condition: 0
|
||||||
|
no-nested-ternary: 0
|
||||||
|
no-new-object: 0
|
||||||
|
no-plusplus: 0
|
||||||
|
no-restricted-syntax: 0
|
||||||
|
no-spaced-func: 0
|
||||||
|
no-ternary: 0
|
||||||
|
no-trailing-spaces: 0
|
||||||
|
no-underscore-dangle: 0
|
||||||
|
no-unneeded-ternary: 0
|
||||||
|
object-curly-spacing: 0
|
||||||
|
one-var: 0
|
||||||
|
operator-assignment: 0
|
||||||
|
operator-linebreak: 0
|
||||||
|
padded-blocks: 0
|
||||||
|
quote-props: 0
|
||||||
|
quotes: 0
|
||||||
|
require-jsdoc: 0
|
||||||
|
semi-spacing: 0
|
||||||
|
semi: 0
|
||||||
|
sort-vars: 0
|
||||||
|
space-after-keywords: 0
|
||||||
|
space-before-blocks: 0
|
||||||
|
space-before-function-paren: 0
|
||||||
|
space-before-keywords: 0
|
||||||
|
space-in-parens: 0
|
||||||
|
space-infix-ops: 0
|
||||||
|
space-return-throw-case: 0
|
||||||
|
space-unary-ops: 0
|
||||||
|
spaced-comment: 0
|
||||||
|
wrap-regex: 0
|
||||||
|
|
||||||
|
# ECMAScript 6
|
||||||
|
arrow-body-style: 0
|
||||||
|
arrow-parens: 0
|
||||||
|
arrow-spacing: 0
|
||||||
|
constructor-super: 0
|
||||||
|
generator-star-spacing: 0
|
||||||
|
no-arrow-condition: 0
|
||||||
|
no-class-assign: 0
|
||||||
|
no-const-assign: 0
|
||||||
|
no-dupe-class-members: 0
|
||||||
|
no-this-before-super: 0
|
||||||
|
no-var: 0
|
||||||
|
object-shorthand: 0
|
||||||
|
prefer-arrow-callback: 0
|
||||||
|
prefer-const: 0
|
||||||
|
prefer-reflect: 0
|
||||||
|
prefer-spread: 0
|
||||||
|
prefer-template: 0
|
||||||
|
require-yield: 0
|
||||||
7
.gitignore
vendored
@@ -1,3 +1,6 @@
|
|||||||
|
tmp/
|
||||||
|
db.sqlite3
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
@@ -25,9 +28,6 @@ var/
|
|||||||
|
|
||||||
# Continer extras
|
# Continer extras
|
||||||
.vagrant
|
.vagrant
|
||||||
_builds
|
|
||||||
_steps
|
|
||||||
_projects
|
|
||||||
|
|
||||||
# PyInstaller
|
# PyInstaller
|
||||||
# Usually these files are written by a python script from a template
|
# Usually these files are written by a python script from a template
|
||||||
@@ -53,6 +53,7 @@ coverage.xml
|
|||||||
|
|
||||||
# Django stuff:
|
# Django stuff:
|
||||||
*.log
|
*.log
|
||||||
|
db.sqlite3
|
||||||
|
|
||||||
# Sphinx documentation
|
# Sphinx documentation
|
||||||
docs/_build/
|
docs/_build/
|
||||||
|
|||||||
1156
.rubocop.yml
Normal file
32
.travis.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
language: python
|
||||||
|
python:
|
||||||
|
"3.6"
|
||||||
|
cache: pip
|
||||||
|
|
||||||
|
addons:
|
||||||
|
chrome: stable
|
||||||
|
|
||||||
|
install:
|
||||||
|
- wget https://chromedriver.storage.googleapis.com/2.36/chromedriver_linux64.zip
|
||||||
|
- unzip chromedriver_linux64.zip
|
||||||
|
- export PATH=$PATH:$(pwd)
|
||||||
|
- chmod +x chromedriver
|
||||||
|
- pip install -r requirements.txt
|
||||||
|
- pip install coveralls codeclimate-test-reporter pep8
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- export PATH=$PATH:/usr/lib/chromium-browser/
|
||||||
|
- python manage.py collectstatic --noinput
|
||||||
|
|
||||||
|
script:
|
||||||
|
- pep8 . --exclude=migrations,importer*
|
||||||
|
- python manage.py check
|
||||||
|
- python manage.py makemigrations --check --dry-run
|
||||||
|
- coverage run manage.py test --verbosity=2
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- coveralls
|
||||||
|
- codeclimate-test-reporter
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
webhooks: https://fathomless-fjord-24024.herokuapp.com/notify
|
||||||
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM python:3.6
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ADD . /app
|
||||||
|
|
||||||
|
RUN pip install -r requirements.txt && \
|
||||||
|
python manage.py collectstatic --noinput
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
||||||
@@ -1,26 +1,39 @@
|
|||||||
from django.contrib.auth import REDIRECT_FIELD_NAME
|
from django.contrib.auth import REDIRECT_FIELD_NAME
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render
|
||||||
from django.template import RequestContext
|
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
def user_passes_test_with_403(test_func, login_url=None):
|
from RIGS import models
|
||||||
|
|
||||||
|
|
||||||
|
def user_passes_test_with_403(test_func, login_url=None, oembed_view=None):
|
||||||
"""
|
"""
|
||||||
Decorator for views that checks that the user passes the given test.
|
Decorator for views that checks that the user passes the given test.
|
||||||
|
|
||||||
Anonymous users will be redirected to login_url, while users that fail
|
Anonymous users will be redirected to login_url, while users that fail
|
||||||
the test will be given a 403 error.
|
the test will be given a 403 error.
|
||||||
|
If embed_view is set, then a JS redirect will be used, and a application/json+oembed
|
||||||
|
meta tag set with the url of oembed_view
|
||||||
|
(oembed_view will be passed the kwargs from the main function)
|
||||||
"""
|
"""
|
||||||
if not login_url:
|
if not login_url:
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
login_url = settings.LOGIN_URL
|
login_url = settings.LOGIN_URL
|
||||||
|
|
||||||
def _dec(view_func):
|
def _dec(view_func):
|
||||||
def _checklogin(request, *args, **kwargs):
|
def _checklogin(request, *args, **kwargs):
|
||||||
if test_func(request.user):
|
if test_func(request.user):
|
||||||
return view_func(request, *args, **kwargs)
|
return view_func(request, *args, **kwargs)
|
||||||
elif not request.user.is_authenticated():
|
elif not request.user.is_authenticated:
|
||||||
return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, request.get_full_path()))
|
if oembed_view is not None:
|
||||||
|
context = {}
|
||||||
|
context['oembed_url'] = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'], reverse(oembed_view, kwargs=kwargs))
|
||||||
|
context['login_url'] = "{0}?{1}={2}".format(login_url, REDIRECT_FIELD_NAME, request.get_full_path())
|
||||||
|
resp = render(request, 'login_redirect.html', context=context)
|
||||||
|
return resp
|
||||||
|
else:
|
||||||
|
return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, request.get_full_path()))
|
||||||
else:
|
else:
|
||||||
resp = render_to_response('403.html', context_instance=RequestContext(request))
|
resp = render(request, '403.html')
|
||||||
resp.status_code = 403
|
resp.status_code = 403
|
||||||
return resp
|
return resp
|
||||||
_checklogin.__doc__ = view_func.__doc__
|
_checklogin.__doc__ = view_func.__doc__
|
||||||
@@ -28,14 +41,14 @@ def user_passes_test_with_403(test_func, login_url=None):
|
|||||||
return _checklogin
|
return _checklogin
|
||||||
return _dec
|
return _dec
|
||||||
|
|
||||||
def permission_required_with_403(perm, login_url=None):
|
|
||||||
|
def permission_required_with_403(perm, login_url=None, oembed_view=None):
|
||||||
"""
|
"""
|
||||||
Decorator for views that checks whether a user has a particular permission
|
Decorator for views that checks whether a user has a particular permission
|
||||||
enabled, redirecting to the log-in page or rendering a 403 as necessary.
|
enabled, redirecting to the log-in page or rendering a 403 as necessary.
|
||||||
"""
|
"""
|
||||||
return user_passes_test_with_403(lambda u: u.has_perm(perm), login_url=login_url)
|
return user_passes_test_with_403(lambda u: u.has_perm(perm), login_url=login_url, oembed_view=oembed_view)
|
||||||
|
|
||||||
from RIGS import models
|
|
||||||
|
|
||||||
def api_key_required(function):
|
def api_key_required(function):
|
||||||
"""
|
"""
|
||||||
@@ -48,7 +61,7 @@ def api_key_required(function):
|
|||||||
userid = kwargs.get('api_pk')
|
userid = kwargs.get('api_pk')
|
||||||
key = kwargs.get('api_key')
|
key = kwargs.get('api_key')
|
||||||
|
|
||||||
error_resp = render_to_response('403.html', context_instance=RequestContext(request))
|
error_resp = render(request, '403.html')
|
||||||
error_resp.status_code = 403
|
error_resp.status_code = 403
|
||||||
|
|
||||||
if key is None:
|
if key is None:
|
||||||
@@ -65,3 +78,17 @@ def api_key_required(function):
|
|||||||
return error_resp
|
return error_resp
|
||||||
return function(request, *args, **kwargs)
|
return function(request, *args, **kwargs)
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
|
|
||||||
|
def nottinghamtec_address_required(function):
|
||||||
|
"""
|
||||||
|
Checks that the current user has an email address ending @nottinghamtec.co.uk
|
||||||
|
"""
|
||||||
|
def wrap(request, *args, **kwargs):
|
||||||
|
# Fail if current user's email address isn't @nottinghamtec.co.uk
|
||||||
|
if not request.user.email.endswith('@nottinghamtec.co.uk'):
|
||||||
|
error_resp = render(request, 'RIGS/eventauthorisation_request_error.html')
|
||||||
|
return error_resp
|
||||||
|
|
||||||
|
return function(request, *args, **kwargs)
|
||||||
|
return wrap
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
DATETIME_FORMAT = ('d/m/Y H:i')
|
DATETIME_FORMAT = ('d/m/Y H:i')
|
||||||
DATE_FORMAT = ('d/m/Y')
|
DATE_FORMAT = ('d/m/Y')
|
||||||
|
|||||||
@@ -10,24 +10,37 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
|
|||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
import os
|
import os
|
||||||
|
import raven
|
||||||
|
import secrets
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
|
# 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 = os.environ.get('SECRET_KEY') if os.environ.get('SECRET_KEY') else 'gxhy(a#5mhp289_=6xx$7jh=eh$ymxg^ymc+di*0c*geiu3p_e'
|
SECRET_KEY = os.environ.get('SECRET_KEY') if os.environ.get(
|
||||||
|
'SECRET_KEY') else '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 = bool(int(os.environ.get('DEBUG'))) if os.environ.get('DEBUG') else True
|
DEBUG = bool(int(os.environ.get('DEBUG'))) if os.environ.get('DEBUG') else True
|
||||||
|
|
||||||
TEMPLATE_DEBUG = True
|
|
||||||
|
STAGING = bool(int(os.environ.get('STAGING'))) if os.environ.get('STAGING') else 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']
|
||||||
|
|
||||||
|
if STAGING:
|
||||||
|
ALLOWED_HOSTS.append('.herokuapp.com')
|
||||||
|
|
||||||
|
if DEBUG:
|
||||||
|
ALLOWED_HOSTS.append('localhost')
|
||||||
|
ALLOWED_HOSTS.append('example.com')
|
||||||
|
ALLOWED_HOSTS.append('127.0.0.1')
|
||||||
|
|
||||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
if not DEBUG:
|
if not DEBUG:
|
||||||
SECURE_SSL_REDIRECT = True # Redirect all http requests to https
|
SECURE_SSL_REDIRECT = True # Redirect all http requests to https
|
||||||
|
|
||||||
INTERNAL_IPS = ['127.0.0.1']
|
INTERNAL_IPS = ['127.0.0.1']
|
||||||
|
|
||||||
@@ -35,7 +48,6 @@ ADMINS = (
|
|||||||
('Tom Price', 'tomtom5152@gmail.com')
|
('Tom Price', 'tomtom5152@gmail.com')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
@@ -46,7 +58,6 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'RIGS',
|
'RIGS',
|
||||||
'subhire',
|
|
||||||
|
|
||||||
'debug_toolbar',
|
'debug_toolbar',
|
||||||
'registration',
|
'registration',
|
||||||
@@ -56,15 +67,15 @@ INSTALLED_APPS = (
|
|||||||
'raven.contrib.django.raven_compat',
|
'raven.contrib.django.raven_compat',
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = (
|
MIDDLEWARE = (
|
||||||
'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',
|
'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'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',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
)
|
)
|
||||||
@@ -73,7 +84,6 @@ ROOT_URLCONF = 'PyRIGS.urls'
|
|||||||
|
|
||||||
WSGI_APPLICATION = 'PyRIGS.wsgi.application'
|
WSGI_APPLICATION = 'PyRIGS.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
@@ -85,6 +95,7 @@ DATABASES = {
|
|||||||
|
|
||||||
if not DEBUG:
|
if not DEBUG:
|
||||||
import dj_database_url
|
import dj_database_url
|
||||||
|
|
||||||
DATABASES['default'] = dj_database_url.config()
|
DATABASES['default'] = dj_database_url.config()
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
@@ -115,12 +126,12 @@ LOGGING = {
|
|||||||
'mail_admins': {
|
'mail_admins': {
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
'class': 'django.utils.log.AdminEmailHandler',
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
# But the emails are plain text by default - HTML is nicer
|
# But the emails are plain text by default - HTML is nicer
|
||||||
'include_html': True,
|
'include_html': True,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'loggers': {
|
'loggers': {
|
||||||
# Again, default Django configuration to email unhandled exceptions
|
# Again, default Django configuration to email unhandled exceptions
|
||||||
'django.request': {
|
'django.request': {
|
||||||
'handlers': ['mail_admins'],
|
'handlers': ['mail_admins'],
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
@@ -135,8 +146,6 @@ LOGGING = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
import raven
|
|
||||||
|
|
||||||
RAVEN_CONFIG = {
|
RAVEN_CONFIG = {
|
||||||
'dsn': os.environ.get('RAVEN_DSN'),
|
'dsn': os.environ.get('RAVEN_DSN'),
|
||||||
# If you are using git, you can also automatically configure the
|
# If you are using git, you can also automatically configure the
|
||||||
@@ -148,14 +157,14 @@ RAVEN_CONFIG = {
|
|||||||
AUTH_USER_MODEL = 'RIGS.Profile'
|
AUTH_USER_MODEL = 'RIGS.Profile'
|
||||||
|
|
||||||
LOGIN_REDIRECT_URL = '/'
|
LOGIN_REDIRECT_URL = '/'
|
||||||
LOGIN_URL = '/user/login'
|
LOGIN_URL = '/user/login/'
|
||||||
LOGOUT_URL = '/user/logout'
|
LOGOUT_URL = '/user/logout/'
|
||||||
|
|
||||||
ACCOUNT_ACTIVATION_DAYS = 7
|
ACCOUNT_ACTIVATION_DAYS = 7
|
||||||
|
|
||||||
# reCAPTCHA settings
|
# reCAPTCHA settings
|
||||||
RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY', None)
|
RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY', "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI") # If not set, use development key
|
||||||
RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY', None)
|
RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY', "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe") # If not set, use development key
|
||||||
NOCAPTCHA = True
|
NOCAPTCHA = True
|
||||||
|
|
||||||
# Email
|
# Email
|
||||||
@@ -163,7 +172,7 @@ EMAILER_TEST = False
|
|||||||
if not DEBUG or EMAILER_TEST:
|
if not DEBUG or EMAILER_TEST:
|
||||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||||
EMAIL_HOST = os.environ.get('EMAIL_HOST')
|
EMAIL_HOST = os.environ.get('EMAIL_HOST')
|
||||||
EMAIL_PORT = int(os.environ.get('EMAIL_PORT'))
|
EMAIL_PORT = int(os.environ.get('EMAIL_PORT', 25))
|
||||||
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
|
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
|
||||||
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
|
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
|
||||||
EMAIL_USE_TLS = bool(int(os.environ.get('EMAIL_USE_TLS', 0)))
|
EMAIL_USE_TLS = bool(int(os.environ.get('EMAIL_USE_TLS', 0)))
|
||||||
@@ -187,19 +196,7 @@ USE_L10N = True
|
|||||||
|
|
||||||
USE_TZ = True
|
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')
|
||||||
|
|
||||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
|
||||||
"django.contrib.auth.context_processors.auth",
|
|
||||||
"django.core.context_processors.debug",
|
|
||||||
"django.core.context_processors.i18n",
|
|
||||||
"django.core.context_processors.media",
|
|
||||||
"django.core.context_processors.static",
|
|
||||||
"django.core.context_processors.tz",
|
|
||||||
"django.core.context_processors.request",
|
|
||||||
"django.contrib.messages.context_processors.messages",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/1.7/howto/static-files/
|
# https://docs.djangoproject.com/en/1.7/howto/static-files/
|
||||||
@@ -210,10 +207,34 @@ STATIC_DIRS = (
|
|||||||
os.path.join(BASE_DIR, 'static/')
|
os.path.join(BASE_DIR, 'static/')
|
||||||
)
|
)
|
||||||
|
|
||||||
TEMPLATE_DIRS = (
|
TEMPLATES = [
|
||||||
os.path.join(BASE_DIR, 'templates'),
|
{
|
||||||
)
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
'DIRS': [
|
||||||
|
os.path.join(BASE_DIR, 'templates'),
|
||||||
|
],
|
||||||
|
'APP_DIRS': True,
|
||||||
|
'OPTIONS': {
|
||||||
|
'context_processors': [
|
||||||
|
"django.contrib.auth.context_processors.auth",
|
||||||
|
"django.template.context_processors.debug",
|
||||||
|
"django.template.context_processors.i18n",
|
||||||
|
"django.template.context_processors.media",
|
||||||
|
"django.template.context_processors.static",
|
||||||
|
"django.template.context_processors.tz",
|
||||||
|
"django.template.context_processors.request",
|
||||||
|
"django.contrib.messages.context_processors.messages",
|
||||||
|
],
|
||||||
|
'debug': DEBUG
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
USE_GRAVATAR=True
|
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'
|
||||||
|
RISK_ASSESSMENT_URL = os.environ.get('RISK_ASSESSMENT_URL') if os.environ.get(
|
||||||
|
'RISK_ASSESSMENT_URL') else "http://example.com"
|
||||||
|
RISK_ASSESSMENT_SECRET = os.environ.get('RISK_ASSESSMENT_SECRET') if os.environ.get(
|
||||||
|
'RISK_ASSESSMENT_SECRET') else secrets.token_hex(15)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from django.conf.urls import patterns, include, url
|
from django.conf.urls import include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -6,7 +6,7 @@ from registration.backends.default.views import RegistrationView
|
|||||||
import RIGS
|
import RIGS
|
||||||
from RIGS import regbackend
|
from RIGS import regbackend
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = [
|
||||||
# Examples:
|
# Examples:
|
||||||
# url(r'^$', 'PyRIGS.views.home', name='home'),
|
# url(r'^$', 'PyRIGS.views.home', name='home'),
|
||||||
# url(r'^blog/', include('blog.urls')),
|
# url(r'^blog/', include('blog.urls')),
|
||||||
@@ -17,8 +17,13 @@ urlpatterns = patterns('',
|
|||||||
url('^user/', include('django.contrib.auth.urls')),
|
url('^user/', include('django.contrib.auth.urls')),
|
||||||
url('^user/', include('registration.backends.default.urls')),
|
url('^user/', include('registration.backends.default.urls')),
|
||||||
|
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', admin.site.urls),
|
||||||
)
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += staticfiles_urlpatterns()
|
urlpatterns += staticfiles_urlpatterns()
|
||||||
|
|
||||||
|
import debug_toolbar
|
||||||
|
urlpatterns = [
|
||||||
|
url(r'^__debug__/', include(debug_toolbar.urls)),
|
||||||
|
] + urlpatterns
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
|
|||||||
import os
|
import os
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PyRIGS.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PyRIGS.settings")
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application # noqa
|
||||||
from dj_static import Cling
|
from dj_static import Cling # noqa
|
||||||
|
|
||||||
application = Cling(get_wsgi_application())
|
application = Cling(get_wsgi_application())
|
||||||
|
|||||||
43
README.md
@@ -1,5 +1,8 @@
|
|||||||
# TEC PA & Lighting - PyRIGS #
|
# TEC PA & Lighting - PyRIGS #
|
||||||
[](https://app.wercker.com/project/bykey/2dbe0517c3d83859c985ffc5a55a2802)
|
[](https://travis-ci.org/nottinghamtec/PyRIGS)
|
||||||
|
[](https://coveralls.io/github/nottinghamtec/PyRIGS?branch=develop)
|
||||||
|
[](https://gemnasium.com/github.com/nottinghamtec/PyRIGS)
|
||||||
|
|
||||||
|
|
||||||
Welcome to TEC PA & Lightings PyRIGS program. This is a reimplementation of the existing Rig Information Gathering System (RIGS) that was developed using Ruby on Rails.
|
Welcome to TEC PA & Lightings PyRIGS program. This is a reimplementation of the existing Rig Information Gathering System (RIGS) that was developed using Ruby on Rails.
|
||||||
|
|
||||||
@@ -74,5 +77,43 @@ python manage.py runserver
|
|||||||
```
|
```
|
||||||
Please refer to Django documentation for a full list of options available here.
|
Please refer to Django documentation for a full list of options available here.
|
||||||
|
|
||||||
|
### Development using docker
|
||||||
|
|
||||||
|
```
|
||||||
|
docker build . -t pyrigs
|
||||||
|
docker run -it --rm -p=8000:8000 -v $(pwd):/app pyrigs
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sample Data ###
|
||||||
|
Sample data is available to aid local development and user acceptance testing. To load this data into your local database, first ensure the database is empty:
|
||||||
|
```
|
||||||
|
python manage.py flush
|
||||||
|
```
|
||||||
|
Then load the sample data using the command:
|
||||||
|
```
|
||||||
|
python manage.py generateSampleData
|
||||||
|
```
|
||||||
|
4 user accounts are created for convenience:
|
||||||
|
|
||||||
|
|Username |Password |
|
||||||
|
|---------|---------|
|
||||||
|
|superuser|superuser|
|
||||||
|
|finance |finance |
|
||||||
|
|keyholder|keyholder|
|
||||||
|
|basic |basic |
|
||||||
|
|
||||||
|
### Testing ###
|
||||||
|
Tests are contained in 3 files. `RIGS/test_models.py` contains tests for logic within the data models. `RIGS/test_unit.py` contains "Live server" tests, using raw web requests. `RIGS/test_integration.py` contains user interface tests which take control of a web browser. For automated Travis tests, we use [Sauce Labs](https://saucelabs.com). When debugging locally, ensure that you have the latest version of Google Chrome installed, then install [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/) and ensure it is on the `PATH`.
|
||||||
|
|
||||||
|
You can run the entire test suite, or you can run specific sections individually. For example, in order of specificity:
|
||||||
|
|
||||||
|
```
|
||||||
|
python manage.py test
|
||||||
|
python manage.py test RIGS.test_models
|
||||||
|
python manage.py test RIGS.test_models.EventTestCase
|
||||||
|
python manage.py test RIGS.test_models.EventTestCase.test_current_events
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
### Committing, pushing and testing ###
|
### Committing, pushing and testing ###
|
||||||
Feel free to commit as you wish, on your own branch. On my branch (master for development) do not commit code that you either know doesn't work or don't know works. If you must commit this code, please make sure you say in the commit message that it isn't working, and if you can why it isn't working. If and only if you absolutely must push, then please don't leave it as the HEAD for too long, it's not much to ask but when you are done just make sure you haven't broken the HEAD for the next person.
|
Feel free to commit as you wish, on your own branch. On my branch (master for development) do not commit code that you either know doesn't work or don't know works. If you must commit this code, please make sure you say in the commit message that it isn't working, and if you can why it isn't working. If and only if you absolutely must push, then please don't leave it as the HEAD for too long, it's not much to ask but when you are done just make sure you haven't broken the HEAD for the next person.
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
default_app_config = 'RIGS.apps.RIGSAppConfig'
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from django.contrib import admin
|
|||||||
from RIGS import models, forms
|
from RIGS import models, forms
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
import reversion
|
from reversion.admin import VersionAdmin
|
||||||
|
|
||||||
from django.contrib.admin import helpers
|
from django.contrib.admin import helpers
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
@@ -12,10 +12,12 @@ from django.core.exceptions import ObjectDoesNotExist
|
|||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
|
|
||||||
|
from reversion import revisions as reversion
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
admin.site.register(models.VatRate, reversion.VersionAdmin)
|
admin.site.register(models.VatRate, VersionAdmin)
|
||||||
admin.site.register(models.Event, reversion.VersionAdmin)
|
admin.site.register(models.Event, VersionAdmin)
|
||||||
admin.site.register(models.EventItem, reversion.VersionAdmin)
|
admin.site.register(models.EventItem, VersionAdmin)
|
||||||
admin.site.register(models.Invoice)
|
admin.site.register(models.Invoice)
|
||||||
admin.site.register(models.Payment)
|
admin.site.register(models.Payment)
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ class ProfileAdmin(UserAdmin):
|
|||||||
add_form = forms.ProfileCreationForm
|
add_form = forms.ProfileCreationForm
|
||||||
|
|
||||||
|
|
||||||
class AssociateAdmin(reversion.VersionAdmin):
|
class AssociateAdmin(VersionAdmin):
|
||||||
list_display = ('id', 'name', 'number_of_events')
|
list_display = ('id', 'name', 'number_of_events')
|
||||||
search_fields = ['id', 'name']
|
search_fields = ['id', 'name']
|
||||||
list_display_links = ['id', 'name']
|
list_display_links = ['id', 'name']
|
||||||
@@ -93,8 +95,7 @@ class AssociateAdmin(reversion.VersionAdmin):
|
|||||||
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
|
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
|
||||||
'forms': forms
|
'forms': forms
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, 'RIGS/admin_associate_merge.html', context,
|
return TemplateResponse(request, 'RIGS/admin_associate_merge.html', context)
|
||||||
current_app=self.admin_site.name)
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(models.Person)
|
@admin.register(models.Person)
|
||||||
|
|||||||
8
RIGS/apps.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class RIGSAppConfig(AppConfig):
|
||||||
|
name = 'RIGS'
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
import RIGS.signals
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
import cStringIO as StringIO
|
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.http import Http404, HttpResponseRedirect
|
from django.http import Http404, HttpResponseRedirect
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
@@ -15,6 +14,9 @@ from z3c.rml import rml2pdf
|
|||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
forms.DateField.widget = forms.DateInput(attrs={'type': 'date'})
|
||||||
|
|
||||||
|
|
||||||
class InvoiceIndex(generic.ListView):
|
class InvoiceIndex(generic.ListView):
|
||||||
model = models.Invoice
|
model = models.Invoice
|
||||||
@@ -55,8 +57,8 @@ class InvoicePrint(generic.View):
|
|||||||
invoice = get_object_or_404(models.Invoice, pk=pk)
|
invoice = get_object_or_404(models.Invoice, pk=pk)
|
||||||
object = invoice.event
|
object = invoice.event
|
||||||
template = get_template('RIGS/event_print.xml')
|
template = get_template('RIGS/event_print.xml')
|
||||||
copies = ('TEC', 'Client')
|
|
||||||
context = RequestContext(request, {
|
context = {
|
||||||
'object': object,
|
'object': object,
|
||||||
'fonts': {
|
'fonts': {
|
||||||
'opensans': {
|
'opensans': {
|
||||||
@@ -66,10 +68,9 @@ class InvoicePrint(generic.View):
|
|||||||
},
|
},
|
||||||
'invoice': invoice,
|
'invoice': invoice,
|
||||||
'current_user': request.user,
|
'current_user': request.user,
|
||||||
})
|
}
|
||||||
|
|
||||||
rml = template.render(context)
|
rml = template.render(context)
|
||||||
buffer = StringIO.StringIO()
|
|
||||||
|
|
||||||
buffer = rml2pdf.parseString(rml)
|
buffer = rml2pdf.parseString(rml)
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ class InvoicePrint(generic.View):
|
|||||||
escapedEventName = re.sub('[^a-zA-Z0-9 \n\.]', '', object.name)
|
escapedEventName = re.sub('[^a-zA-Z0-9 \n\.]', '', object.name)
|
||||||
|
|
||||||
response = HttpResponse(content_type='application/pdf')
|
response = HttpResponse(content_type='application/pdf')
|
||||||
response['Content-Disposition'] = "filename=Invoice %05d | %s.pdf" % (invoice.pk, escapedEventName)
|
response['Content-Disposition'] = "filename=Invoice %05d - N%05d | %s.pdf" % (invoice.pk, invoice.event.pk, escapedEventName)
|
||||||
response.write(pdfData)
|
response.write(pdfData)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@@ -95,6 +96,27 @@ class InvoiceVoid(generic.View):
|
|||||||
return HttpResponseRedirect(reverse_lazy('invoice_detail', kwargs={'pk': object.pk}))
|
return HttpResponseRedirect(reverse_lazy('invoice_detail', kwargs={'pk': object.pk}))
|
||||||
|
|
||||||
|
|
||||||
|
class InvoiceDelete(generic.DeleteView):
|
||||||
|
model = models.Invoice
|
||||||
|
|
||||||
|
def get(self, request, pk):
|
||||||
|
obj = self.get_object()
|
||||||
|
if obj.payment_set.all().count() > 0:
|
||||||
|
messages.info(self.request, 'To delete an invoice, delete the payments first.')
|
||||||
|
return HttpResponseRedirect(reverse_lazy('invoice_detail', kwargs={'pk': obj.pk}))
|
||||||
|
return super(InvoiceDelete, self).get(pk)
|
||||||
|
|
||||||
|
def post(self, request, pk):
|
||||||
|
obj = self.get_object()
|
||||||
|
if obj.payment_set.all().count() > 0:
|
||||||
|
messages.info(self.request, 'To delete an invoice, delete the payments first.')
|
||||||
|
return HttpResponseRedirect(reverse_lazy('invoice_detail', kwargs={'pk': obj.pk}))
|
||||||
|
return super(InvoiceDelete, self).post(pk)
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return self.request.POST.get('next')
|
||||||
|
|
||||||
|
|
||||||
class InvoiceArchive(generic.ListView):
|
class InvoiceArchive(generic.ListView):
|
||||||
model = models.Invoice
|
model = models.Invoice
|
||||||
template_name = 'RIGS/invoice_list_archive.html'
|
template_name = 'RIGS/invoice_list_archive.html'
|
||||||
@@ -123,11 +145,11 @@ class InvoiceWaiting(generic.ListView):
|
|||||||
events = self.model.objects.filter(
|
events = self.model.objects.filter(
|
||||||
(
|
(
|
||||||
Q(start_date__lte=datetime.date.today(), end_date__isnull=True) | # Starts before with no end
|
Q(start_date__lte=datetime.date.today(), end_date__isnull=True) | # Starts before with no end
|
||||||
Q(end_date__lte=datetime.date.today()) # Has end date, finishes before
|
Q(end_date__lte=datetime.date.today()) # Has end date, finishes before
|
||||||
) & Q(invoice__isnull=True) # Has not already been invoiced
|
) & Q(invoice__isnull=True) & # Has not already been invoiced
|
||||||
& Q(is_rig=True) # Is a rig (not non-rig)
|
Q(is_rig=True) # Is a rig (not non-rig)
|
||||||
|
|
||||||
).order_by('start_date') \
|
).order_by('start_date') \
|
||||||
.select_related('person',
|
.select_related('person',
|
||||||
'organisation',
|
'organisation',
|
||||||
'venue', 'mic') \
|
'venue', 'mic') \
|
||||||
@@ -144,6 +166,7 @@ class InvoiceEvent(generic.View):
|
|||||||
|
|
||||||
if created:
|
if created:
|
||||||
invoice.invoice_date = datetime.date.today()
|
invoice.invoice_date = datetime.date.today()
|
||||||
|
messages.success(self.request, 'Invoice created successfully')
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse_lazy('invoice_detail', kwargs={'pk': invoice.pk}))
|
return HttpResponseRedirect(reverse_lazy('invoice_detail', kwargs={'pk': invoice.pk}))
|
||||||
|
|
||||||
@@ -155,7 +178,7 @@ class PaymentCreate(generic.CreateView):
|
|||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super(generic.CreateView, self).get_initial()
|
initial = super(generic.CreateView, self).get_initial()
|
||||||
invoicepk = self.request.GET.get('invoice', self.request.POST.get('invoice', None))
|
invoicepk = self.request.GET.get('invoice', self.request.POST.get('invoice', None))
|
||||||
if invoicepk == None:
|
if invoicepk is None:
|
||||||
raise Http404()
|
raise Http404()
|
||||||
invoice = get_object_or_404(models.Invoice, pk=invoicepk)
|
invoice = get_object_or_404(models.Invoice, pk=invoicepk)
|
||||||
initial.update({'invoice': invoice})
|
initial.update({'invoice': invoice})
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
__author__ = 'Ghost'
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils import formats
|
from django.utils import formats
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -10,8 +9,14 @@ import simplejson
|
|||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
|
|
||||||
|
# Override the django form defaults to use the HTML date/time/datetime UI elements
|
||||||
|
forms.DateField.widget = forms.DateInput(attrs={'type': 'date'})
|
||||||
|
forms.TimeField.widget = forms.TextInput(attrs={'type': 'time'})
|
||||||
|
forms.DateTimeField.widget = forms.DateTimeInput(attrs={'type': 'datetime-local'})
|
||||||
|
|
||||||
# Registration
|
# Registration
|
||||||
|
|
||||||
|
|
||||||
class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
|
class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
|
||||||
captcha = ReCaptchaField()
|
captcha = ReCaptchaField()
|
||||||
|
|
||||||
@@ -28,7 +33,12 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
|
|||||||
return self.cleaned_data['initials']
|
return self.cleaned_data['initials']
|
||||||
|
|
||||||
|
|
||||||
# Login form
|
# Embedded Login form - remove the autofocus
|
||||||
|
class EmbeddedAuthenticationForm(AuthenticationForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['username'].widget.attrs.pop('autofocus', None)
|
||||||
|
|
||||||
class PasswordReset(PasswordResetForm):
|
class PasswordReset(PasswordResetForm):
|
||||||
captcha = ReCaptchaField(label='Captcha')
|
captcha = ReCaptchaField(label='Captcha')
|
||||||
|
|
||||||
@@ -45,7 +55,7 @@ class ProfileChangeForm(UserChangeForm):
|
|||||||
|
|
||||||
# Events Shit
|
# Events Shit
|
||||||
class EventForm(forms.ModelForm):
|
class EventForm(forms.ModelForm):
|
||||||
datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS
|
datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + list(settings.DATETIME_INPUT_FORMATS)
|
||||||
meet_at = forms.DateTimeField(input_formats=datetime_input_formats, required=False)
|
meet_at = forms.DateTimeField(input_formats=datetime_input_formats, required=False)
|
||||||
access_at = forms.DateTimeField(input_formats=datetime_input_formats, required=False)
|
access_at = forms.DateTimeField(input_formats=datetime_input_formats, required=False)
|
||||||
|
|
||||||
@@ -140,4 +150,32 @@ 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',
|
||||||
'collector', 'purchase_order']
|
'purchase_order', 'collector']
|
||||||
|
|
||||||
|
|
||||||
|
class BaseClientEventAuthorisationForm(forms.ModelForm):
|
||||||
|
tos = forms.BooleanField(required=True, label="Terms of hire")
|
||||||
|
name = forms.CharField(label="Your Name")
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
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).')
|
||||||
|
return super(BaseClientEventAuthorisationForm, self).clean()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
|
class InternalClientEventAuthorisationForm(BaseClientEventAuthorisationForm):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super(InternalClientEventAuthorisationForm, self).__init__(**kwargs)
|
||||||
|
self.fields['uni_id'].required = True
|
||||||
|
self.fields['account_code'].required = True
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.EventAuthorisation
|
||||||
|
fields = ('tos', 'name', 'amount', 'uni_id', 'account_code')
|
||||||
|
|
||||||
|
|
||||||
|
class EventAuthorisationRequestForm(forms.Form):
|
||||||
|
email = forms.EmailField(required=True, label='Authoriser Email')
|
||||||
|
|||||||
53
RIGS/ical.py
@@ -1,17 +1,19 @@
|
|||||||
from RIGS import models, forms
|
from RIGS import models, forms
|
||||||
from django_ical.views import ICalFeed
|
from django_ical.views import ICalFeed
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.core.urlresolvers import reverse_lazy, reverse, NoReverseMatch
|
from django.urls import reverse_lazy, reverse, NoReverseMatch
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
import datetime, pytz
|
import datetime
|
||||||
|
import pytz
|
||||||
|
|
||||||
|
|
||||||
class CalendarICS(ICalFeed):
|
class CalendarICS(ICalFeed):
|
||||||
"""
|
"""
|
||||||
A simple event calender
|
A simple event calender
|
||||||
"""
|
"""
|
||||||
#Metadata which is passed on to clients
|
# Metadata which is passed on to clients
|
||||||
product_id = 'RIGS'
|
product_id = 'RIGS'
|
||||||
title = 'RIGS Calendar'
|
title = 'RIGS Calendar'
|
||||||
timezone = settings.TIME_ZONE
|
timezone = settings.TIME_ZONE
|
||||||
@@ -27,28 +29,28 @@ class CalendarICS(ICalFeed):
|
|||||||
def get_object(self, request, *args, **kwargs):
|
def get_object(self, request, *args, **kwargs):
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
params['dry-hire'] = request.GET.get('dry-hire','true') == 'true'
|
params['dry-hire'] = request.GET.get('dry-hire', 'true') == 'true'
|
||||||
params['non-rig'] = request.GET.get('non-rig','true') == 'true'
|
params['non-rig'] = request.GET.get('non-rig', 'true') == 'true'
|
||||||
params['rig'] = request.GET.get('rig','true') == 'true'
|
params['rig'] = request.GET.get('rig', 'true') == 'true'
|
||||||
|
|
||||||
params['cancelled'] = request.GET.get('cancelled','false') == 'true'
|
params['cancelled'] = request.GET.get('cancelled', 'false') == 'true'
|
||||||
params['provisional'] = request.GET.get('provisional','true') == 'true'
|
params['provisional'] = request.GET.get('provisional', 'true') == 'true'
|
||||||
params['confirmed'] = request.GET.get('confirmed','true') == 'true'
|
params['confirmed'] = request.GET.get('confirmed', 'true') == 'true'
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def description(self,params):
|
def description(self, params):
|
||||||
desc = "Calendar generated by RIGS system. This includes event types: " + ('Rig, ' if params['rig'] else '') + ('Non-rig, ' if params['non-rig'] else '') + ('Dry Hire ' if params['dry-hire'] else '') + '\n'
|
desc = "Calendar generated by RIGS system. This includes event types: " + ('Rig, ' if params['rig'] else '') + ('Non-rig, ' if params['non-rig'] else '') + ('Dry Hire ' if params['dry-hire'] else '') + '\n'
|
||||||
desc = desc + "Includes events with status: " + ('Cancelled, ' if params['cancelled'] else '') + ('Provisional, ' if params['provisional'] else '') + ('Confirmed/Booked, ' if params['confirmed'] else '')
|
desc = desc + "Includes events with status: " + ('Cancelled, ' if params['cancelled'] else '') + ('Provisional, ' if params['provisional'] else '') + ('Confirmed/Booked, ' if params['confirmed'] else '')
|
||||||
|
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
def items(self, params):
|
def items(self, params):
|
||||||
#include events from up to 1 year ago
|
# include events from up to 1 year ago
|
||||||
start = datetime.datetime.now() - datetime.timedelta(days=365)
|
start = datetime.datetime.now() - datetime.timedelta(days=365)
|
||||||
filter = Q(start_date__gte=start)
|
filter = Q(start_date__gte=start)
|
||||||
|
|
||||||
typeFilters = Q(pk=None) #Need something that is false for every entry
|
typeFilters = Q(pk=None) # Need something that is false for every entry
|
||||||
|
|
||||||
if params['dry-hire']:
|
if params['dry-hire']:
|
||||||
typeFilters = typeFilters | Q(dry_hire=True, is_rig=True)
|
typeFilters = typeFilters | Q(dry_hire=True, is_rig=True)
|
||||||
@@ -59,7 +61,7 @@ class CalendarICS(ICalFeed):
|
|||||||
if params['rig']:
|
if params['rig']:
|
||||||
typeFilters = typeFilters | Q(is_rig=True, dry_hire=False)
|
typeFilters = typeFilters | Q(is_rig=True, dry_hire=False)
|
||||||
|
|
||||||
statusFilters = Q(pk=None) #Need something that is false for every entry
|
statusFilters = Q(pk=None) # Need something that is false for every entry
|
||||||
|
|
||||||
if params['cancelled']:
|
if params['cancelled']:
|
||||||
statusFilters = statusFilters | Q(status=models.Event.CANCELLED)
|
statusFilters = statusFilters | Q(status=models.Event.CANCELLED)
|
||||||
@@ -89,7 +91,7 @@ class CalendarICS(ICalFeed):
|
|||||||
title += item.name
|
title += item.name
|
||||||
|
|
||||||
# Add the status
|
# Add the status
|
||||||
title += ' ('+str(item.get_status_display())+')'
|
title += ' (' + str(item.get_status_display()) + ')'
|
||||||
|
|
||||||
return title
|
return title
|
||||||
|
|
||||||
@@ -97,12 +99,12 @@ class CalendarICS(ICalFeed):
|
|||||||
return item.earliest_time
|
return item.earliest_time
|
||||||
|
|
||||||
def item_end_datetime(self, item):
|
def item_end_datetime(self, item):
|
||||||
if type(item.latest_time) is datetime.date: # Ical end_datetime is non-inclusive, so add a day
|
if type(item.latest_time) == datetime.date: # Ical end_datetime is non-inclusive, so add a day
|
||||||
return item.latest_time + datetime.timedelta(days=1)
|
return item.latest_time + datetime.timedelta(days=1)
|
||||||
|
|
||||||
return item.latest_time
|
return item.latest_time
|
||||||
|
|
||||||
def item_location(self,item):
|
def item_location(self, item):
|
||||||
return item.venue
|
return item.venue
|
||||||
|
|
||||||
def item_description(self, item):
|
def item_description(self, item):
|
||||||
@@ -111,33 +113,32 @@ class CalendarICS(ICalFeed):
|
|||||||
|
|
||||||
tz = pytz.timezone(self.timezone)
|
tz = pytz.timezone(self.timezone)
|
||||||
|
|
||||||
desc = 'Rig ID = '+str(item.pk)+'\n'
|
desc = 'Rig ID = ' + str(item.pk) + '\n'
|
||||||
desc += 'Event = ' + item.name + '\n'
|
desc += 'Event = ' + item.name + '\n'
|
||||||
desc += 'Venue = ' + (item.venue.name if item.venue else '---') + '\n'
|
desc += 'Venue = ' + (item.venue.name if item.venue else '---') + '\n'
|
||||||
if item.is_rig and item.person:
|
if item.is_rig and item.person:
|
||||||
desc += 'Client = ' + item.person.name + ( (' for '+item.organisation.name) if item.organisation else '') + '\n'
|
desc += 'Client = ' + item.person.name + ((' for ' + item.organisation.name) if item.organisation else '') + '\n'
|
||||||
desc += 'Status = ' + str(item.get_status_display()) + '\n'
|
desc += 'Status = ' + str(item.get_status_display()) + '\n'
|
||||||
desc += 'MIC = ' + (item.mic.name if item.mic else '---') + '\n'
|
desc += 'MIC = ' + (item.mic.name if item.mic else '---') + '\n'
|
||||||
|
|
||||||
|
|
||||||
desc += '\n'
|
desc += '\n'
|
||||||
if item.meet_at:
|
if item.meet_at:
|
||||||
desc += 'Crew Meet = ' + (item.meet_at.astimezone(tz).strftime('%Y-%m-%d %H:%M') if item.meet_at else '---') + '\n'
|
desc += 'Crew Meet = ' + (item.meet_at.astimezone(tz).strftime('%Y-%m-%d %H:%M') if item.meet_at else '---') + '\n'
|
||||||
if item.access_at:
|
if item.access_at:
|
||||||
desc += 'Access At = ' + (item.access_at.astimezone(tz).strftime('%Y-%m-%d %H:%M') if item.access_at else '---') + '\n'
|
desc += 'Access At = ' + (item.access_at.astimezone(tz).strftime('%Y-%m-%d %H:%M') if item.access_at else '---') + '\n'
|
||||||
if item.start_date:
|
if item.start_date:
|
||||||
desc += 'Event Start = ' + item.start_date.strftime('%Y-%m-%d') + ((' '+item.start_time.strftime('%H:%M')) if item.has_start_time else '') + '\n'
|
desc += 'Event Start = ' + item.start_date.strftime('%Y-%m-%d') + ((' ' + item.start_time.strftime('%H:%M')) if item.has_start_time else '') + '\n'
|
||||||
if item.end_date:
|
if item.end_date:
|
||||||
desc += 'Event End = ' + item.end_date.strftime('%Y-%m-%d') + ((' '+item.end_time.strftime('%H:%M')) if item.has_end_time else '') + '\n'
|
desc += 'Event End = ' + item.end_date.strftime('%Y-%m-%d') + ((' ' + item.end_time.strftime('%H:%M')) if item.has_end_time else '') + '\n'
|
||||||
|
|
||||||
desc += '\n'
|
desc += '\n'
|
||||||
if item.description:
|
if item.description:
|
||||||
desc += 'Event Description:\n'+item.description+'\n\n'
|
desc += 'Event Description:\n' + item.description + '\n\n'
|
||||||
# if item.notes: // Need to add proper keyholder checks before this gets put back
|
# if item.notes: // Need to add proper keyholder checks before this gets put back
|
||||||
# desc += 'Notes:\n'+item.notes+'\n\n'
|
# desc += 'Notes:\n'+item.notes+'\n\n'
|
||||||
|
|
||||||
base_url = "http://rigs.nottinghamtec.co.uk"
|
base_url = "https://rigs.nottinghamtec.co.uk"
|
||||||
desc += 'URL = '+base_url+str(item.get_absolute_url())
|
desc += 'URL = ' + base_url + str(item.get_absolute_url())
|
||||||
|
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
@@ -149,8 +150,8 @@ class CalendarICS(ICalFeed):
|
|||||||
# def item_created(self, item): #TODO - Implement created date-time (using django-reversion?) - not really necessary though
|
# def item_created(self, item): #TODO - Implement created date-time (using django-reversion?) - not really necessary though
|
||||||
# return ''
|
# return ''
|
||||||
|
|
||||||
def item_updated(self, item): # some ical clients will display this
|
def item_updated(self, item): # some ical clients will display this
|
||||||
return item.last_edited_at
|
return item.last_edited_at
|
||||||
|
|
||||||
def item_guid(self, item): # use the rig-id as the ical unique event identifier
|
def item_guid(self, item): # use the rig-id as the ical unique event identifier
|
||||||
return item.pk
|
return item.pk
|
||||||
252
RIGS/management/commands/generateSampleData.py
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
from django.contrib.auth.models import Group, Permission
|
||||||
|
from django.db import transaction
|
||||||
|
from reversion import revisions as reversion
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
|
from RIGS import models
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Adds sample data to use for testing'
|
||||||
|
can_import_settings = True
|
||||||
|
|
||||||
|
people = []
|
||||||
|
organisations = []
|
||||||
|
venues = []
|
||||||
|
profiles = []
|
||||||
|
|
||||||
|
keyholder_group = None
|
||||||
|
finance_group = None
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
if not (settings.DEBUG or settings.STAGING):
|
||||||
|
raise CommandError('You cannot run this command in production')
|
||||||
|
|
||||||
|
random.seed('Some object to seed the random number generator') # otherwise it is done by time, which could lead to inconsistant tests
|
||||||
|
|
||||||
|
with transaction.atomic():
|
||||||
|
models.VatRate.objects.create(start_at='2014-03-05', rate=0.20, comment='test1')
|
||||||
|
|
||||||
|
self.setupGenericProfiles()
|
||||||
|
|
||||||
|
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", "Bartemius Crouch", "Fleur Delacour", "Cedric Diggory", "Alberforth Dumbledore", "Albus Dumbledore", "Dudley Dursley", "Petunia Dursley", "Vernon Dursley", "Argus Filch", "Seamus Finnigan", "Nicolas Flamel", "Cornelius Fudge", "Goyle", "Gregory Goyle", "Hermione Granger", "Rubeus Hagrid", "Igor Karkaroff", "Viktor Krum", "Bellatrix Lestrange", "Alice Longbottom", "Frank Longbottom", "Neville Longbottom", "Luna Lovegood", "Xenophilius Lovegood", # noqa
|
||||||
|
"Remus Lupin", "Draco Malfoy", "Lucius Malfoy", "Narcissa Malfoy", "Olympe Maxime", "Minerva McGonagall", "Mad-Eye Moody", "Peter Pettigrew", "Harry Potter", "James Potter", "Lily Potter", "Quirinus Quirrell", "Tom Riddle", "Mary Riddle", "Lord Voldemort", "Rita Skeeter", "Severus Snape", "Nymphadora Tonks", "Dolores Janes Umbridge", "Arthur Weasley", "Bill Weasley", "Charlie Weasley", "Fred Weasley", "George Weasley", "Ginny Weasley", "Molly Weasley", "Percy Weasley", "Ron Weasley", "Dobby", "Fluffy", "Hedwig", "Moaning Myrtle", "Aragog", "Grawp"] # noqa
|
||||||
|
for i, name in enumerate(names):
|
||||||
|
with reversion.create_revision():
|
||||||
|
reversion.set_user(random.choice(self.profiles))
|
||||||
|
|
||||||
|
newPerson = models.Person.objects.create(name=name)
|
||||||
|
if i % 3 == 0:
|
||||||
|
newPerson.email = "address@person.com"
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
if i % 7 == 0:
|
||||||
|
newPerson.address = "1 Person Test Street \n Demoton \n United States of TEC \n RMRF 567"
|
||||||
|
|
||||||
|
if i % 9 == 0:
|
||||||
|
newPerson.phone = "01234 567894"
|
||||||
|
|
||||||
|
newPerson.save()
|
||||||
|
self.people.append(newPerson)
|
||||||
|
|
||||||
|
def setupOrganisations(self):
|
||||||
|
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", "Acme Corp", "Allied Biscuit", "Ankh-Sto Associates", "Extensive Enterprise", "Galaxy Corp", "Globo-Chem", "Mr. Sparkle", "Globex Corporation", "LexCorp", "LuthorCorp", "North Central Positronics", "Omni Consimer Products", "Praxis Corporation", "Sombra Corporation", "Sto Plains Holdings", "Tessier-Ashpool", "Wayne Enterprises", "Wentworth Industries", "ZiffCorp", "Bluth Company", "Strickland Propane", "Thatherton Fuels", "Three Waters", "Water and Power", "Western Gas & Electric", "Mammoth Pictures", "Mooby Corp", "Gringotts", "Thrift Bank", "Flowers By Irene", "The Legitimate Businessmens Club", "Osato Chemicals", "Transworld Consortium", "Universal Export", "United Fried Chicken", "Virtucon", "Kumatsu Motors", "Keedsler Motors", "Powell Motors", "Industrial Automation", "Sirius Cybernetics Corporation", "U.S. Robotics and Mechanical Men", "Colonial Movers", "Corellian Engineering Corporation", "Incom Corporation", "General Products", "Leeding Engines Ltd.", "Blammo", # noqa
|
||||||
|
"Input, Inc.", "Mainway Toys", "Videlectrix", "Zevo Toys", "Ajax", "Axis Chemical Co.", "Barrytron", "Carrys Candles", "Cogswell Cogs", "Spacely Sprockets", "General Forge and Foundry", "Duff Brewing Company", "Dunder Mifflin", "General Services Corporation", "Monarch Playing Card Co.", "Krustyco", "Initech", "Roboto Industries", "Primatech", "Sonky Rubber Goods", "St. Anky Beer", "Stay Puft Corporation", "Vandelay Industries", "Wernham Hogg", "Gadgetron", "Burleigh and Stronginthearm", "BLAND Corporation", "Nordyne Defense Dynamics", "Petrox Oil Company", "Roxxon", "McMahon and Tate", "Sixty Second Avenue", "Charles Townsend Agency", "Spade and Archer", "Megadodo Publications", "Rouster and Sideways", "C.H. Lavatory and Sons", "Globo Gym American Corp", "The New Firm", "SpringShield", "Compuglobalhypermeganet", "Data Systems", "Gizmonic Institute", "Initrode", "Taggart Transcontinental", "Atlantic Northern", "Niagular", "Plow King", "Big Kahuna Burger", "Big T Burgers and Fries", "Chez Quis", "Chotchkies", "The Frying Dutchman", "Klimpys", "The Krusty Krab", "Monks Diner", "Milliways", "Minuteman Cafe", "Taco Grande", "Tip Top Cafe", "Moes Tavern", "Central Perk", "Chasers"] # noqa
|
||||||
|
for i, name in enumerate(names):
|
||||||
|
with reversion.create_revision():
|
||||||
|
reversion.set_user(random.choice(self.profiles))
|
||||||
|
newOrganisation = models.Organisation.objects.create(name=name)
|
||||||
|
if i % 2 == 0:
|
||||||
|
newOrganisation.has_su_account = True
|
||||||
|
|
||||||
|
if i % 3 == 0:
|
||||||
|
newOrganisation.email = "address@organisation.com"
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
if i % 7 == 0:
|
||||||
|
newOrganisation.address = "1 Organisation Test Street \n Demoton \n United States of TEC \n RMRF 567"
|
||||||
|
|
||||||
|
if i % 9 == 0:
|
||||||
|
newOrganisation.phone = "01234 567894"
|
||||||
|
|
||||||
|
newOrganisation.save()
|
||||||
|
self.organisations.append(newOrganisation)
|
||||||
|
|
||||||
|
def setupVenues(self):
|
||||||
|
names = ["Bear Island", "Crossroads Inn", "Deepwood Motte", "The Dreadfort", "The Eyrie", "Greywater Watch", "The Iron Islands", "Karhold", "Moat Cailin", "Oldstones", "Raventree Hall", "Riverlands", "The Ruby Ford", "Saltpans", "Seagard", "Torrhen's Square", "The Trident", "The Twins", "The Vale of Arryn", "The Whispering Wood", "White Harbor", "Winterfell", "The Arbor", "Ashemark", "Brightwater Keep", "Casterly Rock", "Clegane's Keep", "Dragonstone", "Dorne", "God's Eye", "The Golden Tooth", # noqa
|
||||||
|
"Harrenhal", "Highgarden", "Horn Hill", "Fingers", "King's Landing", "Lannisport", "Oldtown", "Rainswood", "Storm's End", "Summerhall", "Sunspear", "Tarth", "Castle Black", "Craster's Keep", "Fist of the First Men", "The Frostfangs", "The Gift", "The Skirling Pass", "The Wall", "Asshai", "Astapor", "Braavos", "The Dothraki Sea", "Lys", "Meereen", "Myr", "Norvos", "Pentos", "Qarth", "Qohor", "The Red Waste", "Tyrosh", "Vaes Dothrak", "Valyria", "Village of the Lhazareen", "Volantis", "Yunkai"] # noqa
|
||||||
|
for i, name in enumerate(names):
|
||||||
|
with reversion.create_revision():
|
||||||
|
reversion.set_user(random.choice(self.profiles))
|
||||||
|
newVenue = models.Venue.objects.create(name=name)
|
||||||
|
if i % 2 == 0:
|
||||||
|
newVenue.three_phase_available = True
|
||||||
|
|
||||||
|
if i % 3 == 0:
|
||||||
|
newVenue.email = "address@venue.com"
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
if i % 7 == 0:
|
||||||
|
newVenue.address = "1 Venue Test Street \n Demoton \n United States of TEC \n RMRF 567"
|
||||||
|
|
||||||
|
if i % 9 == 0:
|
||||||
|
newVenue.phone = "01234 567894"
|
||||||
|
|
||||||
|
newVenue.save()
|
||||||
|
self.venues.append(newVenue)
|
||||||
|
|
||||||
|
def setupGroups(self):
|
||||||
|
self.keyholder_group = Group.objects.create(name='Keyholders')
|
||||||
|
self.finance_group = Group.objects.create(name='Finance')
|
||||||
|
|
||||||
|
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"]
|
||||||
|
financePerms = ["change_event", "view_event", "add_eventitem", "change_eventitem", "add_invoice", "change_invoice", "view_invoice", "add_organisation", "change_organisation", "view_organisation", "add_payment", "change_payment", "delete_payment", "add_person", "change_person", "view_person"]
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
|
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)
|
||||||
|
financeUser.groups.add(self.finance_group)
|
||||||
|
financeUser.groups.add(self.keyholder_group)
|
||||||
|
financeUser.set_password('finance')
|
||||||
|
financeUser.save()
|
||||||
|
|
||||||
|
keyholderUser = models.Profile.objects.create(username="keyholder", first_name="Keyholder", last_name="User", initials="KU",
|
||||||
|
email="keyholderuser@example.com", is_active=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)
|
||||||
|
basicUser.set_password('basic')
|
||||||
|
basicUser.save()
|
||||||
|
|
||||||
|
def setupEvents(self):
|
||||||
|
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",
|
||||||
|
"End of Term Show", "Theatre Show", "Outdoor Fun Day", "Summer Carnival", "Open Days", "Magic Show", "Awards Ceremony", "Debating Event", "Club Night", "DJ Evening", "Building Projection", "Choir Concert"]
|
||||||
|
descriptions = ["A brief desciption of the event", "This event is boring", "Probably wont happen", "Warning: this has lots of kit"]
|
||||||
|
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!"]
|
||||||
|
|
||||||
|
itemOptions = [{'name': 'Speakers', 'description': 'Some really really big speakers \n these are very loud', 'quantity': 2, 'cost': 200.00},
|
||||||
|
{'name': 'Projector', 'description': 'Some kind of video thinamejig, probably with unnecessary processing for free', 'quantity': 1, 'cost': 500.00},
|
||||||
|
{'name': 'Lighting Desk', 'description': 'Cannot provide guarentee that it will work', 'quantity': 1, 'cost': 200.52},
|
||||||
|
{'name': 'Moving lights', 'description': 'Flashy lights, with the copper', 'quantity': 8, 'cost': 50.00},
|
||||||
|
{'name': 'Microphones', 'description': 'Make loud noise \n you will want speakers with this', 'quantity': 5, 'cost': 0.50},
|
||||||
|
{'name': 'Sound Mixer Thing', 'description': 'Might be analogue, might be digital', 'quantity': 1, 'cost': 100.00},
|
||||||
|
{'name': 'Electricity', 'description': 'You need this', 'quantity': 1, 'cost': 200.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}]
|
||||||
|
|
||||||
|
dayDelta = -120 # start adding events from 4 months ago
|
||||||
|
|
||||||
|
for i in range(150): # Let's add 100 events
|
||||||
|
with reversion.create_revision():
|
||||||
|
reversion.set_user(random.choice(self.profiles))
|
||||||
|
|
||||||
|
name = names[i % len(names)]
|
||||||
|
|
||||||
|
startDate = datetime.date.today() + datetime.timedelta(days=dayDelta)
|
||||||
|
dayDelta = dayDelta + random.randint(0, 3)
|
||||||
|
|
||||||
|
newEvent = models.Event.objects.create(name=name, start_date=startDate)
|
||||||
|
|
||||||
|
if random.randint(0, 2) > 1: # 1 in 3 have a start time
|
||||||
|
newEvent.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
|
||||||
|
newEvent.end_time = datetime.time(random.randint(21, 23))
|
||||||
|
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)
|
||||||
|
newEvent.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
|
||||||
|
newEvent.end_date = newEvent.start_date + datetime.timedelta(days=random.randint(1, 4))
|
||||||
|
|
||||||
|
if random.randint(0, 6) > 0: # 5 in 6 have MIC
|
||||||
|
newEvent.mic = random.choice(self.profiles)
|
||||||
|
|
||||||
|
if random.randint(0, 6) > 0: # 5 in 6 have organisation
|
||||||
|
newEvent.organisation = random.choice(self.organisations)
|
||||||
|
|
||||||
|
if random.randint(0, 6) > 0: # 5 in 6 have person
|
||||||
|
newEvent.person = random.choice(self.people)
|
||||||
|
|
||||||
|
if random.randint(0, 6) > 0: # 5 in 6 have venue
|
||||||
|
newEvent.venue = random.choice(self.venues)
|
||||||
|
|
||||||
|
# Could have any status, equally weighted
|
||||||
|
newEvent.status = random.choice([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
|
||||||
|
|
||||||
|
if random.randint(0, 1) > 0: # 1 in 2 have description
|
||||||
|
newEvent.description = random.choice(descriptions)
|
||||||
|
|
||||||
|
if random.randint(0, 1) > 0: # 1 in 2 have notes
|
||||||
|
newEvent.notes = random.choice(notes)
|
||||||
|
|
||||||
|
newEvent.save()
|
||||||
|
|
||||||
|
# Now add some items
|
||||||
|
for j in range(random.randint(1, 5)):
|
||||||
|
itemData = itemOptions[random.randint(0, len(itemOptions) - 1)]
|
||||||
|
newItem = models.EventItem.objects.create(event=newEvent, order=j, **itemData)
|
||||||
|
newItem.save()
|
||||||
|
|
||||||
|
while newEvent.sum_total < 0:
|
||||||
|
itemData = itemOptions[random.randint(0, len(itemOptions) - 1)]
|
||||||
|
newItem = models.EventItem.objects.create(event=newEvent, order=j, **itemData)
|
||||||
|
newItem.save()
|
||||||
|
|
||||||
|
with reversion.create_revision():
|
||||||
|
reversion.set_user(random.choice(self.profiles))
|
||||||
|
if newEvent.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
|
||||||
|
newInvoice = models.Invoice.objects.create(event=newEvent)
|
||||||
|
if newEvent.status is models.Event.CANCELLED: # void cancelled events
|
||||||
|
newInvoice.void = True
|
||||||
|
elif random.randint(0, 2) > 1: # 1 in 3 have been paid
|
||||||
|
models.Payment.objects.create(invoice=newInvoice, amount=newInvoice.balance, date=datetime.date.today())
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -18,7 +18,7 @@ class Migration(migrations.Migration):
|
|||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
('postedAt', models.DateTimeField(auto_now=True)),
|
('postedAt', models.DateTimeField(auto_now=True)),
|
||||||
('message', models.TextField()),
|
('message', models.TextField()),
|
||||||
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
|
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import RIGS.models
|
import RIGS.models
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import RIGS.models
|
import RIGS.models
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -33,11 +33,11 @@ class Migration(migrations.Migration):
|
|||||||
('payment_method', models.CharField(blank=True, null=True, max_length=255)),
|
('payment_method', models.CharField(blank=True, null=True, max_length=255)),
|
||||||
('payment_received', models.CharField(blank=True, null=True, max_length=255)),
|
('payment_received', models.CharField(blank=True, null=True, max_length=255)),
|
||||||
('purchase_order', models.CharField(blank=True, null=True, max_length=255)),
|
('purchase_order', models.CharField(blank=True, null=True, max_length=255)),
|
||||||
('based_on', models.ForeignKey(to='RIGS.Event', related_name='future_events')),
|
('based_on', models.ForeignKey(to='RIGS.Event', related_name='future_events', on_delete=models.CASCADE)),
|
||||||
('checked_in_by', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='event_checked_in')),
|
('checked_in_by', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='event_checked_in', on_delete=models.CASCADE)),
|
||||||
('mic', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='event_mic')),
|
('mic', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='event_mic', on_delete=models.CASCADE)),
|
||||||
('organisation', models.ForeignKey(to='RIGS.Organisation')),
|
('organisation', models.ForeignKey(to='RIGS.Organisation', on_delete=models.CASCADE)),
|
||||||
('person', models.ForeignKey(to='RIGS.Person')),
|
('person', models.ForeignKey(to='RIGS.Person', on_delete=models.CASCADE)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
@@ -52,7 +52,7 @@ class Migration(migrations.Migration):
|
|||||||
('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()),
|
||||||
('event', models.ForeignKey(to='RIGS.Event', related_name='item')),
|
('event', models.ForeignKey(to='RIGS.Event', related_name='item', on_delete=models.CASCADE)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
@@ -75,7 +75,7 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='venue',
|
name='venue',
|
||||||
field=models.ForeignKey(to='RIGS.Venue'),
|
field=models.ForeignKey(to='RIGS.Venue', on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -14,26 +14,26 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='based_on',
|
name='based_on',
|
||||||
field=models.ForeignKey(to='RIGS.Event', related_name='future_events', blank=True, null=True),
|
field=models.ForeignKey(to='RIGS.Event', related_name='future_events', blank=True, null=True, on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='checked_in_by',
|
name='checked_in_by',
|
||||||
field=models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='event_checked_in', blank=True,
|
field=models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='event_checked_in', blank=True,
|
||||||
null=True),
|
null=True, on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='mic',
|
name='mic',
|
||||||
field=models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='event_mic', blank=True, null=True),
|
field=models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='event_mic', blank=True, null=True, on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='organisation',
|
name='organisation',
|
||||||
field=models.ForeignKey(to='RIGS.Organisation', blank=True, null=True),
|
field=models.ForeignKey(to='RIGS.Organisation', blank=True, null=True, on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -19,8 +19,8 @@ class Migration(migrations.Migration):
|
|||||||
('run', models.BooleanField(default=False)),
|
('run', models.BooleanField(default=False)),
|
||||||
('derig', models.BooleanField(default=False)),
|
('derig', models.BooleanField(default=False)),
|
||||||
('notes', models.TextField(blank=True, null=True)),
|
('notes', models.TextField(blank=True, null=True)),
|
||||||
('event', models.ForeignKey(related_name='crew', to='RIGS.Event')),
|
('event', models.ForeignKey(related_name='crew', to='RIGS.Event', on_delete=models.CASCADE)),
|
||||||
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
|
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
@@ -35,7 +35,7 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='eventitem',
|
model_name='eventitem',
|
||||||
name='event',
|
name='event',
|
||||||
field=models.ForeignKey(related_name='items', to='RIGS.Event'),
|
field=models.ForeignKey(related_name='items', to='RIGS.Event', on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='person',
|
name='person',
|
||||||
field=models.ForeignKey(blank=True, null=True, to='RIGS.Person'),
|
field=models.ForeignKey(blank=True, null=True, to='RIGS.Person', on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
@@ -14,13 +14,13 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='venue',
|
name='venue',
|
||||||
field=models.ForeignKey(blank=True, to='RIGS.Venue', null=True),
|
field=models.ForeignKey(blank=True, to='RIGS.Venue', null=True, on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='eventitem',
|
model_name='eventitem',
|
||||||
name='event',
|
name='event',
|
||||||
field=models.ForeignKey(related_name='items', blank=True, to='RIGS.Event'),
|
field=models.ForeignKey(related_name='items', blank=True, to='RIGS.Event', on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -18,7 +18,7 @@ class Migration(migrations.Migration):
|
|||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
('invoice_date', models.DateField(auto_now_add=True)),
|
('invoice_date', models.DateField(auto_now_add=True)),
|
||||||
('void', models.BooleanField()),
|
('void', models.BooleanField()),
|
||||||
('event', models.OneToOneField(to='RIGS.Event')),
|
('event', models.OneToOneField(to='RIGS.Event', on_delete=models.CASCADE)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
@@ -31,7 +31,7 @@ class Migration(migrations.Migration):
|
|||||||
('date', models.DateField()),
|
('date', models.DateField()),
|
||||||
('amount', models.DecimalField(help_text=b'Please use ex. VAT', max_digits=10, decimal_places=2)),
|
('amount', models.DecimalField(help_text=b'Please use ex. VAT', max_digits=10, decimal_places=2)),
|
||||||
('method', models.CharField(max_length=2, choices=[(b'C', b'Cash'), (b'I', b'Internal'), (b'E', b'External'), (b'SU', b'SU Core'), (b'M', b'Members')])),
|
('method', models.CharField(max_length=2, choices=[(b'C', b'Cash'), (b'I', b'Internal'), (b'E', b'External'), (b'SU', b'SU Core'), (b'M', b'Members')])),
|
||||||
('invoice', models.ForeignKey(to='RIGS.Invoice')),
|
('invoice', models.ForeignKey(to='RIGS.Invoice', on_delete=models.CASCADE)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
},
|
},
|
||||||
@@ -40,7 +40,7 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='event',
|
model_name='event',
|
||||||
name='mic',
|
name='mic',
|
||||||
field=models.ForeignKey(related_name='event_mic', verbose_name=b'MIC', blank=True, to=settings.AUTH_USER_MODEL, null=True),
|
field=models.ForeignKey(related_name='event_mic', verbose_name=b'MIC', blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|||||||
26
RIGS/migrations/0025_auto_20160331_1302.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.4 on 2016-03-31 12:02
|
||||||
|
|
||||||
|
|
||||||
|
import django.core.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0024_auto_20160229_2042'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='profile',
|
||||||
|
name='username',
|
||||||
|
field=models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=30, unique=True, validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.')], verbose_name='username'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='vatrate',
|
||||||
|
name='start_at',
|
||||||
|
field=models.DateField(),
|
||||||
|
),
|
||||||
|
]
|
||||||
27
RIGS/migrations/0025_eventauthorisation.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0024_auto_20160229_2042'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='EventAuthorisation',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('email', models.EmailField(max_length=254)),
|
||||||
|
('name', models.CharField(max_length=255)),
|
||||||
|
('uni_id', models.CharField(max_length=10, null=True, verbose_name=b'University ID', blank=True)),
|
||||||
|
('account_code', models.CharField(max_length=50, null=True, blank=True)),
|
||||||
|
('amount', models.DecimalField(verbose_name=b'authorisation amount', max_digits=10, decimal_places=2)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('event', models.ForeignKey(related_name='authroisations', to='RIGS.Event', on_delete=models.CASCADE)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
21
RIGS/migrations/0026_auto_20170510_1846.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.1 on 2017-05-10 17:46
|
||||||
|
|
||||||
|
|
||||||
|
import django.contrib.auth.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0025_auto_20160331_1302'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='profile',
|
||||||
|
name='username',
|
||||||
|
field=models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.ASCIIUsernameValidator()], verbose_name='username'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
RIGS/migrations/0026_remove_eventauthorisation_created_at.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0025_eventauthorisation'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='eventauthorisation',
|
||||||
|
name='created_at',
|
||||||
|
),
|
||||||
|
]
|
||||||
19
RIGS/migrations/0027_eventauthorisation_event_singular.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0026_remove_eventauthorisation_created_at'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventauthorisation',
|
||||||
|
name='event',
|
||||||
|
field=models.OneToOneField(related_name='authorisation', to='RIGS.Event', on_delete=models.CASCADE),
|
||||||
|
),
|
||||||
|
]
|
||||||
21
RIGS/migrations/0029_eventauthorisation_sent_by.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0027_eventauthorisation_event_singular'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='eventauthorisation',
|
||||||
|
name='sent_by',
|
||||||
|
field=models.ForeignKey(default=1, to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
||||||
30
RIGS/migrations/0030_auth_request_sending.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0029_eventauthorisation_sent_by'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='event',
|
||||||
|
name='auth_request_at',
|
||||||
|
field=models.DateTimeField(null=True, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='event',
|
||||||
|
name='auth_request_by',
|
||||||
|
field=models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='event',
|
||||||
|
name='auth_request_to',
|
||||||
|
field=models.EmailField(max_length=254, null=True, blank=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
16
RIGS/migrations/0031_merge_20170512_2102.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.1 on 2017-05-12 20:02
|
||||||
|
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0030_auth_request_sending'),
|
||||||
|
('RIGS', '0026_auto_20170510_1846'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
]
|
||||||
69
RIGS/migrations/0032_auto_20170904_2355.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.4 on 2017-09-04 22:55
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
import django.contrib.auth.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('reversion', '0001_squashed_0004_auto_20160611_1202'),
|
||||||
|
('RIGS', '0031_merge_20170512_2102'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='RIGSVersion',
|
||||||
|
fields=[
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'indexes': [],
|
||||||
|
'proxy': True,
|
||||||
|
},
|
||||||
|
bases=('reversion.version',),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='collector',
|
||||||
|
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='collected by'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='mic',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='event_mic', to=settings.AUTH_USER_MODEL, verbose_name='MIC'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='purchase_order',
|
||||||
|
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='PO'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventauthorisation',
|
||||||
|
name='amount',
|
||||||
|
field=models.DecimalField(decimal_places=2, max_digits=10, verbose_name='authorisation amount'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventauthorisation',
|
||||||
|
name='uni_id',
|
||||||
|
field=models.CharField(blank=True, max_length=10, null=True, verbose_name='University ID'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='payment',
|
||||||
|
name='amount',
|
||||||
|
field=models.DecimalField(decimal_places=2, help_text='Please use ex. VAT', max_digits=10),
|
||||||
|
),
|
||||||
|
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')], max_length=2, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='profile',
|
||||||
|
name='username',
|
||||||
|
field=models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
RIGS/migrations/0033_auto_20180325_0016.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 2.0.3 on 2018-03-25 00:16
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0032_auto_20170904_2355'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='profile',
|
||||||
|
name='last_name',
|
||||||
|
field=models.CharField(blank=True, max_length=150, verbose_name='last name'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
RIGS/migrations/0034_event_risk_assessment_edit_url.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 2.0.5 on 2019-07-28 21:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0033_auto_20180325_0016'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='event',
|
||||||
|
name='risk_assessment_edit_url',
|
||||||
|
field=models.CharField(blank=True, max_length=255, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
146
RIGS/models.py
@@ -1,19 +1,24 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import datetime
|
||||||
import pytz
|
import pytz
|
||||||
import random
|
|
||||||
|
from django.db import models
|
||||||
|
from django.contrib.auth.models import AbstractUser
|
||||||
|
from django.conf import settings
|
||||||
|
from django.utils import timezone
|
||||||
|
from django.utils.functional import cached_property
|
||||||
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
from reversion import revisions as reversion
|
||||||
|
from reversion.models import Version
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
import random
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
import reversion
|
|
||||||
from django.conf import settings
|
|
||||||
from django.contrib.auth.models import AbstractUser
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.db import models
|
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
|
||||||
from django.utils.functional import cached_property
|
|
||||||
|
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
@@ -28,13 +33,13 @@ class Profile(AbstractUser):
|
|||||||
size = 20
|
size = 20
|
||||||
chars = string.ascii_letters + string.digits
|
chars = string.ascii_letters + string.digits
|
||||||
new_api_key = ''.join(random.choice(chars) for x in range(size))
|
new_api_key = ''.join(random.choice(chars) for x in range(size))
|
||||||
return new_api_key;
|
return new_api_key
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def profile_picture(self):
|
def profile_picture(self):
|
||||||
url = ""
|
url = ""
|
||||||
if settings.USE_GRAVATAR or settings.USE_GRAVATAR is None:
|
if settings.USE_GRAVATAR or settings.USE_GRAVATAR is None:
|
||||||
url = "https://www.gravatar.com/avatar/" + hashlib.md5(self.email).hexdigest() + "?d=wavatar&s=500"
|
url = "https://www.gravatar.com/avatar/" + hashlib.md5(self.email.encode('utf-8')).hexdigest() + "?d=wavatar&s=500"
|
||||||
return url
|
return url
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -58,32 +63,31 @@ class Profile(AbstractUser):
|
|||||||
|
|
||||||
|
|
||||||
class RevisionMixin(object):
|
class RevisionMixin(object):
|
||||||
|
@property
|
||||||
|
def current_version(self):
|
||||||
|
version = Version.objects.get_for_object(self).select_related('revision').first()
|
||||||
|
return version
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def last_edited_at(self):
|
def last_edited_at(self):
|
||||||
versions = reversion.get_for_object(self)
|
version = self.current_version
|
||||||
if versions:
|
if version is None:
|
||||||
version = reversion.get_for_object(self)[0]
|
|
||||||
return version.revision.date_created
|
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
return version.revision.date_created
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def last_edited_by(self):
|
def last_edited_by(self):
|
||||||
versions = reversion.get_for_object(self)
|
version = self.current_version
|
||||||
if versions:
|
if version is None:
|
||||||
version = reversion.get_for_object(self)[0]
|
|
||||||
return version.revision.user
|
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
return version.revision.user
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_version_id(self):
|
def current_version_id(self):
|
||||||
versions = reversion.get_for_object(self)
|
version = self.current_version
|
||||||
if versions:
|
if version is None:
|
||||||
version = reversion.get_for_object(self)[0]
|
|
||||||
return "V{0} | R{1}".format(version.pk, version.revision.pk)
|
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
return "V{0} | R{1}".format(version.pk, version.revision.pk)
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
@@ -175,7 +179,7 @@ class Organisation(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
class VatManager(models.Manager):
|
class VatManager(models.Manager):
|
||||||
def current_rate(self):
|
def current_rate(self):
|
||||||
return self.find_rate(datetime.datetime.now())
|
return self.find_rate(timezone.now())
|
||||||
|
|
||||||
def find_rate(self, date):
|
def find_rate(self, date):
|
||||||
# return self.filter(startAt__lte=date).latest()
|
# return self.filter(startAt__lte=date).latest()
|
||||||
@@ -190,7 +194,7 @@ class VatManager(models.Manager):
|
|||||||
@reversion.register
|
@reversion.register
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class VatRate(models.Model, RevisionMixin):
|
class VatRate(models.Model, RevisionMixin):
|
||||||
start_at = models.DateTimeField()
|
start_at = models.DateField()
|
||||||
rate = models.DecimalField(max_digits=6, decimal_places=6)
|
rate = models.DecimalField(max_digits=6, decimal_places=6)
|
||||||
comment = models.CharField(max_length=255)
|
comment = models.CharField(max_length=255)
|
||||||
|
|
||||||
@@ -241,18 +245,12 @@ class Venue(models.Model, RevisionMixin):
|
|||||||
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=datetime.date.today(), end_date__isnull=True, dry_hire=False) & ~models.Q(
|
(models.Q(start_date__gte=timezone.now().date(), 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(status=Event.CANCELLED)) | # Ends after
|
||||||
(models.Q(end_date__gte=datetime.date.today(), dry_hire=False) & ~models.Q(
|
(models.Q(dry_hire=True, start_date__gte=timezone.now().date()) & ~models.Q(status=Event.CANCELLED)) | # Active dry hire
|
||||||
status=Event.CANCELLED)) | # Ends after
|
(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(dry_hire=True, start_date__gte=datetime.date.today()) & ~models.Q(
|
models.Q(status=Event.CANCELLED, start_date__gte=timezone.now().date()) # Canceled but not started
|
||||||
status=Event.CANCELLED)) | # Active dry hire
|
).order_by('start_date', 'end_date', 'start_time', 'end_time', 'meet_at').select_related('person', 'organisation', 'venue', 'mic')
|
||||||
(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.CANCELLED, start_date__gte=datetime.date.today()) # Canceled but not started
|
|
||||||
).order_by('start_date', 'end_date', 'start_time', 'end_time', 'meet_at').select_related('person',
|
|
||||||
'organisation',
|
|
||||||
'venue', 'mic')
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
def events_in_bounds(self, start, end):
|
def events_in_bounds(self, start, end):
|
||||||
@@ -275,12 +273,12 @@ 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=datetime.date.today(), end_date__isnull=True, dry_hire=False,
|
(models.Q(start_date__gte=timezone.now().date(), 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=datetime.date.today(), dry_hire=False, is_rig=True) & ~models.Q(
|
(models.Q(end_date__gte=timezone.now().date(), 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=datetime.date.today(), is_rig=True) & ~models.Q(
|
(models.Q(dry_hire=True, start_date__gte=timezone.now().date(), is_rig=True) & ~models.Q(
|
||||||
status=Event.CANCELLED)) | # Active dry hire
|
status=Event.CANCELLED)) | # Active dry hire
|
||||||
(models.Q(dry_hire=True, checked_in_by__isnull=True, is_rig=True) & (
|
(models.Q(dry_hire=True, checked_in_by__isnull=True, is_rig=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
|
||||||
@@ -304,9 +302,9 @@ class Event(models.Model, RevisionMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
person = models.ForeignKey('Person', null=True, blank=True)
|
person = models.ForeignKey('Person', null=True, blank=True, on_delete=models.CASCADE)
|
||||||
organisation = models.ForeignKey('Organisation', blank=True, null=True)
|
organisation = models.ForeignKey('Organisation', blank=True, null=True, on_delete=models.CASCADE)
|
||||||
venue = models.ForeignKey('Venue', blank=True, null=True)
|
venue = models.ForeignKey('Venue', blank=True, null=True, on_delete=models.CASCADE)
|
||||||
description = models.TextField(blank=True, null=True)
|
description = models.TextField(blank=True, null=True)
|
||||||
notes = models.TextField(blank=True, null=True)
|
notes = models.TextField(blank=True, null=True)
|
||||||
status = models.IntegerField(choices=EVENT_STATUS_CHOICES, default=PROVISIONAL)
|
status = models.IntegerField(choices=EVENT_STATUS_CHOICES, default=PROVISIONAL)
|
||||||
@@ -325,9 +323,9 @@ class Event(models.Model, RevisionMixin):
|
|||||||
meet_info = models.CharField(max_length=255, 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, on_delete=models.CASCADE)
|
||||||
mic = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='event_mic', blank=True, null=True,
|
mic = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='event_mic', blank=True, null=True,
|
||||||
verbose_name="MIC")
|
verbose_name="MIC", on_delete=models.CASCADE)
|
||||||
|
|
||||||
# Monies
|
# Monies
|
||||||
payment_method = models.CharField(max_length=255, blank=True, null=True)
|
payment_method = models.CharField(max_length=255, blank=True, null=True)
|
||||||
@@ -335,6 +333,14 @@ class Event(models.Model, RevisionMixin):
|
|||||||
purchase_order = models.CharField(max_length=255, blank=True, null=True, verbose_name='PO')
|
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')
|
collector = models.CharField(max_length=255, blank=True, null=True, verbose_name='collected by')
|
||||||
|
|
||||||
|
# Authorisation request details
|
||||||
|
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_to = models.EmailField(null=True, blank=True)
|
||||||
|
|
||||||
|
# Risk assessment info
|
||||||
|
risk_assessment_edit_url = models.CharField(verbose_name="risk assessment", max_length=255, blank=True, null=True)
|
||||||
|
|
||||||
# Calculated values
|
# Calculated values
|
||||||
"""
|
"""
|
||||||
EX Vat
|
EX Vat
|
||||||
@@ -367,7 +373,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def vat(self):
|
def vat(self):
|
||||||
return self.sum_total * self.vat_rate.rate
|
return Decimal(self.sum_total * self.vat_rate.rate).quantize(Decimal('.01'))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Inc VAT
|
Inc VAT
|
||||||
@@ -375,7 +381,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def total(self):
|
def total(self):
|
||||||
return self.sum_total + self.vat
|
return Decimal(self.sum_total + self.vat).quantize(Decimal('.01'))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cancelled(self):
|
def cancelled(self):
|
||||||
@@ -385,6 +391,10 @@ class Event(models.Model, RevisionMixin):
|
|||||||
def confirmed(self):
|
def confirmed(self):
|
||||||
return (self.status == self.BOOKED or self.status == self.CONFIRMED)
|
return (self.status == self.BOOKED or self.status == self.CONFIRMED)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def authorised(self):
|
||||||
|
return not self.internal and self.purchase_order or self.authorisation.amount == self.total
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_start_time(self):
|
def has_start_time(self):
|
||||||
return self.start_time is not None
|
return self.start_time is not None
|
||||||
@@ -445,13 +455,17 @@ class Event(models.Model, RevisionMixin):
|
|||||||
else:
|
else:
|
||||||
return endDate
|
return endDate
|
||||||
|
|
||||||
|
@property
|
||||||
|
def internal(self):
|
||||||
|
return self.organisation and self.organisation.union_account
|
||||||
|
|
||||||
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_lazy('event_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.pk) + ": " + self.name
|
return str(self.pk) + ": " + self.name
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if self.end_date and self.start_date > self.end_date:
|
if self.end_date and self.start_date > self.end_date:
|
||||||
@@ -474,7 +488,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
|
|
||||||
class EventItem(models.Model):
|
class EventItem(models.Model):
|
||||||
event = models.ForeignKey('Event', related_name='items', blank=True)
|
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, null=True)
|
||||||
quantity = models.IntegerField()
|
quantity = models.IntegerField()
|
||||||
@@ -493,17 +507,35 @@ class EventItem(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class EventCrew(models.Model):
|
class EventCrew(models.Model):
|
||||||
event = models.ForeignKey('Event', related_name='crew')
|
event = models.ForeignKey('Event', related_name='crew', on_delete=models.CASCADE)
|
||||||
user = models.ForeignKey(settings.AUTH_USER_MODEL)
|
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||||
rig = models.BooleanField(default=False)
|
rig = models.BooleanField(default=False)
|
||||||
run = models.BooleanField(default=False)
|
run = models.BooleanField(default=False)
|
||||||
derig = models.BooleanField(default=False)
|
derig = models.BooleanField(default=False)
|
||||||
notes = models.TextField(blank=True, null=True)
|
notes = models.TextField(blank=True, null=True)
|
||||||
|
|
||||||
|
|
||||||
|
@reversion.register
|
||||||
|
class EventAuthorisation(models.Model, RevisionMixin):
|
||||||
|
event = models.OneToOneField('Event', related_name='authorisation', on_delete=models.CASCADE)
|
||||||
|
email = models.EmailField()
|
||||||
|
name = models.CharField(max_length=255)
|
||||||
|
uni_id = models.CharField(max_length=10, blank=True, null=True, verbose_name="University ID")
|
||||||
|
account_code = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="authorisation amount")
|
||||||
|
sent_by = models.ForeignKey('RIGS.Profile', on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse_lazy('event_detail', kwargs={'pk': self.event.pk})
|
||||||
|
|
||||||
|
@property
|
||||||
|
def activity_feed_string(self):
|
||||||
|
return str("N%05d" % self.event.pk + ' (requested by ' + self.sent_by.initials + ')')
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class Invoice(models.Model):
|
class Invoice(models.Model):
|
||||||
event = models.OneToOneField('Event')
|
event = models.OneToOneField('Event', on_delete=models.CASCADE)
|
||||||
invoice_date = models.DateField(auto_now_add=True)
|
invoice_date = models.DateField(auto_now_add=True)
|
||||||
void = models.BooleanField(default=False)
|
void = models.BooleanField(default=False)
|
||||||
|
|
||||||
@@ -526,6 +558,10 @@ class Invoice(models.Model):
|
|||||||
def balance(self):
|
def balance(self):
|
||||||
return self.sum_total - self.payment_total
|
return self.sum_total - self.payment_total
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_closed(self):
|
||||||
|
return self.balance == 0 or self.void
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%i: %s (%.2f)" % (self.pk, self.event, self.balance)
|
return "%i: %s (%.2f)" % (self.pk, self.event, self.balance)
|
||||||
|
|
||||||
@@ -551,7 +587,7 @@ class Payment(models.Model):
|
|||||||
(ADJUSTMENT, 'TEC Adjustment'),
|
(ADJUSTMENT, 'TEC Adjustment'),
|
||||||
)
|
)
|
||||||
|
|
||||||
invoice = models.ForeignKey('Invoice')
|
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, null=True, blank=True)
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
from RIGS.models import Profile
|
from RIGS.models import Profile
|
||||||
from RIGS.forms import ProfileRegistrationFormUniqueEmail
|
from RIGS.forms import ProfileRegistrationFormUniqueEmail
|
||||||
|
from registration.signals import user_registered
|
||||||
|
|
||||||
|
|
||||||
def user_created(sender, user, request, **kwargs):
|
def user_created(sender, user, request, **kwargs):
|
||||||
form = ProfileRegistrationFormUniqueEmail(request.POST)
|
form = ProfileRegistrationFormUniqueEmail(request.POST)
|
||||||
user.first_name = form.data['first_name']
|
user.first_name = form.data['first_name']
|
||||||
user.last_name = form.data['last_name']
|
user.last_name = form.data['last_name']
|
||||||
user.initials = form.data['initials']
|
user.initials = form.data['initials']
|
||||||
user.phone = form.data['phone']
|
user.phone = form.data['phone']
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
|
|
||||||
from registration.signals import user_registered
|
|
||||||
user_registered.connect(user_created)
|
user_registered.connect(user_created)
|
||||||
315
RIGS/rigboard.py
@@ -1,21 +1,31 @@
|
|||||||
import os
|
|
||||||
import cStringIO as StringIO
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import urllib2
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||||
|
from django.core.mail import EmailMessage, EmailMultiAlternatives
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.core import signing
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from django.core.exceptions import SuspiciousOperation
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from z3c.rml import rml2pdf
|
from z3c.rml import rml2pdf
|
||||||
from PyPDF2 import PdfFileMerger, PdfFileReader
|
from PyPDF2 import PdfFileMerger, PdfFileReader
|
||||||
|
import simplejson
|
||||||
|
import premailer
|
||||||
|
|
||||||
from RIGS import models, forms
|
from RIGS import models, forms
|
||||||
|
from PyRIGS import decorators
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
import copy
|
import copy
|
||||||
@@ -34,19 +44,61 @@ class RigboardIndex(generic.TemplateView):
|
|||||||
context['events'] = models.Event.objects.current_events()
|
context['events'] = models.Event.objects.current_events()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class WebCalendar(generic.TemplateView):
|
class WebCalendar(generic.TemplateView):
|
||||||
template_name = 'RIGS/calendar.html'
|
template_name = 'RIGS/calendar.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(WebCalendar, self).get_context_data(**kwargs)
|
context = super(WebCalendar, self).get_context_data(**kwargs)
|
||||||
context['view'] = kwargs.get('view','')
|
context['view'] = kwargs.get('view', '')
|
||||||
context['date'] = kwargs.get('date','')
|
context['date'] = kwargs.get('date', '')
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventDetail(generic.DetailView):
|
class EventDetail(generic.DetailView):
|
||||||
model = models.Event
|
model = models.Event
|
||||||
|
|
||||||
|
|
||||||
|
class EventOembed(generic.View):
|
||||||
|
model = models.Event
|
||||||
|
|
||||||
|
def get(self, request, pk=None):
|
||||||
|
embed_url = reverse('event_embed', args=[pk])
|
||||||
|
full_url = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'], embed_url)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'html': '<iframe src="{0}" frameborder="0" width="100%" height="250"></iframe>'.format(full_url),
|
||||||
|
'version': '1.0',
|
||||||
|
'type': 'rich',
|
||||||
|
'height': '250'
|
||||||
|
}
|
||||||
|
|
||||||
|
json = simplejson.JSONEncoderForHTML().encode(data)
|
||||||
|
return HttpResponse(json, content_type="application/json")
|
||||||
|
|
||||||
|
|
||||||
|
class EventEmbed(EventDetail):
|
||||||
|
template_name = 'RIGS/event_embed.html'
|
||||||
|
|
||||||
|
|
||||||
|
class EventRA(generic.base.RedirectView):
|
||||||
|
permanent = False
|
||||||
|
def get_redirect_url(self, *args, **kwargs):
|
||||||
|
event = get_object_or_404(models.Event, pk=kwargs['pk'])
|
||||||
|
|
||||||
|
if event.risk_assessment_edit_url:
|
||||||
|
return event.risk_assessment_edit_url
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'entry.708610078': f'N{event.pk:05}',
|
||||||
|
'entry.905899507': event.name,
|
||||||
|
'entry.139491562': event.venue.name if event.venue else '',
|
||||||
|
'entry.1689826056': event.start_date.strftime('%Y-%m-%d') + ((' - ' + event.end_date.strftime('%Y-%m-%d')) if event.end_date else ''),
|
||||||
|
'entry.902421165': event.mic.name if event.mic else ''
|
||||||
|
}
|
||||||
|
return settings.RISK_ASSESSMENT_URL + "?" + urllib.parse.urlencode(params)
|
||||||
|
|
||||||
|
|
||||||
class EventCreate(generic.CreateView):
|
class EventCreate(generic.CreateView):
|
||||||
model = models.Event
|
model = models.Event
|
||||||
form_class = forms.EventForm
|
form_class = forms.EventForm
|
||||||
@@ -60,9 +112,8 @@ class EventCreate(generic.CreateView):
|
|||||||
if re.search('"-\d+"', form['items_json'].value()):
|
if re.search('"-\d+"', form['items_json'].value()):
|
||||||
messages.info(self.request, "Your item changes have been saved. Please fix the errors and save the event.")
|
messages.info(self.request, "Your item changes have been saved. Please fix the errors and save the event.")
|
||||||
|
|
||||||
|
|
||||||
# Get some other objects to include in the form. Used when there are errors but also nice and quick.
|
# Get 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.iteritems():
|
for field, model in form.related_models.items():
|
||||||
value = form[field].value()
|
value = form[field].value()
|
||||||
if value is not None and value != '':
|
if value is not None and value != '':
|
||||||
context[field] = model.objects.get(pk=value)
|
context[field] = model.objects.get(pk=value)
|
||||||
@@ -83,25 +134,45 @@ class EventUpdate(generic.UpdateView):
|
|||||||
form = context['form']
|
form = context['form']
|
||||||
|
|
||||||
# Get some other objects to include in the form. Used when there are errors but also nice and quick.
|
# Get 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.iteritems():
|
for field, model in form.related_models.items():
|
||||||
value = form[field].value()
|
value = form[field].value()
|
||||||
if value is not None and value != '':
|
if value is not None and value != '':
|
||||||
context[field] = model.objects.get(pk=value)
|
context[field] = model.objects.get(pk=value)
|
||||||
|
|
||||||
|
# If this event has already been emailed to a client, show a warning
|
||||||
|
if self.object.auth_request_at is not None:
|
||||||
|
messages.info(self.request, 'This event has already been sent to the client for authorisation, any changes you make will be visible to them immediately.')
|
||||||
|
|
||||||
|
if hasattr(self.object, 'authorised'):
|
||||||
|
messages.warning(self.request, 'This event has already been authorised by client, any changes to price will require reauthorisation.')
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy('event_detail', kwargs={'pk': self.object.pk})
|
return reverse_lazy('event_detail', kwargs={'pk': self.object.pk})
|
||||||
|
|
||||||
|
|
||||||
class EventDuplicate(EventUpdate):
|
class EventDuplicate(EventUpdate):
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
old = super(EventDuplicate, self).get_object(queryset) # Get the object (the event you're duplicating)
|
old = super(EventDuplicate, self).get_object(queryset) # Get the object (the event you're duplicating)
|
||||||
new = copy.copy(old) # Make a copy of the object in memory
|
new = copy.copy(old) # Make a copy of the object in memory
|
||||||
new.based_on = old # Make the new event based on the old event
|
new.based_on = old # Make the new event based on the old event
|
||||||
|
new.purchase_order = None # Remove old PO
|
||||||
|
|
||||||
if self.request.method in ('POST', 'PUT'): # This only happens on save (otherwise items won't display in editor)
|
# Clear checked in by if it's a dry hire
|
||||||
new.pk = None # This means a new event will be created on save, and all items will be re-created
|
if new.dry_hire is True:
|
||||||
|
new.checked_in_by = None
|
||||||
|
|
||||||
messages.info(self.request, 'Event data duplicated but not yet saved. Click save to complete operation.')
|
# Remove all the authorisation information from the new event
|
||||||
|
new.auth_request_to = None
|
||||||
|
new.auth_request_by = None
|
||||||
|
new.auth_request_at = None
|
||||||
|
|
||||||
|
if self.request.method in (
|
||||||
|
'POST', 'PUT'): # This only happens on save (otherwise items won't display in editor)
|
||||||
|
new.pk = None # This means a new event will be created on save, and all items will be re-created
|
||||||
|
else:
|
||||||
|
messages.info(self.request, 'Event data duplicated but not yet saved. Click save to complete operation.')
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
@@ -110,41 +181,34 @@ class EventDuplicate(EventUpdate):
|
|||||||
context["duplicate"] = True
|
context["duplicate"] = True
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EventPrint(generic.View):
|
class EventPrint(generic.View):
|
||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
object = get_object_or_404(models.Event, pk=pk)
|
object = get_object_or_404(models.Event, pk=pk)
|
||||||
template = get_template('RIGS/event_print.xml')
|
template = get_template('RIGS/event_print.xml')
|
||||||
copies = ('TEC', 'Client')
|
|
||||||
|
|
||||||
merger = PdfFileMerger()
|
merger = PdfFileMerger()
|
||||||
|
|
||||||
for copy in copies:
|
context = {
|
||||||
|
'object': object,
|
||||||
|
'fonts': {
|
||||||
|
'opensans': {
|
||||||
|
'regular': 'RIGS/static/fonts/OPENSANS-REGULAR.TTF',
|
||||||
|
'bold': 'RIGS/static/fonts/OPENSANS-BOLD.TTF',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'quote': True,
|
||||||
|
'current_user': request.user,
|
||||||
|
}
|
||||||
|
|
||||||
context = RequestContext(request, { # this should be outside the loop, but bug in 1.8.2 prevents this
|
rml = template.render(context)
|
||||||
'object': object,
|
|
||||||
'fonts': {
|
|
||||||
'opensans': {
|
|
||||||
'regular': 'RIGS/static/fonts/OPENSANS-REGULAR.TTF',
|
|
||||||
'bold': 'RIGS/static/fonts/OPENSANS-BOLD.TTF',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'copy':copy,
|
|
||||||
'current_user':request.user,
|
|
||||||
})
|
|
||||||
|
|
||||||
# context['copy'] = copy # this is the way to do it once we upgrade to Django 1.8.3
|
buffer = rml2pdf.parseString(rml)
|
||||||
|
merger.append(PdfFileReader(buffer))
|
||||||
|
buffer.close()
|
||||||
|
|
||||||
rml = template.render(context)
|
terms = urllib.request.urlopen(settings.TERMS_OF_HIRE_URL)
|
||||||
buffer = StringIO.StringIO()
|
merger.append(BytesIO(terms.read()))
|
||||||
|
|
||||||
buffer = rml2pdf.parseString(rml)
|
|
||||||
|
|
||||||
merger.append(PdfFileReader(buffer))
|
|
||||||
|
|
||||||
buffer.close()
|
|
||||||
|
|
||||||
terms = urllib2.urlopen(settings.TERMS_OF_HIRE_URL)
|
|
||||||
merger.append(StringIO.StringIO(terms.read()))
|
|
||||||
|
|
||||||
merged = BytesIO()
|
merged = BytesIO()
|
||||||
merger.write(merged)
|
merger.write(merged)
|
||||||
@@ -157,6 +221,7 @@ class EventPrint(generic.View):
|
|||||||
response.write(merged.getvalue())
|
response.write(merged.getvalue())
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
class EventArchive(generic.ArchiveIndexView):
|
class EventArchive(generic.ArchiveIndexView):
|
||||||
model = models.Event
|
model = models.Event
|
||||||
date_field = "start_date"
|
date_field = "start_date"
|
||||||
@@ -193,3 +258,173 @@ class EventArchive(generic.ArchiveIndexView):
|
|||||||
messages.add_message(self.request, messages.WARNING, "No events have been found matching those criteria.")
|
messages.add_message(self.request, messages.WARNING, "No events have been found matching those criteria.")
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
class EventAuthorise(generic.UpdateView):
|
||||||
|
template_name = 'RIGS/eventauthorisation_form.html'
|
||||||
|
success_template = 'RIGS/eventauthorisation_success.html'
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
self.object = form.save()
|
||||||
|
|
||||||
|
self.template_name = self.success_template
|
||||||
|
messages.add_message(self.request, messages.SUCCESS,
|
||||||
|
'Success! Your event has been authorised. ' +
|
||||||
|
'You will also receive email confirmation to %s.' % (self.object.email))
|
||||||
|
return self.render_to_response(self.get_context_data())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def event(self):
|
||||||
|
return models.Event.objects.select_related('organisation', 'person', 'venue').get(pk=self.kwargs['pk'])
|
||||||
|
|
||||||
|
def get_object(self, queryset=None):
|
||||||
|
return getattr(self.event, 'authorisation', None)
|
||||||
|
|
||||||
|
def get_form_class(self):
|
||||||
|
return forms.InternalClientEventAuthorisationForm
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(EventAuthorise, self).get_context_data(**kwargs)
|
||||||
|
context['event'] = self.event
|
||||||
|
|
||||||
|
context['tos_url'] = settings.TERMS_OF_HIRE_URL
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
if self.get_object() is not None and self.get_object().pk is not None:
|
||||||
|
if self.event.authorised:
|
||||||
|
messages.add_message(self.request, messages.WARNING,
|
||||||
|
"This event has already been authorised. "
|
||||||
|
"Reauthorising is not necessary at this time.")
|
||||||
|
else:
|
||||||
|
messages.add_message(self.request, messages.WARNING,
|
||||||
|
"This event has already been authorised, but the amount has changed. " +
|
||||||
|
"Please check the amount and reauthorise.")
|
||||||
|
return super(EventAuthorise, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_form(self, **kwargs):
|
||||||
|
form = super(EventAuthorise, self).get_form(**kwargs)
|
||||||
|
form.instance.event = self.event
|
||||||
|
form.instance.email = self.request.email
|
||||||
|
form.instance.sent_by = self.request.sent_by
|
||||||
|
return form
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
# Verify our signature matches up and all is well with the integrity of the URL
|
||||||
|
try:
|
||||||
|
data = signing.loads(kwargs.get('hmac'))
|
||||||
|
assert int(kwargs.get('pk')) == int(data.get('pk'))
|
||||||
|
request.email = data['email']
|
||||||
|
request.sent_by = models.Profile.objects.get(pk=data['sent_by'])
|
||||||
|
except (signing.BadSignature, AssertionError, KeyError, models.Profile.DoesNotExist):
|
||||||
|
raise SuspiciousOperation(
|
||||||
|
"This URL is invalid. Please ask your TEC contact for a new URL")
|
||||||
|
return super(EventAuthorise, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMixin):
|
||||||
|
model = models.Event
|
||||||
|
form_class = forms.EventAuthorisationRequestForm
|
||||||
|
template_name = 'RIGS/eventauthorisation_request.html'
|
||||||
|
|
||||||
|
@method_decorator(decorators.nottinghamtec_address_required)
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
return super(EventAuthorisationRequest, self).dispatch(*args, **kwargs)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def object(self):
|
||||||
|
return self.get_object()
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
if self.request.is_ajax():
|
||||||
|
url = reverse_lazy('closemodal')
|
||||||
|
messages.info(self.request, "location.reload()")
|
||||||
|
else:
|
||||||
|
url = reverse_lazy('event_detail', kwargs={
|
||||||
|
'pk': self.object.pk,
|
||||||
|
})
|
||||||
|
messages.add_message(self.request, messages.SUCCESS, "Authorisation request successfully sent.")
|
||||||
|
return url
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
email = form.cleaned_data['email']
|
||||||
|
event = self.object
|
||||||
|
event.auth_request_by = self.request.user
|
||||||
|
event.auth_request_at = datetime.datetime.now()
|
||||||
|
event.auth_request_to = email
|
||||||
|
event.save()
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'object': self.object,
|
||||||
|
'request': self.request,
|
||||||
|
'hmac': signing.dumps({
|
||||||
|
'pk': self.object.pk,
|
||||||
|
'email': email,
|
||||||
|
'sent_by': self.request.user.pk,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
if event.person is not None and email == event.person.email:
|
||||||
|
context['to_name'] = event.person.name
|
||||||
|
elif event.organisation is not None and email == event.organisation.email:
|
||||||
|
context['to_name'] = event.organisation.name
|
||||||
|
|
||||||
|
msg = EmailMultiAlternatives(
|
||||||
|
"N%05d | %s - Event Authorisation Request" % (self.object.pk, self.object.name),
|
||||||
|
get_template("RIGS/eventauthorisation_client_request.txt").render(context),
|
||||||
|
to=[email],
|
||||||
|
reply_to=[self.request.user.email],
|
||||||
|
)
|
||||||
|
css = staticfiles_storage.path('css/email.css')
|
||||||
|
html = premailer.Premailer(get_template("RIGS/eventauthorisation_client_request.html").render(context),
|
||||||
|
external_styles=css).transform()
|
||||||
|
msg.attach_alternative(html, 'text/html')
|
||||||
|
|
||||||
|
msg.send()
|
||||||
|
|
||||||
|
return super(EventAuthorisationRequest, self).form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
class EventAuthoriseRequestEmailPreview(generic.DetailView):
|
||||||
|
template_name = "RIGS/eventauthorisation_client_request.html"
|
||||||
|
model = models.Event
|
||||||
|
|
||||||
|
def render_to_response(self, context, **response_kwargs):
|
||||||
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||||
|
css = staticfiles_storage.path('css/email.css')
|
||||||
|
response = super(EventAuthoriseRequestEmailPreview, self).render_to_response(context, **response_kwargs)
|
||||||
|
assert isinstance(response, HttpResponse)
|
||||||
|
response.content = premailer.Premailer(response.rendered_content, external_styles=css).transform()
|
||||||
|
return response
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(EventAuthoriseRequestEmailPreview, self).get_context_data(**kwargs)
|
||||||
|
context['hmac'] = signing.dumps({
|
||||||
|
'pk': self.object.pk,
|
||||||
|
'email': self.request.GET.get('email', 'hello@world.test'),
|
||||||
|
'sent_by': self.request.user.pk,
|
||||||
|
})
|
||||||
|
context['to_name'] = self.request.GET.get('to_name', None)
|
||||||
|
return context
|
||||||
|
|
||||||
|
@method_decorator(csrf_exempt, name='dispatch')
|
||||||
|
class LogRiskAssessment(generic.View):
|
||||||
|
http_method_names = ["post"]
|
||||||
|
|
||||||
|
def post(self, request, **kwargs):
|
||||||
|
data = request.POST
|
||||||
|
shared_secret = data.get("secret")
|
||||||
|
edit_url = data.get("editUrl")
|
||||||
|
rig_number = data.get("rigNum")
|
||||||
|
if shared_secret is None or edit_url is None or rig_number is None:
|
||||||
|
return HttpResponse(status=422)
|
||||||
|
|
||||||
|
if shared_secret != settings.RISK_ASSESSMENT_SECRET:
|
||||||
|
return HttpResponse(status=403)
|
||||||
|
|
||||||
|
rig_number = int(re.sub("[^0-9]", "", rig_number))
|
||||||
|
|
||||||
|
event = get_object_or_404(models.Event, pk=rig_number)
|
||||||
|
event.risk_assessment_edit_url = edit_url
|
||||||
|
event.save()
|
||||||
|
|
||||||
|
return HttpResponse(status=200)
|
||||||
|
|||||||
104
RIGS/signals.py
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import re
|
||||||
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
from django.db.models.signals import post_save
|
||||||
|
from PyPDF2 import PdfFileReader, PdfFileMerger
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||||
|
from django.core.mail import EmailMessage, EmailMultiAlternatives
|
||||||
|
from django.template.loader import get_template
|
||||||
|
from premailer import Premailer
|
||||||
|
from z3c.rml import rml2pdf
|
||||||
|
|
||||||
|
from RIGS import models
|
||||||
|
|
||||||
|
|
||||||
|
def send_eventauthorisation_success_email(instance):
|
||||||
|
# Generate PDF first to prevent context conflicts
|
||||||
|
context = {
|
||||||
|
'object': instance.event,
|
||||||
|
'fonts': {
|
||||||
|
'opensans': {
|
||||||
|
'regular': 'RIGS/static/fonts/OPENSANS-REGULAR.TTF',
|
||||||
|
'bold': 'RIGS/static/fonts/OPENSANS-BOLD.TTF',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'receipt': True,
|
||||||
|
'current_user': False,
|
||||||
|
}
|
||||||
|
|
||||||
|
template = get_template('RIGS/event_print.xml')
|
||||||
|
merger = PdfFileMerger()
|
||||||
|
|
||||||
|
rml = template.render(context)
|
||||||
|
|
||||||
|
buffer = rml2pdf.parseString(rml)
|
||||||
|
merger.append(PdfFileReader(buffer))
|
||||||
|
buffer.close()
|
||||||
|
|
||||||
|
terms = urllib.request.urlopen(settings.TERMS_OF_HIRE_URL)
|
||||||
|
merger.append(BytesIO(terms.read()))
|
||||||
|
|
||||||
|
merged = BytesIO()
|
||||||
|
merger.write(merged)
|
||||||
|
|
||||||
|
# Produce email content
|
||||||
|
context = {
|
||||||
|
'object': instance,
|
||||||
|
}
|
||||||
|
|
||||||
|
if instance.event.person is not None and instance.email == instance.event.person.email:
|
||||||
|
context['to_name'] = instance.event.person.name
|
||||||
|
elif instance.event.organisation is not None and instance.email == instance.event.organisation.email:
|
||||||
|
context['to_name'] = instance.event.organisation.name
|
||||||
|
|
||||||
|
subject = "N%05d | %s - Event Authorised" % (instance.event.pk, instance.event.name)
|
||||||
|
|
||||||
|
client_email = EmailMultiAlternatives(
|
||||||
|
subject,
|
||||||
|
get_template("RIGS/eventauthorisation_client_success.txt").render(context),
|
||||||
|
to=[instance.email],
|
||||||
|
reply_to=[settings.AUTHORISATION_NOTIFICATION_ADDRESS],
|
||||||
|
)
|
||||||
|
|
||||||
|
css = staticfiles_storage.path('css/email.css')
|
||||||
|
html = Premailer(get_template("RIGS/eventauthorisation_client_success.html").render(context),
|
||||||
|
external_styles=css).transform()
|
||||||
|
client_email.attach_alternative(html, 'text/html')
|
||||||
|
|
||||||
|
escapedEventName = re.sub('[^a-zA-Z0-9 \n\.]', '', instance.event.name)
|
||||||
|
|
||||||
|
client_email.attach('N%05d - %s - CONFIRMATION.pdf' % (instance.event.pk, escapedEventName),
|
||||||
|
merged.getvalue(),
|
||||||
|
'application/pdf'
|
||||||
|
)
|
||||||
|
|
||||||
|
if instance.event.mic:
|
||||||
|
mic_email_address = instance.event.mic.email
|
||||||
|
else:
|
||||||
|
mic_email_address = settings.AUTHORISATION_NOTIFICATION_ADDRESS
|
||||||
|
|
||||||
|
mic_email = EmailMessage(
|
||||||
|
subject,
|
||||||
|
get_template("RIGS/eventauthorisation_mic_success.txt").render(context),
|
||||||
|
to=[mic_email_address]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Now we have both emails successfully generated, send them out
|
||||||
|
client_email.send(fail_silently=True)
|
||||||
|
mic_email.send(fail_silently=True)
|
||||||
|
|
||||||
|
# Set event to booked now that it's authorised
|
||||||
|
instance.event.status = models.Event.BOOKED
|
||||||
|
instance.event.save()
|
||||||
|
|
||||||
|
|
||||||
|
def on_revision_commit(sender, instance, created, **kwargs):
|
||||||
|
if created:
|
||||||
|
send_eventauthorisation_success_email(instance)
|
||||||
|
|
||||||
|
|
||||||
|
post_save.connect(on_revision_commit, sender=models.EventAuthorisation)
|
||||||
6
RIGS/static/css/bootstrap-select.min.css
vendored
Normal file → Executable file
1
RIGS/static/css/email.css
Normal file
@@ -0,0 +1 @@
|
|||||||
|
body{margin:0px}.main-table{width:100%;border-collapse:collapse}.client-header{background-image:url("https://www.nottinghamtec.co.uk/imgs/wof2014-1.jpg");background-color:#222;background-repeat:no-repeat;background-position:center;width:100%;margin-bottom:28px}.client-header .logos{width:100%;max-width:640px}.client-header img{height:110px}.content-container{width:100%}.content-container .content{font-family:"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;width:100%;max-width:600px;padding:10px;text-align:left}.content-container .content .button-container{width:100%}.content-container .content .button-container .button{padding:6px 12px;background-color:#357ebf;border-radius:4px}.content-container .content .button-container .button a{color:#fff;text-decoration:none}
|
||||||
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 2.2 KiB |
12
RIGS/static/js/affix.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: affix.js v3.3.2
|
* Bootstrap: affix.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#affix
|
* http://getbootstrap.com/javascript/#affix
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -21,14 +21,14 @@
|
|||||||
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
|
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
|
||||||
|
|
||||||
this.$element = $(element)
|
this.$element = $(element)
|
||||||
this.affixed =
|
this.affixed = null
|
||||||
this.unpin =
|
this.unpin = null
|
||||||
this.pinnedOffset = null
|
this.pinnedOffset = null
|
||||||
|
|
||||||
this.checkPosition()
|
this.checkPosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
Affix.VERSION = '3.3.2'
|
Affix.VERSION = '3.3.7'
|
||||||
|
|
||||||
Affix.RESET = 'affix affix-top affix-bottom'
|
Affix.RESET = 'affix affix-top affix-bottom'
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
var offset = this.options.offset
|
var offset = this.options.offset
|
||||||
var offsetTop = offset.top
|
var offsetTop = offset.top
|
||||||
var offsetBottom = offset.bottom
|
var offsetBottom = offset.bottom
|
||||||
var scrollHeight = $('body').height()
|
var scrollHeight = Math.max($(document).height(), $(document.body).height())
|
||||||
|
|
||||||
if (typeof offset != 'object') offsetBottom = offsetTop = offset
|
if (typeof offset != 'object') offsetBottom = offsetTop = offset
|
||||||
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
|
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
|
||||||
|
|||||||
84
RIGS/static/js/ajax-bootstrap-select.js
Executable file → Normal file
@@ -3,16 +3,16 @@
|
|||||||
*
|
*
|
||||||
* Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON.
|
* Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON.
|
||||||
*
|
*
|
||||||
* @version 1.3.1
|
* @version 1.4.1
|
||||||
* @author Adam Heim - https://github.com/truckingsim
|
* @author Adam Heim - https://github.com/truckingsim
|
||||||
* @link https://github.com/truckingsim/Ajax-Bootstrap-Select
|
* @link https://github.com/truckingsim/Ajax-Bootstrap-Select
|
||||||
* @copyright 2015 Adam Heim
|
* @copyright 2017 Adam Heim
|
||||||
* @license Released under the MIT license.
|
* @license Released under the MIT license.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Mark Carver - https://github.com/markcarver
|
* Mark Carver - https://github.com/markcarver
|
||||||
*
|
*
|
||||||
* Last build: 2015-01-06 8:43:11 PM EST
|
* Last build: 2017-07-21 1:08:54 PM GMT-0400
|
||||||
*/
|
*/
|
||||||
!(function ($, window) {
|
!(function ($, window) {
|
||||||
|
|
||||||
@@ -186,10 +186,25 @@ var AjaxBootstrapSelect = function (element, options) {
|
|||||||
if (dataKeys.length) {
|
if (dataKeys.length) {
|
||||||
// Object containing the data attribute options.
|
// Object containing the data attribute options.
|
||||||
var dataOptions = {};
|
var dataOptions = {};
|
||||||
|
var flattenedOptions = ['locale'];
|
||||||
for (i = 0, l = dataKeys.length; i < l; i++) {
|
for (i = 0, l = dataKeys.length; i < l; i++) {
|
||||||
var name = dataKeys[i].replace(/^abs([A-Z])/, matchToLowerCase).replace(/([A-Z])/g, '-$1').toLowerCase();
|
var name = dataKeys[i].replace(/^abs([A-Z])/, matchToLowerCase).replace(/([A-Z])/g, '-$1').toLowerCase();
|
||||||
|
var keys = name.split('-');
|
||||||
|
|
||||||
|
// Certain options should be flattened to a single object
|
||||||
|
// and not fully expanded (such as Locale).
|
||||||
|
if (keys[0] && keys.length > 1 && flattenedOptions.indexOf(keys[0]) !== -1) {
|
||||||
|
var newKeys = [keys.shift()];
|
||||||
|
var property = '';
|
||||||
|
// Combine the remaining keys as a single property.
|
||||||
|
for (var ii = 0; ii < keys.length; ii++) {
|
||||||
|
property += (ii === 0 ? keys[ii] : keys[ii].charAt(0).toUpperCase() + keys[ii].slice(1));
|
||||||
|
}
|
||||||
|
newKeys.push(property);
|
||||||
|
keys = newKeys;
|
||||||
|
}
|
||||||
this.log(this.LOG_DEBUG, 'Processing data attribute "data-abs-' + name + '":', data[dataKeys[i]]);
|
this.log(this.LOG_DEBUG, 'Processing data attribute "data-abs-' + name + '":', data[dataKeys[i]]);
|
||||||
expandObject(name.split('-'), data[dataKeys[i]], dataOptions);
|
expandObject(keys, data[dataKeys[i]], dataOptions);
|
||||||
}
|
}
|
||||||
this.options = $.extend(true, {}, this.options, dataOptions);
|
this.options = $.extend(true, {}, this.options, dataOptions);
|
||||||
this.log(this.LOG_DEBUG, 'Merged in the data attribute options: ', dataOptions, this.options);
|
this.log(this.LOG_DEBUG, 'Merged in the data attribute options: ', dataOptions, this.options);
|
||||||
@@ -316,6 +331,12 @@ AjaxBootstrapSelect.prototype.init = function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't process if below minimum query length
|
||||||
|
if (query.length < plugin.options.minLength) {
|
||||||
|
plugin.list.setStatus(plugin.t('statusTooShort'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Clear out any existing timer.
|
// Clear out any existing timer.
|
||||||
clearTimeout(requestDelayTimer);
|
clearTimeout(requestDelayTimer);
|
||||||
|
|
||||||
@@ -573,8 +594,25 @@ var AjaxBootstrapSelectList = function (plugin) {
|
|||||||
this.title = null;
|
this.title = null;
|
||||||
this.selectedTextFormat = plugin.selectpicker.options.selectedTextFormat;
|
this.selectedTextFormat = plugin.selectpicker.options.selectedTextFormat;
|
||||||
|
|
||||||
|
// Save initial options
|
||||||
|
var initial_options = [];
|
||||||
|
plugin.$element.find('option').each(function() {
|
||||||
|
var $option = $(this);
|
||||||
|
var value = $option.attr('value');
|
||||||
|
initial_options.push({
|
||||||
|
value: value,
|
||||||
|
text: $option.text(),
|
||||||
|
'class': $option.attr('class') || '',
|
||||||
|
data: $option.data() || {},
|
||||||
|
preserved: plugin.options.preserveSelected,
|
||||||
|
selected: !!$option.attr('selected')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.cacheSet(/*query=*/'', initial_options);
|
||||||
|
|
||||||
// Preserve selected options.
|
// Preserve selected options.
|
||||||
if (plugin.options.preserveSelected) {
|
if (plugin.options.preserveSelected) {
|
||||||
|
that.selected = initial_options;
|
||||||
plugin.$element.on('change.abs.preserveSelected', function (e) {
|
plugin.$element.on('change.abs.preserveSelected', function (e) {
|
||||||
var $selected = plugin.$element.find(':selected');
|
var $selected = plugin.$element.find(':selected');
|
||||||
that.selected = [];
|
that.selected = [];
|
||||||
@@ -644,7 +682,7 @@ AjaxBootstrapSelectList.prototype.build = function (data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set various properties.
|
// Set various properties.
|
||||||
$option.val(item.value).text(item.text);
|
$option.val(item.value).text(item.text).attr('title', item.text);
|
||||||
if (item['class'].length) {
|
if (item['class'].length) {
|
||||||
$option.attr('class', item['class']);
|
$option.attr('class', item['class']);
|
||||||
}
|
}
|
||||||
@@ -732,7 +770,13 @@ AjaxBootstrapSelectList.prototype.refresh = function (triggerChange) {
|
|||||||
if (!this.plugin.$element.find('option').length && emptyTitle && emptyTitle.length) {
|
if (!this.plugin.$element.find('option').length && emptyTitle && emptyTitle.length) {
|
||||||
this.setTitle(emptyTitle);
|
this.setTitle(emptyTitle);
|
||||||
}
|
}
|
||||||
else if (this.title) {
|
else if (
|
||||||
|
this.title ||
|
||||||
|
(
|
||||||
|
this.selectedTextFormat !== 'static' &&
|
||||||
|
this.selectedTextFormat !== this.plugin.selectpicker.options.selectedTextFormat
|
||||||
|
)
|
||||||
|
) {
|
||||||
this.restoreTitle();
|
this.restoreTitle();
|
||||||
}
|
}
|
||||||
this.plugin.selectpicker.refresh();
|
this.plugin.selectpicker.refresh();
|
||||||
@@ -1224,6 +1268,14 @@ $.fn.ajaxSelectPicker.defaults = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @member $.fn.ajaxSelectPicker.defaults
|
||||||
|
* @cfg {Number} minLength = 0
|
||||||
|
* @markdown
|
||||||
|
* Invoke a request for empty search values.
|
||||||
|
*/
|
||||||
|
minLength: 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @member $.fn.ajaxSelectPicker.defaults
|
* @member $.fn.ajaxSelectPicker.defaults
|
||||||
* @cfg {String} ajaxSearchUrl
|
* @cfg {String} ajaxSearchUrl
|
||||||
@@ -1296,8 +1348,7 @@ $.fn.ajaxSelectPicker.defaults = {
|
|||||||
* 39: "right",
|
* 39: "right",
|
||||||
* 38: "up",
|
* 38: "up",
|
||||||
* 40: "down",
|
* 40: "down",
|
||||||
* 91: "meta",
|
* 91: "meta"
|
||||||
* 229: "unknown"
|
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@@ -1311,8 +1362,7 @@ $.fn.ajaxSelectPicker.defaults = {
|
|||||||
39: "right",
|
39: "right",
|
||||||
38: "up",
|
38: "up",
|
||||||
40: "down",
|
40: "down",
|
||||||
91: "meta",
|
91: "meta"
|
||||||
229: "unknown"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1406,7 +1456,7 @@ $.fn.ajaxSelectPicker.defaults = {
|
|||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
preprocessData: function(){},
|
preprocessData: function () { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @member $.fn.ajaxSelectPicker.defaults
|
* @member $.fn.ajaxSelectPicker.defaults
|
||||||
@@ -1434,7 +1484,7 @@ $.fn.ajaxSelectPicker.defaults = {
|
|||||||
* @markdown
|
* @markdown
|
||||||
* Process the data returned after this plugin, but before the list is built.
|
* Process the data returned after this plugin, but before the list is built.
|
||||||
*/
|
*/
|
||||||
processData: function(){},
|
processData: function () { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @member $.fn.ajaxSelectPicker.defaults
|
* @member $.fn.ajaxSelectPicker.defaults
|
||||||
@@ -1547,7 +1597,15 @@ $.fn.ajaxSelectPicker.locale['en-US'] = {
|
|||||||
* @markdown
|
* @markdown
|
||||||
* The text to use in the status container when a request is being initiated.
|
* The text to use in the status container when a request is being initiated.
|
||||||
*/
|
*/
|
||||||
statusSearching: 'Searching...'
|
statusSearching: 'Searching...',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @member $.fn.ajaxSelectPicker.locale
|
||||||
|
* @cfg {String} statusToShort = 'Please enter more characters'
|
||||||
|
* @markdown
|
||||||
|
* The text used in the status container when the request returns no results.
|
||||||
|
*/
|
||||||
|
statusTooShort: 'Please enter more characters'
|
||||||
};
|
};
|
||||||
$.fn.ajaxSelectPicker.locale.en = $.fn.ajaxSelectPicker.locale['en-US'];
|
$.fn.ajaxSelectPicker.locale.en = $.fn.ajaxSelectPicker.locale['en-US'];
|
||||||
|
|
||||||
|
|||||||
8
RIGS/static/js/alert.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: alert.js v3.3.2
|
* Bootstrap: alert.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#alerts
|
* http://getbootstrap.com/javascript/#alerts
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
$(el).on('click', dismiss, this.close)
|
$(el).on('click', dismiss, this.close)
|
||||||
}
|
}
|
||||||
|
|
||||||
Alert.VERSION = '3.3.2'
|
Alert.VERSION = '3.3.7'
|
||||||
|
|
||||||
Alert.TRANSITION_DURATION = 150
|
Alert.TRANSITION_DURATION = 150
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
||||||
}
|
}
|
||||||
|
|
||||||
var $parent = $(selector)
|
var $parent = $(selector === '#' ? [] : selector)
|
||||||
|
|
||||||
if (e) e.preventDefault()
|
if (e) e.preventDefault()
|
||||||
|
|
||||||
|
|||||||
1485
RIGS/static/js/bootstrap-select.js
vendored
37
RIGS/static/js/button.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: button.js v3.3.2
|
* Bootstrap: button.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#buttons
|
* http://getbootstrap.com/javascript/#buttons
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Button.VERSION = '3.3.2'
|
Button.VERSION = '3.3.7'
|
||||||
|
|
||||||
Button.DEFAULTS = {
|
Button.DEFAULTS = {
|
||||||
loadingText: 'loading...'
|
loadingText: 'loading...'
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
var val = $el.is('input') ? 'val' : 'html'
|
var val = $el.is('input') ? 'val' : 'html'
|
||||||
var data = $el.data()
|
var data = $el.data()
|
||||||
|
|
||||||
state = state + 'Text'
|
state += 'Text'
|
||||||
|
|
||||||
if (data.resetText == null) $el.data('resetText', $el[val]())
|
if (data.resetText == null) $el.data('resetText', $el[val]())
|
||||||
|
|
||||||
@@ -41,10 +41,10 @@
|
|||||||
|
|
||||||
if (state == 'loadingText') {
|
if (state == 'loadingText') {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
$el.addClass(d).attr(d, d)
|
$el.addClass(d).attr(d, d).prop(d, true)
|
||||||
} else if (this.isLoading) {
|
} else if (this.isLoading) {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
$el.removeClass(d).removeAttr(d)
|
$el.removeClass(d).removeAttr(d).prop(d, false)
|
||||||
}
|
}
|
||||||
}, this), 0)
|
}, this), 0)
|
||||||
}
|
}
|
||||||
@@ -56,15 +56,19 @@
|
|||||||
if ($parent.length) {
|
if ($parent.length) {
|
||||||
var $input = this.$element.find('input')
|
var $input = this.$element.find('input')
|
||||||
if ($input.prop('type') == 'radio') {
|
if ($input.prop('type') == 'radio') {
|
||||||
if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
|
if ($input.prop('checked')) changed = false
|
||||||
else $parent.find('.active').removeClass('active')
|
$parent.find('.active').removeClass('active')
|
||||||
|
this.$element.addClass('active')
|
||||||
|
} else if ($input.prop('type') == 'checkbox') {
|
||||||
|
if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false
|
||||||
|
this.$element.toggleClass('active')
|
||||||
}
|
}
|
||||||
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
|
$input.prop('checked', this.$element.hasClass('active'))
|
||||||
|
if (changed) $input.trigger('change')
|
||||||
} else {
|
} else {
|
||||||
this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
|
this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
|
||||||
|
this.$element.toggleClass('active')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) this.$element.toggleClass('active')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -104,10 +108,15 @@
|
|||||||
|
|
||||||
$(document)
|
$(document)
|
||||||
.on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
|
.on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
|
||||||
var $btn = $(e.target)
|
var $btn = $(e.target).closest('.btn')
|
||||||
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
|
|
||||||
Plugin.call($btn, 'toggle')
|
Plugin.call($btn, 'toggle')
|
||||||
e.preventDefault()
|
if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) {
|
||||||
|
// Prevent double click on radios, and the double selections (so cancellation) on checkboxes
|
||||||
|
e.preventDefault()
|
||||||
|
// The target component still receive the focus
|
||||||
|
if ($btn.is('input,button')) $btn.trigger('focus')
|
||||||
|
else $btn.find('input:visible,button:visible').first().trigger('focus')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
|
.on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
|
||||||
$(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))
|
$(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))
|
||||||
|
|||||||
14
RIGS/static/js/carousel.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: carousel.js v3.3.2
|
* Bootstrap: carousel.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#carousel
|
* http://getbootstrap.com/javascript/#carousel
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
this.$element = $(element)
|
this.$element = $(element)
|
||||||
this.$indicators = this.$element.find('.carousel-indicators')
|
this.$indicators = this.$element.find('.carousel-indicators')
|
||||||
this.options = options
|
this.options = options
|
||||||
this.paused =
|
this.paused = null
|
||||||
this.sliding =
|
this.sliding = null
|
||||||
this.interval =
|
this.interval = null
|
||||||
this.$active =
|
this.$active = null
|
||||||
this.$items = null
|
this.$items = null
|
||||||
|
|
||||||
this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
|
this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
.on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
|
.on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
|
||||||
}
|
}
|
||||||
|
|
||||||
Carousel.VERSION = '3.3.2'
|
Carousel.VERSION = '3.3.7'
|
||||||
|
|
||||||
Carousel.TRANSITION_DURATION = 600
|
Carousel.TRANSITION_DURATION = 600
|
||||||
|
|
||||||
|
|||||||
17
RIGS/static/js/collapse.js
Normal file → Executable file
@@ -1,11 +1,12 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: collapse.js v3.3.2
|
* Bootstrap: collapse.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#collapse
|
* http://getbootstrap.com/javascript/#collapse
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
|
/* jshint latedef: false */
|
||||||
|
|
||||||
+function ($) {
|
+function ($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
@@ -16,7 +17,8 @@
|
|||||||
var Collapse = function (element, options) {
|
var Collapse = function (element, options) {
|
||||||
this.$element = $(element)
|
this.$element = $(element)
|
||||||
this.options = $.extend({}, Collapse.DEFAULTS, options)
|
this.options = $.extend({}, Collapse.DEFAULTS, options)
|
||||||
this.$trigger = $(this.options.trigger).filter('[href="#' + element.id + '"], [data-target="#' + element.id + '"]')
|
this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
|
||||||
|
'[data-toggle="collapse"][data-target="#' + element.id + '"]')
|
||||||
this.transitioning = null
|
this.transitioning = null
|
||||||
|
|
||||||
if (this.options.parent) {
|
if (this.options.parent) {
|
||||||
@@ -28,13 +30,12 @@
|
|||||||
if (this.options.toggle) this.toggle()
|
if (this.options.toggle) this.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
Collapse.VERSION = '3.3.2'
|
Collapse.VERSION = '3.3.7'
|
||||||
|
|
||||||
Collapse.TRANSITION_DURATION = 350
|
Collapse.TRANSITION_DURATION = 350
|
||||||
|
|
||||||
Collapse.DEFAULTS = {
|
Collapse.DEFAULTS = {
|
||||||
toggle: true,
|
toggle: true
|
||||||
trigger: '[data-toggle="collapse"]'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Collapse.prototype.dimension = function () {
|
Collapse.prototype.dimension = function () {
|
||||||
@@ -172,7 +173,7 @@
|
|||||||
var data = $this.data('bs.collapse')
|
var data = $this.data('bs.collapse')
|
||||||
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
||||||
|
|
||||||
if (!data && options.toggle && option == 'show') options.toggle = false
|
if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false
|
||||||
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
|
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
|
||||||
if (typeof option == 'string') data[option]()
|
if (typeof option == 'string') data[option]()
|
||||||
})
|
})
|
||||||
@@ -203,7 +204,7 @@
|
|||||||
|
|
||||||
var $target = getTargetFromTrigger($this)
|
var $target = getTargetFromTrigger($this)
|
||||||
var data = $target.data('bs.collapse')
|
var data = $target.data('bs.collapse')
|
||||||
var option = data ? 'toggle' : $.extend({}, $this.data(), { trigger: this })
|
var option = data ? 'toggle' : $this.data()
|
||||||
|
|
||||||
Plugin.call($target, option)
|
Plugin.call($target, option)
|
||||||
})
|
})
|
||||||
|
|||||||
94
RIGS/static/js/dropdown.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: dropdown.js v3.3.2
|
* Bootstrap: dropdown.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#dropdowns
|
* http://getbootstrap.com/javascript/#dropdowns
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -19,7 +19,41 @@
|
|||||||
$(element).on('click.bs.dropdown', this.toggle)
|
$(element).on('click.bs.dropdown', this.toggle)
|
||||||
}
|
}
|
||||||
|
|
||||||
Dropdown.VERSION = '3.3.2'
|
Dropdown.VERSION = '3.3.7'
|
||||||
|
|
||||||
|
function getParent($this) {
|
||||||
|
var selector = $this.attr('data-target')
|
||||||
|
|
||||||
|
if (!selector) {
|
||||||
|
selector = $this.attr('href')
|
||||||
|
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
||||||
|
}
|
||||||
|
|
||||||
|
var $parent = selector && $(selector)
|
||||||
|
|
||||||
|
return $parent && $parent.length ? $parent : $this.parent()
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearMenus(e) {
|
||||||
|
if (e && e.which === 3) return
|
||||||
|
$(backdrop).remove()
|
||||||
|
$(toggle).each(function () {
|
||||||
|
var $this = $(this)
|
||||||
|
var $parent = getParent($this)
|
||||||
|
var relatedTarget = { relatedTarget: this }
|
||||||
|
|
||||||
|
if (!$parent.hasClass('open')) return
|
||||||
|
|
||||||
|
if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
|
||||||
|
|
||||||
|
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
|
||||||
|
|
||||||
|
if (e.isDefaultPrevented()) return
|
||||||
|
|
||||||
|
$this.attr('aria-expanded', 'false')
|
||||||
|
$parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
Dropdown.prototype.toggle = function (e) {
|
Dropdown.prototype.toggle = function (e) {
|
||||||
var $this = $(this)
|
var $this = $(this)
|
||||||
@@ -34,7 +68,10 @@
|
|||||||
if (!isActive) {
|
if (!isActive) {
|
||||||
if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
|
if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
|
||||||
// if mobile we use a backdrop because click events don't delegate
|
// if mobile we use a backdrop because click events don't delegate
|
||||||
$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
|
$(document.createElement('div'))
|
||||||
|
.addClass('dropdown-backdrop')
|
||||||
|
.insertAfter($(this))
|
||||||
|
.on('click', clearMenus)
|
||||||
}
|
}
|
||||||
|
|
||||||
var relatedTarget = { relatedTarget: this }
|
var relatedTarget = { relatedTarget: this }
|
||||||
@@ -48,7 +85,7 @@
|
|||||||
|
|
||||||
$parent
|
$parent
|
||||||
.toggleClass('open')
|
.toggleClass('open')
|
||||||
.trigger('shown.bs.dropdown', relatedTarget)
|
.trigger($.Event('shown.bs.dropdown', relatedTarget))
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -67,57 +104,25 @@
|
|||||||
var $parent = getParent($this)
|
var $parent = getParent($this)
|
||||||
var isActive = $parent.hasClass('open')
|
var isActive = $parent.hasClass('open')
|
||||||
|
|
||||||
if ((!isActive && e.which != 27) || (isActive && e.which == 27)) {
|
if (!isActive && e.which != 27 || isActive && e.which == 27) {
|
||||||
if (e.which == 27) $parent.find(toggle).trigger('focus')
|
if (e.which == 27) $parent.find(toggle).trigger('focus')
|
||||||
return $this.trigger('click')
|
return $this.trigger('click')
|
||||||
}
|
}
|
||||||
|
|
||||||
var desc = ' li:not(.divider):visible a'
|
var desc = ' li:not(.disabled):visible a'
|
||||||
var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
|
var $items = $parent.find('.dropdown-menu' + desc)
|
||||||
|
|
||||||
if (!$items.length) return
|
if (!$items.length) return
|
||||||
|
|
||||||
var index = $items.index(e.target)
|
var index = $items.index(e.target)
|
||||||
|
|
||||||
if (e.which == 38 && index > 0) index-- // up
|
if (e.which == 38 && index > 0) index-- // up
|
||||||
if (e.which == 40 && index < $items.length - 1) index++ // down
|
if (e.which == 40 && index < $items.length - 1) index++ // down
|
||||||
if (!~index) index = 0
|
if (!~index) index = 0
|
||||||
|
|
||||||
$items.eq(index).trigger('focus')
|
$items.eq(index).trigger('focus')
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearMenus(e) {
|
|
||||||
if (e && e.which === 3) return
|
|
||||||
$(backdrop).remove()
|
|
||||||
$(toggle).each(function () {
|
|
||||||
var $this = $(this)
|
|
||||||
var $parent = getParent($this)
|
|
||||||
var relatedTarget = { relatedTarget: this }
|
|
||||||
|
|
||||||
if (!$parent.hasClass('open')) return
|
|
||||||
|
|
||||||
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
|
|
||||||
|
|
||||||
if (e.isDefaultPrevented()) return
|
|
||||||
|
|
||||||
$this.attr('aria-expanded', 'false')
|
|
||||||
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function getParent($this) {
|
|
||||||
var selector = $this.attr('data-target')
|
|
||||||
|
|
||||||
if (!selector) {
|
|
||||||
selector = $this.attr('href')
|
|
||||||
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
|
||||||
}
|
|
||||||
|
|
||||||
var $parent = selector && $(selector)
|
|
||||||
|
|
||||||
return $parent && $parent.length ? $parent : $this.parent()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// DROPDOWN PLUGIN DEFINITION
|
// DROPDOWN PLUGIN DEFINITION
|
||||||
// ==========================
|
// ==========================
|
||||||
@@ -155,7 +160,6 @@
|
|||||||
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
|
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
|
||||||
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
|
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
|
||||||
.on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
|
.on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
|
||||||
.on('keydown.bs.dropdown.data-api', '[role="menu"]', Dropdown.prototype.keydown)
|
.on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
|
||||||
.on('keydown.bs.dropdown.data-api', '[role="listbox"]', Dropdown.prototype.keydown)
|
|
||||||
|
|
||||||
}(jQuery);
|
}(jQuery);
|
||||||
|
|||||||
10
RIGS/static/js/modal.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: modal.js v3.3.5
|
* Bootstrap: modal.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#modals
|
* http://getbootstrap.com/javascript/#modals
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.VERSION = '3.3.5'
|
Modal.VERSION = '3.3.7'
|
||||||
|
|
||||||
Modal.TRANSITION_DURATION = 300
|
Modal.TRANSITION_DURATION = 300
|
||||||
Modal.BACKDROP_TRANSITION_DURATION = 150
|
Modal.BACKDROP_TRANSITION_DURATION = 150
|
||||||
@@ -140,7 +140,9 @@
|
|||||||
$(document)
|
$(document)
|
||||||
.off('focusin.bs.modal') // guard against infinite focus loop
|
.off('focusin.bs.modal') // guard against infinite focus loop
|
||||||
.on('focusin.bs.modal', $.proxy(function (e) {
|
.on('focusin.bs.modal', $.proxy(function (e) {
|
||||||
if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
|
if (document !== e.target &&
|
||||||
|
this.$element[0] !== e.target &&
|
||||||
|
!this.$element.has(e.target).length) {
|
||||||
this.$element.trigger('focus')
|
this.$element.trigger('focus')
|
||||||
}
|
}
|
||||||
}, this))
|
}, this))
|
||||||
|
|||||||
13
RIGS/static/js/popover.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: popover.js v3.3.2
|
* Bootstrap: popover.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#popovers
|
* http://getbootstrap.com/javascript/#popovers
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
|
if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
|
||||||
|
|
||||||
Popover.VERSION = '3.3.2'
|
Popover.VERSION = '3.3.7'
|
||||||
|
|
||||||
Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
|
Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
|
||||||
placement: 'right',
|
placement: 'right',
|
||||||
@@ -75,11 +75,6 @@
|
|||||||
return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
|
return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
|
||||||
}
|
}
|
||||||
|
|
||||||
Popover.prototype.tip = function () {
|
|
||||||
if (!this.$tip) this.$tip = $(this.options.template)
|
|
||||||
return this.$tip
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// POPOVER PLUGIN DEFINITION
|
// POPOVER PLUGIN DEFINITION
|
||||||
// =========================
|
// =========================
|
||||||
@@ -90,7 +85,7 @@
|
|||||||
var data = $this.data('bs.popover')
|
var data = $this.data('bs.popover')
|
||||||
var options = typeof option == 'object' && option
|
var options = typeof option == 'object' && option
|
||||||
|
|
||||||
if (!data && option == 'destroy') return
|
if (!data && /destroy|hide/.test(option)) return
|
||||||
if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
|
if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
|
||||||
if (typeof option == 'string') data[option]()
|
if (typeof option == 'string') data[option]()
|
||||||
})
|
})
|
||||||
|
|||||||
39
RIGS/static/js/scrollspy.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: scrollspy.js v3.3.2
|
* Bootstrap: scrollspy.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#scrollspy
|
* http://getbootstrap.com/javascript/#scrollspy
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -14,10 +14,8 @@
|
|||||||
// ==========================
|
// ==========================
|
||||||
|
|
||||||
function ScrollSpy(element, options) {
|
function ScrollSpy(element, options) {
|
||||||
var process = $.proxy(this.process, this)
|
this.$body = $(document.body)
|
||||||
|
this.$scrollElement = $(element).is(document.body) ? $(window) : $(element)
|
||||||
this.$body = $('body')
|
|
||||||
this.$scrollElement = $(element).is('body') ? $(window) : $(element)
|
|
||||||
this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
|
this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
|
||||||
this.selector = (this.options.target || '') + ' .nav li > a'
|
this.selector = (this.options.target || '') + ' .nav li > a'
|
||||||
this.offsets = []
|
this.offsets = []
|
||||||
@@ -25,12 +23,12 @@
|
|||||||
this.activeTarget = null
|
this.activeTarget = null
|
||||||
this.scrollHeight = 0
|
this.scrollHeight = 0
|
||||||
|
|
||||||
this.$scrollElement.on('scroll.bs.scrollspy', process)
|
this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))
|
||||||
this.refresh()
|
this.refresh()
|
||||||
this.process()
|
this.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollSpy.VERSION = '3.3.2'
|
ScrollSpy.VERSION = '3.3.7'
|
||||||
|
|
||||||
ScrollSpy.DEFAULTS = {
|
ScrollSpy.DEFAULTS = {
|
||||||
offset: 10
|
offset: 10
|
||||||
@@ -41,20 +39,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
ScrollSpy.prototype.refresh = function () {
|
ScrollSpy.prototype.refresh = function () {
|
||||||
var offsetMethod = 'offset'
|
var that = this
|
||||||
var offsetBase = 0
|
var offsetMethod = 'offset'
|
||||||
|
var offsetBase = 0
|
||||||
|
|
||||||
|
this.offsets = []
|
||||||
|
this.targets = []
|
||||||
|
this.scrollHeight = this.getScrollHeight()
|
||||||
|
|
||||||
if (!$.isWindow(this.$scrollElement[0])) {
|
if (!$.isWindow(this.$scrollElement[0])) {
|
||||||
offsetMethod = 'position'
|
offsetMethod = 'position'
|
||||||
offsetBase = this.$scrollElement.scrollTop()
|
offsetBase = this.$scrollElement.scrollTop()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.offsets = []
|
|
||||||
this.targets = []
|
|
||||||
this.scrollHeight = this.getScrollHeight()
|
|
||||||
|
|
||||||
var self = this
|
|
||||||
|
|
||||||
this.$body
|
this.$body
|
||||||
.find(this.selector)
|
.find(this.selector)
|
||||||
.map(function () {
|
.map(function () {
|
||||||
@@ -69,8 +66,8 @@
|
|||||||
})
|
})
|
||||||
.sort(function (a, b) { return a[0] - b[0] })
|
.sort(function (a, b) { return a[0] - b[0] })
|
||||||
.each(function () {
|
.each(function () {
|
||||||
self.offsets.push(this[0])
|
that.offsets.push(this[0])
|
||||||
self.targets.push(this[1])
|
that.targets.push(this[1])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +96,7 @@
|
|||||||
for (i = offsets.length; i--;) {
|
for (i = offsets.length; i--;) {
|
||||||
activeTarget != targets[i]
|
activeTarget != targets[i]
|
||||||
&& scrollTop >= offsets[i]
|
&& scrollTop >= offsets[i]
|
||||||
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
|
&& (offsets[i + 1] === undefined || scrollTop < offsets[i + 1])
|
||||||
&& this.activate(targets[i])
|
&& this.activate(targets[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,8 +107,8 @@
|
|||||||
this.clear()
|
this.clear()
|
||||||
|
|
||||||
var selector = this.selector +
|
var selector = this.selector +
|
||||||
'[data-target="' + target + '"],' +
|
'[data-target="' + target + '"],' +
|
||||||
this.selector + '[href="' + target + '"]'
|
this.selector + '[href="' + target + '"]'
|
||||||
|
|
||||||
var active = $(selector)
|
var active = $(selector)
|
||||||
.parents('li')
|
.parents('li')
|
||||||
|
|||||||
12
RIGS/static/js/tab.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: tab.js v3.3.2
|
* Bootstrap: tab.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#tabs
|
* http://getbootstrap.com/javascript/#tabs
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -14,10 +14,12 @@
|
|||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
var Tab = function (element) {
|
var Tab = function (element) {
|
||||||
|
// jscs:disable requireDollarBeforejQueryAssignment
|
||||||
this.element = $(element)
|
this.element = $(element)
|
||||||
|
// jscs:enable requireDollarBeforejQueryAssignment
|
||||||
}
|
}
|
||||||
|
|
||||||
Tab.VERSION = '3.3.2'
|
Tab.VERSION = '3.3.7'
|
||||||
|
|
||||||
Tab.TRANSITION_DURATION = 150
|
Tab.TRANSITION_DURATION = 150
|
||||||
|
|
||||||
@@ -65,7 +67,7 @@
|
|||||||
var $active = container.find('> .active')
|
var $active = container.find('> .active')
|
||||||
var transition = callback
|
var transition = callback
|
||||||
&& $.support.transition
|
&& $.support.transition
|
||||||
&& (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length)
|
&& ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
|
||||||
|
|
||||||
function next() {
|
function next() {
|
||||||
$active
|
$active
|
||||||
@@ -88,7 +90,7 @@
|
|||||||
element.removeClass('fade')
|
element.removeClass('fade')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.parent('.dropdown-menu')) {
|
if (element.parent('.dropdown-menu').length) {
|
||||||
element
|
element
|
||||||
.closest('li.dropdown')
|
.closest('li.dropdown')
|
||||||
.addClass('active')
|
.addClass('active')
|
||||||
|
|||||||
120
RIGS/static/js/tooltip.js
Normal file → Executable file
@@ -1,9 +1,9 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: tooltip.js v3.3.2
|
* Bootstrap: tooltip.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#tooltip
|
* http://getbootstrap.com/javascript/#tooltip
|
||||||
* Inspired by the original jQuery.tipsy by Jason Frame
|
* Inspired by the original jQuery.tipsy by Jason Frame
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -15,17 +15,18 @@
|
|||||||
// ===============================
|
// ===============================
|
||||||
|
|
||||||
var Tooltip = function (element, options) {
|
var Tooltip = function (element, options) {
|
||||||
this.type =
|
this.type = null
|
||||||
this.options =
|
this.options = null
|
||||||
this.enabled =
|
this.enabled = null
|
||||||
this.timeout =
|
this.timeout = null
|
||||||
this.hoverState =
|
this.hoverState = null
|
||||||
this.$element = null
|
this.$element = null
|
||||||
|
this.inState = null
|
||||||
|
|
||||||
this.init('tooltip', element, options)
|
this.init('tooltip', element, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.VERSION = '3.3.2'
|
Tooltip.VERSION = '3.3.7'
|
||||||
|
|
||||||
Tooltip.TRANSITION_DURATION = 150
|
Tooltip.TRANSITION_DURATION = 150
|
||||||
|
|
||||||
@@ -50,7 +51,12 @@
|
|||||||
this.type = type
|
this.type = type
|
||||||
this.$element = $(element)
|
this.$element = $(element)
|
||||||
this.options = this.getOptions(options)
|
this.options = this.getOptions(options)
|
||||||
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
|
this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
|
||||||
|
this.inState = { click: false, hover: false, focus: false }
|
||||||
|
|
||||||
|
if (this.$element[0] instanceof document.constructor && !this.options.selector) {
|
||||||
|
throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
|
||||||
|
}
|
||||||
|
|
||||||
var triggers = this.options.trigger.split(' ')
|
var triggers = this.options.trigger.split(' ')
|
||||||
|
|
||||||
@@ -105,16 +111,20 @@
|
|||||||
var self = obj instanceof this.constructor ?
|
var self = obj instanceof this.constructor ?
|
||||||
obj : $(obj.currentTarget).data('bs.' + this.type)
|
obj : $(obj.currentTarget).data('bs.' + this.type)
|
||||||
|
|
||||||
if (self && self.$tip && self.$tip.is(':visible')) {
|
|
||||||
self.hoverState = 'in'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!self) {
|
if (!self) {
|
||||||
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
|
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
|
||||||
$(obj.currentTarget).data('bs.' + this.type, self)
|
$(obj.currentTarget).data('bs.' + this.type, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj instanceof $.Event) {
|
||||||
|
self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.tip().hasClass('in') || self.hoverState == 'in') {
|
||||||
|
self.hoverState = 'in'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
clearTimeout(self.timeout)
|
clearTimeout(self.timeout)
|
||||||
|
|
||||||
self.hoverState = 'in'
|
self.hoverState = 'in'
|
||||||
@@ -126,6 +136,14 @@
|
|||||||
}, self.options.delay.show)
|
}, self.options.delay.show)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tooltip.prototype.isInStateTrue = function () {
|
||||||
|
for (var key in this.inState) {
|
||||||
|
if (this.inState[key]) return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
Tooltip.prototype.leave = function (obj) {
|
Tooltip.prototype.leave = function (obj) {
|
||||||
var self = obj instanceof this.constructor ?
|
var self = obj instanceof this.constructor ?
|
||||||
obj : $(obj.currentTarget).data('bs.' + this.type)
|
obj : $(obj.currentTarget).data('bs.' + this.type)
|
||||||
@@ -135,6 +153,12 @@
|
|||||||
$(obj.currentTarget).data('bs.' + this.type, self)
|
$(obj.currentTarget).data('bs.' + this.type, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj instanceof $.Event) {
|
||||||
|
self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.isInStateTrue()) return
|
||||||
|
|
||||||
clearTimeout(self.timeout)
|
clearTimeout(self.timeout)
|
||||||
|
|
||||||
self.hoverState = 'out'
|
self.hoverState = 'out'
|
||||||
@@ -181,6 +205,7 @@
|
|||||||
.data('bs.' + this.type, this)
|
.data('bs.' + this.type, this)
|
||||||
|
|
||||||
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
|
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
|
||||||
|
this.$element.trigger('inserted.bs.' + this.type)
|
||||||
|
|
||||||
var pos = this.getPosition()
|
var pos = this.getPosition()
|
||||||
var actualWidth = $tip[0].offsetWidth
|
var actualWidth = $tip[0].offsetWidth
|
||||||
@@ -188,13 +213,12 @@
|
|||||||
|
|
||||||
if (autoPlace) {
|
if (autoPlace) {
|
||||||
var orgPlacement = placement
|
var orgPlacement = placement
|
||||||
var $container = this.options.container ? $(this.options.container) : this.$element.parent()
|
var viewportDim = this.getPosition(this.$viewport)
|
||||||
var containerDim = this.getPosition($container)
|
|
||||||
|
|
||||||
placement = placement == 'bottom' && pos.bottom + actualHeight > containerDim.bottom ? 'top' :
|
placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' :
|
||||||
placement == 'top' && pos.top - actualHeight < containerDim.top ? 'bottom' :
|
placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' :
|
||||||
placement == 'right' && pos.right + actualWidth > containerDim.width ? 'left' :
|
placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' :
|
||||||
placement == 'left' && pos.left - actualWidth < containerDim.left ? 'right' :
|
placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' :
|
||||||
placement
|
placement
|
||||||
|
|
||||||
$tip
|
$tip
|
||||||
@@ -235,8 +259,8 @@
|
|||||||
if (isNaN(marginTop)) marginTop = 0
|
if (isNaN(marginTop)) marginTop = 0
|
||||||
if (isNaN(marginLeft)) marginLeft = 0
|
if (isNaN(marginLeft)) marginLeft = 0
|
||||||
|
|
||||||
offset.top = offset.top + marginTop
|
offset.top += marginTop
|
||||||
offset.left = offset.left + marginLeft
|
offset.left += marginLeft
|
||||||
|
|
||||||
// $.fn.offset doesn't round pixel values
|
// $.fn.offset doesn't round pixel values
|
||||||
// so we use setOffset directly with our own function B-0
|
// so we use setOffset directly with our own function B-0
|
||||||
@@ -272,10 +296,10 @@
|
|||||||
this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
|
this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.replaceArrow = function (delta, dimension, isHorizontal) {
|
Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
|
||||||
this.arrow()
|
this.arrow()
|
||||||
.css(isHorizontal ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
|
.css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
|
||||||
.css(isHorizontal ? 'top' : 'left', '')
|
.css(isVertical ? 'top' : 'left', '')
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.setContent = function () {
|
Tooltip.prototype.setContent = function () {
|
||||||
@@ -288,14 +312,16 @@
|
|||||||
|
|
||||||
Tooltip.prototype.hide = function (callback) {
|
Tooltip.prototype.hide = function (callback) {
|
||||||
var that = this
|
var that = this
|
||||||
var $tip = this.tip()
|
var $tip = $(this.$tip)
|
||||||
var e = $.Event('hide.bs.' + this.type)
|
var e = $.Event('hide.bs.' + this.type)
|
||||||
|
|
||||||
function complete() {
|
function complete() {
|
||||||
if (that.hoverState != 'in') $tip.detach()
|
if (that.hoverState != 'in') $tip.detach()
|
||||||
that.$element
|
if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary.
|
||||||
.removeAttr('aria-describedby')
|
that.$element
|
||||||
.trigger('hidden.bs.' + that.type)
|
.removeAttr('aria-describedby')
|
||||||
|
.trigger('hidden.bs.' + that.type)
|
||||||
|
}
|
||||||
callback && callback()
|
callback && callback()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +331,7 @@
|
|||||||
|
|
||||||
$tip.removeClass('in')
|
$tip.removeClass('in')
|
||||||
|
|
||||||
$.support.transition && this.$tip.hasClass('fade') ?
|
$.support.transition && $tip.hasClass('fade') ?
|
||||||
$tip
|
$tip
|
||||||
.one('bsTransitionEnd', complete)
|
.one('bsTransitionEnd', complete)
|
||||||
.emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
|
.emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
|
||||||
@@ -318,7 +344,7 @@
|
|||||||
|
|
||||||
Tooltip.prototype.fixTitle = function () {
|
Tooltip.prototype.fixTitle = function () {
|
||||||
var $e = this.$element
|
var $e = this.$element
|
||||||
if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
|
if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
|
||||||
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
|
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,7 +364,10 @@
|
|||||||
// width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
|
// width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
|
||||||
elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
|
elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
|
||||||
}
|
}
|
||||||
var elOffset = isBody ? { top: 0, left: 0 } : $element.offset()
|
var isSvg = window.SVGElement && el instanceof window.SVGElement
|
||||||
|
// Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
|
||||||
|
// See https://github.com/twbs/bootstrap/issues/20280
|
||||||
|
var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
|
||||||
var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
|
var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
|
||||||
var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
|
var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
|
||||||
|
|
||||||
@@ -373,7 +402,7 @@
|
|||||||
var rightEdgeOffset = pos.left + viewportPadding + actualWidth
|
var rightEdgeOffset = pos.left + viewportPadding + actualWidth
|
||||||
if (leftEdgeOffset < viewportDimensions.left) { // left overflow
|
if (leftEdgeOffset < viewportDimensions.left) { // left overflow
|
||||||
delta.left = viewportDimensions.left - leftEdgeOffset
|
delta.left = viewportDimensions.left - leftEdgeOffset
|
||||||
} else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
|
} else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
|
||||||
delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
|
delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -399,7 +428,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.tip = function () {
|
Tooltip.prototype.tip = function () {
|
||||||
return (this.$tip = this.$tip || $(this.options.template))
|
if (!this.$tip) {
|
||||||
|
this.$tip = $(this.options.template)
|
||||||
|
if (this.$tip.length != 1) {
|
||||||
|
throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.$tip
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.arrow = function () {
|
Tooltip.prototype.arrow = function () {
|
||||||
@@ -428,7 +463,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
|
if (e) {
|
||||||
|
self.inState.click = !self.inState.click
|
||||||
|
if (self.isInStateTrue()) self.enter(self)
|
||||||
|
else self.leave(self)
|
||||||
|
} else {
|
||||||
|
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.destroy = function () {
|
Tooltip.prototype.destroy = function () {
|
||||||
@@ -436,6 +477,13 @@
|
|||||||
clearTimeout(this.timeout)
|
clearTimeout(this.timeout)
|
||||||
this.hide(function () {
|
this.hide(function () {
|
||||||
that.$element.off('.' + that.type).removeData('bs.' + that.type)
|
that.$element.off('.' + that.type).removeData('bs.' + that.type)
|
||||||
|
if (that.$tip) {
|
||||||
|
that.$tip.detach()
|
||||||
|
}
|
||||||
|
that.$tip = null
|
||||||
|
that.$arrow = null
|
||||||
|
that.$viewport = null
|
||||||
|
that.$element = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +497,7 @@
|
|||||||
var data = $this.data('bs.tooltip')
|
var data = $this.data('bs.tooltip')
|
||||||
var options = typeof option == 'object' && option
|
var options = typeof option == 'object' && option
|
||||||
|
|
||||||
if (!data && option == 'destroy') return
|
if (!data && /destroy|hide/.test(option)) return
|
||||||
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
|
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
|
||||||
if (typeof option == 'string') data[option]()
|
if (typeof option == 'string') data[option]()
|
||||||
})
|
})
|
||||||
|
|||||||
4
RIGS/static/js/transition.js
Normal file → Executable file
@@ -1,8 +1,8 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: transition.js v3.3.2
|
* Bootstrap: transition.js v3.3.7
|
||||||
* http://getbootstrap.com/javascript/#transitions
|
* http://getbootstrap.com/javascript/#transitions
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
|
|||||||
64
RIGS/static/scss/email.scss
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
$button_color: #357ebf;
|
||||||
|
|
||||||
|
body{
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-table{
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.client-header {
|
||||||
|
background-image: url("https://www.nottinghamtec.co.uk/imgs/wof2014-1.jpg");
|
||||||
|
background-color: #222;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
margin-bottom: 28px;
|
||||||
|
|
||||||
|
.logos{
|
||||||
|
width: 100%;
|
||||||
|
max-width: 640px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
height: 110px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-container{
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.content {
|
||||||
|
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
max-width: 600px;
|
||||||
|
padding: 10px;
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
|
.button-container{
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.button {
|
||||||
|
padding: 6px 12px;
|
||||||
|
background-color: $button_color;
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -147,3 +147,48 @@ ins {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html.embedded{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
body{
|
||||||
|
padding:0;
|
||||||
|
width:100%;
|
||||||
|
background:none;
|
||||||
|
overflow: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
.embed_container{
|
||||||
|
border:5px solid #e9e9e9;
|
||||||
|
padding:12px 0px;
|
||||||
|
min-height:100%;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source{
|
||||||
|
background: url('/static/imgs/pyrigs-avatar.png') no-repeat;
|
||||||
|
background-size: 16px 16px;
|
||||||
|
padding-left: 20px;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3{
|
||||||
|
margin-top:10px;
|
||||||
|
margin-bottom:5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p{
|
||||||
|
margin-bottom:2px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-mic-photo{
|
||||||
|
max-width: 3em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,13 +33,13 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<p>
|
<p>
|
||||||
<small>
|
<small>
|
||||||
{% if version.old == None %}
|
{% if version.changes.old == None %}
|
||||||
Created
|
Created
|
||||||
{% else %}
|
{% else %}
|
||||||
Changed {% include 'RIGS/version_changes.html' %} in
|
Changed {% include 'RIGS/version_changes.html' %} in
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% include 'RIGS/object_button.html' with object=version.new %}
|
{% include 'RIGS/object_button.html' with object=version.changes.new %}
|
||||||
{% if version.revision.comment %}
|
{% if version.revision.comment %}
|
||||||
({{ version.revision.comment }})
|
({{ version.revision.comment }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -67,16 +67,16 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ version.revision.date_created }}</td>
|
<td>{{ version.revision.date_created }}</td>
|
||||||
<td><a href="{{ version.new.get_absolute_url }}">{{version.new|to_class_name}} {{ version.new.pk|stringformat:"05d" }}</a></td>
|
<td><a href="{{ version.changes.new.get_absolute_url }}">{{version.changes.new|to_class_name}} {{ version.changes.new.pk|stringformat:"05d" }}</a></td>
|
||||||
<td>{{ version.version.pk }}|{{ version.revision.pk }}</td>
|
<td>{{ version.pk }}|{{ version.revision.pk }}</td>
|
||||||
<td>{{ version.revision.user.name }}</td>
|
<td>{{ version.revision.user.name }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if version.old == None %}
|
{% if version.changes.old == None %}
|
||||||
{{version.new|to_class_name}} Created
|
{{version.changes.new|to_class_name}} Created
|
||||||
{% else %}
|
{% else %}
|
||||||
{% include 'RIGS/version_changes.html' %}
|
{% include 'RIGS/version_changes.html' %}
|
||||||
{% endif %} </td>
|
{% endif %} </td>
|
||||||
<td>{{ version.revision.comment }}</td>
|
<td>{{ version.changes.revision.comment }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
78
RIGS/templates/RIGS/client_eventdetails.html
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 col-md-6 col-lg-5">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Contact Details</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>Person</dt>
|
||||||
|
<dd>
|
||||||
|
{% if event.person %}
|
||||||
|
{{ event.person.name }}
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Email</dt>
|
||||||
|
<dd>
|
||||||
|
<span class="overflow-ellipsis">{{ event.person.email }}</span>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Phone Number</dt>
|
||||||
|
<dd>{{ event.person.phone }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% if event.organisation %}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Organisation</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>Organisation</dt>
|
||||||
|
<dd>
|
||||||
|
{{ event.organisation.name }}
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Phone Number</dt>
|
||||||
|
<dd>{{ object.organisation.phone }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-12 col-md-6 col-lg-7">
|
||||||
|
<div class="panel panel-info">
|
||||||
|
<div class="panel-heading">Event Info</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>Event Venue</dt>
|
||||||
|
<dd>
|
||||||
|
{% if object.venue %}
|
||||||
|
<a href="{% url 'venue_detail' object.venue.pk %}" class="modal-href">
|
||||||
|
{{ object.venue }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Status</dt>
|
||||||
|
<dd>{{ event.get_status_display }}</dd>
|
||||||
|
|
||||||
|
<dd> </dd>
|
||||||
|
|
||||||
|
<dt>Access From</dt>
|
||||||
|
<dd>{{ event.access_at|date:"D d M Y H:i"|default:"" }}</dd>
|
||||||
|
|
||||||
|
<dt>Event Starts</dt>
|
||||||
|
<dd>{{ event.start_date|date:"D d M Y" }} {{ event.start_time|date:"H:i" }}</dd>
|
||||||
|
|
||||||
|
<dt>Event Ends</dt>
|
||||||
|
<dd>{{ event.end_date|date:"D d M Y" }} {{ event.end_time|date:"H:i" }}</dd>
|
||||||
|
|
||||||
|
<dd> </dd>
|
||||||
|
|
||||||
|
<dt>Event Description</dt>
|
||||||
|
<dd>{{ event.description|linebreaksbr }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -11,26 +11,7 @@
|
|||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 text-right">
|
<div class="col-sm-12 text-right">
|
||||||
<div class="btn-group btn-page">
|
{% include 'RIGS/event_detail_buttons.html' %}
|
||||||
<a href="{% url 'event_update' event.pk %}" class="btn btn-default"><span
|
|
||||||
class="glyphicon glyphicon-edit"></span> <span
|
|
||||||
class="hidden-xs">Edit</span></a>
|
|
||||||
{% if event.is_rig %}
|
|
||||||
<a href="{% url 'event_print' event.pk %}" target="_blank" class="btn btn-default"><span
|
|
||||||
class="glyphicon glyphicon-print"></span> <span
|
|
||||||
class="hidden-xs">Print</span></a>
|
|
||||||
{% endif %}
|
|
||||||
<a href="{% url 'event_duplicate' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
|
||||||
class="glyphicon glyphicon-duplicate"></span> <span
|
|
||||||
class="hidden-xs">Duplicate</span></a>
|
|
||||||
{% if event.is_rig %}
|
|
||||||
{% if perms.RIGS.add_invoice %}
|
|
||||||
<a href="{% url 'invoice_event' event.pk %}" class="btn btn-default" title="Invoice Rig"><span
|
|
||||||
class="glyphicon glyphicon-gbp"></span> <span
|
|
||||||
class="hidden-xs">Invoice</span></a>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -89,6 +70,39 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if event.is_rig and event.internal %}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Client Authorisation</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>Authorised</dt>
|
||||||
|
<dd>{{ object.authorised|yesno:"Yes,No" }}</dd>
|
||||||
|
|
||||||
|
<dt>Authorised by</dt>
|
||||||
|
<dd>
|
||||||
|
{% if object.authorisation %}
|
||||||
|
{{ object.authorisation.name }}
|
||||||
|
(<a href="mailto:{{ object.authorisation.email }}">{{ object.authorisation.email }}</a>)
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Authorised at</dt>
|
||||||
|
<dd>{{ object.authorisation.last_edited_at }}</dd>
|
||||||
|
|
||||||
|
<dt>Authorised amount</dt>
|
||||||
|
<dd>
|
||||||
|
{% if object.authorisation %}
|
||||||
|
£ {{ object.authorisation.amount|floatformat:"2" }}
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Requested by</dt>
|
||||||
|
<dd>{{ object.authorisation.sent_by }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="col-sm-12 {% if event.is_rig %}col-md-6 col-lg-7{% endif %}">
|
<div class="col-sm-12 {% if event.is_rig %}col-md-6 col-lg-7{% endif %}">
|
||||||
@@ -167,8 +181,25 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if event.is_rig %}
|
{% if event.is_rig %}
|
||||||
<dt>PO</dt>
|
<dd> </dd>
|
||||||
<dd>{{ object.purchase_order }}</dd>
|
|
||||||
|
{% if object.internal %}
|
||||||
|
<dt>Authorisation Request</dt>
|
||||||
|
<dd>{{ object.auth_request_to|yesno:"Yes,No" }}</dd>
|
||||||
|
|
||||||
|
<dt>By</dt>
|
||||||
|
<dd>{{ object.auth_request_by }}</dd>
|
||||||
|
|
||||||
|
<dt>At</dt>
|
||||||
|
<dd>{{ object.auth_request_at|date:"D d M Y H:i"|default:"" }}</dd>
|
||||||
|
|
||||||
|
<dt>To</dt>
|
||||||
|
<dd>{{ object.auth_request_to }}</dd>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
<dt>PO</dt>
|
||||||
|
<dd>{{ object.purchase_order }}</dd>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
@@ -176,26 +207,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% if not request.is_ajax %}
|
{% if not request.is_ajax %}
|
||||||
<div class="col-sm-12 text-right">
|
<div class="col-sm-12 text-right">
|
||||||
<div class="btn-group btn-page">
|
{% include 'RIGS/event_detail_buttons.html' %}
|
||||||
<a href="{% url 'event_update' event.pk %}" class="btn btn-default"><span
|
|
||||||
class="glyphicon glyphicon-edit"></span> <span
|
|
||||||
class="hidden-xs">Edit</span></a>
|
|
||||||
{% if event.is_rig %}
|
|
||||||
<a href="{% url 'event_print' event.pk %}" target="_blank" class="btn btn-default"><span
|
|
||||||
class="glyphicon glyphicon-print"></span> <span
|
|
||||||
class="hidden-xs">Print</span></a>
|
|
||||||
{% endif %}
|
|
||||||
<a href="{% url 'event_duplicate' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
|
||||||
class="glyphicon glyphicon-duplicate"></span> <span
|
|
||||||
class="hidden-xs">Duplicate</span></a>
|
|
||||||
{% if event.is_rig %}
|
|
||||||
{% if perms.RIGS.add_invoice %}
|
|
||||||
<a href="{% url 'invoice_event' event.pk %}" class="btn btn-default" title="Invoice Rig"><span
|
|
||||||
class="glyphicon glyphicon-gbp"></span> <span
|
|
||||||
class="hidden-xs">Invoice</span></a>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if event.is_rig %}
|
{% if event.is_rig %}
|
||||||
@@ -213,26 +225,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% if not request.is_ajax %}
|
{% if not request.is_ajax %}
|
||||||
<div class="col-sm-12 text-right">
|
<div class="col-sm-12 text-right">
|
||||||
<div class="btn-group btn-page">
|
{% include 'RIGS/event_detail_buttons.html' %}
|
||||||
<a href="{% url 'event_update' event.pk %}" class="btn btn-default"><span
|
|
||||||
class="glyphicon glyphicon-edit"></span> <span
|
|
||||||
class="hidden-xs">Edit</span></a>
|
|
||||||
{% if event.is_rig %}
|
|
||||||
<a href="{% url 'event_print' event.pk %}" target="_blank" class="btn btn-default"><span
|
|
||||||
class="glyphicon glyphicon-print"></span> <span
|
|
||||||
class="hidden-xs">Print</span></a>
|
|
||||||
{% endif %}
|
|
||||||
<a href="{% url 'event_duplicate' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
|
||||||
class="glyphicon glyphicon-duplicate"></span> <span
|
|
||||||
class="hidden-xs">Duplicate</span></a>
|
|
||||||
{% if event.is_rig %}
|
|
||||||
{% if perms.RIGS.add_invoice %}
|
|
||||||
<a href="{% url 'invoice_event' event.pk %}" class="btn btn-default" title="Invoice Rig"><span
|
|
||||||
class="glyphicon glyphicon-gbp"></span> <span
|
|
||||||
class="hidden-xs">Invoice</span></a>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
65
RIGS/templates/RIGS/event_detail_buttons.html
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<div class="btn-group btn-page">
|
||||||
|
<a href="{% url 'event_update' event.pk %}" class="btn btn-default"><span
|
||||||
|
class="glyphicon glyphicon-edit"></span> <span
|
||||||
|
class="hidden-xs">Edit</span></a>
|
||||||
|
{% if event.is_rig %}
|
||||||
|
{% if not event.dry_hire %}
|
||||||
|
<a href="{% url 'event_ra' event.pk %}" class="btn btn-default
|
||||||
|
{% if event.risk_assessment_edit_url %}
|
||||||
|
btn-success
|
||||||
|
{% else %}
|
||||||
|
btn-warning
|
||||||
|
{% endif %}
|
||||||
|
"><span
|
||||||
|
class="glyphicon glyphicon-paperclip"></span> <span
|
||||||
|
class="hidden-xs">RA</span></a>
|
||||||
|
{% endif %}
|
||||||
|
<a href="{% url 'event_print' event.pk %}" target="_blank" class="btn btn-default"><span
|
||||||
|
class="glyphicon glyphicon-print"></span> <span
|
||||||
|
class="hidden-xs">Print</span></a>
|
||||||
|
{% endif %}
|
||||||
|
<a href="{% url 'event_duplicate' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
||||||
|
class="glyphicon glyphicon-duplicate"></span> <span
|
||||||
|
class="hidden-xs">Duplicate</span></a>
|
||||||
|
{% if event.is_rig %}
|
||||||
|
{% if event.internal %}
|
||||||
|
<a class="btn btn-default item-add modal-href event-authorise-request
|
||||||
|
{% if event.authorised %}
|
||||||
|
btn-success
|
||||||
|
{% elif event.authorisation and event.authorisation.amount != event.total and event.authorisation.last_edited_at > event.auth_request_at %}
|
||||||
|
btn-warning
|
||||||
|
{% elif event.auth_request_to %}
|
||||||
|
btn-info
|
||||||
|
{% endif %}
|
||||||
|
"
|
||||||
|
href="{% url 'event_authorise_request' object.pk %}">
|
||||||
|
<span class="glyphicon glyphicon-send"></span>
|
||||||
|
<span class="hidden-xs">
|
||||||
|
{% if event.authorised %}
|
||||||
|
Authorised
|
||||||
|
{% elif event.authorisation and event.authorisation.amount != event.total and event.authorisation.last_edited_at > event.auth_request_at %}
|
||||||
|
Authorisation Issue
|
||||||
|
{% elif event.auth_request_to %}
|
||||||
|
Awaiting Authorisation
|
||||||
|
{% else %}
|
||||||
|
Request Authorisation
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if perms.RIGS.add_invoice %}
|
||||||
|
<a id="invoiceDropdownLabel" href="{% url 'invoice_event' event.pk %}" class="btn
|
||||||
|
{% if event.invoice and event.invoice.is_closed %}
|
||||||
|
btn-success
|
||||||
|
{% elif event.invoice %}
|
||||||
|
btn-warning
|
||||||
|
{% else %}
|
||||||
|
btn-danger
|
||||||
|
{% endif %}
|
||||||
|
" title="Invoice Rig"><span
|
||||||
|
class="glyphicon glyphicon-gbp"></span>
|
||||||
|
<span class="hidden-xs">Invoice</span></a>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
106
RIGS/templates/RIGS/event_embed.html
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
{% extends 'base_embed.html' %}
|
||||||
|
{% load static from staticfiles %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<a href="/">
|
||||||
|
<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">
|
||||||
|
<span class="pull-right">
|
||||||
|
{% if object.mic %}
|
||||||
|
<div class="text-center">
|
||||||
|
<img src="{{ object.mic.profile_picture }}" class="event-mic-photo img-rounded"/>
|
||||||
|
</div>
|
||||||
|
{% elif object.is_rig %}
|
||||||
|
<span class="glyphicon glyphicon-exclamation-sign"></span>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
<a {% if perms.RIGS.view_event %}href="{% url 'event_detail' object.pk %}"{% endif %}>
|
||||||
|
{% if object.is_rig %}N{{ object.pk|stringformat:"05d" }}{% else %}{{ object.pk }}{% endif %}
|
||||||
|
| {{ object.name }} </a>
|
||||||
|
{% if object.venue %}
|
||||||
|
<small>at {{ object.venue }}</small>
|
||||||
|
{% endif %}
|
||||||
|
<br/><small>
|
||||||
|
{{ object.start_date|date:"D d/m/Y" }}
|
||||||
|
{% if object.has_start_time %}
|
||||||
|
{{ object.start_time|date:"H:i" }}
|
||||||
|
{% endif %}
|
||||||
|
{% if object.end_date or object.has_end_time %}
|
||||||
|
–
|
||||||
|
{% endif %}
|
||||||
|
{% if object.end_date and object.end_date != object.start_date %}
|
||||||
|
{{ object.end_date|date:"D d/m/Y" }}
|
||||||
|
{% endif %}
|
||||||
|
{% if object.has_end_time %}
|
||||||
|
{{ object.end_time|date:"H:i" }}
|
||||||
|
{% endif %}
|
||||||
|
</small>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-6">
|
||||||
|
<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>
|
||||||
|
<strong>Description: </strong>
|
||||||
|
{{ object.description|linebreaksbr }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
} else {
|
} else {
|
||||||
$('.form-is_rig').slideDown();
|
$('.form-is_rig').slideDown();
|
||||||
}
|
}
|
||||||
$('.form-hws').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();
|
$('.form-is_rig').slideUp();
|
||||||
@@ -289,10 +289,10 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<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 type="date" class+="form-control" %}
|
{% render_field form.start_date class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-5" data-toggle="tooltip" title="Start time of event, can be left blank">
|
<div class="col-sm-12 col-md-5" data-toggle="tooltip" title="Start time of event, can be left blank">
|
||||||
{% render_field form.start_time type="time" class+="form-control" %}
|
{% render_field form.start_time class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -304,10 +304,10 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<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 type="date" class+="form-control" %}
|
{% render_field form.end_date class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-5" data-toggle="tooltip" title="End time of event, leave blank if unknown">
|
<div class="col-sm-12 col-md-5" data-toggle="tooltip" title="End time of event, leave blank if unknown">
|
||||||
{% render_field form.end_time type="time" class+="form-control" %}
|
{% render_field form.end_time class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@
|
|||||||
class="col-sm-4 control-label">{{ form.access_at.label }}</label>
|
class="col-sm-4 control-label">{{ form.access_at.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
{% render_field form.access_at type="datetime-local" class+="form-control" %}
|
{% render_field form.access_at class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" data-toggle="tooltip" title="The date/time at which crew should meet for this event">
|
<div class="form-group" data-toggle="tooltip" title="The date/time at which crew should meet for this event">
|
||||||
@@ -337,7 +337,7 @@
|
|||||||
class="col-sm-4 control-label">{{ form.meet_at.label }}</label>
|
class="col-sm-4 control-label">{{ form.meet_at.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
{% render_field form.meet_at type="datetime-local" class+="form-control" %}
|
{% render_field form.meet_at class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -398,6 +398,7 @@
|
|||||||
{% render_field form.collector class+="form-control" %}
|
{% render_field form.collector class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" data-toggle="tooltip" title="The purchase order number (for external clients)">
|
<div class="form-group" data-toggle="tooltip" title="The purchase order number (for external clients)">
|
||||||
<label for="{{ form.purchase_order.id_for_label }}"
|
<label for="{{ form.purchase_order.id_for_label }}"
|
||||||
class="col-sm-4 control-label">{{ form.purchase_order.label }}</label>
|
class="col-sm-4 control-label">{{ form.purchase_order.label }}</label>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>Event #</th>
|
||||||
<th>Start Date</th>
|
<th>Start Date</th>
|
||||||
<th>Event Name</th>
|
<th>Event Name</th>
|
||||||
<th>Client</th>
|
<th>Client</th>
|
||||||
@@ -54,20 +54,22 @@
|
|||||||
<td><a href="{% url 'event_detail' object.pk %}">N{{ object.pk|stringformat:"05d" }}</a><br>
|
<td><a href="{% url 'event_detail' object.pk %}">N{{ object.pk|stringformat:"05d" }}</a><br>
|
||||||
<span class="text-muted">{{ object.get_status_display }}</span></td>
|
<span class="text-muted">{{ object.get_status_display }}</span></td>
|
||||||
<td>{{ object.start_date }}</td>
|
<td>{{ object.start_date }}</td>
|
||||||
<td>{{ object.name }}</td>
|
|
||||||
<td>
|
<td>
|
||||||
{% if object.organisation %}
|
{{ object.name }}
|
||||||
{{ object.organisation.name }}
|
{% if object.is_rig and perms.RIGS.view_event and object.authorised %}
|
||||||
<br>
|
<span class="glyphicon glyphicon-check"></span>
|
||||||
<span class="text-muted">{{ object.organisation.union_account|yesno:'Internal,External' }}</span>
|
|
||||||
{% else %}
|
|
||||||
{{ object.person.name }}
|
|
||||||
<br>
|
|
||||||
<span class="text-muted">External</span>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>{{ object.sum_total|floatformat:2 }}</td>
|
<td>
|
||||||
|
{{ object.organisation.name }}
|
||||||
|
<br>
|
||||||
|
<span class="text-muted">{{ object.internal|yesno:'Internal,External' }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ object.sum_total|floatformat:2 }}
|
||||||
|
<br />
|
||||||
|
<span class="text-muted">{% if not object.internal %}{{ object.purchase_order }}{% endif %}</span>
|
||||||
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
{% if object.mic %}
|
{% if object.mic %}
|
||||||
{{ object.mic.initials }}<br>
|
{{ object.mic.initials }}<br>
|
||||||
@@ -77,7 +79,10 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
<a href="{% url 'invoice_event' object.pk %}" class="btn btn-default" data-toggle="tooltip" title="'Invoice' this event - click this when paperwork has been sent to treasury">
|
<a href="{% url 'invoice_event' object.pk %}"
|
||||||
|
class="btn btn-default"
|
||||||
|
data-toggle="tooltip"
|
||||||
|
title="'Invoice' this event - click this when paperwork has been sent to treasury">
|
||||||
<span class="glyphicon glyphicon-gbp"></span>
|
<span class="glyphicon glyphicon-gbp"></span>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -22,21 +22,21 @@
|
|||||||
<paraStyle name="style.Heading2" fontName="OpenSans-Bold" fontSize="10" spaceAfter="2"/>
|
<paraStyle name="style.Heading2" fontName="OpenSans-Bold" fontSize="10" spaceAfter="2"/>
|
||||||
<paraStyle name="style.Heading3" fontName="OpenSans" fontSize="10" spaceAfter="0"/>
|
<paraStyle name="style.Heading3" fontName="OpenSans" fontSize="10" spaceAfter="0"/>
|
||||||
<paraStyle name="center" alignment="center"/>
|
<paraStyle name="center" alignment="center"/>
|
||||||
<paraStyle name="invoice-head" alignment="center" fontName="OpenSans-Bold" fontSize="16" leading="18" spaceAfter="0"/>
|
<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.event_description" fontName="OpenSans" textColor="DarkGray" />
|
||||||
<paraStyle name="style.item_description" fontName="OpenSans" textColor="DarkGray" leftIndent="10" />
|
<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.specific_description" fontName="OpenSans" textColor="DarkGray" fontSize="10" />
|
||||||
<paraStyle name="style.times" fontName="OpenSans" fontSize="10" />
|
<paraStyle name="style.times" fontName="OpenSans" fontSize="10" />
|
||||||
<paraStyle name="style.invoice_titles" fontName="OpenSans-Bold" fontSize="10" />
|
<paraStyle name="style.head_titles" fontName="OpenSans-Bold" fontSize="10" />
|
||||||
<paraStyle name="style.invoice_numbers" fontName="OpenSans" fontSize="10" />
|
<paraStyle name="style.head_numbers" fontName="OpenSans" fontSize="10" />
|
||||||
|
|
||||||
<blockTableStyle id="eventSpecifics">
|
<blockTableStyle id="eventSpecifics">
|
||||||
<blockValign value="top"/>
|
<blockValign value="top"/>
|
||||||
<lineStyle kind="LINEAFTER" colorName="LightGrey" start="0,0" stop="1,0" thickness="1"/>
|
<lineStyle kind="LINEAFTER" colorName="LightGrey" start="0,0" stop="1,0" thickness="1"/>
|
||||||
</blockTableStyle>
|
</blockTableStyle>
|
||||||
|
|
||||||
<blockTableStyle id="invoiceLayout">
|
<blockTableStyle id="headLayout">
|
||||||
<blockValign value="top"/>
|
<blockValign value="top"/>
|
||||||
|
|
||||||
</blockTableStyle>
|
</blockTableStyle>
|
||||||
@@ -100,10 +100,11 @@
|
|||||||
|
|
||||||
|
|
||||||
<setFont name="OpenSans" size="10" />
|
<setFont name="OpenSans" size="10" />
|
||||||
{% if not invoice %}<drawCenteredString x="302.5" y="50">[{{ copy }} Copy]</drawCenteredString>{% endif %}
|
|
||||||
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
||||||
<setFont name="OpenSans" size="7" />
|
<setFont name="OpenSans" size="7" />
|
||||||
<drawCenteredString x="302.5" y="26">[Paperwork generated by {{current_user.name}} | {% now "d/m/Y H:i" %} | {{object.current_version_id}}]</drawCenteredString>
|
<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>
|
</pageGraphics>
|
||||||
|
|
||||||
<frame id="main" x1="50" y1="65" width="495" height="645"/>
|
<frame id="main" x1="50" y1="65" width="495" height="645"/>
|
||||||
@@ -115,10 +116,11 @@
|
|||||||
<image file="RIGS/static/imgs/paperwork/corner-bl.jpg" x="0" y="0" 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"/>
|
<setFont name="OpenSans" size="10"/>
|
||||||
{% if not invoice %}<drawCenteredString x="302.5" y="50">[{{ copy }} Copy]</drawCenteredString>{% endif %}
|
|
||||||
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
||||||
<setFont name="OpenSans" size="7" />
|
<setFont name="OpenSans" size="7" />
|
||||||
<drawCenteredString x="302.5" y="26">[Paperwork generated by {{current_user.name}} | {% now "d/m/Y H:i" %} | {{object.current_version_id}}]</drawCenteredString>
|
<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>
|
</pageGraphics>
|
||||||
<frame id="main" x1="50" y1="65" width="495" height="727"/>
|
<frame id="main" x1="50" y1="65" width="495" height="727"/>
|
||||||
</pageTemplate>
|
</pageTemplate>
|
||||||
|
|||||||
@@ -1,59 +1,70 @@
|
|||||||
<setNextFrame name="main"/>
|
<setNextFrame name="main"/>
|
||||||
<nextFrame/>
|
<nextFrame/>
|
||||||
|
|
||||||
{% if invoice %}
|
|
||||||
|
|
||||||
<blockTable style="invoiceLayout" colWidths="330,165">
|
<blockTable style="headLayout" colWidths="330,165">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% endif %}
|
<h1><b>N{{ object.pk|stringformat:"05d" }}:</b> '{{ object.name }}'<small></small></h1>
|
||||||
|
|
||||||
<h1><b>N{{ object.pk|stringformat:"05d" }}:</b> '{{ object.name }}'<small></small></h1>
|
<para style="style.event_description">
|
||||||
|
<b>{{object.start_date|date:"D jS N Y"}}</b>
|
||||||
<para style="style.event_description">
|
|
||||||
<b>{{object.start_date|date:"D jS N Y"}}</b>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<keepInFrame>
|
|
||||||
<para style="style.event_description">
|
|
||||||
{{ object.description|default_if_none:""|linebreaksbr }}
|
|
||||||
</para>
|
</para>
|
||||||
</keepInFrame>
|
|
||||||
|
|
||||||
{% if invoice %}
|
|
||||||
|
|
||||||
|
<keepInFrame>
|
||||||
|
<para style="style.event_description">
|
||||||
|
{{ object.description|default_if_none:""|linebreaksbr }}
|
||||||
|
</para>
|
||||||
|
</keepInFrame>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<para style="invoice-head">INVOICE</para>
|
{% if invoice %}
|
||||||
<spacer length="10"/>
|
<para style="page-head">INVOICE</para>
|
||||||
<blockTable style="eventDetails" colWidths="100,175">
|
<spacer length="10"/>
|
||||||
<tr>
|
<blockTable style="eventDetails" colWidths="100,175">
|
||||||
<td><para style="invoice_titles">Invoice Number</para></td>
|
<tr>
|
||||||
<td>
|
<td><para style="head_titles">Invoice Number</para></td>
|
||||||
<para style="invoice_numbers">{{ invoice.pk|stringformat:"05d" }}</para>
|
<td>
|
||||||
</td>
|
<para style="head_numbers">{{ invoice.pk|stringformat:"05d" }}</para>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td><para style="invoice_titles">Invoice Date</para></td>
|
<tr>
|
||||||
<td>
|
<td><para style="head_titles">Invoice Date</para></td>
|
||||||
<para style="invoice_numbers">{{ invoice.invoice_date|date:"d/m/Y" }}</para>
|
<td>
|
||||||
</td>
|
<para style="head_numbers">{{ invoice.invoice_date|date:"d/m/Y" }}</para>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td><para style="invoice_titles">PO Number</para></td>
|
|
||||||
<td>
|
|
||||||
<para style="invoice_numbers">{{ object.purchase_order|default_if_none:"" }}</para>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</blockTable>
|
{% if not object.internal %}
|
||||||
|
<tr>
|
||||||
|
<td><para style="head_titles">PO</para></td>
|
||||||
|
<td><para style="head_numbers">{{ object.purchase_order }}</para></td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
</blockTable>
|
||||||
|
|
||||||
|
{% elif quote %}
|
||||||
|
|
||||||
|
<para style="page-head">QUOTE</para>
|
||||||
|
<spacer length="10"/>
|
||||||
|
<blockTable style="eventDetails" colWidths="100,175">
|
||||||
|
<tr>
|
||||||
|
<td><para style="head_titles">Quote Date</para></td>
|
||||||
|
<td>
|
||||||
|
<para style="head_numbers">{% now "d/m/Y" %}</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
|
||||||
|
{% elif receipt %}
|
||||||
|
|
||||||
|
<para style="page-head">CONFIRMATION</para>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</blockTable>
|
</blockTable>
|
||||||
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<spacer length="15"/>
|
<spacer length="15"/>
|
||||||
<blockTable style="eventSpecifics" colWidths="165,165,165">
|
<blockTable style="eventSpecifics" colWidths="165,165,165">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -189,16 +200,16 @@
|
|||||||
<keepTogether>
|
<keepTogether>
|
||||||
<blockTable style="totalTable" colWidths="300,115,80">
|
<blockTable style="totalTable" colWidths="300,115,80">
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% if not invoice %}VAT Registration Number: 170734807{% endif %}</td>
|
<td>{% if quote %}VAT Registration Number: 170734807{% endif %}</td>
|
||||||
<td>Total (ex. VAT)</td>
|
<td>Total (ex. VAT)</td>
|
||||||
<td>£ {{ object.sum_total|floatformat:2 }}</td>
|
<td>£ {{ object.sum_total|floatformat:2 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if not invoice %}
|
{% if quote %}
|
||||||
<para>
|
<para>
|
||||||
<b>The full hire fee is payable at least 10 days before the event.</b>
|
This quote is valid for 30 days unless otherwise arranged.
|
||||||
</para>
|
</para>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>VAT @ {{ object.vat_rate.as_percent|floatformat:2 }}%</td>
|
<td>VAT @ {{ object.vat_rate.as_percent|floatformat:2 }}%</td>
|
||||||
@@ -206,113 +217,140 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
{% if quote %}
|
||||||
|
<para>
|
||||||
|
<b>The full hire fee is payable at least 10 days before the event.</b>
|
||||||
|
</para>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% if invoice %}
|
||||||
|
<td>Total</td>
|
||||||
|
<td>£ {{ object.total|floatformat:2 }}</td>
|
||||||
|
{% else %}
|
||||||
|
<td>
|
||||||
|
<para>
|
||||||
|
<b>Total</b>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para>
|
||||||
|
<b>£ {{ object.total|floatformat:2 }}</b>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
</keepTogether>
|
||||||
|
|
||||||
<para>
|
{% if invoice %}
|
||||||
{% if invoice %}
|
<spacer length="15"/>
|
||||||
VAT Registration Number: 170734807
|
<keepTogether>
|
||||||
|
<h2>Payments</h2>
|
||||||
|
<blockTable style="itemTable" colWidths="300,115,80">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para>
|
||||||
|
<b>Method</b>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para>
|
||||||
|
<b>Date</b>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para>
|
||||||
|
<b>Amount</b>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% for payment in object.invoice.payment_set.all %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ payment.get_method_display }}</td>
|
||||||
|
<td>{{ payment.date }}</td>
|
||||||
|
<td>£ {{ payment.amount|floatformat:2 }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</blockTable>
|
||||||
|
<blockTable style="totalTable" colWidths="300,115,80">
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>Payment Total</td>
|
||||||
|
<td>£ {{ object.invoice.payment_total|floatformat:2 }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<para>
|
||||||
|
<b>Balance</b> (ex. VAT)
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para>
|
||||||
|
<b>£ {{ object.invoice.balance|floatformat:2 }}</b>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
</keepTogether>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<keepTogether>
|
||||||
|
<blockTable style="infoTable">>
|
||||||
|
{% if quote %}
|
||||||
|
<tr><td><spacer length="15" /></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{% if object.internal %}
|
||||||
|
<para>Bookings will
|
||||||
|
<b>not</b>
|
||||||
|
be confirmed until the event is authorised online.
|
||||||
|
</para>
|
||||||
{% else %}
|
{% else %}
|
||||||
<b>This contract is not an invoice.</b>
|
<para>Bookings will
|
||||||
|
<b>not</b>
|
||||||
|
be confirmed until we have received written confirmation and a Purchase Order.
|
||||||
|
</para>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</para>
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>24 Hour Emergency Contacts: 07825 065681 and 07825 065678</td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para>VAT Registration Number: 170734807</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</td>
|
<tr><td><spacer length="15" /></td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<para>
|
{% if object.internal and object.authorised %}
|
||||||
<b>Total</b>
|
<para>
|
||||||
</para>
|
Event authorised online by {{ object.authorisation.name }} ({{ object.authorisation.email }}) at
|
||||||
</td>
|
{{ object.authorisation.last_edited_at }}.
|
||||||
<td>
|
</para>
|
||||||
<para>
|
|
||||||
<b>£ {{ object.total|floatformat:2 }}</b>
|
<blockTable colWidths="165,165,165">
|
||||||
</para>
|
<tr>
|
||||||
|
<td><para><b>University ID</b></para></td>
|
||||||
|
<td><para><b>Account Code</b></para></td>
|
||||||
|
<td><para><b>Authorised Amount</b></para></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ object.authorisation.uni_id }}</td>
|
||||||
|
<td>{{ object.authorisation.account_code }}</td>
|
||||||
|
<td>£ {{ object.authorisation.amount|floatformat:2 }}</td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</blockTable>
|
</blockTable>
|
||||||
</keepTogether>
|
</keepTogether>
|
||||||
{% if not invoice %}
|
|
||||||
<keepTogether>
|
|
||||||
<blockTable style="infoTable">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<para>Bookings will
|
|
||||||
<b>not</b>
|
|
||||||
be confirmed until payment is received and the contract is signed.
|
|
||||||
</para>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>24 Hour Emergency Contacts: 07825 065681 and 07825 065678</td>
|
|
||||||
</tr>
|
|
||||||
</blockTable>
|
|
||||||
</keepTogether>
|
|
||||||
<spacer length="15"/>
|
|
||||||
<keepTogether>
|
|
||||||
|
|
||||||
<para style="blockPara">
|
|
||||||
<b>To be signed on booking:</b>
|
|
||||||
</para>
|
|
||||||
{% if object.organisation.union_account %}
|
|
||||||
<para style="blockPara">
|
|
||||||
<i>
|
|
||||||
I agree that am authorised to sign this invoice. I agree that I am the President/Treasurer of the hirer, or
|
|
||||||
that I have provided written permission from either the President or Treasurer of the hirer stating that I can
|
|
||||||
sign for this invoice.
|
|
||||||
</i>
|
|
||||||
</para>
|
|
||||||
<para style="blockPara">
|
|
||||||
<i>
|
|
||||||
I have read, understood and fully accepted the current conditions of hire. I agree to return any dry hire
|
|
||||||
items to TEC PA & Lighting in the same condition at the end of the hire period.
|
|
||||||
</i>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para style="blockPara">
|
|
||||||
<b>
|
|
||||||
Conditions of hire attached and available on the TEC PA & Lighting website. E&OE
|
|
||||||
</b>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para style="blockPara">
|
|
||||||
Please return this form directly to TEC PA & Lighting and not the Students' Union Finance Department.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<blockTable style="signatureTable" colWidths="70,100,325">
|
|
||||||
<tr>
|
|
||||||
<td>Account Code</td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</blockTable>
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
<para style="blockPara">
|
|
||||||
<i>
|
|
||||||
I, the hirer, have read, understand and fully accept the current conditions of hire. This document forms a
|
|
||||||
binding contract between TEC PA & Lighting and the hirer, the aforementioned conditions of hire forming
|
|
||||||
an integral part of it.
|
|
||||||
</i>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para style="blockPara">
|
|
||||||
<b>
|
|
||||||
Conditions of hire attached and available on the TEC PA & Lighting website. E&OE
|
|
||||||
</b>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
{% include "RIGS/event_print_signature.xml" %}
|
|
||||||
<spacer length="10"/>
|
|
||||||
<para style="blockPara">
|
|
||||||
<b>To be signed on the day of the event/hire:</b>
|
|
||||||
</para>
|
|
||||||
<para style="blockPara">
|
|
||||||
<i>
|
|
||||||
I, the hirer, have received the goods/services as requested and in good order. I agree to return any dry hire
|
|
||||||
items to TEC PA & Lighting in a similar condition at the end of the hire period.
|
|
||||||
</i>
|
|
||||||
</para>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% include "RIGS/event_print_signature.xml" %}
|
|
||||||
</keepTogether>
|
|
||||||
{% endif %}
|
|
||||||
<namedString id="lastPage"><pageNumber/></namedString>
|
<namedString id="lastPage"><pageNumber/></namedString>
|
||||||