easyapi-django 0.2__tar.gz → 0.22__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.
Files changed (25) hide show
  1. {easyapi_django-0.2/easyapi_django.egg-info → easyapi_django-0.22}/PKG-INFO +1 -1
  2. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/base.py +13 -3
  3. {easyapi_django-0.2 → easyapi_django-0.22/easyapi_django.egg-info}/PKG-INFO +1 -1
  4. {easyapi_django-0.2 → easyapi_django-0.22}/pyproject.toml +1 -1
  5. {easyapi_django-0.2 → easyapi_django-0.22}/LICENSE +0 -0
  6. {easyapi_django-0.2 → easyapi_django-0.22}/README.md +0 -0
  7. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/__init__.py +0 -0
  8. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/calc.py +0 -0
  9. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/calc_resource.py +0 -0
  10. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/constants.py +0 -0
  11. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/dates.py +0 -0
  12. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/exception.py +0 -0
  13. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/filters.py +0 -0
  14. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/middleware.py +0 -0
  15. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/orm/__init__.py +0 -0
  16. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/rate_limit.py +0 -0
  17. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/routes.py +0 -0
  18. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/tenant/__init__.py +0 -0
  19. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/tenant/db_router.py +0 -0
  20. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/tenant/tenant.py +0 -0
  21. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi/util.py +0 -0
  22. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi_django.egg-info/SOURCES.txt +0 -0
  23. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi_django.egg-info/dependency_links.txt +0 -0
  24. {easyapi_django-0.2 → easyapi_django-0.22}/easyapi_django.egg-info/top_level.txt +0 -0
  25. {easyapi_django-0.2 → easyapi_django-0.22}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: easyapi_django
3
- Version: 0.2
3
+ Version: 0.22
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
@@ -234,6 +234,7 @@ class BaseResource(View):
234
234
  edit_exclude_fields = ['_state']
235
235
  update_fields = []
236
236
  create_fields = False
237
+ filters = []
237
238
 
238
239
  default_filter = None
239
240
  search_operator = 'icontains'
@@ -334,7 +335,7 @@ class BaseResource(View):
334
335
  await redis.expire(f'{PREFIX}rate_limit:blocked:{identifier}', 86400)
335
336
  await redis.close()
336
337
  await redis.connection_pool.disconnect()
337
- raise HTTPException(403, 'Unavailable')
338
+ raise HTTPException(403, 'Blocked due to misbehavior')
338
339
 
339
340
  async def check_is_blocked(self, identifier):
340
341
  redis = await aioredis.Redis(
@@ -347,7 +348,7 @@ class BaseResource(View):
347
348
  await redis.close()
348
349
  await redis.connection_pool.disconnect()
349
350
  if blocked:
350
- raise HTTPException(403, 'Unavailable')
351
+ raise HTTPException(403, 'Blocked due to misbehavior')
351
352
 
352
353
  async def dispatch(self, request, *args, **kwargs) -> None:
353
354
  self.identifier = request.META.get('HTTP_X_REAL_IP', request.META['REMOTE_ADDR'])
@@ -365,7 +366,7 @@ class BaseResource(View):
365
366
  await self.block(self.identifier)
366
367
 
367
368
  if result['rate_limited']:
368
- raise HTTPException(429, 'Too many requests')
369
+ raise HTTPException(429, 'Slow down, too many requests. You will be blocked.')
369
370
 
370
371
  session = None
371
372
  if request.headers.get('X-Api-Key'):
@@ -714,6 +715,9 @@ class BaseResource(View):
714
715
 
715
716
  # filtro por segmento/filter só se aplica a listagens
716
717
  async def get_filters(self, request):
718
+ if self.filters:
719
+ self.queryset = self.queryset.filter(self.filters)
720
+
717
721
  filter_ = request.GET.get('filter')
718
722
 
719
723
  normalize_list = request.GET.get('normalize_list')
@@ -752,6 +756,9 @@ class BaseResource(View):
752
756
  )
753
757
  queryset = queryset.filter(filters)
754
758
 
759
+ if self.filters:
760
+ queryset = queryset.filter(self.filters)
761
+
755
762
  self.queryset = queryset.distinct()
756
763
 
757
764
  async def return_results(self, results):
@@ -890,6 +897,9 @@ class BaseResource(View):
890
897
  related = []
891
898
  m2m = []
892
899
 
900
+ if self.filters:
901
+ self.queryset = self.queryset.filter(self.filters)
902
+
893
903
  if self.edit_related_fields:
894
904
  for key in self.edit_related_fields.keys():
895
905
  if key in self.fk_fields:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: easyapi_django
3
- Version: 0.2
3
+ Version: 0.22
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
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
11
11
 
12
12
  [project]
13
13
  name = "easyapi_django"
14
- version = "0.2"
14
+ version = "0.22"
15
15
  authors = [
16
16
  { name="Stamatios Stamou Jr", email="bushier.outsets.0c@icloud.com" },
17
17
  ]
File without changes
File without changes
File without changes