Exemplo n.º 1
0
def theme_picker(request, template_name="theme_editor/theme_picker.html"):
    if not request.user.profile.is_superuser:
        raise Http403

    themes = []
    for theme in theme_choice_list():
        theme_info = ThemeInfo(theme)
        themes.append(theme_info)

    if request.method == "POST":
        selected_theme = request.POST.get('theme')
        call_command('set_theme', selected_theme)
        checklist_update('choose-theme')
        messages.add_message(
            request, messages.SUCCESS,
            "Your theme has been changed to %s." % selected_theme.title())
        return redirect('home')

    current_theme = get_setting('module', 'theme_editor', 'theme')
    themes = sorted(themes, key=lambda theme: theme.create_dt)

    return render_to_response(template_name, {
        'themes': themes,
        'current_theme': current_theme,
        'theme_choices': theme_choice_list(),
    },
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def theme_picker(request, template_name="theme_editor/theme_picker.html"):
    if not request.user.profile.is_superuser:
        raise Http403

    themes = []
    for theme in theme_choices():
        theme_info = ThemeInfo(theme)
        themes.append(theme_info)

    if request.method == "POST":
        selected_theme = request.POST.get('theme')
        if not is_valid_theme(selected_theme):
            raise Http403
        call_command('set_theme', selected_theme)
        checklist_update('choose-theme')
        msg_string = "Your theme has been changed to %s." % selected_theme.title(
        )
        messages.add_message(request, messages.SUCCESS, _(msg_string))
        return redirect('home')

    active_theme = get_active_theme()
    themes = sorted(themes, key=lambda theme: theme.create_dt)

    return render_to_resp(request=request,
                          template_name=template_name,
                          context={
                              'themes': themes,
                              'current_theme': active_theme,
                              'theme_choices': theme_choices(),
                          })
Exemplo n.º 3
0
def theme_picker(request, template_name="theme_editor/theme_picker.html"):
    if not request.user.profile.is_superuser:
        raise Http403

    themes = []
    for theme in theme_choice_list():
        theme_info = ThemeInfo(theme)
        themes.append(theme_info)

    if request.method == "POST":
        selected_theme = request.POST.get('theme')
        theme_setting = Setting.objects.get(name='theme')
        theme_setting.set_value(selected_theme)
        theme_setting.save()
        messages.add_message(
            request, messages.SUCCESS,
            "Your theme has been changed to %s." % selected_theme.title())

    current_theme = get_setting('module', 'theme_editor', 'theme')

    return render_to_response(template_name, {
        'themes': themes,
        'current_theme': current_theme,
        'theme_choices': theme_choice_list(),
    },
                              context_instance=RequestContext(request))