fmartingr
/
shelfzilla
Archived
1
0
Fork 0
This repository has been archived on 2021-06-29. You can view files and clone it, but cannot push or open issues or pull requests.
shelfzilla/shelfzilla/middleware.py

15 lines
528 B
Python

from django.http import HttpResponseRedirect
from django.conf import settings
class BetaMiddleware(object):
"""
Allow access only to people on the Beta group.
"""
def process_request(self, request):
beta_group_id = settings.BETA_ACCESS_GROUP_ID
if request.user and not request.user.is_superuser:
if not request.user.groups.filter(pk=beta_group_id):
if request.path not in settings.BETA_ACCESS_ALLOW_URLS:
return HttpResponseRedirect('/landing/')