TNL-1907 Implement Course Team Membership API
This commit is contained in:
@@ -70,6 +70,16 @@ class DeveloperErrorViewMixin(object):
|
||||
raise
|
||||
|
||||
|
||||
class ExpandableFieldViewMixin(object):
|
||||
"""A view mixin to add expansion information to the serializer context for later use by an ExpandableField."""
|
||||
|
||||
def get_serializer_context(self):
|
||||
"""Adds expand information from query parameters to the serializer context to support expandable fields."""
|
||||
result = super(ExpandableFieldViewMixin, self).get_serializer_context()
|
||||
result['expand'] = [x for x in self.request.QUERY_PARAMS.get('expand', '').split(',') if x]
|
||||
return result
|
||||
|
||||
|
||||
def view_course_access(depth=0, access_action='load', check_for_milestones=False):
|
||||
"""
|
||||
Method decorator for an API endpoint that verifies the user has access to the course.
|
||||
@@ -142,6 +152,21 @@ def add_serializer_errors(serializer, data, field_errors):
|
||||
return field_errors
|
||||
|
||||
|
||||
def build_api_error(message, **kwargs):
|
||||
"""Build an error dict corresponding to edX API conventions.
|
||||
|
||||
Args:
|
||||
message (string): The string to use for developer and user messages.
|
||||
The user message will be translated, but for this to work message
|
||||
must have already been scraped. ugettext_noop is useful for this.
|
||||
**kwargs: format parameters for message
|
||||
"""
|
||||
return {
|
||||
'developer_message': message.format(**kwargs),
|
||||
'user_message': _(message).format(**kwargs), # pylint: disable=translation-of-non-string
|
||||
}
|
||||
|
||||
|
||||
class RetrievePatchAPIView(RetrieveModelMixin, UpdateModelMixin, GenericAPIView):
|
||||
"""Concrete view for retrieving and updating a model instance.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user