Esempio n. 1
0
def theme(request):
    contexts = {}
    if 'theme' in request.GET and request.user.profile.is_superuser:
        if request.GET.get('theme'):
            request.session['theme'] = request.GET.get('theme')
        elif 'theme' in request.session:
            del request.session['theme']

    if 'toggle_template' in request.GET:
        contexts['TOGGLE_TEMPLATE'] = True

    contexts['ACTIVE_THEME'] = get_setting('module', 'theme_editor', 'theme')
    theme = request.session.get('theme', contexts['ACTIVE_THEME'])
    contexts['THEME'] = theme

    if settings.USE_S3_STORAGE:
        contexts['THEME_URL'] = '%s/%s/%s/themes/%s/' % (settings.S3_ROOT_URL,
            settings.AWS_STORAGE_BUCKET_NAME, settings.AWS_LOCATION, theme)
    else:
        contexts['THEME_URL'] = '/themes/' + theme + '/'

    contexts['LOCAL_THEME_URL'] = '/themes/' + theme + '/'
    

    contexts['THEME_INFO'] = get_theme_info(theme)

    return contexts
Esempio n. 2
0
def theme(request):
    contexts = {}
    if "theme" in request.GET and request.user.profile.is_superuser:
        if request.GET.get("theme"):
            request.session["theme"] = request.GET.get("theme")
        elif "theme" in request.session:
            del request.session["theme"]

    if "toggle_template" in request.GET:
        contexts["TOGGLE_TEMPLATE"] = True

    theme = request.session.get("theme", get_setting("module", "theme_editor", "theme"))
    contexts["THEME"] = theme

    if settings.USE_S3_STORAGE:
        contexts["THEME_URL"] = "%s/%s/%s/themes/%s/" % (
            settings.S3_ROOT_URL,
            settings.AWS_STORAGE_BUCKET_NAME,
            settings.AWS_LOCATION,
            theme,
        )
    else:
        contexts["THEME_URL"] = "/themes/" + theme + "/"

    contexts["LOCAL_THEME_URL"] = "/themes/" + theme + "/"
    contexts["ACTIVE_THEME"] = get_setting("module", "theme_editor", "theme")

    contexts["THEME_INFO"] = get_theme_info(theme)

    return contexts
Esempio n. 3
0
def theme(request):
    contexts = {}
    if 'theme' in request.GET and request.user.profile.is_superuser:
        if request.GET.get('theme'):
            request.session['theme'] = request.GET.get('theme')
        elif 'theme' in request.session:
            del request.session['theme']

    if 'toggle_template' in request.GET:
        contexts['TOGGLE_TEMPLATE'] = True

    contexts['ACTIVE_THEME'] = get_setting('module', 'theme_editor', 'theme')
    theme = request.session.get('theme', contexts['ACTIVE_THEME'])
    contexts['THEME'] = theme

    if settings.USE_S3_STORAGE:
        contexts['THEME_URL'] = '%s/%s/%s/themes/%s/' % (
            settings.S3_ROOT_URL, settings.AWS_STORAGE_BUCKET_NAME,
            settings.AWS_LOCATION, theme)
    else:
        contexts['THEME_URL'] = '/themes/' + theme + '/'

    contexts['LOCAL_THEME_URL'] = '/themes/' + theme + '/'

    contexts['THEME_INFO'] = get_theme_info(theme)

    return contexts
Esempio n. 4
0
def checklist(request, template_name="base/checklist.html"):
    theme_info = get_theme_info()
    try:
        checklist_enabled = theme_info['SSU']['checklist']
    except KeyError:
        raise Http404
    if not checklist_enabled:
        raise Http404

    checklist = ChecklistItem.objects.all()

    total_count = checklist.count()
    completed = checklist.filter(done=True)
    completed_count = completed.count()

    percent = (Decimal(completed_count) / Decimal(total_count)) * 100

    return render_to_response(template_name,
                              {'checklist': checklist, "percent": percent},
                              context_instance=RequestContext(request))
Esempio n. 5
0
def checklist(request, template_name="base/checklist.html"):
    theme_info = get_theme_info()
    try:
        checklist_enabled = theme_info['SSU']['checklist']
    except KeyError:
        raise Http404
    if not checklist_enabled:
        raise Http404

    checklist = ChecklistItem.objects.all()

    total_count = checklist.count()
    completed = checklist.filter(done=True)
    completed_count = completed.count()

    percent = (Decimal(completed_count) / Decimal(total_count)) * 100

    return render_to_response(template_name,
                              {'checklist': checklist, "percent": percent},
                              context_instance=RequestContext(request))