Skip to content

Commit

Permalink
Merge pull request #1246 from MIT-LCP/citireportlink
Browse files Browse the repository at this point in the history
Display link to CITI training if available. Download PDF if not.
  • Loading branch information
Lucas-Mc authored Feb 3, 2021
2 parents 9cd9d06 + fe314ee commit dabf985
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ <h5>Location</h5>
<h5>Training</h5>

<ul>
<li>CITI report: <mark><a href="{% url 'training_report' application.slug %}" target="_blank">View file</a></mark></li>
{% if application.training_completion_report_url %}
<li>Report (CITI): <mark><a href="{{ application.training_completion_report_url }}" target="_blank">View file</a></mark></li>
{% else %}
<li>Report (Unknown): <mark><a href="{% url 'training_report' application.slug %}" target="_blank">Download</a></mark></li>
{% endif %}
</ul>

<h5>Reference</h5>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{# Status section #}
<p><a href="{% url 'training_report' application.slug %}" target="_blank">Training Completion Report</a><br></p>
<p><a href="{% url 'training_report_view' application.slug %}" target="_blank">Training Completion Report</a><br></p>

{# Personal details #}

Expand Down
2 changes: 2 additions & 0 deletions physionet-django/user/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@
views.credential_reference, name='credential_reference'),
path('credential-applications/<application_slug>/training-report/',
views.training_report, name='training_report'),
path('credential-applications/<application_slug>/training-report/view/',
views.training_report_view, name='training_report_view'),
]
14 changes: 12 additions & 2 deletions physionet-django/user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def credential_application(request):


@login_required
def training_report(request, application_slug):
def training_report(request, application_slug, attach=True):
"""
Serve a training report file
"""
Expand All @@ -561,13 +561,23 @@ def training_report(request, application_slug):

if request.user == application.user or request.user.is_admin:
try:
return utility.serve_file(application.training_completion_report.path, False)
return utility.serve_file(application.training_completion_report.path,
attach=attach)
except FileNotFoundError:
raise Http404()

raise PermissionDenied()


@login_required
def training_report_view(request, application_slug):
"""
Wrapper for training_report. Serves the training report in the browser
for KP's custom pages.
"""
return training_report(request, application_slug, attach=False)


# @login_required
def credential_reference(request, application_slug):
"""
Expand Down

0 comments on commit dabf985

Please sign in to comment.