Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor buildsystem to NPM/Gulp, port to BS4 & rewrite RIGS tests accordingly... #412

Merged
merged 288 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
288 commits
Select commit Hold shift + click to select a range
0144bd3
Start to seperate versioning into its own app
FreneticScribbler Mar 18, 2020
50ca782
Start reworking invoice things
FreneticScribbler Mar 18, 2020
41b0387
Reduced overall font size a touch
FreneticScribbler Mar 22, 2020
ee7ba3e
Improvements to generic lists
FreneticScribbler Mar 22, 2020
7a08f2d
Tweak some colours to be a bit less OTT
FreneticScribbler Mar 24, 2020
0271840
Improvements to event table mobile
FreneticScribbler Mar 24, 2020
de210ca
First pass at mobile-ising the generic list
FreneticScribbler Mar 25, 2020
d351d9e
Item table fixes
FreneticScribbler Apr 6, 2020
4c40226
Fixed fullcalendar print css not included
FreneticScribbler Apr 6, 2020
7aa19cc
Asset list table improvements
FreneticScribbler Apr 6, 2020
55e37d8
Tweak asset list to be more in line with other lists
FreneticScribbler Apr 6, 2020
d216dd4
Versioning template improvements
FreneticScribbler Apr 6, 2020
176324e
Tweak versioning templates to allow ID overrides
FreneticScribbler Apr 6, 2020
c8d0c0d
Asset form fixes
FreneticScribbler Apr 6, 2020
2bf643c
Use the right autocompleter.js...
FreneticScribbler Apr 12, 2020
f308a09
Breakout (most) user stuff to separate module
FreneticScribbler Apr 12, 2020
5e60675
Python Format/import opt
FreneticScribbler Apr 12, 2020
70995a0
Merge branch 'master' into bs4
FreneticScribbler Apr 15, 2020
abb8dc2
Test Refactor Part 1 - Shuffle things around
FreneticScribbler Apr 15, 2020
3f48c51
Fix migrations
FreneticScribbler Apr 15, 2020
e3c1da9
Start on new tests
FreneticScribbler May 11, 2020
5a3547e
Initial work on event create test reimpl
FreneticScribbler May 21, 2020
c23d18c
Init other tests, more rigs test faffery
FreneticScribbler May 21, 2020
0d0c783
Desaturate theme colors even more
FreneticScribbler May 21, 2020
919975e
Fix event item adding
FreneticScribbler May 21, 2020
813db2c
Initial refactor of event item testing
FreneticScribbler May 21, 2020
34bf498
Upgrade bootstrap-select
FreneticScribbler May 21, 2020
8ffb5ab
Updated bootstrap-select for BS4
mattysmith22 May 21, 2020
3c0005d
Initial port of duplicate testing
FreneticScribbler May 23, 2020
cc225b2
Refactor date validation test
FreneticScribbler May 23, 2020
928d5cd
Deduplication of testing code
FreneticScribbler May 24, 2020
c9ea1bb
pep8
FreneticScribbler May 24, 2020
544b6df
Fix some tests
FreneticScribbler May 24, 2020
e6d06db
FIX: Prevent setting access time after start time
FreneticScribbler May 25, 2020
f06dc56
Refactor calendar tests
FreneticScribbler May 25, 2020
18fde7c
FIX: Don't show asset buttons/history for basic users
FreneticScribbler May 25, 2020
2f7389d
Really ought to get a pre-commit hook for pep8...
FreneticScribbler May 25, 2020
d070f97
Fully replace test_functional
FreneticScribbler May 25, 2020
177c37f
Dedupe generic search logic
FreneticScribbler May 25, 2020
fd6aee8
Fix the remaining tests
FreneticScribbler May 25, 2020
07641a2
Ensure submit button is scrolled to in tests
FreneticScribbler May 25, 2020
c4c4291
Fix asset creation test + actually verify its results
FreneticScribbler May 25, 2020
b52709f
Make CI use latest (stable) chromedriver rather than some ancient one
FreneticScribbler May 25, 2020
1d0e8e1
Of course | is part of YAML syntax, of course...
FreneticScribbler May 26, 2020
08f40bc
Update python version
FreneticScribbler May 26, 2020
7356d02
Minor test futzing
FreneticScribbler May 26, 2020
0bbc238
Well that wasn't clever of me
FreneticScribbler May 26, 2020
3f78b9f
That was even less clever of me
FreneticScribbler May 26, 2020
e45e583
Revert to old submit wait behaviour
FreneticScribbler May 26, 2020
920ea0d
What about if I did this
FreneticScribbler May 26, 2020
6ded711
Try disabling chrome cache
FreneticScribbler May 26, 2020
6d47be7
Added screenshot recording of test failures
mattysmith22 May 27, 2020
f37228e
Fixed RIGS tests not being run
mattysmith22 May 27, 2020
170c2f6
Fixed Pep8 - I promise I'll make a pre-commit hook sometime!
mattysmith22 May 27, 2020
06f67f4
Very initial work at togglable darktheme.
FreneticScribbler May 27, 2020
06d7ef0
Merge remote-tracking branch 'origin/bs4' into bs4
FreneticScribbler May 27, 2020
b742d3f
More dark theme wangling
FreneticScribbler May 27, 2020
4081918
Fix some asset template things
FreneticScribbler May 27, 2020
14d2113
FIX: CI Locale Issues
FreneticScribbler May 27, 2020
1b1775d
Fix sample command
FreneticScribbler May 27, 2020
b75b6a6
Initial work at integrating the risk assessment
FreneticScribbler May 28, 2020
00226e9
FIX: Don't set every boolean input to radios
FreneticScribbler May 28, 2020
4cfd83e
Different approach to RA linking
FreneticScribbler May 28, 2020
d3b3d1c
Move text definitions to somewhere more authoratitive
FreneticScribbler May 28, 2020
9350499
FIX: Undo breakage causing autopep8
FreneticScribbler May 28, 2020
eb0c027
Expand detail template
FreneticScribbler May 29, 2020
0e2adf3
Use correct view for RA history
FreneticScribbler May 29, 2020
156e639
Initial work at coercing activity feed into showing RAs
FreneticScribbler May 29, 2020
e45324f
Refactor activity feed template logic
FreneticScribbler May 30, 2020
6867359
Initial work on caching activity feed
FreneticScribbler May 30, 2020
3768f4a
Start RA list template
FreneticScribbler May 30, 2020
d31900c
Refactor RA creation stuff, again
FreneticScribbler Jun 3, 2020
9e93d89
Add H&S Details to Event Detail View
FreneticScribbler Jun 3, 2020
a7c4b90
Display venue notes in event detail
FreneticScribbler Jun 3, 2020
7035731
Add ability to filter event archive by status
FreneticScribbler Jun 4, 2020
1239fbf
Fix lingering naive time
FreneticScribbler Jun 4, 2020
aedb4c2
Use locmem cache in sqlite environments
FreneticScribbler Jun 4, 2020
9e1d146
Update dependencies
FreneticScribbler Jun 5, 2020
6e7fa26
Add global ctrl/meta-enter shortcut for form submission
FreneticScribbler Jun 15, 2020
c65330c
Update dependencies
FreneticScribbler Jun 19, 2020
cb1a8e1
Fix for a situation that should be impossible
FreneticScribbler Jun 19, 2020
e4e8823
Fix navbar alignment
FreneticScribbler Jun 19, 2020
84618de
FEAT: Improve 'omni'search
FreneticScribbler Jun 19, 2020
eafb394
Move closemodal into PyRIGS
FreneticScribbler Jun 19, 2020
141e1c9
Fix tests for search improvements
FreneticScribbler Jun 19, 2020
b28377e
Dark mode colour improvements
FreneticScribbler Jun 24, 2020
8a9eefb
Fix table colors for dry hires
FreneticScribbler Jun 24, 2020
86fe8a8
further darktheme fixes
FreneticScribbler Jun 24, 2020
8820ed1
Remove the dark header from light theme
FreneticScribbler Jun 24, 2020
3ceb488
Fix reload loops when CSS/JS is changed
FreneticScribbler Jun 25, 2020
d50d2bd
Move dark theme SCSS to separate file, fix inactive pagination styling
FreneticScribbler Jun 25, 2020
a6cee78
Genercise detail pages
FreneticScribbler Jun 25, 2020
be48dd3
Testing something re notes
FreneticScribbler Jun 25, 2020
a4ef69a
Dark theme palette shenanigans
FreneticScribbler Jun 25, 2020
cd168d9
Match darktheme palette to forum darktheme palette
FreneticScribbler Jun 25, 2020
1138cfc
Make supplier detail use the generic template
FreneticScribbler Jun 25, 2020
1dfaa4d
Disable mobile event table PoC for now
FreneticScribbler Jul 2, 2020
b57b918
Remove the defaults from the RA fields + make them required
FreneticScribbler Jul 2, 2020
721439d
More RA fixes
FreneticScribbler Jul 2, 2020
d800a78
Fixes to revisions for RAs
FreneticScribbler Jul 2, 2020
79eb0cb
Add bootstrap 4 test page
FreneticScribbler Jul 3, 2020
d09f399
Bunch of dark mode fixes from test page
FreneticScribbler Jul 3, 2020
2e60c5e
Do not use Django 'required' for radio selects
FreneticScribbler Jul 3, 2020
67bf60e
Properly fixed popover darktheme
FreneticScribbler Aug 4, 2020
9d6948e
Fixed search for events
FreneticScribbler Aug 4, 2020
b88554a
Style fixes to asset list
FreneticScribbler Aug 4, 2020
9237722
Start RA 'mark review' feature
FreneticScribbler Aug 5, 2020
4514de1
Add reviewing to revision history, fix RA editing not working
FreneticScribbler Aug 5, 2020
902476e
Fix Power MIC being lost on RA edit
FreneticScribbler Aug 6, 2020
d3d7c05
Invalidate RA review if it is edited after review
FreneticScribbler Aug 14, 2020
d3f5552
Start work on event checklist
FreneticScribbler Aug 14, 2020
a6ac55b
Add a button for creating and instantly voiding invoices
FreneticScribbler Aug 24, 2020
da60cad
Mooooore status chips, mooore
FreneticScribbler Aug 24, 2020
8bb0872
Initial shenanigans on storing my overly fancy EC form
FreneticScribbler Aug 24, 2020
9cf081e
Proof of concept for JSON parsing/storage
FreneticScribbler Aug 25, 2020
3438489
Add new line functionality for vehicles/drivers
FreneticScribbler Aug 27, 2020
828964e
Alter rig_count to not include un-checked-in dry hires
FreneticScribbler Aug 27, 2020
de04498
Insert a divider between still-out dry hires and actually upcoming ev…
FreneticScribbler Aug 27, 2020
8ea9667
Initial work on new checklist handling. No more JSON!
FreneticScribbler Aug 29, 2020
d708207
Versioning module now does magic
FreneticScribbler Aug 29, 2020
1feb944
Cleanup
FreneticScribbler Aug 29, 2020
dbe0d35
Event checklist crew works
FreneticScribbler Aug 29, 2020
9198724
Medium event power stuff done, barring worst case stuff
FreneticScribbler Aug 29, 2020
bfe80db
Misc fixes
FreneticScribbler Aug 30, 2020
f3c2ce2
Validation of power reqs
FreneticScribbler Aug 30, 2020
8842c2c
Worst case points on checklist
FreneticScribbler Aug 30, 2020
689124a
Templating improvements to RA/EC stuff
FreneticScribbler Aug 31, 2020
945e521
Do event table color logic at python level
FreneticScribbler Aug 31, 2020
6ee9efa
Audit template fixes
FreneticScribbler Sep 1, 2020
1d54290
Restrict versioning to one level of depth for speed
FreneticScribbler Sep 1, 2020
87e831a
Event properties internal/authorised always return a explicit boolean…
FreneticScribbler Sep 1, 2020
c1182ef
Use template filter for notes
FreneticScribbler Sep 1, 2020
e602058
Fix list templates
FreneticScribbler Sep 3, 2020
6d836ee
Fix cable table template
FreneticScribbler Sep 12, 2020
ba6dbc6
Rethink rigboard color logic again
FreneticScribbler Sep 12, 2020
cf7ada3
Test fixes
FreneticScribbler Sep 12, 2020
1cf9107
Modify auth test so it doesn't try and test for external authorisations
FreneticScribbler Sep 12, 2020
d8e6f2f
Why does this work
FreneticScribbler Sep 12, 2020
b959ca1
Formatting...
FreneticScribbler Sep 12, 2020
eb7d8e4
Merge branch 'master' into bs4
FreneticScribbler Sep 12, 2020
aa0184a
Initial work on RA tests
FreneticScribbler Sep 12, 2020
6426880
Pages/start of tests for EventChecklists
FreneticScribbler Sep 14, 2020
5487b73
Much better coverage of H&S things
FreneticScribbler Sep 15, 2020
a5516ee
Cleanup & Squash migrations
FreneticScribbler Sep 15, 2020
1ecc508
Fix wrong variable name in settings.py
FreneticScribbler Sep 15, 2020
fd926ae
Fix broken invoice list template
FreneticScribbler Sep 15, 2020
ce5a92d
Add revision history to invoices/payments.
FreneticScribbler Sep 16, 2020
dcc0e53
Various misc fixes
FreneticScribbler Sep 17, 2020
b90be70
Fix for my fix
FreneticScribbler Sep 17, 2020
9739af7
Curse youuuuu pep8
FreneticScribbler Sep 17, 2020
31f63ba
Invoice template improvements
FreneticScribbler Sep 18, 2020
1ea8090
Minor fixes
FreneticScribbler Sep 19, 2020
77c82ef
More tweaks
FreneticScribbler Sep 19, 2020
2a1bb57
More fixes
FreneticScribbler Sep 19, 2020
143b654
Major improvements/fixes to authorisation templates
FreneticScribbler Sep 25, 2020
018397d
Add ability to mark event checklists as Large Event
FreneticScribbler Sep 25, 2020
74066e9
Remove database ID from generic list
FreneticScribbler Sep 28, 2020
6936b94
Put power threshold values in a collapse
FreneticScribbler Sep 28, 2020
c38105a
Use template filter for consistent removal of 'None links'
FreneticScribbler Sep 28, 2020
1dad8d2
Tweak asset list markup
FreneticScribbler Sep 28, 2020
70cc554
Begin to change add buttons success -> primary
FreneticScribbler Sep 28, 2020
bea762b
Begin to improve event checklist on mobile
FreneticScribbler Sep 28, 2020
a78bb19
Asset detail template improvements
FreneticScribbler Sep 28, 2020
8424424
Fix #326 (again)
FreneticScribbler Sep 29, 2020
70de16e
Fix errors being squashed
FreneticScribbler Sep 29, 2020
932180f
Fix rigboard validation tests
FreneticScribbler Sep 29, 2020
0117002
Initial work on BS4 button templatetag
FreneticScribbler Sep 29, 2020
813b1da
Allow multiple event checklists per event
FreneticScribbler Sep 29, 2020
84c4ec0
Minor event detail fixes
FreneticScribbler Sep 29, 2020
f70421b
Fix tests
FreneticScribbler Sep 30, 2020
acf814e
Rework button tag
FreneticScribbler Sep 30, 2020
0b751d6
Mobile fixes for search
FreneticScribbler Oct 6, 2020
f147f19
Fix event checklist on mobile
FreneticScribbler Oct 6, 2020
50ae302
Redo light theme palette
FreneticScribbler Oct 6, 2020
2f8e099
Switch rigboard new button to primary
FreneticScribbler Oct 6, 2020
350a301
Kill off excess whitespace on rigboard
FreneticScribbler Oct 6, 2020
7c79a6a
Rigboard Timing display tweaks
FreneticScribbler Oct 6, 2020
abf3cfe
Fix tests
FreneticScribbler Oct 6, 2020
ae13cab
Properly handle eventauthorisations in new versioning
FreneticScribbler Oct 7, 2020
cce0ad0
Prevent creating duplicate revisions on event
FreneticScribbler Oct 7, 2020
2db2cc6
Template improvements
FreneticScribbler Oct 7, 2020
025a31f
Minor test fixes
FreneticScribbler Oct 7, 2020
af7d3c4
Revert "Prevent creating duplicate revisions on event"
FreneticScribbler Oct 7, 2020
3903481
Better approach to generic list templates + other deduplication
FreneticScribbler Oct 8, 2020
5d56f4f
Also apply better approach to generic detail pages
FreneticScribbler Oct 8, 2020
5af0759
One of these days I'll remember to test BEFORE pushing...
FreneticScribbler Oct 8, 2020
565e757
And now the same for generic forms
FreneticScribbler Oct 9, 2020
ee9dbf8
Display tick/cross rather than true/false in boolean version diffs
FreneticScribbler Oct 9, 2020
f41064a
Upgrade dependencies
FreneticScribbler Oct 9, 2020
3602da9
Fixes fixes fixes
FreneticScribbler Oct 9, 2020
934c07b
Fix dependency hell
FreneticScribbler Oct 9, 2020
12a60e1
Correct handling of spaces in paperwork filenames
FreneticScribbler Oct 9, 2020
5a99560
Buggerit millennium hand and shrimp
FreneticScribbler Oct 9, 2020
7f3a169
FIX: Set duplicated event status to provisional
FreneticScribbler Oct 9, 2020
d7678f6
Update polyfill for datetime-local
FreneticScribbler Oct 9, 2020
58b1867
Curses!
FreneticScribbler Oct 9, 2020
5a5bb43
Minor typo fixes
FreneticScribbler Oct 10, 2020
3cb0d82
Initial pass at soop-consult confirmation screen for RAs
FreneticScribbler Oct 10, 2020
026e2a0
Fix migration
FreneticScribbler Oct 10, 2020
49a2bc8
Make venue/date editable on EC
FreneticScribbler Oct 10, 2020
8c8c580
Clearer logic for RA inverted fields
FreneticScribbler Oct 10, 2020
a0e1702
(probably) fix tests
FreneticScribbler Oct 12, 2020
b69883c
Give keyholders supplier edit perm
FreneticScribbler Oct 12, 2020
e926731
Generic list only displays edit button if user has perm
FreneticScribbler Oct 12, 2020
0f019e2
Same perm check for generic details
FreneticScribbler Oct 12, 2020
2cb5453
H&S Details takes up free space on non-internal events
FreneticScribbler Oct 12, 2020
fd85d50
Remove flash of content when loading new rig page
FreneticScribbler Oct 12, 2020
d255e1f
First pass at clearer display of asset list filters
FreneticScribbler Oct 12, 2020
8b2f2a9
Fix tests / default to headless tests
FreneticScribbler Oct 13, 2020
f57dc9f
Fix autocompleter.js to properly disable edit links again
FreneticScribbler Oct 14, 2020
a950b94
Move status color logic back to template
FreneticScribbler Oct 15, 2020
3d7ff43
Display note icon on event detail page
FreneticScribbler Oct 15, 2020
bb4d314
Fix caching
FreneticScribbler Oct 15, 2020
0fee753
Put rounded corners back where they belong
FreneticScribbler Oct 17, 2020
848e8c8
Remove lingering use of 'page-header'
FreneticScribbler Oct 17, 2020
4bb1c0a
More search and replace for BS changes
FreneticScribbler Oct 17, 2020
30df597
Remove enforced linebreak on status chips
FreneticScribbler Oct 17, 2020
7736a2d
Fix horizontal-ness on some forms
FreneticScribbler Oct 17, 2020
59756ab
Remove animation on prefers-reduced-motion/low referesh rate devices
FreneticScribbler Oct 18, 2020
5299412
Make version changes badges more readable
FreneticScribbler Oct 18, 2020
8a4fcdc
First pass at making the calendar less crap
FreneticScribbler Oct 18, 2020
ab2c2f6
Fix event table success logic
FreneticScribbler Oct 18, 2020
320ace1
Use borders rather than block colors for coloured tables under darktheme
FreneticScribbler Oct 18, 2020
e6eed9f
First pass at porting calendar from FC V3 to V5
FreneticScribbler Oct 18, 2020
20d4ddd
Rework version name method to avoid blank names on eventchecklist veh…
FreneticScribbler Oct 24, 2020
7f9a7bb
Fix cable test
FreneticScribbler Oct 24, 2020
14e12f0
Made radio button focus much more obvious on dark theme
FreneticScribbler Oct 24, 2020
e9a29f9
Implement Jerb's wording changes
FreneticScribbler Oct 24, 2020
d06895b
Fix one test, break another...
FreneticScribbler Oct 25, 2020
44fef39
Fix recent change stream list mutation issue
FreneticScribbler Oct 25, 2020
4b76b77
FIX: Do not naively cache event table
FreneticScribbler Oct 25, 2020
bbc4d1d
FEAT: Implement #413 show associated assets on cable type detail pg
FreneticScribbler Oct 30, 2020
ac91624
Allow H&S for non-events
FreneticScribbler Nov 12, 2020
06e22b0
Update emergency contact number
FreneticScribbler Nov 13, 2020
0aa10d8
Improvements to profile detail page
FreneticScribbler Nov 15, 2020
97b29bc
Merge branch 'master' into bs4
FreneticScribbler Nov 15, 2020
e0615f3
Implement some of Jonny's suggested changes
FreneticScribbler Nov 16, 2020
dfdbcb6
Test fixes
FreneticScribbler Dec 13, 2020
124b7a8
Add space for power/rigging plans to be linked to RAs
FreneticScribbler Dec 13, 2020
13fcada
Start move of event size logic to RA from Ec
FreneticScribbler Dec 13, 2020
dd95447
Javascript required shenanigans for RA power
FreneticScribbler Dec 13, 2020
c027182
More moving of event size logic
FreneticScribbler Dec 14, 2020
80837c3
Fixing tests for new logic etc
FreneticScribbler Dec 27, 2020
a0c6793
Why does this work
FreneticScribbler Dec 27, 2020
0e656b4
FIX: Stupid typo in versioning.py
FreneticScribbler Dec 27, 2020
72221e4
Further minor fixes to versioning
FreneticScribbler Dec 27, 2020
fe38d5c
Add icons to H&S menu items
FreneticScribbler Jan 23, 2021
4ca4ea9
Should fix calendar breaking in production
FreneticScribbler Jan 23, 2021
0ed7dc4
Small alignment fix in asset list
FreneticScribbler Jan 23, 2021
ce0e477
Squash migrations
FreneticScribbler Jan 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 11 additions & 2 deletions PyRIGS/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

