Commit 45b26d08 by Asad Azam Committed by AsadAzam

Ordered subjects in course metadata courses

parent 925bc682
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-01-26 12:04
from __future__ import unicode_literals
import sortedm2m.fields
from django.db import migrations
from sortedm2m.operations import AlterSortedManyToManyField
class Migration(migrations.Migration):
dependencies = [
('course_metadata', '0076_auto_20171219_1841'),
]
operations = [
AlterSortedManyToManyField(
model_name='course',
name='subjects',
field=sortedm2m.fields.SortedManyToManyField(blank=True, help_text=None, to='course_metadata.Subject'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-02-09 10:44
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('course_metadata', '0077_auto_20180131_1956'),
('course_metadata', '0077_auto_20180126_1204'),
]
operations = [
]
......@@ -340,7 +340,7 @@ class Course(TimeStampedModel):
full_description = models.TextField(default=None, null=True, blank=True)
authoring_organizations = SortedManyToManyField(Organization, blank=True, related_name='authored_courses')
sponsoring_organizations = SortedManyToManyField(Organization, blank=True, related_name='sponsored_courses')
subjects = models.ManyToManyField(Subject, blank=True)
subjects = SortedManyToManyField(Subject, blank=True)
prerequisites = models.ManyToManyField(Prerequisite, blank=True)
level_type = models.ForeignKey(LevelType, default=None, null=True, blank=True)
expected_learning_items = SortedManyToManyField(ExpectedLearningItem, blank=True)
......
import logging
from collections import OrderedDict
from edx_rest_api_client.client import EdxRestApiClient
from edx_rest_framework_extensions.authentication import JwtAuthentication
from rest_framework import permissions, serializers, status, viewsets
......@@ -112,11 +113,12 @@ class CourseRunViewSet(viewsets.GenericViewSet):
discovery_course.image.save(publisher_course.image.name, publisher_course.image.file)
discovery_course.authoring_organizations.add(*publisher_course.organizations.all())
subjects = [subject for subject in set([
subjects = [subject for subject in [
publisher_course.primary_subject,
publisher_course.secondary_subject,
publisher_course.tertiary_subject
]) if subject]
] if subject]
subjects = list(OrderedDict.fromkeys(subjects))
discovery_course.subjects.add(*subjects)
defaults = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment