easyapi-django 0.22__tar.gz → 0.24__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.
- {easyapi_django-0.22/easyapi_django.egg-info → easyapi_django-0.24}/PKG-INFO +1 -1
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/base.py +20 -15
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/filters.py +9 -11
- {easyapi_django-0.22 → easyapi_django-0.24/easyapi_django.egg-info}/PKG-INFO +1 -1
- {easyapi_django-0.22 → easyapi_django-0.24}/pyproject.toml +1 -1
- {easyapi_django-0.22 → easyapi_django-0.24}/LICENSE +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/README.md +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/__init__.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/calc.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/calc_resource.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/constants.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/dates.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/exception.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/middleware.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/orm/__init__.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/rate_limit.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/routes.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/tenant/__init__.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/tenant/db_router.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/tenant/tenant.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi/util.py +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi_django.egg-info/SOURCES.txt +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi_django.egg-info/dependency_links.txt +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/easyapi_django.egg-info/top_level.txt +0 -0
- {easyapi_django-0.22 → easyapi_django-0.24}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: easyapi_django
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.24
|
|
4
4
|
Summary: A simple rest api generator for django based on models
|
|
5
5
|
Author-email: Stamatios Stamou Jr <bushier.outsets.0c@icloud.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/ssjunior/easyapi-django
|
|
@@ -268,10 +268,10 @@ class BaseResource(View):
|
|
|
268
268
|
self.m2m_fields.append(field.name)
|
|
269
269
|
continue
|
|
270
270
|
|
|
271
|
-
if field.concrete and field.many_to_one:
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
271
|
+
# if field.concrete and field.many_to_one:
|
|
272
|
+
# self.fk_fields.append(field.name)
|
|
273
|
+
# fields.append(f'{field.name}_id')
|
|
274
|
+
# continue
|
|
275
275
|
|
|
276
276
|
# if not field.concrete and field.one_to_many:
|
|
277
277
|
# self.related_fields.append(field.name)
|
|
@@ -529,12 +529,12 @@ class BaseResource(View):
|
|
|
529
529
|
return response
|
|
530
530
|
|
|
531
531
|
async def build_filters(self, request):
|
|
532
|
-
if self.queryset is None or not await self.queryset.aexists():
|
|
533
|
-
return
|
|
534
|
-
|
|
535
532
|
if hasattr(self, 'model_filter'):
|
|
536
533
|
self.queryset = self.queryset.filter(**self.model_filter)
|
|
537
534
|
|
|
535
|
+
if self.queryset is None or not await self.queryset.aexists():
|
|
536
|
+
return
|
|
537
|
+
|
|
538
538
|
if request.GET.get('search'):
|
|
539
539
|
self.search_fields += ['id']
|
|
540
540
|
filters = reduce(
|
|
@@ -739,11 +739,12 @@ class BaseResource(View):
|
|
|
739
739
|
if not conditions:
|
|
740
740
|
return
|
|
741
741
|
|
|
742
|
-
|
|
742
|
+
orm_filter = OrmFilter(
|
|
743
743
|
self.model,
|
|
744
|
-
self.user.get('timezone', 'UTC') if self.user else 'UTC'
|
|
744
|
+
self.user.get('timezone', 'UTC') if self.user else 'UTC',
|
|
745
|
+
base_queryset=self.queryset
|
|
745
746
|
)
|
|
746
|
-
queryset =
|
|
747
|
+
queryset = orm_filter.filter_by(conditions)
|
|
747
748
|
|
|
748
749
|
if request.GET.get('search'):
|
|
749
750
|
self.search_fields += ['id']
|
|
@@ -902,11 +903,11 @@ class BaseResource(View):
|
|
|
902
903
|
|
|
903
904
|
if self.edit_related_fields:
|
|
904
905
|
for key in self.edit_related_fields.keys():
|
|
905
|
-
if key in self.
|
|
906
|
-
related.append(key)
|
|
907
|
-
|
|
908
|
-
elif key in self.m2m_fields:
|
|
906
|
+
if key in self.m2m_fields:
|
|
909
907
|
m2m.append(key)
|
|
908
|
+
else:
|
|
909
|
+
# Adiciona tudo que não é M2M (FKs diretos e encadeados)
|
|
910
|
+
related.append(key)
|
|
910
911
|
|
|
911
912
|
for key in related:
|
|
912
913
|
for rf in self.edit_related_fields[key]:
|
|
@@ -917,8 +918,12 @@ class BaseResource(View):
|
|
|
917
918
|
else:
|
|
918
919
|
related_fields.append(key)
|
|
919
920
|
|
|
920
|
-
|
|
921
|
+
try:
|
|
922
|
+
self.queryset = self.queryset.select_related(*related_fields)
|
|
923
|
+
except Exception as e:
|
|
924
|
+
raise HTTPException(500, f'Invalid related field in edit_related_fields: {str(e)}')
|
|
921
925
|
|
|
926
|
+
print(related_fields)
|
|
922
927
|
prefetch_fields = self.edit_prefetch_related.keys() if self.edit_prefetch_related else []
|
|
923
928
|
if prefetch_fields:
|
|
924
929
|
self.queryset = self.queryset.prefetch_related(*prefetch_fields)
|
|
@@ -50,16 +50,14 @@ class Filter(object):
|
|
|
50
50
|
|
|
51
51
|
def __init__(self, model, tz='UTC', **kwargs):
|
|
52
52
|
self.db_model = model
|
|
53
|
-
|
|
53
|
+
base_queryset = kwargs.get('base_queryset')
|
|
54
54
|
extra_filters = kwargs.get('extra_filters')
|
|
55
55
|
|
|
56
|
-
#
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
# elif self.original_model.model._meta.model_name == 'card':
|
|
62
|
-
# self.original_model = self.original_model.exclude(archived=1)
|
|
56
|
+
# Usa o queryset base se fornecido, caso contrário usa model.objects
|
|
57
|
+
if base_queryset is not None:
|
|
58
|
+
self.original_model = base_queryset.all()
|
|
59
|
+
else:
|
|
60
|
+
self.original_model = model.objects
|
|
63
61
|
|
|
64
62
|
if extra_filters:
|
|
65
63
|
self.original_model = self.original_model.filter(**extra_filters)
|
|
@@ -69,7 +67,7 @@ class Filter(object):
|
|
|
69
67
|
# interaction-with-default-ordering-or-order-by
|
|
70
68
|
self.original_model = self.original_model.order_by()
|
|
71
69
|
|
|
72
|
-
self.model =
|
|
70
|
+
self.model = self.original_model.all()
|
|
73
71
|
self.now = timezone.now().replace(tzinfo=pytz_timezone(tz))
|
|
74
72
|
self.tz = tz
|
|
75
73
|
self.date_start = None
|
|
@@ -81,7 +79,7 @@ class Filter(object):
|
|
|
81
79
|
self.working_model = None
|
|
82
80
|
|
|
83
81
|
def reset(self):
|
|
84
|
-
self.model =
|
|
82
|
+
self.model = self.original_model.all()
|
|
85
83
|
|
|
86
84
|
def change_timezone(self, tz):
|
|
87
85
|
self.tz = tz
|
|
@@ -570,7 +568,7 @@ class Filter(object):
|
|
|
570
568
|
|
|
571
569
|
def filter_by(self, filter_by_conditions, queryset=None, apply_dates=True, report=False):
|
|
572
570
|
if not self.working_model:
|
|
573
|
-
self.working_model =
|
|
571
|
+
self.working_model = self.model.all()
|
|
574
572
|
self.overrided = True
|
|
575
573
|
|
|
576
574
|
if queryset:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: easyapi_django
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.24
|
|
4
4
|
Summary: A simple rest api generator for django based on models
|
|
5
5
|
Author-email: Stamatios Stamou Jr <bushier.outsets.0c@icloud.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/ssjunior/easyapi-django
|
|
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
|