django-camomilla-cms 6.0.0b15__py2.py3-none-any.whl → 6.0.0b16__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. camomilla/__init__.py +1 -1
  2. camomilla/managers/pages.py +7 -7
  3. camomilla/model_api.py +9 -4
  4. camomilla/models/media.py +1 -1
  5. camomilla/models/menu.py +3 -2
  6. camomilla/models/page.py +12 -11
  7. camomilla/openapi/schema.py +4 -0
  8. camomilla/serializers/base/__init__.py +3 -1
  9. camomilla/serializers/fields/json.py +0 -1
  10. camomilla/serializers/fields/related.py +5 -1
  11. camomilla/serializers/mixins/__init__.py +51 -6
  12. camomilla/serializers/mixins/filter_fields.py +56 -0
  13. camomilla/serializers/utils.py +3 -1
  14. camomilla/storages/default.py +6 -0
  15. camomilla/storages/optimize.py +2 -2
  16. camomilla/storages/overwrite.py +2 -2
  17. camomilla/templates/defaults/parts/menu.html +1 -1
  18. camomilla/theme/__init__.py +1 -1
  19. camomilla/utils/query_parser.py +148 -0
  20. camomilla/views/base/__init__.py +2 -2
  21. camomilla/views/menus.py +0 -2
  22. camomilla/views/mixins/__init__.py +9 -2
  23. camomilla/views/mixins/pagination.py +4 -13
  24. {django_camomilla_cms-6.0.0b15.dist-info → django_camomilla_cms-6.0.0b16.dist-info}/METADATA +1 -1
  25. {django_camomilla_cms-6.0.0b15.dist-info → django_camomilla_cms-6.0.0b16.dist-info}/RECORD +38 -28
  26. {django_camomilla_cms-6.0.0b15.dist-info → django_camomilla_cms-6.0.0b16.dist-info}/WHEEL +1 -1
  27. tests/fixtures/__init__.py +17 -0
  28. tests/test_api.py +2 -11
  29. tests/test_camomilla_filters.py +7 -13
  30. tests/test_media.py +80 -0
  31. tests/test_model_api.py +68 -0
  32. tests/test_model_api_permissions.py +39 -0
  33. tests/test_query_parser.py +59 -0
  34. tests/test_utils.py +64 -64
  35. tests/utils/__init__.py +0 -0
  36. tests/utils/api.py +29 -0
  37. {django_camomilla_cms-6.0.0b15.dist-info → django_camomilla_cms-6.0.0b16.dist-info}/LICENSE +0 -0
  38. {django_camomilla_cms-6.0.0b15.dist-info → django_camomilla_cms-6.0.0b16.dist-info}/top_level.txt +0 -0
tests/test_utils.py CHANGED
@@ -13,74 +13,74 @@ from django.utils.translation import activate, get_language
13
13
  from requests import RequestException
14
14
 
15
15
 
16
- class UtilsTestCase(TestCase):
17
- def setUp(self):
18
- pass
16
+ # class UtilsTestCase(TestCase):
17
+ # def setUp(self):
18
+ # pass
19
19
 
20
- def test_get_host_url(self):
21
- """Our beloved get_host_url utility"""
22
- request_factory = RequestFactory()
23
- request = request_factory.get("/path")
24
- request.META["HTTP_HOST"] = "localhost"
25
- host_url = get_host_url(request)
26
- self.assertEqual(host_url, "http://localhost")
27
- host_url = get_host_url(None)
28
- self.assertEqual(host_url, None)
20
+ # def test_get_host_url(self):
21
+ # """Our beloved get_host_url utility"""
22
+ # request_factory = RequestFactory()
23
+ # request = request_factory.get("/path")
24
+ # request.META["HTTP_HOST"] = "localhost"
25
+ # host_url = get_host_url(request)
26
+ # self.assertEqual(host_url, "http://localhost")
27
+ # host_url = get_host_url(None)
28
+ # self.assertEqual(host_url, None)
29
29
 
30
- def test_get_complete_url(self):
31
- """Our beloved get_complete_url utility"""
32
- request_factory = RequestFactory()
33
- request = request_factory.get("/path")
34
- request.META["HTTP_HOST"] = "localhost"
35
- complete_url = get_complete_url(request, "path")
36
- self.assertEqual(complete_url, "http://localhost/path")
37
- complete_url = get_complete_url(request, "path", "it")
38
- self.assertEqual(complete_url, "http://localhost/path")
39
- complete_url = get_complete_url(request, "path", "fr")
40
- self.assertEqual(complete_url, "http://localhost/fr/path")
30
+ # def test_get_complete_url(self):
31
+ # """Our beloved get_complete_url utility"""
32
+ # request_factory = RequestFactory()
33
+ # request = request_factory.get("/path")
34
+ # request.META["HTTP_HOST"] = "localhost"
35
+ # complete_url = get_complete_url(request, "path")
36
+ # self.assertEqual(complete_url, "http://localhost/path")
37
+ # complete_url = get_complete_url(request, "path", "it")
38
+ # self.assertEqual(complete_url, "http://localhost/path")
39
+ # complete_url = get_complete_url(request, "path", "fr")
40
+ # self.assertEqual(complete_url, "http://localhost/fr/path")
41
41
 
