Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on Tuesday 26 May 2020 starting at approximately 10am CDT. It is expected to take around 30 minutes and will involve a short period of downtime, around 5 minutes, towards the end of the maintenance period. Please address any questions, comments, or concerns to uwm-help@cgca.uwm.edu.

Commit 43b683b2 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Add decorator for LV-EM only access

parent 8cee1ae4
......@@ -25,3 +25,26 @@ def internal_user_required(function=None, raise_exception=True, **kwargs):
if function:
return actual_decorator(function)
return actual_decorator
def lvem_observers_only(function=None, login_url=None, superuser_allowed=False,
raise_exception=True):
"""Allow access only to non-LVC LV-EM observers"""
def check_groups(user):
in_lvem_obs = user.groups.filter(
name=settings.LVEM_OBSERVERS_GROUP).exists()
in_lvc = user.groups.filter(name=settings.LVC_GROUP).exists()
if ((in_lvem_obs and not in_lvc) or
(superuser_allowed and user.is_superuser)):
return True
if raise_exception:
raise PermissionDenied
return False
actual_decorator = user_passes_test(check_groups, login_url=login_url)
if function:
return actual_decorator(function)
return actual_decorator
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment