Beispiel #1
0
def group_settings(request,
                   group,
                   template='livesettings/group_settings.html'):
    # Determine what set of settings this editor is used for

    use_db, overrides = get_overrides()

    mgr = ConfigurationSettings()

    settings = mgr[group]
    title = settings.name
    log.debug('title: %s', title)

    if use_db:
        # Create an editor customized for the current user
        #editor = forms.customized_editor(settings)

        if request.method == 'POST':

            # Populate the form with user-submitted data
            data = request.POST.copy()
            form = forms.SettingsEditor(data, request.FILES, settings=settings)
            if form.is_valid():
                for name, value in form.cleaned_data.items():
                    group, key = name.split('__')
                    cfg = mgr.get_config(group, key)

                    if isinstance(cfg, ImageValue):
                        if request.FILES and name in request.FILES:
                            value = request.FILES[name]
                        else:
                            continue

                    if cfg.update(value):
                        # Give user feedback as to which settings were changed
                        message = 'Updated %s on %s' % (cfg.key, cfg.group.key)
                        request.user.message_set.create(message=message)

                return HttpResponseRedirect(request.path)
        else:
            # Leave the form populated with current setting values
            #form = editor()
            form = forms.SettingsEditor(settings=settings)
    else:
        form = None

    return render_to_response(template, {
        'all_groups': mgr.groups(),
        'title': title,
        'group': settings,
        'form': form,
        'use_db': use_db
    },
                              context_instance=RequestContext(request))
Beispiel #2
0
def group_settings(request, group, template='livesettings/group_settings.html'):
    # Determine what set of settings this editor is used for
    
    use_db, overrides = get_overrides();
    
    mgr = ConfigurationSettings()

    settings = mgr[group]
    title = settings.name
    log.debug('title: %s', title)

    if use_db:
        # Create an editor customized for the current user
        #editor = forms.customized_editor(settings)

        if request.method == 'POST':

            # Populate the form with user-submitted data
            data = request.POST.copy()
            form = forms.SettingsEditor(data, request.FILES, settings=settings)
            if form.is_valid():
                for name, value in form.cleaned_data.items():
                    group, key = name.split('__')
                    cfg = mgr.get_config(group, key)

                    if isinstance(cfg, ImageValue):
                        if request.FILES and name in request.FILES:
                            value = request.FILES[name]
                        else:
                            continue

                    if cfg.update(value):
                        # Give user feedback as to which settings were changed
                        message='Updated %s on %s' % (cfg.key, cfg.group.key)
                        request.user.message_set.create(message = message)

                return HttpResponseRedirect(request.path)
        else:
            # Leave the form populated with current setting values
            #form = editor()
            form = forms.SettingsEditor(settings=settings)
    else:
        form = None

    return render_to_response(template, {
        'all_groups': mgr.groups(),
        'title': title,
        'group' : settings,
        'form': form,
        'use_db' : use_db
    }, context_instance=RequestContext(request))
Beispiel #3
0
def site_settings(request):
    mgr = ConfigurationSettings()
    default_group = mgr.groups()[0].key
    return HttpResponseRedirect(reverse('group_settings', args=[default_group]))
Beispiel #4
0
def site_settings(request):
    mgr = ConfigurationSettings()
    default_group = mgr.groups()[0].key
    return HttpResponseRedirect(reverse('group_settings',
                                        args=[default_group]))