lms.djangoapps.commerce.api.v1 package

Contents

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: object

Pseudo-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.

class lms.djangoapps.commerce.api.v1.permissions.ApiKeyOrModelPermission#

Bases: BasePermission

Access granted for requests with API key in header, or made by user with appropriate Django model permissions.

has_permission(request, view)#

Return True if permission is granted, False otherwise.

class lms.djangoapps.commerce.api.v1.permissions.IsAuthenticatedOrActivationOverridden#

Bases: BasePermission

Considers the account activation override switch when determining the authentication status of the user

has_permission(request, view)#

Return True if permission is granted, False otherwise.

lms.djangoapps.commerce.api.v1.serializers module#

API v1 serializers.

class lms.djangoapps.commerce.api.v1.serializers.CourseModeSerializer(*args, **kwargs)#

Bases: ModelSerializer

CourseMode 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: Serializer

Course serializer.

class Meta#

Bases: object

ref_name = 'commerce.Course'#
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.Course object.

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: DateTimeField

We 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: ListAPIView

List 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, RetrieveUpdateAPIView

Retrieve, 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

class lms.djangoapps.commerce.api.v1.views.OrderView(**kwargs)#

Bases: APIView

Retrieve order details.

get(request, number)#

HTTP handler.

permission_classes = (<class 'lms.djangoapps.commerce.api.v1.permissions.IsAuthenticatedOrActivationOverridden'>,)#

Module contents#