Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2210 from rebeccacremona/researcher-button
Browse files Browse the repository at this point in the history
Remove info about special "researcher" access and disable forms.
  • Loading branch information
rebeccacremona authored Mar 7, 2024
2 parents e06fa94 + 683cd3a commit f5b0429
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
34 changes: 18 additions & 16 deletions capstone/capapi/templates/registration/user-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,27 @@
<span class="case-number">{{ request.user.total_case_allowance }}</span> total per day
</div>
</div>
<div class="row">
<div class="h5 col-sm-12">Unrestricted access</div>
<div class="col-sm-12">
{% if research_contract %}
You submitted an application for unrestricted access on
{{ research_contract.user_signature_date|date:"F j, Y" }}.
{% if research_contract.status == "denied" %}
Your application was denied by LexisNexis. Please contact us if you would like to discuss further options.
{% if not DISABLE_SIGNUPS %}
<div class="row">
<div class="h5 col-sm-12">Unrestricted access</div>
<div class="col-sm-12">
{% if research_contract %}
You submitted an application for unrestricted access on
{{ research_contract.user_signature_date|date:"F j, Y" }}.
{% if research_contract.status == "denied" %}
Your application was denied by LexisNexis. Please contact us if you would like to discuss further options.
{% else %}
Your application is pending.
{% endif %}
{% elif research_request %}
You submitted a request for unrestricted access on {{ research_request.submitted_date }}
{% else %}
Your application is pending.
Are you a research scholar? <br/>
<a href="{% url 'research-options' %}">Request access</a>
{% endif %}
{% elif research_request %}
You submitted a request for unrestricted access on {{ research_request.submitted_date }}
{% else %}
Are you a research scholar? <br/>
<a href="{% url 'research-options' %}">Request access</a>
{% endif %}
</div>
</div>
</div>
{% endif %}
{% endif %}
<div class="row">
<div class="h5 col-sm-12">History</div>
Expand Down
9 changes: 9 additions & 0 deletions capstone/capapi/views/user_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,19 @@ 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')


@login_required
@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})

Expand Down Expand Up @@ -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})

Expand Down
8 changes: 7 additions & 1 deletion capstone/capweb/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions capstone/capweb/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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
Expand Down

0 comments on commit f5b0429

Please sign in to comment.