Require users to have nottinghamtec.co.uk address before allowing them to send messages to clients

This commit is contained in:
David Taylor
2017-05-10 15:39:13 +01:00
parent 6b05938953
commit 286e4314f5
4 changed files with 47 additions and 3 deletions

View File

@@ -79,3 +79,17 @@ def api_key_required(function):
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_to_response('RIGS/eventauthorisation_request_error.html', context_instance=RequestContext(request))
return error_resp
return function(request, *args, **kwargs)
return wrap