django-pfx 1.2.dev34__tar.gz → 1.2.dev38__tar.gz
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.
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/PKG-INFO +1 -1
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/django_pfx.egg-info/PKG-INFO +1 -1
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/__init__.py +2 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/management/commands/makeapidoc.py +8 -1
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/views/rest_views.py +13 -3
- django-pfx-1.2.dev38/tests/tests/test_api_doc.py +53 -0
- django-pfx-1.2.dev34/tests/tests/test_api_doc.py +0 -24
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/.gitignore +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/.gitlab-ci.yml +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/.pre-commit-config.yaml +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/LICENSE +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/MANIFEST.in +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/README.md +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/django_pfx.egg-info/SOURCES.txt +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/django_pfx.egg-info/dependency_links.txt +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/django_pfx.egg-info/requires.txt +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/django_pfx.egg-info/top_level.txt +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/img/pfx.png +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/img/pfx.svg +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/apps.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/decorator/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/decorator/rest.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/default_settings.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/exceptions.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/fields.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/http/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/http/json_response.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/locale/fr/LC_MESSAGES/django.mo +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/locale/fr/LC_MESSAGES/django.po +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/management/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/management/commands/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/middleware/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/middleware/authentication.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/middleware/locale.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/models/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/models/cache_mixins.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/models/not_null_fields.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/models/pfx_models.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/models/user_filtered_queryset_mixin.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/serializers/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/serializers/json.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/settings.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/shortcuts.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/storage/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/storage/s3_storage.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/templates/registration/password_reset_email.txt +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/templates/registration/password_reset_subject.txt +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/templates/registration/welcome_email.txt +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/templates/registration/welcome_subject.txt +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/test.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/urls.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/views/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/views/authentication_views.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/views/fields.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/views/filters_views.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/views/locale_views.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pyproject.toml +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/requirements.txt +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/runtest.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/setup.cfg +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/setup.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/models.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/settings/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/settings/ci.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/settings/common.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/settings/dev.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/settings/dev_custom_example.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/settings/dev_default.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/__init__.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/basic_api_errors.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/basic_api_test.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_auth_api.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_cache.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_fields.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_filters.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_locale_api.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_perm_tests.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_perms_api.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_shortcuts.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_timezone_middleware.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_tools.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_user_queryset.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_view_decorators.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/tests/test_view_fields.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/urls.py +0 -0
- {django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/tests/views.py +0 -0
|
@@ -5,6 +5,7 @@ from django.core.management.base import BaseCommand
|
|
|
5
5
|
|
|
6
6
|
from apispec import APISpec
|
|
7
7
|
|
|
8
|
+
from pfx.pfxcore import __PFX_VIEWS__
|
|
8
9
|
from pfx.pfxcore.settings import PFXSettings
|
|
9
10
|
|
|
10
11
|
settings = PFXSettings()
|
|
@@ -15,7 +16,13 @@ DEFAULT_TEMPLATE = dict(
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
def get_spec():
|
|
18
|
-
|
|
19
|
+
spec = APISpec(**{**DEFAULT_TEMPLATE, **settings.PFX_OPENAPI_TEMPLATE})
|
|
20
|
+
for view in __PFX_VIEWS__:
|
|
21
|
+
for url in view.get_urls():
|
|
22
|
+
spec.path(
|
|
23
|
+
path=url['path'],
|
|
24
|
+
operations={k: {} for k, v in url['methods'].items()})
|
|
25
|
+
return spec
|
|
19
26
|
|
|
20
27
|
|
|
21
28
|
class Command(BaseCommand):
|
|
@@ -12,6 +12,7 @@ from django.urls import path
|
|
|
12
12
|
from django.utils.translation import gettext_lazy as _
|
|
13
13
|
from django.views import View
|
|
14
14
|
|
|
15
|
+
from pfx.pfxcore import __PFX_VIEWS__
|
|
15
16
|
from pfx.pfxcore.decorator import rest_api
|
|
16
17
|
from pfx.pfxcore.exceptions import (
|
|
17
18
|
APIError,
|
|
@@ -551,9 +552,10 @@ class BaseRestView(SecuredRestViewMixin, View):
|
|
|
551
552
|
process, path.lstrip('/').split('/'))
|
|
552
553
|
|
|
553
554
|
@classmethod
|
|
554
|
-
def
|
|
555
|
+
def get_urls(cls, as_pattern=False):
|
|
555
556
|
def fullpath(p2):
|
|
556
|
-
|
|
557
|
+
res = f'{cls.rest_view_path}{p2}'.lstrip('/')
|
|
558
|
+
return res if as_pattern else f'/{res}'
|
|
557
559
|
|
|
558
560
|
paths = {}
|
|
559
561
|
for name in dir(cls):
|
|
@@ -568,11 +570,19 @@ class BaseRestView(SecuredRestViewMixin, View):
|
|
|
568
570
|
"you cannot set different priority for same path")
|
|
569
571
|
methods['priority'] = m.rest_api_priority
|
|
570
572
|
return [
|
|
571
|
-
path(fullpath(p), cls.as_view(pfx_methods=ms))
|
|
573
|
+
path(fullpath(p), cls.as_view(pfx_methods=ms)) if as_pattern
|
|
574
|
+
else dict(path=fullpath(p), methods={
|
|
575
|
+
k: v for k, v in ms.items() if k != 'priority'})
|
|
572
576
|
for p, ms in sorted(
|
|
573
577
|
paths.items(), key=lambda e: cls._path_order(*e),
|
|
574
578
|
reverse=True)]
|
|
575
579
|
|
|
580
|
+
@classmethod
|
|
581
|
+
def as_urlpatterns(cls):
|
|
582
|
+
if cls not in __PFX_VIEWS__:
|
|
583
|
+
__PFX_VIEWS__.append(cls)
|
|
584
|
+
return cls.get_urls(as_pattern=True)
|
|
585
|
+
|
|
576
586
|
|
|
577
587
|
class RestView(
|
|
578
588
|
ListRestViewMixin,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from django.test import TestCase, override_settings
|
|
2
|
+
|
|
3
|
+
from pfx.pfxcore.management.commands.makeapidoc import get_spec
|
|
4
|
+
from pfx.pfxcore.test import TestAssertMixin
|
|
5
|
+
from tests.views import AuthorRestView
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ApiDocTest(TestAssertMixin, TestCase):
|
|
9
|
+
def test_default_generation(self):
|
|
10
|
+
spec = get_spec().to_dict()
|
|
11
|
+
self.assertEqual(spec['openapi'], "3.0.2")
|
|
12
|
+
info = spec['info']
|
|
13
|
+
self.assertEqual(info['title'], "PFX API")
|
|
14
|
+
self.assertEqual(info['version'], "1.0.0")
|
|
15
|
+
|
|
16
|
+
@override_settings(PFX_OPENAPI_TEMPLATE=dict(
|
|
17
|
+
title="MyAPI",
|
|
18
|
+
info=dict(description="A test API")))
|
|
19
|
+
def test_default_customized_generation(self):
|
|
20
|
+
spec = get_spec().to_dict()
|
|
21
|
+
self.assertEqual(spec['openapi'], "3.0.2")
|
|
22
|
+
info = spec['info']
|
|
23
|
+
self.assertEqual(info['title'], "MyAPI")
|
|
24
|
+
self.assertEqual(info['version'], "1.0.0")
|
|
25
|
+
self.assertEqual(info['description'], "A test API")
|
|
26
|
+
|
|
27
|
+
def test_paths_generation(self):
|
|
28
|
+
def assertMethods(paths, p, methods):
|
|
29
|
+
self.assertEqual(set(paths[p].keys()), methods)
|
|
30
|
+
|
|
31
|
+
spec = get_spec().to_dict()
|
|
32
|
+
paths = spec['paths']
|
|
33
|
+
assertMethods(paths, '/authors', {'get', 'post'})
|
|
34
|
+
assertMethods(paths, '/authors/<int:id>', {'get', 'put', 'delete'})
|
|
35
|
+
assertMethods(paths, '/authors/slug/<slug:slug>', {'get'})
|
|
36
|
+
assertMethods(paths, '/authors/cache/<int:id>', {'get'})
|
|
37
|
+
|
|
38
|
+
def test_view_get_urls(self):
|
|
39
|
+
def assertMethods(urls, p, methods):
|
|
40
|
+
self.assertEqual(next(filter(
|
|
41
|
+
lambda u: u['path'] == p, urls))['methods'], methods)
|
|
42
|
+
|
|
43
|
+
urls = AuthorRestView.get_urls()
|
|
44
|
+
|
|
45
|
+
# Methods from RestView
|
|
46
|
+
assertMethods(urls, '/authors', dict(get='get_list', post='post'))
|
|
47
|
+
assertMethods(urls, '/authors/<int:id>', dict(
|
|
48
|
+
delete='delete', get='get', put='put'))
|
|
49
|
+
# A method from SlugDetailRestViewMixin
|
|
50
|
+
assertMethods(urls, '/authors/slug/<slug:slug>', dict(
|
|
51
|
+
get='get_by_slug'))
|
|
52
|
+
# A method from AuthorRestView itself
|
|
53
|
+
assertMethods(urls, '/authors/cache/<int:id>', dict(get='cache_get'))
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
from django.test import TestCase, override_settings
|
|
2
|
-
|
|
3
|
-
from pfx.pfxcore.management.commands.makeapidoc import get_spec
|
|
4
|
-
from pfx.pfxcore.test import TestAssertMixin
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class ApiDocTest(TestAssertMixin, TestCase):
|
|
8
|
-
def test_default_generation(self):
|
|
9
|
-
spec = get_spec().to_dict()
|
|
10
|
-
self.assertEqual(spec['openapi'], "3.0.2")
|
|
11
|
-
info = spec['info']
|
|
12
|
-
self.assertEqual(info['title'], "PFX API")
|
|
13
|
-
self.assertEqual(info['version'], "1.0.0")
|
|
14
|
-
|
|
15
|
-
@override_settings(PFX_OPENAPI_TEMPLATE=dict(
|
|
16
|
-
title="MyAPI",
|
|
17
|
-
info=dict(description="A test API")))
|
|
18
|
-
def test_default_customized_generation(self):
|
|
19
|
-
spec = get_spec().to_dict()
|
|
20
|
-
self.assertEqual(spec['openapi'], "3.0.2")
|
|
21
|
-
info = spec['info']
|
|
22
|
-
self.assertEqual(info['title'], "MyAPI")
|
|
23
|
-
self.assertEqual(info['version'], "1.0.0")
|
|
24
|
-
self.assertEqual(info['description'], "A test API")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/models/user_filtered_queryset_mixin.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/templates/registration/welcome_email.txt
RENAMED
|
File without changes
|
{django-pfx-1.2.dev34 → django-pfx-1.2.dev38}/pfx/pfxcore/templates/registration/welcome_subject.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|