Create new djangoapp and a new blank tab view.

This commit is contained in:
Diana Huang
2018-01-31 10:01:19 -05:00
parent f4a5a68568
commit 124e4c2ca1
6 changed files with 73 additions and 0 deletions

View File

@@ -2360,6 +2360,7 @@ INSTALLED_APPS = [
'openedx.features.enterprise_support.apps.EnterpriseSupportConfig',
'openedx.features.learner_profile',
'openedx.features.learner_analytics',
'openedx.features.portfolio_project',
'experiments',

View File

@@ -676,6 +676,14 @@ urlpatterns += [
),
include('openedx.features.learner_analytics.urls'),
),
# Portfolio project experiment
url(
r'^courses/{}/xfeature/portfolio/'.format(
settings.COURSE_ID_PATTERN,
),
include('openedx.features.portfolio_project.urls'),
),
]
if settings.FEATURES['ENABLE_TEAMS']:

View File

@@ -0,0 +1,10 @@
## mako
<%page expression_filter="h"/>
<%namespace name='static' file='../static_content.html'/>
<%block name="content">
<div class="course-view page-content-container" id="course-container">
</div>
</%block>
<%namespace name='static' file='../static_content.html'/>

View File

@@ -0,0 +1,15 @@
"""
Url setup for portfolio project.
"""
from django.conf.urls import url
from views import GenericTabView
urlpatterns = [
url(
r'^$',
GenericTabView.as_view(),
name='openedx.portfolio.generic_tab',
),
]

View File

@@ -0,0 +1,39 @@
"""
Portfolio views.
"""
from django.template.loader import render_to_string
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_control
from lms.djangoapps.courseware.views.views import CourseTabView
from util.views import ensure_valid_course_key
from web_fragments.fragment import Fragment
class GenericTabView(CourseTabView):
"""
Provides a blank page that acts as its own tab in courseware for displaying content.
"""
@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True))
@method_decorator(ensure_valid_course_key)
def get(self, request, course_id, **kwargs):
"""
Displays a generic tab for the specified course.
"""
return super(GenericTabView, self).get(request, course_id, 'courseware', **kwargs)
def render_to_fragment(self, request, course=None, tab=None, **kwargs):
"""
Render out the bootstrap page.
"""
context = {
'course': course,
'user': request.user,
'uses_bootstrap': True,
'tab_name': tab,
}
html = render_to_string('portfolio_project/generic_tab.html', context)
return Fragment(html)