Skip to content

Commit

Permalink
Merge pull request #2071 from MIT-LCP/trainings_rearrange
Browse files Browse the repository at this point in the history
Rearranged the training frontend into certification & training
  • Loading branch information
tompollard authored Sep 12, 2023
2 parents fd07a2f + 122b71e commit ab4e43d
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 128 deletions.
30 changes: 30 additions & 0 deletions physionet-django/user/templates/user/edit_certification.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends "user/settings.html" %}

{% block title %}{{ SITE_NAME }} Certification{% endblock %}

{% block main_content %}
<h1>Certification</h1>
<hr>
<p>To gain access to certain datasets on {{ SITE_NAME }}, you are required to demonstrate that you have completed relevant training. You can find specific training requirements in the "Files" section of the project description.</p>
<h6> To submit a new completion report, please go to the <a href="{% url 'edit_training' %}">Training</a> page.</h6>
<hr>

{% for status, group in training_by_status.items %}
<div class="mb-3">
<h4>{{ status|capfirst }}</h4>
<ul class="list-group list-group-flush">
{% for course in group %}
<li class="list-group-item d-flex align-items-center justify-content-between">
<div>
{{ course.training_type.name }}
</div>
<a href="{% url 'edit_training_detail' course.id %}" class="btn btn-sm btn-primary" role="button">View</a>
</li>
{% empty %}
<p>N/A</p>
{% endfor %}
</ul>
</div>
{% endfor %}

{% endblock %}
49 changes: 5 additions & 44 deletions physionet-django/user/templates/user/edit_training.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,11 @@
{% block main_content %}
<h1>Training</h1>
<hr>
<p>To gain access to certain datasets on {{ SITE_NAME }}, you are required to demonstrate that you have completed relevant training. You can find specific training requirements in the "Files" section of the project description.</p>

{% for status, group in training_by_status.items %}
{% if not status == 'under review' %}
<div class="mb-3">
<h4>{{ status|capfirst }}</h4>
<ul class="list-group list-group-flush">
{% for course in group %}
<li class="list-group-item d-flex align-items-center justify-content-between">
<div>
{{ course.training_type.name }}
</div>
<a href="{% url 'edit_training_detail' course.id %}" class="btn btn-sm btn-primary" role="button">View</a>
</li>
{% empty %}
<p>N/A</p>
{% endfor %}
</ul>
</div>
{% endif %}
{% endfor %}

<p>To gain access to certain datasets on {{ SITE_NAME }}, you are required to demonstrate that you have completed relevant training. You can find specific training requirements in the "Files" section of the project description.</p>

<h6>You can view the status of your training submissions on the <a href="{% url 'edit_certification' %}">Certification</a> page.</h6>
<hr>
<h4>Submit evidence of a completed course</h4>

{% for status, group in training_by_status.items %}
{% if status == 'under review' and group %}
<div class="mb-3">
<div class="alert alert-warning">
The following training is under review:
<ul class="list-group list-group-flush">
{% for course in group %}
<li class="d-flex align-items-center justify-content-between">
<div>
{{ course.training_type.name }}
</div>
<a href="{% url 'edit_training_detail' course.id %}" class="btn btn-sm btn-primary" role="button">View</a>
</li>
{% endfor %}
</div>
</ul>
</div>
{% endif %}
{% endfor %}
<h4>Submit evidence of a completed Training</h4>

<p>Please use the form below to submit a new completion report.</p>
<p>For CITI training, please refer to our <a href="{% url "citi_course" %}" target="_blank">step-by-step instructions</a> and
Expand All @@ -70,7 +31,7 @@ <h5 class="modal-title">Submit Training</h5>
</button>
</div>
<div class="modal-body">
<p>Are you sure you want to submit the training?</p>
<p>Are you sure you want to submit the Training?</p>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Submit Training</button>
Expand Down
3 changes: 2 additions & 1 deletion physionet-django/user/templatetags/user_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

