mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-06-06 17:13:02 -04:00
feat: LTI support and Moodle plugin
This commit is contained in:
@@ -23,17 +23,18 @@ class CategoryList(APIView):
|
||||
},
|
||||
)
|
||||
def get(self, request, format=None):
|
||||
base_filters = {}
|
||||
|
||||
if not is_mediacms_editor(request.user):
|
||||
base_filters = {"is_rbac_category": False}
|
||||
|
||||
base_queryset = Category.objects.prefetch_related("user")
|
||||
categories = base_queryset.filter(**base_filters)
|
||||
show_lms = getattr(settings, 'SHOW_LMS_COURSES_IN_CATEGORIES', True)
|
||||
categories = Category.objects.prefetch_related("user")
|
||||
|
||||
if not show_lms:
|
||||
categories = categories.filter(is_lms_course=False)
|
||||
|
||||
if not is_mediacms_editor(request.user):
|
||||
categories = categories.filter(is_rbac_category=False)
|
||||
if getattr(settings, 'USE_RBAC', False) and request.user.is_authenticated:
|
||||
rbac_categories = request.user.get_rbac_categories_as_member()
|
||||
if not show_lms:
|
||||
rbac_categories = rbac_categories.filter(is_lms_course=False)
|
||||
categories = categories.union(rbac_categories)
|
||||
|
||||
categories = categories.order_by("title")
|
||||
@@ -43,6 +44,27 @@ class CategoryList(APIView):
|
||||
return Response(ret)
|
||||
|
||||
|
||||
class CategoryListContributor(APIView):
|
||||
"""List LMS courses where the user has contributor access"""
|
||||
|
||||
@swagger_auto_schema(
|
||||
tags=['Categories'],
|
||||
operation_summary='Lists LMS courses for Contributors',
|
||||
operation_description='Lists LMS courses where the user has contributor access',
|
||||
responses={
|
||||
200: openapi.Response('response description', CategorySerializer),
|
||||
},
|
||||
)
|
||||
def get(self, request, format=None):
|
||||
if not request.user.is_authenticated:
|
||||
return Response([])
|
||||
|
||||
categories = request.user.get_rbac_categories_as_contributor().filter(is_lms_course=True)
|
||||
|
||||
serializer = CategorySerializer(categories.order_by("title"), many=True, context={"request": request})
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
class TagList(APIView):
|
||||
"""List tags"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user