def get_concept_page_data(self, request, pk=None): concept = get_object_or_404(Concept, pk=pk) self.check_object_permissions(request, concept.group.course) isOwnerObj = IsOwner() inInstructorOrContentDeveloperModeObj = InInstructorOrContentDeveloperMode( ) if not inInstructorOrContentDeveloperModeObj.has_permission( request, None): if (not concept.is_published and not isOwnerObj.has_object_permission( request=request, view=None, obj=concept.group.course)): return Response({"error": "Concept does not exist"}, status.HTTP_400_BAD_REQUEST) data = {} data['id'] = concept.id data['title'] = concept.title data['description'] = concept.description data['title_document'] = concept.title_document.to_dict() if concept.image: data['image'] = concept.image.url else: data['image'] = DEFAULT_CONCEPT_IMAGE group = Group.objects.filter(id=concept.group_id)[0] course1 = Course.objects.filter(id=group.course_id)[0] data['group'] = group.id data['group_title'] = group.title data['course'] = course1.id data['course_title'] = course1.title data['group_playlist'] = [] for id1 in json.loads(group.playlist): concept = Concept.objects.get(id=id1[0]) if concept.is_published: data['group_playlist'].append({ 'id': id1[0], 'title': concept.title }) course_playlist = [{ 'id': id_pair[0], 'title': Group.objects.filter(id=id_pair[0])[0].title } for id_pair in json.loads(course1.playlist)] # course_playlist = [grp for grp in course_playlist if grp.is_published] data['course_playlist'] = course_playlist data['playlist'] = self.playlist_as_array(request, pk, True) data['current_element'] = int(request.GET.get('item', 0)) return Response(data)
def view_concept(request, concept_id): """ View Concept Page """ concept = get_object_or_404(Concept, pk=concept_id) inInstructorOrContentDeveloperModeObject = InInstructorOrContentDeveloperMode() isOwnerObj = IsOwner() if inInstructorOrContentDeveloperModeObject.has_permission(request, None): return view_content_developer(request, concept_id) elif (concept.is_published or isOwnerObj.has_object_permission(request=request, obj=concept.group.course, view=None)): return view_student(request, concept_id) else: return render(request, 'error.html', {'error': 'Concept does not exist !'})
def get_concept_page_data(self, request, pk=None): concept = get_object_or_404(Concept, pk=pk) self.check_object_permissions(request, concept.group.course) isOwnerObj = IsOwner() inInstructorOrContentDeveloperModeObj = InInstructorOrContentDeveloperMode() if not inInstructorOrContentDeveloperModeObj.has_permission(request, None): if (not concept.is_published and not isOwnerObj.has_object_permission(request=request, view=None, obj=concept.group.course)): return Response({"error": "Concept does not exist"}, status.HTTP_400_BAD_REQUEST) data = {} data['id'] = concept.id data['title'] = concept.title data['description'] = concept.description data['title_document'] = concept.title_document.to_dict() if concept.image: data['image'] = concept.image.url else: data['image'] = DEFAULT_CONCEPT_IMAGE group = Group.objects.filter(id=concept.group_id)[0] course1 = Course.objects.filter(id=group.course_id)[0] data['group'] = group.id data['group_title'] = group.title data['course'] = course1.id data['course_title'] = course1.title data['group_playlist'] = [] for id1 in json.loads(group.playlist): concept = Concept.objects.get(id=id1[0]) if concept.is_published: data['group_playlist'].append({ 'id': id1[0], 'title': concept.title }) course_playlist = [ { 'id': id_pair[0], 'title': Group.objects.filter(id=id_pair[0])[0].title } for id_pair in json.loads(course1.playlist) ] # course_playlist = [grp for grp in course_playlist if grp.is_published] data['course_playlist'] = course_playlist data['playlist'] = self.playlist_as_array(request, pk, True) data['current_element'] = int(request.GET.get('item', 0)) return Response(data)
def view_concept(request, concept_id): """ View Concept Page """ concept = get_object_or_404(Concept, pk=concept_id) inInstructorOrContentDeveloperModeObject = InInstructorOrContentDeveloperMode( ) isOwnerObj = IsOwner() if inInstructorOrContentDeveloperModeObject.has_permission(request, None): return view_content_developer(request, concept_id) elif (concept.is_published or isOwnerObj.has_object_permission( request=request, obj=concept.group.course, view=None)): return view_student(request, concept_id) else: return render(request, 'error.html', {'error': 'Concept does not exist !'})
from django.contrib.auth.decorators import login_required from django.shortcuts import get_object_or_404, render from elearning_academy.permissions import InInstructorOrContentDeveloperMode, get_mode from elearning_academy.permissions import InInstructorMode, InContentDeveloperMode from courseware.models import Course, CourseHistory from courseware.vsserializers.course import CourseSerializer, CourseInfoSerializer from rest_framework import status from django.http import HttpResponse import json from django.utils import timezone inInstructorOrContentDeveloperModeObject = InInstructorOrContentDeveloperMode() inInstructorModeObject = InInstructorMode() inContentDeveloperModeObject = InContentDeveloperMode() def parent_categories(request): """ Serves parent_categories.html template """ context = {"request": request} return render(request, "category/parent_categories.html", context) def categories(request, pk): """ Serves categories.html template