lms.djangoapps.commerce.api.v1 package#
Submodules#
lms.djangoapps.commerce.api.v1.models module#
API v1 models.
- class lms.djangoapps.commerce.api.v1.models.Course(id, modes, **kwargs)#
Bases:
objectPseudo-course model used to group CourseMode objects.
- classmethod get(course_id)#
Retrieve a single course.
- get_mode_display_name(mode)#
Returns display name for the given mode.
- id = None#
- classmethod iterator()#
Generator that yields all courses.
- modes = None#
- property name#
Return course name.
- save(*args, **kwargs)#
Save the CourseMode objects to the database.
- update(attrs)#
Update the model with external data (usually passed via API call).
lms.djangoapps.commerce.api.v1.permissions module#
Custom API permissions.
lms.djangoapps.commerce.api.v1.serializers module#
API v1 serializers.
- class lms.djangoapps.commerce.api.v1.serializers.CourseModeSerializer(*args, **kwargs)#
Bases:
ModelSerializerCourseMode serializer.
- class Meta#
Bases:
object- fields = ('name', 'currency', 'price', 'sku', 'bulk_sku', 'expires', 'android_sku', 'ios_sku')#
- model#
alias of
CourseMode
- ref_name = 'commerce.CourseMode'#
- get_identity(data)#
- class lms.djangoapps.commerce.api.v1.serializers.CourseSerializer(*args, **kwargs)#
Bases:
SerializerCourse serializer.
- create(validated_data)#
Create course modes for a course.
- Parameters:
validated_data – The result of self.validate() - a dictionary containing ‘id’, ‘modes’, and optionally
key. (a 'verification_deadline`)
- Returns:
A
commerce.api.v1.models.Courseobject.
- update(instance, validated_data)#
Update course modes for an existing course.
- validate(attrs)#
Ensure the verification deadline occurs AFTER the course mode enrollment deadlines.
- class lms.djangoapps.commerce.api.v1.serializers.PossiblyUndefinedDateTimeField(*args, **kwargs)#
Bases:
DateTimeFieldWe need a DateTime serializer that can deal with the non-JSON-serializable UNDEFINED object.
- to_representation(value)#
Transform the outgoing native value into primitive data.
- lms.djangoapps.commerce.api.v1.serializers.validate_course_id(course_id)#
Check that course id is valid and exists in modulestore.
lms.djangoapps.commerce.api.v1.urls module#
Commerce URLs
lms.djangoapps.commerce.api.v1.views module#
Commerce views
- class lms.djangoapps.commerce.api.v1.views.CourseListView(**kwargs)#
Bases:
ListAPIViewList courses and modes.
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
- get_queryset()#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- pagination_class = None#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- serializer_class#
alias of
CourseSerializer
- class lms.djangoapps.commerce.api.v1.views.CourseRetrieveUpdateView(**kwargs)#
Bases:
PutAsCreateMixin,RetrieveUpdateAPIViewRetrieve, update, or create courses/modes.
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
- get_object(queryset=None)#
Returns the object the view is displaying.
You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.
- lookup_field = 'id'#
- lookup_url_kwarg = 'course_id'#
- model#
alias of
CourseMode
- permission_classes = (<class 'lms.djangoapps.commerce.api.v1.permissions.ApiKeyOrModelPermission'>,)#
- pre_save(obj)#
- queryset#
- serializer_class#
alias of
CourseSerializer