Esempio n. 1
0
 def test_should_raise_error_when_slug_collides_with_reserved_name_for_child_page_of_homepage(
         self):
     settings = self.create_settings_with_homepage(self.page)
     form = self._create_form(page=self.page, edit=False, slug='admin')
     self.assertFalse(form.is_valid())
     self.assertEqual({'slug': [PageForm.ERROR_SLUG_SYSTEM_NAME]},
                      form.errors)
     settings.delete()
Esempio n. 2
0
 def test_should_raise_error_when_slug_collides_with_child_page_attached_to_homepage(
         self):
     child_page = self.create_child_page(1, self.page)
     settings = self.create_settings_with_homepage(self.page)
     form = self._create_form(edit=False, slug='child-page-1')
     self.assertFalse(form.is_valid())
     self.assertEqual({'slug': [PageForm.ERROR_SLUG_COLLISION]},
                      form.errors)
     settings.delete()
Esempio n. 3
0
 def test_should_raise_error_when_colliding_with_page_as_child_page_of_homepage(
         self):
     settings = self.create_settings_with_homepage(self.page)
     another_page = self.create_page('Another Page')
     form = self._create_form(page=self.page,
                              edit=False,
                              slug='another-page')
     self.assertFalse(form.is_valid())
     self.assertEqual({'slug': [PageForm.ERROR_SLUG_COLLISION]},
                      form.errors)
     settings.delete()
Esempio n. 4
0
    def test_settings(self):
        settings = Settings.load()
        assert settings

        settings.save()

        # delete should have no effect
        settings.delete()
        settings = Settings.load()
        assert settings

        s = str(settings)
        self.__logger.info(s)
Esempio n. 5
0
def settingsDelete(request, pk):
    settings = get_object_or_404(Settings, pk=pk)
    data = dict()
    if request.method == 'POST':
        settings.delete()
        data['form_is_valid'] = True
        settings = Settings.objects.all()
        data['html_account_list'] = render_to_string(
            'app/settingsPartial.html', {'settings': settings})
    else:
        context = {'settings': settings}
        data['html_form'] = render_to_string('app/settingsDeletePartial.html',
                                             context,
                                             request=request)
    return JsonResponse(data)
Esempio n. 6
0
 def delete_settings(self, request, pk=None):
     settings = Settings.objects.filter(project=Project.objects.get(id=pk),
                                        key=request.data['key'],
                                        value=request.data['value'])
     settings.delete()
     return Response(status=status.HTTP_200_OK, data={'message': 'ok'})