def get_oembed(login_url, request, oembed_view, kwargs):
context = {}
context['oembed_url'] = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'], reverse(oembed_view, kwargs=kwargs))
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
Expand All @@ -28,9 +29,11 @@ def _checklogin(request, *args, **kwargs):
return get_oembed(login_url, request, oembed_view, kwargs)
else:
return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, request.get_full_path()))

_checklogin.__doc__ = view_func.__doc__
_checklogin.__dict__ = view_func.__dict__
return _checklogin

return _dec


Expand Down Expand Up @@ -60,9 +63,11 @@ def _checklogin(request, *args, **kwargs):
resp = render(request, '403.html')
resp.status_code = 403
return resp

_checklogin.__doc__ = view_func.__doc__
_checklogin.__dict__ = view_func.__dict__
return _checklogin

return _dec


Expand All @@ -80,6 +85,7 @@ def api_key_required(function):
Failed users will be given a 403 error.
Should only be used for urls which include <api_pk> and <api_key> kwargs
"""

def wrap(request, *args, **kwargs):

userid = kwargs.get('api_pk')
Expand All @@ -101,18 +107,21 @@ def wrap(request, *args, **kwargs):
if user_object.api_key != key:
return error_resp
return function(request, *args, **kwargs)

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')
error_resp = render(request, 'eventauthorisation_request_error.html')
return error_resp

return function(request, *args, **kwargs)

return wrap
2 changes: 0 additions & 2 deletions PyRIGS/formats/en/formats.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


DATETIME_FORMAT = ('d/m/Y H:i')
DATE_FORMAT = ('d/m/Y')
TIME_FORMAT = ('H:i')
Empty file added PyRIGS/forms.py
Whitespace-only changes.
43 changes: 37 additions & 6 deletions PyRIGS/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
# 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


STAGING = bool(int(os.environ.get('STAGING'))) if os.environ.get('STAGING') else False

CI = bool(int(os.environ.get('CI'))) if os.environ.get('CI') else False

ALLOWED_HOSTS = ['pyrigs.nottinghamtec.co.uk', 'rigs.nottinghamtec.co.uk', 'pyrigs.herokuapp.com']

if STAGING:
Expand All @@ -45,7 +46,8 @@

INTERNAL_IPS = ['127.0.0.1']

ADMINS = [('Tom Price', 'tomtom5152@gmail.com'), ('IT Manager', 'it@nottinghamtec.co.uk'), ('Arona Jones', 'arona.jones@nottinghamtec.co.uk')]
ADMINS = [('Tom Price', 'tomtom5152@gmail.com'), ('IT Manager', 'it@nottinghamtec.co.uk'),
('Arona Jones', 'arona.jones@nottinghamtec.co.uk')]
if DEBUG:
ADMINS.append(('Testing Superuser', 'superuser@example.com'))

Expand All @@ -57,6 +59,9 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'versioning',
'users',
'RIGS',
'assets',

Expand Down Expand Up @@ -147,6 +152,27 @@
}
}

# Tests lock up SQLite otherwise
if STAGING or CI:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
}
}
elif DEBUG:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache'
}
}
else:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'cache_table',
}
}

RAVEN_CONFIG = {
'dsn': os.environ.get('RAVEN_DSN'),
# If you are using git, you can also automatically configure the
Expand All @@ -164,8 +190,10 @@
ACCOUNT_ACTIVATION_DAYS = 7

# reCAPTCHA settings
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', "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe") # If not set, use development key
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',
"6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe") # If not set, use development key
NOCAPTCHA = True

SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error']
Expand Down Expand Up @@ -201,10 +229,10 @@

USE_TZ = True

# Need to allow seconds as datetime-local input type spits out a time that has seconds
DATETIME_INPUT_FORMATS = ('%Y-%m-%dT%H:%M', '%Y-%m-%dT%H:%M:%S')

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
Expand All @@ -216,7 +244,7 @@
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
os.path.join(BASE_DIR, 'templates')
],
'APP_DIRS': True,
'OPTIONS': {
Expand All @@ -243,3 +271,6 @@
'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)

IMGUR_UPLOAD_CLIENT_ID = os.environ.get('IMGUR_UPLOAD_CLIENT_ID', '')
IMGUR_UPLOAD_CLIENT_SECRET = os.environ.get('IMGUR_UPLOAD_CLIENT_SECRET', '')
65 changes: 64 additions & 1 deletion PyRIGS/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,31 @@
from RIGS import models as rigsmodels
from . import pages
import os
import pytz
from datetime import date, time, datetime, timedelta
from django.conf import settings
import imgurpython
import PyRIGS.settings
import sys
import pathlib
import inspect


def create_datetime(year, month, day, hour, min):
tz = pytz.timezone(settings.TIME_ZONE)
return tz.localize(datetime(year, month, day, hour, min)).astimezone(pytz.utc)


def create_browser():
options = webdriver.ChromeOptions()
options.add_argument("--window-size=1920,1080")
if os.environ.get('CI', False):
# No caching, please and thank you
options.add_argument("--aggressive-cache-discard")
options.add_argument("--disk-cache-size=0")
# God Save The Queen
options.add_argument("--lang=en_GB")
options.add_argument("--headless")
if os.environ.get('CI', False):
options.add_argument("--no-sandbox")
driver = webdriver.Chrome(options=options)
return driver
Expand All @@ -34,3 +52,48 @@ def setUp(self):
self.profile.save()
loginPage = pages.LoginPage(self.driver, self.live_server_url).open()
loginPage.login("EventTest", "EventTestPassword")


def screenshot_failure(func):
def wrapper_func(self, *args, **kwargs):
try:
func(self, *args, **kwargs)
except Exception as e:
screenshot_name = func.__module__ + "." + func.__qualname__
screenshot_file = "screenshots/" + func.__qualname__ + ".png"
if not pathlib.Path("screenshots").is_dir():
os.mkdir("screenshots")
self.driver.save_screenshot(screenshot_file)

if settings.IMGUR_UPLOAD_CLIENT_ID != "":
config = {
'album': None,
'name': screenshot_name,
'title': screenshot_name,
'description': ""
}
client = imgurpython.ImgurClient(settings.IMGUR_UPLOAD_CLIENT_ID, settings.IMGUR_UPLOAD_CLIENT_SECRET)
image = client.upload_from_path(screenshot_file, config=config)
print("Error in test {} is at url {}".format(screenshot_name, image['link']), file=sys.stderr)
else:
print("Error in test {} is at path {}".format(screenshot_name, screenshot_file), file=sys.stderr)
raise e
return wrapper_func


def screenshot_failure_cls(cls):
for attr in cls.__dict__:
if callable(getattr(cls, attr)) and attr.startswith("test"):
setattr(cls, attr, screenshot_failure(getattr(cls, attr)))
return cls


# Checks if animation is done
class animation_is_finished():
def __call__(self, driver):
numberAnimating = driver.execute_script('return $(":animated").length')
finished = numberAnimating == 0
if finished:
import time
time.sleep(0.1)
return finished
12 changes: 9 additions & 3 deletions PyRIGS/tests/pages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pypom import Page, Region
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver import Chrome
from selenium.common.exceptions import NoSuchElementException
Expand Down Expand Up @@ -30,14 +31,19 @@ def __setattr__(self, name, value):

class FormPage(BasePage):
_errors_selector = (By.CLASS_NAME, "alert-danger")
_submit_locator = (By.XPATH, "//button[@type='submit' and contains(., 'Save')]")

def remove_all_required(self):
self.driver.execute_script("Array.from(document.getElementsByTagName(\"input\")).forEach(function (el, ind, arr) { el.removeAttribute(\"required\")});")
self.driver.execute_script("Array.from(document.getElementsByTagName(\"select\")).forEach(function (el, ind, arr) { el.removeAttribute(\"required\")});")
self.driver.execute_script(
"Array.from(document.getElementsByTagName(\"input\")).forEach(function (el, ind, arr) { el.removeAttribute(\"required\")});")
self.driver.execute_script(
"Array.from(document.getElementsByTagName(\"select\")).forEach(function (el, ind, arr) { el.removeAttribute(\"required\")});")

def submit(self):
previous_errors = self.errors
self.find_element(*self._submit_locator).click()
submit = self.find_element(*self._submit_locator)
ActionChains(self.driver).move_to_element(submit).perform()
submit.click()
self.wait.until(lambda x: self.errors != previous_errors or self.success)

@property
Expand Down
Loading