TNL-7148
This adds another field to the CourseOverviewTab model to support external links.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2.12 on 2020-04-21 15:46
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('course_overviews', '0020_courseoverviewtab_url_slug'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='courseoverviewtab',
|
||||
name='link',
|
||||
field=models.TextField(null=True),
|
||||
),
|
||||
]
|
||||
@@ -59,7 +59,7 @@ class CourseOverview(TimeStampedModel):
|
||||
app_label = 'course_overviews'
|
||||
|
||||
# IMPORTANT: Bump this whenever you modify this model and/or add a migration.
|
||||
VERSION = 9
|
||||
VERSION = 10
|
||||
|
||||
# Cache entry versioning.
|
||||
version = IntegerField()
|
||||
@@ -261,6 +261,7 @@ class CourseOverview(TimeStampedModel):
|
||||
name=tab.name,
|
||||
course_staff_only=tab.course_staff_only,
|
||||
url_slug=tab.get('url_slug'),
|
||||
link=tab.get('link'),
|
||||
course_overview=course_overview)
|
||||
for tab in course.tabs
|
||||
])
|
||||
@@ -862,6 +863,7 @@ class CourseOverviewTab(models.Model):
|
||||
name = models.TextField(null=True)
|
||||
course_staff_only = models.BooleanField(default=False)
|
||||
url_slug = models.TextField(null=True)
|
||||
link = models.TextField(null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.tab_id
|
||||
|
||||
@@ -12,6 +12,7 @@ from lms.djangoapps.courseware.access_utils import (
|
||||
ACCESS_DENIED,
|
||||
ACCESS_GRANTED
|
||||
)
|
||||
from lms.djangoapps.courseware.tabs import ExternalLinkCourseTab
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
from xmodule.modulestore.tests.django_utils import (
|
||||
@@ -40,6 +41,7 @@ class BaseCoursewareTests(SharedModuleStoreTestCase):
|
||||
emit_signals=True,
|
||||
modulestore=cls.store,
|
||||
)
|
||||
|
||||
cls.user = UserFactory(
|
||||
username='student',
|
||||
email=u'user@example.com',
|
||||
@@ -63,6 +65,12 @@ class CourseApiTestViews(BaseCoursewareTests):
|
||||
"""
|
||||
Tests for the courseware REST API
|
||||
"""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
BaseCoursewareTests.setUpClass()
|
||||
cls.course.tabs.append(ExternalLinkCourseTab.load('external_link', name='Zombo', link='http://zombo.com'))
|
||||
cls.store.update_item(cls.course, cls.user.id)
|
||||
|
||||
@ddt.data(
|
||||
(True, None, ACCESS_DENIED),
|
||||
(True, 'audit', ACCESS_DENIED),
|
||||
@@ -85,7 +93,14 @@ class CourseApiTestViews(BaseCoursewareTests):
|
||||
enrollment = response.data['enrollment']
|
||||
assert enrollment_mode == enrollment['mode']
|
||||
assert enrollment['is_active']
|
||||
assert len(response.data['tabs']) == 4
|
||||
assert len(response.data['tabs']) == 5
|
||||
found = False
|
||||
for tab in response.data['tabs']:
|
||||
if tab['type'] == 'external_link' and tab['url'] == 'http://zombo.com':
|
||||
found = True
|
||||
break
|
||||
else:
|
||||
assert found, 'external link not in course tabs'
|
||||
elif enable_anonymous and not logged_in:
|
||||
# multiple checks use this handler
|
||||
check_public_access.assert_called()
|
||||
|
||||
Reference in New Issue
Block a user