@register.inclusion_tag('user/settings_tabs.html')
def settings_tabs(hide_password_settings: bool):
default_tabs = ['Profile', 'Emails', 'Username', 'Cloud', 'ORCID', 'Credentialing', 'Training', 'Agreements']
default_tabs = ['Profile', 'Emails', 'Username', 'Cloud', 'ORCID', 'Credentialing', 'Training',
'Certification', 'Agreements']
if not hide_password_settings:
default_tabs.insert(1, 'Password')
return {'settings_tabs': default_tabs}
Expand Down
177 changes: 110 additions & 67 deletions physionet-django/user/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,89 +7,132 @@


urlpatterns = [
path('login/', login_view, name='login'),

path('logout/', views.logout, name='logout'),

path("login/", login_view, name="login"),
path("logout/", views.logout, name="logout"),
# Settings
path('settings/', views.user_settings, name='user_settings'),
path('settings/profile/', views.edit_profile, name='edit_profile'),
path('settings/emails/', views.edit_emails, name='edit_emails'),
path('settings/username/', views.edit_username, name='edit_username'),
path('settings/cloud/', views.edit_cloud, name='edit_cloud'),
path('settings/orcid/', views.edit_orcid, name='edit_orcid'),
path('authorcid/', views.auth_orcid, name='auth_orcid'),
path('settings/credentialing/', views.edit_credentialing, name='edit_credentialing'),
path('settings/credentialing/applications/',
views.user_credential_applications, name='user_credential_applications'),
path('settings/training/', views.edit_training, name='edit_training'),
path('settings/training/<int:training_id>/', views.edit_training_detail, name='edit_training_detail'),
path('settings/agreements/', views.view_agreements, name='edit_agreements'),
path('settings/agreements/<int:dua_signature_id>/', views.view_signed_agreement, name='view_signed_agreement'),

path("settings/", views.user_settings, name="user_settings"),
path("settings/profile/", views.edit_profile, name="edit_profile"),
path("settings/emails/", views.edit_emails, name="edit_emails"),
path("settings/username/", views.edit_username, name="edit_username"),
path("settings/cloud/", views.edit_cloud, name="edit_cloud"),
path("settings/orcid/", views.edit_orcid, name="edit_orcid"),
path("authorcid/", views.auth_orcid, name="auth_orcid"),
path(
"settings/credentialing/", views.edit_credentialing, name="edit_credentialing"
),
path(
"settings/credentialing/applications/",
views.user_credential_applications,
name="user_credential_applications",
),
path(
"settings/certification/", views.edit_certification, name="edit_certification"
),
path("settings/training/", views.edit_training, name="edit_training"),
path(
"settings/training/<int:training_id>/",
views.edit_training_detail,
name="edit_training_detail",
),
path("settings/agreements/", views.view_agreements, name="edit_agreements"),
path(
"settings/agreements/<int:dua_signature_id>/",
views.view_signed_agreement,
name="view_signed_agreement",
),
# Current tokens are 20 characters long and consist of 0-9A-Za-z
# Obsolete tokens are 34 characters long and also include a hyphen
re_path(r'^verify/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[-0-9A-Za-z]{1,34})/$',
views.verify_email, name='verify_email'),


re_path(
r"^verify/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[-0-9A-Za-z]{1,34})/$",
views.verify_email,
name="verify_email",
),
# Public user profile
path('users/<username>/', views.public_profile,
name='public_profile'),
path('users/<username>/profile-photo/', views.profile_photo,
name='profile_photo'),
path('credential-application/', views.credential_application,
name='credential_application'),
path("users/<username>/", views.public_profile, name="public_profile"),
path("users/<username>/profile-photo/", views.profile_photo, name="profile_photo"),
path(
"credential-application/",
views.credential_application,
name="credential_application",
),
# TODO: remove this after 30 days of commit merge, we want let the old links that was sent to the referees work
path('credential-reference/<application_slug>/',
views.credential_reference, name='credential_reference'),
path('credential-reference/<application_slug>/<verification_token>/',
views.credential_reference_verification, name='credential_reference_verification'),
path('trainings/<int:training_id>/report/', views.training_report, name='training_report'),
path(
"credential-reference/<application_slug>/",
views.credential_reference,
name="credential_reference",
),
path(
"credential-reference/<application_slug>/<verification_token>/",
views.credential_reference_verification,
name="credential_reference_verification",
),
path(
"trainings/<int:training_id>/report/",
views.training_report,
name="training_report",
),
]

