Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Update link to prod site, and add passable copy.
  Fix list in base settings and middleware in test settings.
  Add fa_info app to course manager.
  • Loading branch information
cmurtaugh committed Jan 22, 2020
2 parents 761ee3c + 617696a commit 6177689
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ secure*.py*
!secure.py.j2
data/
http_static/
cert.pem
key.pem
.envrc
3 changes: 2 additions & 1 deletion canvas_manage_course/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
'django.contrib.postgres',
'django.contrib.staticfiles',
'django_auth_lti',
'fa_info',
'icommons_common',
'icommons_common.monitor',
'icommons_ui',
Expand Down Expand Up @@ -303,6 +304,7 @@
LTI_SCHOOL_PERMISSIONS_TOOL_PERMISSIONS = (
'canvas_manage_course', # dashboard
'class_roster',
'fa_info',
'manage_people',
'manage_sections'
)
Expand Down Expand Up @@ -335,4 +337,3 @@
# Default to False, but if testing locally, set to True
ICOMMONS_REST_API_SKIP_CERT_VERIFICATION = SECURE_SETTINGS.get(
'icommons_rest_api_skip_cert_verification', False)

6 changes: 3 additions & 3 deletions canvas_manage_course/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
redis/elasticache. Let's disable the caching middleware, and use the db
to store session data.
"""
MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
MIDDLEWARE_CLASSES[MIDDLEWARE_CLASSES.index('cached_auth.Middleware')] = \
MIDDLEWARE = list(MIDDLEWARE)
MIDDLEWARE[MIDDLEWARE.index('cached_auth.Middleware')] = \
'django.contrib.auth.middleware.AuthenticationMiddleware'
MIDDLEWARE_CLASSES = tuple(MIDDLEWARE_CLASSES)
MIDDLEWARE = tuple(MIDDLEWARE)
SESSION_ENGINE = 'django.contrib.sessions.backends.db'

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ p {
.card_color5 {
border-bottom-color: #FF2FEB;
}
.card_color6 {
border-bottom-color: #D16103;
}
.card_disabled {
border-bottom-color: #ccc;
cursor: default;
Expand Down Expand Up @@ -109,6 +112,9 @@ p {
.card-header_color5 {
background-color: #FF2FEB;
}
.card-header_color6 {
background-color: #D16103;
}
.card-header_disabled {
background-color:#ccc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,27 @@ <h2 class="card-content-title ellipsis" title="Add apps to Canvas">
</a>
</div>
{% endif %}

{% if allowed.fa_info %}
<div class="card card_color6">
<a href="{% url 'fa_info:index' %}" id="fa-info" target="_blank">
<div class="card-body">
<div class="card-header card-header_color6">
</div>
<div class="card-content card-content_normal">
<h2 class="card-content-title ellipsis" title="FA Info Link">
<span class="content-link">
Final Assessment Form
</span>
</h2>
<p title="FA Info link">
Go to this course's FAINFO page.
</p>
</div>
</div>
</a>
</div>
{% endif %}
{% endif %}
</main>

Expand Down
2 changes: 1 addition & 1 deletion canvas_manage_course/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

path('course_dashboard', views.dashboard_course, name='dashboard_course'),
path('class_roster/', include(('class_roster.urls','class_roster'), namespace='class_roster')),
path('fa_info/', include(('fa_info.urls','fa_info'), namespace='fa_info')),
path('lti_auth_error', icommons_ui_views.not_authorized, name='lti_auth_error'),
path('lti_launch', views.lti_launch, name='lti_launch'),

Expand All @@ -30,4 +31,3 @@
]
except:
pass

3 changes: 2 additions & 1 deletion canvas_manage_course/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def dashboard_course(request):
'class_roster',
'manage_people',
'manage_sections',
'custom_fas_card_1']
'custom_fas_card_1',
'fa_info']
# Verify current user permissions to see the apps on the dashboard
allowed = {tool: lti_permission_required_check(request, tool)
for tool in tool_access_permission_names}
Expand Down
Empty file added fa_info/__init__.py
Empty file.
33 changes: 33 additions & 0 deletions fa_info/templates/fa_info/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends 'canvas_manage_course/base.html' %}

{% load static %}

{% block stylesheet %}
{{ block.super }}
<link href="{% static 'canvas_manage_course/css/dashboard.css' %}"
rel="stylesheet"/>
{% endblock stylesheet %}


{% block dashboard_breadcrumb %}
<nav>
<h1>
<a href="{% url 'dashboard_course' %}">Manage Course</a>&nbsp;
<small><i class="fa fa-chevron-right"></i></small>&nbsp;Final Assessment Form
</h1>
</nav>
{% endblock dashboard_breadcrumb %}


{% block tool_content %}
<main>
<div id="content" role="main">
We were unable to route you directly to this course's Final Assessment Form
in my.harvard. You can follow the instructions on
<a href="https://harvard.service-now.com/ithelp?id=kb_article&sys_id=e809be2a1bda8890efd8a79b2d4bcbb6">
this knowledge base article
</a>
to complete the form.
</div>
</main>
{% endblock tool_content %}
Empty file added fa_info/tests/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions fa_info/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from django.test import RequestFactory, TestCase
from icommons_common.models import Course, CourseInstance, Term
from mock import Mock

class FaInfoTestCase(TestCase):
def setUp(self):
self.resource_link_id = uuid.uuid4().hex
self.user_id = uuid.uuid4().hex
self.request = Mock(session={}, method='GET',
resource_link_id=self.resource_link_id)
elf.request.user = Mock(is_authenticated=Mock(return_value=True))
self.request.LTI = {
'lis_course_offering_sourcedid': self.course_instance_id,
'lis_person_sourcedid': self.user_id,
# 'resource_link_id': self.resource_link_id,
}

term = Term.objects.create(cs_strm=1234)
course = Course.objects.create(registrar_code='56k78')
CourseInstance.objects.create(course=course, term=term, course_instance_id=1)

def test_index_redirect(self):
pass

def test_index_redirect_fail(self):
pass
7 changes: 7 additions & 0 deletions fa_info/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path

from fa_info import views

urlpatterns = [
path('index', views.index, name='index'),
]
24 changes: 24 additions & 0 deletions fa_info/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect, render
from django.views.decorators.http import require_http_methods
from icommons_common.models import CourseInstance
from lti_school_permissions.decorators import lti_permission_required

@login_required
@lti_permission_required('fa_info')
@require_http_methods(['GET'])
def index(request):
""" Returns a redirect to the course's FAINFO page """
course_instance_id = request.LTI['lis_course_offering_sourcedid']
course_instance = CourseInstance.objects.get(course_instance_id=course_instance_id)

term_id = course_instance.term.cs_strm
course_id = course_instance.course.registrar_code
url = "https://portal.my.harvard.edu/psp/hrvihprd/EMPLOYEE/HRMS/c/HU_FINAL"\
"_ASSMNT.HU_FINAL_ASSMNT.GBL?Page=HU_EXAM_ROSTER_INS&Action=U&ExactKey"\
"s=Y&INSTITUTION=HRVRD&ACAD_CAREER=FAS&STRM={}&CRSE_ID={}".format(term_id, course_id)
if not term_id or not course_id:
return render(request, 'fa_info/index.html')
return redirect(url)


0 comments on commit 6177689

Please sign in to comment.