Commit 7f106296 by Matt Drayer Committed by Zia Fazal

mattdrayer/rebase-20140701: Updated api to support opaque keys

Also contains:

* mattdrayer/rebase-20140722b: cherry-pick 0325694
* mattdrayer/rebase-20140722: cherry-pick e8b1217
* Sessions API Documentation
* mattdrayer/rebase-20140722: cherry-pick ofao48d
* mattdrayer/rebase-20140722: cherry-pick b0c343c
* mattdrayer/rebase-20140722: cherry-pick d56e973
* mattdrayer/status-500-fix: Small API bug
* added content_id to workgroup review submissions
* mattdrayer/api-user-preferences-delete: Added new Detail view, GET/DELETE operations
* mattdrayer/rebase-20140722: cherry-pick 0624385
* handle exception if user never accessed any course module
* mattdrayer/rebase-20140722: cherry-pick caada51
* cdodge/add-progress-publish-api-endpoint: expose a new xblock runtime publish special cased event type 'progress' which adds an entry into the CourseCompletions table
* add default setting for feature flag in common.py
* mattdrayer/rebase-20140722: cherry-pick 7a1e12c
* mattdrayer/rebase-20140722: Functional stabilization
parent 542b87cf
...@@ -7,6 +7,7 @@ import warnings ...@@ -7,6 +7,7 @@ import warnings
from django.db import models from django.db import models
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey, UsageKey, BlockTypeKey from opaque_keys.edx.keys import CourseKey, UsageKey, BlockTypeKey
from opaque_keys.edx.locator import Locator from opaque_keys.edx.locator import Locator
...@@ -105,7 +106,7 @@ class OpaqueKeyField(models.CharField): ...@@ -105,7 +106,7 @@ class OpaqueKeyField(models.CharField):
return None return None
if isinstance(value, basestring): if isinstance(value, basestring):
return self.KEY_CLASS.from_string(value) return SlashSeparatedCourseKey.from_deprecated_string(value)
else: else:
return value return value
...@@ -167,12 +168,10 @@ class LocationKeyField(UsageKeyField): ...@@ -167,12 +168,10 @@ class LocationKeyField(UsageKeyField):
super(LocationKeyField, self).__init__(*args, **kwargs) super(LocationKeyField, self).__init__(*args, **kwargs)
class BlockTypeKeyField(OpaqueKeyField): if isinstance(value, basestring):
""" return Location.from_deprecated_string(value)
A django Field that stores a BlockTypeKey object as a string. else:
""" return value
description = "A BlockTypeKey object, saved to the DB in the form of a string."
KEY_CLASS = BlockTypeKey
add_introspection_rules([], [r"^xmodule_django\.models\.CourseKeyField"]) add_introspection_rules([], [r"^xmodule_django\.models\.CourseKeyField"])
......
...@@ -71,19 +71,9 @@ class SequenceModule(SequenceFields, XModule): ...@@ -71,19 +71,9 @@ class SequenceModule(SequenceFields, XModule):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(SequenceModule, self).__init__(*args, **kwargs) super(SequenceModule, self).__init__(*args, **kwargs)
# If position is specified in system, then use that instead. # if position is specified in system, then use that instead
position = getattr(self.system, 'position', None) if getattr(self.system, 'position', None) is not None:
if position is not None: self.position = int(self.system.position)
try:
self.position = int(self.system.position)
except (ValueError, TypeError):
# Check for https://openedx.atlassian.net/browse/LMS-6496
warnings.warn(
"Sequential position cannot be converted to an integer: {pos!r}".format(
pos=self.system.position,
),
RuntimeWarning,
)
def get_progress(self): def get_progress(self):
''' Return the total progress, adding total done and total available. ''' Return the total progress, adding total done and total available.
......
...@@ -10,6 +10,7 @@ from api_manager.models import GroupProfile ...@@ -10,6 +10,7 @@ from api_manager.models import GroupProfile
from organizations.models import Organization from organizations.models import Organization
class Command(BaseCommand): class Command(BaseCommand):
""" """
Migrates legacy organization data and user relationships from older Group model approach to newer concrete Organization model Migrates legacy organization data and user relationships from older Group model approach to newer concrete Organization model
......
...@@ -108,6 +108,9 @@ CC_PROCESSOR = { ...@@ -108,6 +108,9 @@ CC_PROCESSOR = {
FEATURES['API'] = True FEATURES['API'] = True
########################## USER API ########################
EDX_API_KEY = None
########################### External REST APIs ################################# ########################### External REST APIs #################################
FEATURES['ENABLE_MOBILE_REST_API'] = True FEATURES['ENABLE_MOBILE_REST_API'] = True
......
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