Exemple #1
0
    def post(self, request):
        form = SiteSettingForm(data=request.POST)
        if form.is_valid():
            form.save(request.user)
            messages.success(request, _('Site settings have been updated'))
            return redirect('staff.site.settings')

        return self.render_to_response({
            'form': form,
        })
Exemple #2
0
    def test_site_setting_form_save(self):
        form = SiteSettingForm(data={
            'announcement': 'This is a sample announcement',
            'enable_comments': 'on',
        })
        self.assertTrue(form.is_valid())
        form.save(self.user)

        settings_dict = SiteSetting.as_dict()
        self.assertEqual(settings_dict.get(SiteSettingKey.ANNOUNCEMENT), 'This is a sample announcement')
        self.assertEqual(settings_dict.get(SiteSettingKey.ENABLE_COMMENTS), True)
        self.assertEqual(settings_dict.get(SiteSettingKey.ENABLE_UPLOADS), False)