コード例 #1
0
ファイル: admin.py プロジェクト: fluckydog232/studio
def administration(request):
    return render(
        request, 'administration.html', {
            "current_user":
            JSONRenderer().render(CurrentUserSerializer(request.user).data),
            "default_sender":
            settings.DEFAULT_FROM_EMAIL,
            "placeholders":
            json.dumps(EMAIL_PLACEHOLDERS, ensure_ascii=False),
            "messages":
            get_messages(),
        })
コード例 #2
0
ファイル: views.py プロジェクト: radinamatic/studio
def channel_page(request, channel, allow_edit=False, staging=False):
    channel_serializer = ChannelSerializer(channel)
    channel_list = Channel.objects.select_related('main_tree').prefetch_related('editors').prefetch_related('viewers')\
                          .exclude(id=channel.pk).filter(Q(deleted=False) & (Q(editors=request.user) | Q(viewers=request.user)))\
                          .annotate(is_view_only=Case(When(editors=request.user, then=Value(0)), default=Value(1), output_field=IntegerField()))\
                          .distinct().values("id", "name", "is_view_only").order_by('name')

    fileformats = get_or_set_cached_constants(FileFormat, FileFormatSerializer)
    licenses = get_or_set_cached_constants(License, LicenseSerializer)
    formatpresets = get_or_set_cached_constants(FormatPreset,
                                                FormatPresetSerializer)
    contentkinds = get_or_set_cached_constants(ContentKind,
                                               ContentKindSerializer)
    languages = get_or_set_cached_constants(Language, LanguageSerializer)

    json_renderer = JSONRenderer()

    return render(
        request, 'channel_edit.html', {
            "allow_edit":
            allow_edit,
            "staging":
            staging,
            "is_public":
            channel.public,
            "channel":
            json_renderer.render(channel_serializer.data),
            "channel_id":
            channel.pk,
            "channel_name":
            channel.name,
            "channel_list":
            channel_list,
            "fileformat_list":
            fileformats,
            "license_list":
            licenses,
            "fpreset_list":
            formatpresets,
            "ckinds_list":
            contentkinds,
            "langs_list":
            languages,
            "current_user":
            json_renderer.render(CurrentUserSerializer(request.user).data),
            "preferences":
            channel.preferences,
            "messages":
            get_messages()
        })
コード例 #3
0
def channel_page(request, channel, allow_edit=False, staging=False):
    channel_serializer = ChannelSerializer(channel)
    channel_list = Channel.objects.select_related('main_tree').prefetch_related('editors').prefetch_related('viewers')\
                          .exclude(id=channel.pk).filter(Q(deleted=False) & (Q(editors=request.user) | Q(viewers=request.user)))\
                          .annotate(is_view_only=Case(When(editors=request.user, then=Value(0)), default=Value(1), output_field=IntegerField()))\
                          .distinct().values("id", "name", "is_view_only").order_by('name')

    token = None
    if channel.secret_tokens.filter(is_primary=True).exists():
        token = channel.secret_tokens.filter(is_primary=True).first().token
        token = token[:5] + "-" + token[5:]

    json_renderer = JSONRenderer()
    return render(
        request, 'channel_edit.html', {
            "allow_edit":
            allow_edit,
            "staging":
            staging,
            "is_public":
            channel.public,
            "channel":
            json_renderer.render(channel_serializer.data),
            "channel_id":
            channel.pk,
            "channel_name":
            channel.name,
            "channel_last_published":
            channel.last_published,
            "channel_has_editors":
            len(channel_serializer.data.get("editors")) > 1,
            "ricecooker_version":
            channel.ricecooker_version,
            "channel_list":
            channel_list,
            "current_user":
            json_renderer.render(CurrentUserSerializer(request.user).data),
            "preferences":
            json.dumps(channel.content_defaults),
            "messages":
            get_messages(),
            "primary_token":
            token or channel.pk,
            "title":
            settings.DEFAULT_TITLE,
        })
コード例 #4
0
def administration(request):
    # Check if browser is supported
    if not check_supported_browsers(request.META['HTTP_USER_AGENT']):
        return redirect(reverse_lazy('unsupported_browser'))

    if not request.user.is_admin:
        return redirect(reverse_lazy('unauthorized'))

    return render(
        request, 'administration.html', {
            "current_user":
            JSONRenderer().render(CurrentUserSerializer(request.user).data),
            "default_sender":
            settings.DEFAULT_FROM_EMAIL,
            "placeholders":
            json.dumps(EMAIL_PLACEHOLDERS, ensure_ascii=False),
        })
コード例 #5
0
ファイル: views.py プロジェクト: jonathanvdmerwe/studio
def channel_page(request, channel, allow_edit=False, staging=False):
    channel_serializer = ChannelSerializer(channel)
    channel_list = Channel.objects.select_related('main_tree').prefetch_related('editors').prefetch_related('viewers')\
                          .exclude(id=channel.pk).filter(Q(deleted=False) & (Q(editors=request.user) | Q(viewers=request.user)))\
                          .annotate(is_view_only=Case(When(editors=request.user, then=Value(0)), default=Value(1), output_field=IntegerField()))\
                          .distinct().values("id", "name", "is_view_only").order_by('name')

    fileformats = get_or_set_cached_constants(FileFormat, FileFormatSerializer)
    licenses = get_or_set_cached_constants(License, LicenseSerializer)
    formatpresets = get_or_set_cached_constants(FormatPreset,
                                                FormatPresetSerializer)
    contentkinds = get_or_set_cached_constants(ContentKind,
                                               ContentKindSerializer)
    languages = get_or_set_cached_constants(Language, LanguageSerializer)

    token = None
    if channel.secret_tokens.filter(is_primary=True).exists():
        token = channel.secret_tokens.filter(is_primary=True).first().token
        token = token[:5] + "-" + token[5:]

    json_renderer = JSONRenderer()
    return render(
        request, 'channel_edit.html', {
            "allow_edit":
            allow_edit,
            "staging":
            staging,
            "is_public":
            channel.public,
            "channel":
            json_renderer.render(channel_serializer.data),
            "channel_id":
            channel.pk,
            "channel_name":
            channel.name,
            "channel_list":
            channel_list,
            "fileformat_list":
            fileformats,
            "license_list":
            licenses,
            "fpreset_list":
            formatpresets,
            "ckinds_list":
            contentkinds,
            "langs_list":
            languages,
            "roles":
            json.dumps([r[0] for r in roles.choices]),
            "mastery":
            json.dumps([
                m[0] for m in exercises.MASTERY_MODELS
                if m[0] != exercises.SKILL_CHECK
            ]),
            "current_user":
            json_renderer.render(CurrentUserSerializer(request.user).data),
            "preferences":
            json.dumps(channel.content_defaults),
            "messages":
            get_messages(),
            "primary_token":
            token or channel.pk,
            "title":
            settings.DEFAULT_TITLE,
        })