feat: Unit page API as DRF

This commit is contained in:
ruzniaievdm
2024-01-10 11:31:20 +02:00
parent 2eabfe10c0
commit ff8d3eae72
11 changed files with 459 additions and 112 deletions

View File

@@ -3,7 +3,6 @@ Serializers for the content libraries REST API
"""
from rest_framework import serializers
from cms.djangoapps.contentstore.helpers import xblock_studio_url, xblock_type_display_name
from common.djangoapps.student.auth import has_studio_read_access
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
@@ -34,6 +33,8 @@ class StagedContentSerializer(serializers.ModelSerializer):
def get_block_type_display(self, obj):
""" Get the friendly name for this XBlock/component type """
from cms.djangoapps.contentstore.helpers import xblock_type_display_name
return xblock_type_display_name(obj.block_type)
@@ -50,6 +51,8 @@ class UserClipboardSerializer(serializers.Serializer):
def get_source_edit_url(self, obj) -> str:
""" Get the URL where the user can edit the given XBlock, if it exists """
from cms.djangoapps.contentstore.helpers import xblock_studio_url
request = self.context.get("request", None)
user = request.user if request else None
if not user: