Ejemplo n.º 1
0
    def post(self):
        form = SiteSettingsForm(self.request.POST)
        success = False

        if form.validate():
            SiteSettings.batch_set(form.data)
            success = True

        return {
            "admin_section": "admin-about",
            "success": success,
            "form": form,
        }
Ejemplo n.º 2
0
def admin_settings(request):
    if request.user.is_authenticated():
        args = {}
        args.update(csrf(request))
        try:
            model = SiteSettings.objects.get(id=1)
            args['form'] = SiteSettingsForm(instance=model)
        except SiteSettings.DoesNotExist:
            args['form'] = SiteSettingsForm()

        if request.POST:
            form = SiteSettingsForm(request.POST, request.FILES)
            if form.is_valid():
                model = form.save(commit=False)
                model.id = 1
                model.save()
                return redirect('/admin/')
            else:
                args['form'] = form

        return render_to_response("admin_settings.html", args)
    else:
        return redirect('/admin/')
Ejemplo n.º 3
0
def admin_settings(request):
    if request.user.is_authenticated():
        args = {}
        args.update(csrf(request))
        try:
            model = SiteSettings.objects.get(id=1)
            args['form'] = SiteSettingsForm(instance=model)
        except SiteSettings.DoesNotExist:
            args['form'] = SiteSettingsForm()

        if request.POST:
            form = SiteSettingsForm(request.POST, request.FILES)
            if form.is_valid():
                model = form.save(commit=False)
                model.id = 1
                model.save()
                return redirect('/admin/')
            else:
                args['form'] = form

        return render_to_response("settings.html", args)
    else:
        return redirect('/admin/')