コード例 #1
0
    def post(self, request):
        suggested_id = request.POST.get('suggested_id', None)
        collection_id = request.POST.get('collection_id', None)
        if 'remove' in request.POST.keys():
            exc = get_object_or_404(ExternalCollection, id=collection_id)
            msg = '%s has been disabled for your class.' % exc.title
            exc.delete()
        elif suggested_id:
            suggested = get_object_or_404(SuggestedExternalCollection,
                                          id=suggested_id)
            exc = ExternalCollection()
            exc.title = suggested.title
            exc.url = suggested.url
            exc.thumb_url = suggested.thumb_url
            exc.description = suggested.description
            exc.course = request.course
            exc.save()
            msg = '%s has been enabled for your class.' % exc.title
        else:
            exc = ExternalCollection()
            exc.title = request.POST.get('title')
            exc.url = request.POST.get('url')
            exc.thumb_url = request.POST.get('thumb')
            exc.description = request.POST.get('description')
            exc.course = request.course
            exc.uploader = request.POST.get('uploader', False)
            exc.save()

            if exc.uploader:
                course_details.add_upload_folder(request.course)

            msg = '%s has been enabled for your class.' % exc.title

        messages.add_message(request, messages.INFO, msg)

        redirect_url = request.POST.get('redirect-url',
                                        reverse(
                                            'class-manage-sources',
                                            args=[request.course.pk]))
        return HttpResponseRedirect(redirect_url)
コード例 #2
0
ファイル: views.py プロジェクト: ccnmtl/mediathread
    def post(self, request):
        suggested_id = request.POST.get('suggested_id', None)
        collection_id = request.POST.get('collection_id', None)
        if 'remove' in request.POST.keys():
            exc = get_object_or_404(ExternalCollection, id=collection_id)
            msg = '%s has been disabled for your class.' % exc.title
            exc.delete()
        elif suggested_id:
            suggested = get_object_or_404(SuggestedExternalCollection,
                                          id=suggested_id)
            exc = ExternalCollection()
            exc.title = suggested.title
            exc.url = suggested.url
            exc.thumb_url = suggested.thumb_url
            exc.description = suggested.description
            exc.course = request.course
            exc.save()
            msg = '%s has been enabled for your class.' % exc.title
        else:
            exc = ExternalCollection()
            exc.title = request.POST.get('title')
            exc.url = request.POST.get('url')
            exc.thumb_url = request.POST.get('thumb')
            exc.description = request.POST.get('description')
            exc.course = request.course
            exc.uploader = request.POST.get('uploader', False)
            exc.save()

            if exc.uploader:
                course_details.add_upload_folder(request.course)

            msg = '%s has been enabled for your class.' % exc.title

        messages.add_message(request, messages.INFO, msg)

        redirect_url = request.POST.get('redirect-url',
                                        reverse('class-manage-sources'))
        return HttpResponseRedirect(redirect_url)
コード例 #3
0
ファイル: views.py プロジェクト: ccnmtl/mediathread
    def post(self, request, *args, **kwargs):
        success_url = reverse('course-convert-materials')
        (url, secret) = self.get_conversion_endpoint()
        if not url:
            messages.add_message(
                self.request, messages.ERROR,
                u'Conversion endpoint is not configured')
            return HttpResponseRedirect(success_url)

        folder = course_details.get_upload_folder(self.request.course)
        if not folder:
            folder = course_details.add_upload_folder(self.request.course)

        for a in Asset.objects.filter(course=self.request.course):
            if a.upload_references() == 1 and not a.primary.is_panopto():
                self.convert_media(url, secret, a, folder)

        messages.add_message(self.request, messages.INFO,
                             'Materials were queued for conversion')
        return HttpResponseRedirect(success_url)
コード例 #4
0
ファイル: views.py プロジェクト: tmnogueira/mediathread
 def get_upload_folder(self, course):
     folder = course_details.get_upload_folder(course)
     if not folder:
         folder = course_details.add_upload_folder(course)
     return folder