コード例 #1
0
ファイル: views.py プロジェクト: val260/podv2
def add_recording(request):
    if in_maintenance():
        return redirect(reverse("maintenance"))
    mediapath = request.GET.get("mediapath") if (
        request.GET.get("mediapath")) else ""
    course_title = (request.GET.get("course_title")
                    if request.GET.get("course_title") else "")
    recorder = request.GET.get("recorder") or None

    recorder = check_recorder(recorder, request)

    initial = {
        "title": course_title,
        "type": recorder.recording_type,
        "recorder": recorder,
        "user": request.user,
    }

    if not mediapath and not (request.user.is_superuser or
                              request.user.has_perm("recorder.add_recording")):
        messages.add_message(request, messages.ERROR,
                             _("Mediapath should be indicated."))
        raise PermissionDenied

    if mediapath != "":
        initial["source_file"] = "%s" % os.path.join(DEFAULT_RECORDER_PATH,
                                                     mediapath)

    form = RecordingForm(request, initial=initial)

    if request.method == "POST":  # If the form has been submitted...
        # A form bound to the POST data
        form = RecordingForm(request, request.POST)
        if form.is_valid():  # All validation rules pass

            if form.cleaned_data["delete"] is True:
                case_delete(form, request)
                return redirect("/")
            med = form.save(commit=False)
            med.user = fetch_user(request, form)
            med.save()
            file = form.cleaned_data["source_file"]
            rec = RecordingFileTreatment.objects.get(file=file)
            rec.delete()
            message = _("Your publication is saved."
                        " Adding it to your videos will be in a few minutes.")

            messages.add_message(request, messages.INFO, message)
            return redirect(reverse("my_videos"))
        else:
            message = _("One or more errors have been found in the form.")
            messages.add_message(request, messages.ERROR, message)

    return render(request, "recorder/add_recording.html", {"form": form})
コード例 #2
0
ファイル: views.py プロジェクト: val260/podv2
def claim_record(request):
    if in_maintenance():
        return redirect(reverse("maintenance"))
    site = get_current_site(request)
    # get records list ordered by date
    records_list = RecordingFileTreatment.objects.filter(
        require_manual_claim=True)

    records_list = records_list.exclude(pk__in=[
        rec.id for rec in records_list if site not in rec.recorder.sites.all()
    ])

    records_list = records_list.order_by("-date_added")
    page = request.GET.get("page", 1)

    full_path = ""
    if page:
        full_path = (request.get_full_path().replace(
            "?page=%s" % page, "").replace("&page=%s" % page, ""))

    paginator = Paginator(records_list, 12)
    try:
        records = paginator.page(page)
    except PageNotAnInteger:
        records = paginator.page(1)
    except EmptyPage:
        records = paginator.page(paginator.num_pages)

    if request.is_ajax():
        return render(
            request,
            "recorder/record_list.html",
            {
                "records": records,
                "full_path": full_path
            },
        )

    return render(
        request,
        "recorder/claim_record.html",
        {
            "records": records,
            "full_path": full_path
        },
    )
コード例 #3
0
ファイル: views.py プロジェクト: EsupPortail/Esup-Pod
def studio_pod(request):
    if in_maintenance():
        return redirect(reverse("maintenance"))
    if RESTRICT_EDIT_VIDEO_ACCESS_TO_STAFF_ONLY and request.user.is_staff is False:
        return render(request, "recorder/opencast-studio.html",
                      {"access_not_allowed": True})
    # Render the Opencast studio index file
    opencast_studio_rendered = render_to_string("studio/index.html")
    # head = opencast_studio_rendered[opencast_studio_rendered.index("<head>")
    # + len("<head>"):opencast_studio_rendered.index("</head>")]
    body = opencast_studio_rendered[opencast_studio_rendered.index("<body>") +
                                    len("<body>"):opencast_studio_rendered.
                                    index("</body>")]
    return render(
        # Render the Opencast studio index file
        request,
        "recorder/opencast-studio.html",
        {
            "body": body,
            "default_presenter": OPENCAST_DEFAULT_PRESENTER
        },
    )