def duplicate(self, user): source = self.cleaned_data.get('source') target = self.cleaned_data.get('target') course = duplicate_course(source, target, user) return course
def post(self, request, *args, **kwargs): response_data = {} source = request.DATA.get('source') target = source extra_fields = { 'invitation_only': True, 'max_student_enrollments_allowed': 3, } scheme = 'https' if request.is_secure() else 'http' course = duplicate_course(source, target, request.user, extra_fields, http_protocol=scheme) unregister_course(request.user, source) response_data = {'course_id': str(course.id)} return Response(response_data)