if not settings.ENABLE_SSO:
urlpatterns.extend([
path('register/', views.register, name='register'),
path('settings/password/', views.edit_password, name='edit_password'),
path('settings/password/changed/', views.edit_password_complete, name='edit_password_complete'),
re_path(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,32})/$',
urlpatterns.extend(
[
path("register/", views.register, name="register"),
path("settings/password/", views.edit_password, name="edit_password"),
path(
"settings/password/changed/",
views.edit_password_complete,
name="edit_password_complete",
),
re_path(
r"^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,32})/$",
views.activate_user,
name='activate_user'),
# Request password reset
path('reset-password/', views.reset_password_request,
name='reset_password_request'),
# Page shown after reset email has been sent
path('reset-password/sent/', views.reset_password_sent,
name='reset_password_sent'),
# Prompt user to enter new password and carry out password reset (if url is valid)
re_path(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,32})/$',
views.reset_password_confirm, name='reset_password_confirm'),
# Password reset successfully carried out
path('reset/complete/', views.reset_password_complete,
name='reset_password_complete'),
])
name="activate_user",
),
# Request password reset
path(
"reset-password/",
views.reset_password_request,
name="reset_password_request",
),
# Page shown after reset email has been sent
path(
"reset-password/sent/",
views.reset_password_sent,
name="reset_password_sent",
),
# Prompt user to enter new password and carry out password reset (if url is valid)
re_path(
r"^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,32})/$",
views.reset_password_confirm,
name="reset_password_confirm",
),
# Password reset successfully carried out
path(
"reset/complete/",
views.reset_password_complete,
name="reset_password_complete",
),
]
)

# Parameters for testing URLs (see physionet/test_urls.py)
TEST_DEFAULTS = {
'_user_': 'aewj',
'training_id': 106,
'dua_signature_id': 1,
'application_slug': 'Osm0FMaavviixpsL26v2',
'verification_token': 'rJ2i7vlzh6AgZ1Wwtcz8zCoI5BqxH0kU',
'username': 'rgmark',
"_user_": "aewj",
"training_id": 106,
"dua_signature_id": 1,
"application_slug": "Osm0FMaavviixpsL26v2",
"verification_token": "rJ2i7vlzh6AgZ1Wwtcz8zCoI5BqxH0kU",
"username": "rgmark",
}
TEST_CASES = {
'verify_email': {
'uidb64': 'MjEx',
'token': 'oax3ZcG47GYUhAobbJyp',
"verify_email": {
"uidb64": "MjEx",
"token": "oax3ZcG47GYUhAobbJyp",
},

# Testing activate_user and reset_password_confirm requires a
# dynamically-generated token. Skip these URLs for now.
'activate_user': {'uidb64': 'x', 'token': 'x', '_skip_': True},
'reset_password_confirm': {'uidb64': 'x', 'token': 'x', '_skip_': True},

"activate_user": {"uidb64": "x", "token": "x", "_skip_": True},
"reset_password_confirm": {"uidb64": "x", "token": "x", "_skip_": True},
# Testing auth_orcid requires a mock oauth server. Skip this URL.
'auth_orcid': {'_skip_': True},
"auth_orcid": {"_skip_": True},
}
Loading

0 comments on commit ab4e43d

Please sign in to comment.