42
- def test_get_page_with_default_seo(self):
43
- """Our beloved get_seo utility with auto attributes"""
44
- request_factory = RequestFactory()
45
- request = request_factory.get("/path")
46
- request.META["HTTP_HOST"] = "localhost"
47
- page = Page.get(request, identifier="home")
48
- self.assertEqual(page.og_url, "http://localhost/path")
49
- self.assertEqual(page.canonical, "http://localhost/path")
42
+ # def test_get_page_with_default_seo(self):
43
+ # """Our beloved get_seo utility with auto attributes"""
44
+ # request_factory = RequestFactory()
45
+ # request = request_factory.get("/path")
46
+ # request.META["HTTP_HOST"] = "localhost"
47
+ # page = Page.get(request, identifier="home")
48
+ # self.assertEqual(page.og_url, "http://localhost/path")
49
+ # self.assertEqual(page.canonical, "http://localhost/path")
50
50
 
51
- def test_get_article_with_default_seo(self):
52
- """Our beloved get_seo utility with auto attributes"""
53
- request_factory = RequestFactory()
54
- request = request_factory.get("/path")
55
- request.META["HTTP_HOST"] = "localhost"
56
- Article.objects.create(permalink="main")
57
- article = Article.get(request, permalink="main")
58
- self.assertEqual(article.og_url, "http://localhost/path")
59
- self.assertEqual(article.canonical, "http://localhost/path")
51
+ # def test_get_article_with_default_seo(self):
52
+ # """Our beloved get_seo utility with auto attributes"""
53
+ # request_factory = RequestFactory()
54
+ # request = request_factory.get("/path")
55
+ # request.META["HTTP_HOST"] = "localhost"
56
+ # Article.objects.create(permalink="main")
57
+ # article = Article.get(request, permalink="main")
58
+ # self.assertEqual(article.og_url, "http://localhost/path")
59
+ # self.assertEqual(article.canonical, "http://localhost/path")
60
60
 
61
- def test_compile_seo_overwrite(self):
62
- """Our beloved get_seo utility with auto attributes"""
63
- request_factory = RequestFactory()
64
- request = request_factory.get("/path")
65
- request.META["HTTP_HOST"] = "localhost"
66
- article = Article.objects.create(permalink="main")
67
- article.canonical = "/myarticle"
68
- article.og_url = "/myarticle"
69
- article.save()
70
- article = Article.get(request, permalink="main")
71
- self.assertEqual(article.og_url, "http://localhost/myarticle")
72
- self.assertEqual(article.canonical, "http://localhost/myarticle")
61
+ # def test_compile_seo_overwrite(self):
62
+ # """Our beloved get_seo utility with auto attributes"""
63
+ # request_factory = RequestFactory()
64
+ # request = request_factory.get("/path")
65
+ # request.META["HTTP_HOST"] = "localhost"
66
+ # article = Article.objects.create(permalink="main")
67
+ # article.canonical = "/myarticle"
68
+ # article.og_url = "/myarticle"
69
+ # article.save()
70
+ # article = Article.get(request, permalink="main")
71
+ # self.assertEqual(article.og_url, "http://localhost/myarticle")
72
+ # self.assertEqual(article.canonical, "http://localhost/myarticle")
73
73
 
74
- def test_get_article_with_redirect(self):
75
- """Our beloved get_seo utility with auto attributes"""
76
- request_factory = RequestFactory()
77
- request = request_factory.get("/articles/articolo-1")
78
- request.META["HTTP_HOST"] = "localhost"
74
+ # def test_get_article_with_redirect(self):
75
+ # """Our beloved get_seo utility with auto attributes"""
76
+ # request_factory = RequestFactory()
77
+ # request = request_factory.get("/articles/articolo-1")
78
+ # request.META["HTTP_HOST"] = "localhost"
79
79
 
80
- article = Article.objects.create(permalink="article-1", language_code="en")
81
- article.translate("it")
82
- article.permalink = "articolo-1"
83
- article.save()
84
- self.assertRaises(NeedARedirect, Article.get, request, permalink="article-1")
85
- activate("de")
86
- self.assertRaises(Http404, Article.get, request, permalink="article-1")
80
+ # article = Article.objects.create(permalink="article-1", language_code="en")
81
+ # article.translate("it")
82
+ # article.permalink = "articolo-1"
83
+ # article.save()
84
+ # self.assertRaises(NeedARedirect, Article.get, request, permalink="article-1")
85
+ # activate("de")
86
+ # self.assertRaises(Http404, Article.get, request, permalink="article-1")
File without changes
tests/utils/api.py ADDED
@@ -0,0 +1,29 @@
1
+ from django.contrib.auth.models import User
2
+ from rest_framework.test import APIClient
3
+ from example.website.models import TestModel
4
+
5
+ client = APIClient()
6
+
7
+
8
+ def login_superuser():
9
+ User.objects.create_superuser("admin", "admin@test.com", "adminadmin")
10
+ response = client.post(
11
+ "/api/camomilla/token-auth/", {"username": "admin", "password": "adminadmin"}
12
+ )
13
+ return response.json()["token"]
14
+
15
+
16
+ def login_user():
17
+ User.objects.create_user("user", "user@test.com", "useruser")
18
+ response = client.post(
19
+ "/api/camomilla/token-auth/", {"username": "user", "password": "useruser"}
20
+ )
21
+ return response.json()["token"]
22
+
23
+
24
+ def login_staff():
25
+ User.objects.create_user("staff", "staff@test.com", "staffstaff", is_staff=True)
26
+ response = client.post(
27
+ "/api/camomilla/token-auth/", {"username": "staff", "password": "staffstaff"}
28
+ )
29
+ return response.json()["token"]