History
diff --git a/capstone/capapi/views/user_views.py b/capstone/capapi/views/user_views.py
index 4b7f46ea7..2c5e0c30b 100644
--- a/capstone/capapi/views/user_views.py
+++ b/capstone/capapi/views/user_views.py
@@ -167,6 +167,9 @@ def user_history(request):
@user_has_harvard_email()
def request_harvard_research_access_intro(request):
""" Warning shown before Harvard access page """
+ if settings.DISABLE_SIGNUPS:
+ return HttpResponseRedirect('/')
+
return render(request, 'research_request/harvard_research_request_intro.html')
@@ -174,6 +177,9 @@ def request_harvard_research_access_intro(request):
@user_has_harvard_email()
def request_harvard_research_access(request):
""" Sign Harvard-email based contract """
+ if settings.DISABLE_SIGNUPS:
+ return HttpResponseRedirect('/')
+
name = "%s %s" % (request.user.first_name, request.user.last_name)
form = form_for_request(request, HarvardContractForm, initial={'name': name, 'email': request.user.email})
@@ -207,6 +213,9 @@ def request_harvard_research_access(request):
@login_required
def request_research_access(request):
""" Sign academic/nonprofit based contract """
+ if settings.DISABLE_SIGNUPS:
+ return HttpResponseRedirect('/')
+
name = "%s %s" % (request.user.first_name, request.user.last_name)
form = form_for_request(request, ResearchContractForm, initial={'name': name, 'email': request.user.email})
diff --git a/capstone/capweb/helpers.py b/capstone/capweb/helpers.py
index 6564ffa29..3f2d5b825 100644
--- a/capstone/capweb/helpers.py
+++ b/capstone/capweb/helpers.py
@@ -172,13 +172,19 @@ def send_contact_email(title, content, from_address):
).send(fail_silently=False)
-def user_has_harvard_email(failure_url='non-harvard-email'):
+def user_has_harvard_email(failure_url=None):
"""
Decorator to forward user if they don't have Harvard email. E.g.:
@user_has_harvard_email()
def my_view(request):
"""
+ if not failure_url:
+ if settings.DISABLE_SIGNUPS:
+ failure_url = '/'
+ else:
+ failure_url = 'non-harvard-email'
+
return user_passes_test(
test_func=lambda u: bool(re.search(r'[.@]harvard.edu$', u.email)),
login_url=failure_url)
diff --git a/capstone/capweb/urls.py b/capstone/capweb/urls.py
index 6fede3d22..2449ddb71 100644
--- a/capstone/capweb/urls.py
+++ b/capstone/capweb/urls.py
@@ -86,7 +86,6 @@
path('user/delete-account', user_views.delete_account, name='delete_account'),
# research access requests
- path('user/research/', TemplateView.as_view(template_name='research_request/index.html'), name='research-options'),
path('user/research/approve/', user_views.approve_research_access, name='research-approval'),
path('user/research/apply/', user_views.request_research_access,
name='research-request'),
@@ -95,14 +94,19 @@
name='research-request-success'),
path('user/research/harvard-intro/', user_views.request_harvard_research_access_intro,
name='harvard-research-request-intro'),
- path('user/research/non-harvard-email/',
- TemplateView.as_view(template_name='research_request/non_harvard_email.html'), name='non-harvard-email'),
path('user/research/harvard/', user_views.request_harvard_research_access, name='harvard-research-request'),
path('user/research/harvard-success/',
TemplateView.as_view(template_name='research_request/harvard_research_request_success.html'),
name='harvard-research-request-success'),
]
+if not settings.DISABLE_SIGNUPS:
+ urlpatterns += [
+ path('user/research/', TemplateView.as_view(template_name='research_request/index.html'), name='research-options'),
+ path('user/research/non-harvard-email/',
+ TemplateView.as_view(template_name='research_request/non_harvard_email.html'), name='non-harvard-email'),
+ ]
+
if settings.DEBUG:
# debugging routes to see error pages
# for example, http://case.test:8000/404.html shows 404 page