utg-base 1.20.3__tar.gz → 1.21.1__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.
- {utg_base-1.20.3 → utg_base-1.21.1}/PKG-INFO +1 -1
- {utg_base-1.20.3 → utg_base-1.21.1}/pyproject.toml +1 -1
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/references_api/utils.py +11 -9
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/date.py +31 -1
- {utg_base-1.20.3 → utg_base-1.21.1}/README.md +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/api/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/api/base.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/api/pagination.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/api/permissions.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/api/routers.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/api/serializers.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/api/spectacular.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/authentications/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/authentications/microservice_authentication.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/authentications/models.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/apps.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/filters/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/filters/task_result.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/management/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/management/commands/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/management/commands/migrate_tasks.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/serializers/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/serializers/periodic_task.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/serializers/task_result.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/urls.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/views/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/views/periodic_task.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/views/task_result.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/constants/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/constants/accessibility_type.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/constants/available_languages.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/env.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/logging.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/middleware/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/middleware/debug.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/middleware/locale.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/migration/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/migration/apps.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/migration/management/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/migration/management/commands/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/migration/management/commands/makemigrations.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/models/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/models/jwt_user.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/models/timestamp.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/permissions/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/permissions/decorators.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/permissions/folder.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/permissions/utils.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/references_api/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/references_api/apps.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/references_api/migrations/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/references_api/urls.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/services/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/services/base_api.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/signals/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/signals/sync_perms.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/u_services/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/u_services/apps.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/u_services/constants.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/u_services/migrations/0001_initial.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/u_services/migrations/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/u_services/models.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/u_services/u_requests.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/__init__.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/data.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/dict_util.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/response_processors.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/signals.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/sql.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/string.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/thread.py +0 -0
- {utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/utils/translation.py +0 -0
|
@@ -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',
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
from calendar import monthrange
|
|
2
2
|
from datetime import date, datetime, timedelta
|
|
3
3
|
|
|
4
|
+
from dateutil.relativedelta import relativedelta
|
|
5
|
+
from django.utils.timezone import make_aware as dj_make_aware
|
|
6
|
+
|
|
4
7
|
DEFAULT_DATE_FORMAT = '%Y-%m-%d'
|
|
5
8
|
DEFAULT_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
|
|
6
9
|
|
|
@@ -23,6 +26,18 @@ class UDate(date):
|
|
|
23
26
|
def yesterday(self):
|
|
24
27
|
return to_udate(self.datetime() - timedelta(days=1))
|
|
25
28
|
|
|
29
|
+
def month_ago(self):
|
|
30
|
+
return self - relativedelta(months=1)
|
|
31
|
+
|
|
32
|
+
def month_later(self):
|
|
33
|
+
return self + relativedelta(months=1)
|
|
34
|
+
|
|
35
|
+
def year_ago(self):
|
|
36
|
+
return self - relativedelta(years=1)
|
|
37
|
+
|
|
38
|
+
def year_later(self):
|
|
39
|
+
return self + relativedelta(years=1)
|
|
40
|
+
|
|
26
41
|
def first_day_of_month(self):
|
|
27
42
|
return self.replace(day=1)
|
|
28
43
|
|
|
@@ -78,7 +93,7 @@ class UDateTime(datetime):
|
|
|
78
93
|
def last_second_of_day(self):
|
|
79
94
|
return self.last_second_of_hour().replace(hour=23)
|
|
80
95
|
|
|
81
|
-
def
|
|
96
|
+
def hour_later(self):
|
|
82
97
|
return self + timedelta(hours=1)
|
|
83
98
|
|
|
84
99
|
def hour_ago(self):
|
|
@@ -90,6 +105,18 @@ class UDateTime(datetime):
|
|
|
90
105
|
def yesterday(self):
|
|
91
106
|
return self - timedelta(days=1)
|
|
92
107
|
|
|
108
|
+
def month_ago(self):
|
|
109
|
+
return self - relativedelta(months=1)
|
|
110
|
+
|
|
111
|
+
def month_later(self):
|
|
112
|
+
return self + relativedelta(months=1)
|
|
113
|
+
|
|
114
|
+
def year_ago(self):
|
|
115
|
+
return self - relativedelta(years=1)
|
|
116
|
+
|
|
117
|
+
def year_later(self):
|
|
118
|
+
return self + relativedelta(years=1)
|
|
119
|
+
|
|
93
120
|
def first_day_of_month(self):
|
|
94
121
|
return self.replace(day=1)
|
|
95
122
|
|
|
@@ -118,6 +145,9 @@ class UDateTime(datetime):
|
|
|
118
145
|
def strftime(self, __format=DEFAULT_DATETIME_FORMAT):
|
|
119
146
|
return super().strftime(__format)
|
|
120
147
|
|
|
148
|
+
def make_aware(self) -> UDateTime:
|
|
149
|
+
return dj_make_aware(self)
|
|
150
|
+
|
|
121
151
|
@staticmethod
|
|
122
152
|
def strptime(__date_string: str, __format=DEFAULT_DATETIME_FORMAT):
|
|
123
153
|
return to_udatetime(datetime.strptime(__date_string, __format))
|
|
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
|
{utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/authentications/microservice_authentication.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
|
{utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/celery/management/commands/migrate_tasks.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
|
|
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
|
{utg_base-1.20.3 → utg_base-1.21.1}/src/utg_base/migration/management/commands/makemigrations.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
|
|
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
|