utg-base 1.21.0__py3-none-any.whl → 1.21.1__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.
utg_base/references_api/utils.py
CHANGED
|
@@ -7,7 +7,6 @@ from django.db.models import Model, CharField
|
|
|
7
7
|
from drf_spectacular.utils import extend_schema, extend_schema_serializer
|
|
8
8
|
from rest_framework import filters
|
|
9
9
|
from rest_framework import viewsets, serializers
|
|
10
|
-
|
|
11
10
|
from utg_base.api.base import BaseAPIView
|
|
12
11
|
from utg_base.permissions.decorators import has_class_perm
|
|
13
12
|
|
|
@@ -20,10 +19,10 @@ def find_model(model_name: str):
|
|
|
20
19
|
return model_class
|
|
21
20
|
|
|
22
21
|
|
|
23
|
-
def get_api_meta_property(model: Model, property_name: str):
|
|
22
|
+
def get_api_meta_property(model: Model, property_name: str, default=None):
|
|
24
23
|
if hasattr(model, 'ApiMeta'):
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
return getattr(model.ApiMeta, property_name, default)
|
|
25
|
+
return default
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
def get_model_class_name(model: Model):
|
|
@@ -84,11 +83,14 @@ def create_view_set(model: Model):
|
|
|
84
83
|
|
|
85
84
|
@extend_schema(tags=[get_url_prefix(model)])
|
|
86
85
|
class ViewSet(viewsets.ModelViewSet, BaseAPIView):
|
|
87
|
-
http_method_names = get_api_meta_property(model, 'http_method_names'
|
|
86
|
+
http_method_names = get_api_meta_property(model, 'http_method_names', ['get', 'patch'])
|
|
88
87
|
manager = model.objects.order_by(*get_ordering(model))
|
|
89
88
|
filter_backends = [filters.SearchFilter]
|
|
90
|
-
search_fields =
|
|
91
|
-
|
|
89
|
+
search_fields = get_api_meta_property(
|
|
90
|
+
model=model,
|
|
91
|
+
property_name='search_fields',
|
|
92
|
+
default=[field.name for field in fields_list if isinstance(field, CharField)]
|
|
93
|
+
)
|
|
92
94
|
|
|
93
95
|
def get_serializer_class(self):
|
|
94
96
|
if self.action == 'create':
|
|
@@ -128,7 +130,7 @@ def create_serializer_for_partial_update(model: Model):
|
|
|
128
130
|
fields = '__all__'
|
|
129
131
|
read_only_fields = list(
|
|
130
132
|
{
|
|
131
|
-
*get_api_meta_property(model, 'readonly_fields'),
|
|
133
|
+
*get_api_meta_property(model, 'readonly_fields', tuple()),
|
|
132
134
|
'created_at',
|
|
133
135
|
'updated_at',
|
|
134
136
|
'deleted_at',
|
|
@@ -174,7 +176,7 @@ def create_serializer(model: Model, depth=0):
|
|
|
174
176
|
fields = '__all__'
|
|
175
177
|
read_only_fields = list(
|
|
176
178
|
{
|
|
177
|
-
*get_api_meta_property(model, 'readonly_fields'),
|
|
179
|
+
*get_api_meta_property(model, 'readonly_fields', tuple()),
|
|
178
180
|
'created_at',
|
|
179
181
|
'updated_at',
|
|
180
182
|
'deleted_at',
|
|
@@ -47,7 +47,7 @@ utg_base/references_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
|
47
47
|
utg_base/references_api/apps.py,sha256=thAGmO-ZT-OD9dHHBSQRL_RRt-Es_jt-mEmHgVTpERs,168
|
|
48
48
|
utg_base/references_api/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
49
|
utg_base/references_api/urls.py,sha256=WkLACQ8GfK5pJkvt8FuYdOxcqSZHj7pYRw51M9WluGw,390
|
|
50
|
-
utg_base/references_api/utils.py,sha256=
|
|
50
|
+
utg_base/references_api/utils.py,sha256=W8IurGgX4Vrat0mVQeA5_a5iOP3YMNKGDSNqxkJa20M,6220
|
|
51
51
|
utg_base/services/__init__.py,sha256=LqtwUiqEZPIbKRGJfve5D5m3ucV6Kw1Nbo5Jnj_hPhY,37
|
|
52
52
|
utg_base/services/base_api.py,sha256=bMTmjy8TRN4WTCgV_1RvkquoqijJQ1hP7BBtPgW_AH0,5677
|
|
53
53
|
utg_base/signals/__init__.py,sha256=5SKumqAQrfrXUzi4NO3zjPAXV2TG3EDKxOomaF-e15M,35
|
|
@@ -69,6 +69,6 @@ utg_base/utils/sql.py,sha256=rqIWcSjdjIMszdRnsnhV5TTYB8W17RPOujIQA9rKC_Y,762
|
|
|
69
69
|
utg_base/utils/string.py,sha256=ATwIo9uLa00p85h_NjRYLcjRs8o3KSGF7s2yhTg5GiA,1073
|
|
70
70
|
utg_base/utils/thread.py,sha256=4RqRnwtyHymY-dNcuPrMSTamE2V7wCMVfzzyIb0P4TI,2191
|
|
71
71
|
utg_base/utils/translation.py,sha256=GxJHUt0iar_0E7RWBPbeLFQ4DhgXBjffHCmxfKyjFtk,463
|
|
72
|
-
utg_base-1.21.
|
|
73
|
-
utg_base-1.21.
|
|
74
|
-
utg_base-1.21.
|
|
72
|
+
utg_base-1.21.1.dist-info/METADATA,sha256=zunw_Sp5QKKQa8ysvtB0XFie011Bndjd90kxjXsRZMk,960
|
|
73
|
+
utg_base-1.21.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
74
|
+
utg_base-1.21.1.dist-info/RECORD,,
|
|
File without changes
|