AA-36: Link to toggle calendar sync

This commit is contained in:
Dillon Dumesnil
2020-02-24 12:06:13 -05:00
parent 0c2dfd136e
commit a59155e83c
16 changed files with 318 additions and 32 deletions

View File

@@ -82,6 +82,9 @@ COURSE_ENABLE_UNENROLLED_ACCESS_FLAG = CourseWaffleFlag(SEO_WAFFLE_FLAG_NAMESPAC
# Waffle flag to enable relative dates for course content
RELATIVE_DATES_FLAG = ExperimentWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'relative_dates', experiment_id=17)
# Waffle flag to enable user calendar syncing
CALENDAR_SYNC_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'calendar_sync')
def course_home_page_title(course): # pylint: disable=unused-argument
"""

View File

@@ -3,12 +3,23 @@ Support for course tool plugins.
"""
from enum import Enum
from openedx.core.lib.plugins import PluginManager
# Stevedore extension point namespace
COURSE_TOOLS_NAMESPACE = 'openedx.course_tool'
class HttpMethod(Enum):
""" Enum for HTTP Methods """
DELETE = 'DELETE'
GET = 'GET'
OPTIONS = 'OPTIONS'
POST = 'POST'
PUT = 'PUT'
class CourseTool(object):
"""
This is an optional base class for Course Tool plugins.
@@ -18,6 +29,8 @@ class CourseTool(object):
not a requirement, and plugin implementations outside of this repo should
simply follow the contract defined below.
"""
http_method = HttpMethod.GET
@classmethod
def analytics_id(cls):
"""
@@ -57,6 +70,16 @@ class CourseTool(object):
"""
raise NotImplementedError("Must specify a url for a course tool.")
@classmethod
def data(cls):
"""
Additional data to send with a form submission
"""
if cls.http_method == HttpMethod.POST:
return {}
else:
return None
class CourseToolsPluginManager(PluginManager):
"""

View File

@@ -15,6 +15,7 @@ from lms.djangoapps.discussion.django_comment_client.permissions import has_perm
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
from openedx.core.djangolib.markup import Text, HTML
from openedx.features.course_experience import UNIFIED_COURSE_TAB_FLAG, SHOW_REVIEWS_TOOL_FLAG
from openedx.features.course_experience.course_tools import HttpMethod
%>
<%block name="header_extras">
@@ -114,10 +115,21 @@ from openedx.features.course_experience import UNIFIED_COURSE_TAB_FLAG, SHOW_REV
<ul class="list-unstyled">
% for course_tool in course_tools:
<li class="course-tool">
<a class="course-tool-link" data-analytics-id="${course_tool.analytics_id()}" href="${course_tool.url(course_key)}">
<span class="icon ${course_tool.icon_classes()}" aria-hidden="true"></span>
${course_tool.title()}
</a>
% if course_tool.http_method == HttpMethod.GET:
<a class="course-tool-link" data-analytics-id="${course_tool.analytics_id()}" href="${course_tool.url(course_key)}">
<span class="icon ${course_tool.icon_classes()}" aria-hidden="true"></span>
${course_tool.title()}
</a>
% elif course_tool.http_method == HttpMethod.POST:
<form class="course-tool-form" action="${course_tool.url(course_key)}" method="post">
<input type="hidden" id="csrf_token" name="csrfmiddlewaretoken" value="${csrf_token}">
<input type="hidden" name="tool_data" value="${course_tool.data()}">
<button class="course-tool-button" data-analytics-id="${course_tool.analytics_id()}" aria-hidden="true">
<span class="icon ${course_tool.icon_classes()}" aria-hidden="true"></span>
${course_tool.title()}
</button>
</form>
% endif
</li>
% endfor
</ul>

View File

@@ -4,7 +4,7 @@ from django.utils.translation import ugettext as _
<%page args="course_date" expression_filter="h"/>
<div class="date-summary date-summary-${course_date.css_class}">
<div class="left-column">
<div class="calendar-icon"></div>
<span class="icon fa fa-calendar" aria-hidden="true"></span>
</div>
<div class="right-column">
% if course_date.date: