django-restit 4.0.13__py3-none-any.whl → 4.1.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.
- {django_restit-4.0.13.dist-info → django_restit-4.1.1.dist-info}/METADATA +1 -1
- {django_restit-4.0.13.dist-info → django_restit-4.1.1.dist-info}/RECORD +18 -14
- metrics/rpc.py +1 -1
- pushit/models.py +1 -1
- rest/__init__.py +1 -1
- rest/crypto/util.py +20 -0
- rest/decorators.py +9 -9
- rest/errors.py +20 -0
- rest/helpers.py +24 -0
- rest/models/__init__.py +3 -0
- rest/{models.py → models/base.py} +79 -454
- rest/models/cacher.py +19 -0
- rest/models/metadata.py +302 -0
- rest/serializers/collection.py +7 -1
- rest/serializers/legacy.py +3 -3
- rest/serializers/model.py +23 -0
- {django_restit-4.0.13.dist-info → django_restit-4.1.1.dist-info}/LICENSE.md +0 -0
- {django_restit-4.0.13.dist-info → django_restit-4.1.1.dist-info}/WHEEL +0 -0
@@ -322,7 +322,7 @@ metrics/models.py,sha256=YGZqx-rN9dhNTSzO9-mZlJZlbtZeaqcnpWxLZlQc5II,10599
|
|
322
322
|
metrics/periodic.py,sha256=QQmN_bTRagOf54QKeJOrW99YqEsozTsZjKaPg-yRgyo,480
|
323
323
|
metrics/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
324
324
|
metrics/providers/aws.py,sha256=1TC3o_sSDETNzIQw-vqJ_J62rnjrWTXuEroWN1sbmfI,7335
|
325
|
-
metrics/rpc.py,sha256=
|
325
|
+
metrics/rpc.py,sha256=cb3D4Xu6yOzD29SmCUyCNGSYtE0yDHAq-hanIdxJxvY,14827
|
326
326
|
metrics/settings.py,sha256=wwHA9Z7BAHNeu3tFVn8Fh5j46KR-eGx0E8r5dzCFlAU,132
|
327
327
|
metrics/tq.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
328
328
|
metrics/utils.py,sha256=4IE1gHAjm6fuan9D27fYEks11Y5Bugk62VSN2InidmU,10490
|
@@ -330,7 +330,7 @@ pushit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
330
330
|
pushit/admin.py,sha256=69HdDZU_Iz8Fm72M8r8FUztsZvW37zdGwVmj8VTqr0c,451
|
331
331
|
pushit/migrations/0001_initial.py,sha256=kYF1ksOlKf9ElrlagGhpNf5GbKEq6SORWGreMH9A7as,4555
|
332
332
|
pushit/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
333
|
-
pushit/models.py,sha256=
|
333
|
+
pushit/models.py,sha256=dbUJgD9W1y_2H5NxMUQhjsucvLkruErRMXkUSbza3ck,5066
|
334
334
|
pushit/rpc/__init__.py,sha256=13ibfbWNdjoNxzCzF8QxasSzFgs8IZJPc05XhErOBCw,88
|
335
335
|
pushit/rpc/githooks.py,sha256=p81qKjIcrFeQll1fKnm2pGRURWxKhT9TlH8PEHoc9po,1874
|
336
336
|
pushit/rpc/legacy.py,sha256=9xsZH1S70htIb0bwKENfhTe-uHvyqSTiPiwYTlLWS3E,5028
|
@@ -341,21 +341,22 @@ pushit/utils.py,sha256=5NcWELJJjmiY2N7SiSh-qonJbLgVtFAu-EMkcFJ5St4,1966
|
|
341
341
|
rest/.gitignore,sha256=TbEvWRMnAiajCTOdhiNrd9eeCAaIjRp9PRjE_VkMM5g,118
|
342
342
|
rest/README.md,sha256=V3ETc-cJu8PZIbKr9xSe_pA4JEUpC8Dhw4bQeVCDJPw,5460
|
343
343
|
rest/RemoteEvents.py,sha256=nL46U7AuxIrlw2JunphR1tsXyqi-ep_gD9CYGpYbNgE,72
|
344
|
-
rest/__init__.py,sha256=
|
344
|
+
rest/__init__.py,sha256=iEYrXYktGlXVVYPSHMGfpqa4QCKPy-tgI2w_NoWjsNE,120
|
345
345
|
rest/arc4.py,sha256=y644IbF1ec--e4cUJ3KEYsewTCITK0gmlwa5mJruFC0,1967
|
346
346
|
rest/cache.py,sha256=1Qg0rkaCJCaVP0-l5hZg2CIblTdeBSlj_0fP6vlKUpU,83
|
347
347
|
rest/crypto/__init__.py,sha256=Tl0U11rgj1eBYqd6OXJ2_XSdNLumW_JkBZnaJqI6Ldw,72
|
348
348
|
rest/crypto/aes.py,sha256=f7UgiTGCfgjCc7dL94vnxkPhq_5NzooI-kw0B8_nA58,3605
|
349
349
|
rest/crypto/privpub.py,sha256=_FioylVcbMmDP80yPYjURmafEiDmEAMkskbc7WF10ac,4082
|
350
|
-
rest/crypto/util.py,sha256=
|
350
|
+
rest/crypto/util.py,sha256=agFN2OCPHC70tHNGWrMkkZX4Tt_Ty6imoKEMdTkZpKA,4514
|
351
351
|
rest/datem.py,sha256=Tv8wF2PX0Ktr1wLgGEj6o0OW45RSkD9XDLnLRk8bRjc,7784
|
352
|
-
rest/decorators.py,sha256=
|
352
|
+
rest/decorators.py,sha256=kT15oKQLRto4rD3tjsdOcf0OvC_Bwo7WTWGNl3wiUxo,15573
|
353
353
|
rest/encryption.py,sha256=x6Kiez0tVqfxK26MSsRL3k8OS05ni1gEX2aj3I0S9V0,788
|
354
|
+
rest/errors.py,sha256=Jy7Hld3d0Ooc-nJ995N5SDx0EXQLWKac7g6VLJpVJf0,501
|
354
355
|
rest/extra/__init__.py,sha256=YzmNsch5H5FFLkUK9mIAKyoRK_rJCA9HGb0kubp4h30,54
|
355
356
|
rest/extra/json_metadata.py,sha256=p_ffzmANmOFix_oC3voR6_NNTjcn7-T7aXcH-I4_Npg,1078
|
356
357
|
rest/fields.py,sha256=_v1TJVc6vyWlqmwFRJ6mtuR5Fo-lS0KcUhPWIrzKZUo,9719
|
357
358
|
rest/forms.py,sha256=66Wm5cdy8tKib_mGicjq_yd-gNVMFWRECnrDksnNnwU,6316
|
358
|
-
rest/helpers.py,sha256=
|
359
|
+
rest/helpers.py,sha256=RRYpmZnsFtaZxUtdbBgud3mFYVkZ0HspGROXhgNDAxA,24650
|
359
360
|
rest/joke.py,sha256=0PpKaX2iN7jlS62kgjfmmqkFBYLPURz15aQ8R7OJkJ8,260
|
360
361
|
rest/jwtoken.py,sha256=1ruZGPTXnodb85ywPd8ZmRiRYCskopA8EhcbX7Adixc,2298
|
361
362
|
rest/log.py,sha256=hd1_4HBOS395sfXJIL6BTw9yekm1SLgBwYx_PdfIhKA,20930
|
@@ -371,18 +372,21 @@ rest/middleware/jwt.py,sha256=p-1v-hIwLxo7wrI16ajrLDL5GRwA1Co_ObmSH81aOg8,5395
|
|
371
372
|
rest/middleware/request.py,sha256=OlWE4_8nJ1krzuiNn2heecPxqtbTEhFzGYp3_7bnEEA,4127
|
372
373
|
rest/middleware/session.py,sha256=-CzKTQHGDzz5tGrdSXC6fsNfRlYEjotAfuTbb_tSER0,9015
|
373
374
|
rest/middleware/session_store.py,sha256=X_i06TnZLW1srV0vkjjLhZ7fl1G56PswXxRpVzdFasw,1874
|
374
|
-
rest/models.py,sha256=
|
375
|
+
rest/models/__init__.py,sha256=M8pvFDq-WCF-QcM58X7pMufYYe0aaQ3U0PwGe9TKbbY,130
|
376
|
+
rest/models/base.py,sha256=B4Jk8lgUgyjOMTy4Fvi6XZ0o_mCd2GpFblb26Imm2h0,62119
|
377
|
+
rest/models/cacher.py,sha256=eKz8TINVhWEqKhJGMsRkKZTtBUIv5rN3NHbZwOC56Uk,578
|
378
|
+
rest/models/metadata.py,sha256=MQKiwXNGkpmloyLMNJoOSCV2ID_Fg9GP2VXm5t8iGX8,11606
|
375
379
|
rest/regexes.yaml,sha256=VoGb4E-P_K9f82Yzcpltgzekpt9usRtwu9PYlo46nUw,149463
|
376
380
|
rest/requestex.py,sha256=eD1eCPhLl7fj0oUKpESCTIr8O7mjOyBUsRXVMQ1h3W8,14894
|
377
381
|
rest/rpc.py,sha256=KMih2Z4Z0Pqgwmcy_14nKqMCKJ9lGDJ6-vwMA2NSlyQ,3713
|
378
382
|
rest/search.py,sha256=i7rnZZhlnuAT0isyVcMHEqGjbiz7EIArgjzzg7xwK-s,7645
|
379
383
|
rest/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
380
|
-
rest/serializers/collection.py,sha256=
|
384
|
+
rest/serializers/collection.py,sha256=A5T6A_iqQiVNt0AirhJrZfkGIKi-tIPtFxxDvrOZYmY,2008
|
381
385
|
rest/serializers/csv.py,sha256=nae_SIIpDH7HReErjNacVxEujzTvJqQxHd29BY-RXh0,2975
|
382
386
|
rest/serializers/excel.py,sha256=KtxqZZU5Huzo31tyVVWbshMudeSAImKLO71ufQQt0-c,1077
|
383
387
|
rest/serializers/json.py,sha256=R1has2PZQuXacA6WwfdrBnMG4rSM6CrnXQOhGoAU6Dk,1736
|
384
|
-
rest/serializers/legacy.py,sha256=
|
385
|
-
rest/serializers/model.py,sha256=
|
388
|
+
rest/serializers/legacy.py,sha256=AhwXFZQQ2XedV5ztQiHPbDRkd4vDX1iTejZrHH-r5Gs,61795
|
389
|
+
rest/serializers/model.py,sha256=60A7ahflZZDiYQjHVOBYdzTT83V5cqlOafDq0MmVN4w,6624
|
386
390
|
rest/serializers/profiler.py,sha256=OxOimhEyvCAuzUBC9Q1dz2xaakjAqmSnekMATsjduXM,997
|
387
391
|
rest/serializers/response.py,sha256=XU_0IVnt48PXPxKqMIS3NuCEM7lRzaL-QdonfQce29k,6464
|
388
392
|
rest/serializers/util.py,sha256=-In89fpuVTd6_Ul8nwEUt3DjVKdpeoEyAxudlyB8K6Y,2734
|
@@ -447,7 +451,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
|
|
447
451
|
ws4redis/settings.py,sha256=lF-6nzv7SWjmFgmontpZKdSBhp8q4FhvFOcEYZGR8pc,1411
|
448
452
|
ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
|
449
453
|
ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
|
450
|
-
django_restit-4.
|
451
|
-
django_restit-4.
|
452
|
-
django_restit-4.
|
453
|
-
django_restit-4.
|
454
|
+
django_restit-4.1.1.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
|
455
|
+
django_restit-4.1.1.dist-info/METADATA,sha256=lAxYOcGU4XHO2wmr3aYEOmX3jyjhb9DiJq1LW2ztABY,7531
|
456
|
+
django_restit-4.1.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
457
|
+
django_restit-4.1.1.dist-info/RECORD,,
|
metrics/rpc.py
CHANGED
@@ -2,7 +2,7 @@ from datetime import datetime
|
|
2
2
|
from rest import decorators as rd
|
3
3
|
from rest import views as rv
|
4
4
|
from rest import settings
|
5
|
-
from rest.
|
5
|
+
from rest.helpers import requestHasPerms
|
6
6
|
from location.models import GeoIP
|
7
7
|
from . import client as metrics
|
8
8
|
from . import models as mm
|
pushit/models.py
CHANGED
@@ -10,7 +10,7 @@ from location.models import GeoIP, Address
|
|
10
10
|
from rest import helpers as rest_helpers
|
11
11
|
from rest.middleware import get_request
|
12
12
|
from rest import RemoteEvents
|
13
|
-
from rest.models import RestModel, MetaDataModel, MetaDataBase
|
13
|
+
from rest.models import RestModel, MetaDataModel, MetaDataBase
|
14
14
|
|
15
15
|
class Product(models.Model, RestModel, MetaDataModel):
|
16
16
|
class RestMeta:
|
rest/__init__.py
CHANGED
rest/crypto/util.py
CHANGED
@@ -13,6 +13,26 @@ def generateKey(bit_size=128, allow_punctuation=False):
|
|
13
13
|
return randomString(byte_size, allow_punctuation)
|
14
14
|
|
15
15
|
|
16
|
+
def generateUUID(*args, **kwargs):
|
17
|
+
upper = kwargs.get("upper", True)
|
18
|
+
max_length = kwargs.get("max_length", None)
|
19
|
+
uuid = ""
|
20
|
+
for key in args:
|
21
|
+
if isinstance(key, float):
|
22
|
+
key = str(float)
|
23
|
+
if isinstance(key, int):
|
24
|
+
uuid += Hashids().encrypt(key)
|
25
|
+
if isinstance(key, str):
|
26
|
+
uuid += toString(md5(toBytes(key)).hexdigest())
|
27
|
+
if len(uuid) > 125:
|
28
|
+
uuid = uuid[:125]
|
29
|
+
if max_length != None:
|
30
|
+
uuid = uuid[:max_length]
|
31
|
+
if upper:
|
32
|
+
return uuid.upper()
|
33
|
+
return uuid
|
34
|
+
|
35
|
+
|
16
36
|
def get_random_bits(bit_size=128):
|
17
37
|
return crypt_random.getrandbits(bit_size)
|
18
38
|
|
rest/decorators.py
CHANGED
@@ -9,8 +9,8 @@ from django.utils.cache import patch_cache_control, add_never_cache_headers, pat
|
|
9
9
|
|
10
10
|
from rest import settings
|
11
11
|
from rest.views import restStatus, restPermissionDenied
|
12
|
-
from rest.
|
13
|
-
from rest import helpers
|
12
|
+
from rest.errors import RestError, PermissionDeniedException
|
13
|
+
from rest import helpers as rh
|
14
14
|
import metrics
|
15
15
|
import incident
|
16
16
|
|
@@ -61,16 +61,16 @@ def rest_error_catcher(func, request, *args, **kwargs):
|
|
61
61
|
metrics.metric(f"rest_call_{slug_path}", category="rest_calls")
|
62
62
|
return func(request, *args, **kwargs)
|
63
63
|
except PermissionDeniedException as err:
|
64
|
-
|
64
|
+
rh.log_error("permission denied: '{}' for {} {}:{}".format(err, request.user, request.method, request.path))
|
65
65
|
return restStatus(request, False, error=err.reason, error_code=err.code)
|
66
66
|
except RestError as err:
|
67
|
-
|
67
|
+
rh.log_exception(err.reason)
|
68
68
|
if settings.get("REST_ERROR_METRICS", True):
|
69
69
|
metrics.metric("rest_errors")
|
70
70
|
return restStatus(request, False, error=err.reason, error_code=err.code)
|
71
71
|
except Exception as err:
|
72
72
|
# TODO email errors to admins
|
73
|
-
|
73
|
+
rh.log_exception(request.path)
|
74
74
|
if settings.get("REST_ERROR_METRICS", True):
|
75
75
|
metrics.metric("rest_errors")
|
76
76
|
stack = str(traceback.format_exc())
|
@@ -194,7 +194,7 @@ def _url_method(pattern, method=None, *args, **kwargs):
|
|
194
194
|
else:
|
195
195
|
func = f
|
196
196
|
if not isinstance(pattern, str):
|
197
|
-
|
197
|
+
rh.log_print("NOT A STRING", pattern)
|
198
198
|
if pattern.startswith("^") or pattern.endswith("$"):
|
199
199
|
rpc_root_module.urlpatterns += [re_path(pattern, func, *args, **kwargs)]
|
200
200
|
else:
|
@@ -369,7 +369,7 @@ class perm_required(object):
|
|
369
369
|
|
370
370
|
def __call__(self, func):
|
371
371
|
def inner_func(request=None, *args, **kwargs):
|
372
|
-
status, error, code = requestHasPerms(request, self.perms)
|
372
|
+
status, error, code = rh.requestHasPerms(request, self.perms)
|
373
373
|
if not status:
|
374
374
|
return restStatus(request, False, error=error, error_code=code)
|
375
375
|
return func(request, *args, **kwargs)
|
@@ -383,7 +383,7 @@ class post_perm_required(object):
|
|
383
383
|
def __call__(self, func):
|
384
384
|
def inner_func(request=None, *args, **kwargs):
|
385
385
|
if request.method == "post":
|
386
|
-
status, error, code = requestHasPerms(request, self.perms)
|
386
|
+
status, error, code = rh.requestHasPerms(request, self.perms)
|
387
387
|
if not status:
|
388
388
|
return restStatus(request, False, error=error, error_code=code)
|
389
389
|
elif not request.user.is_authenticated:
|
@@ -439,7 +439,7 @@ def periodic(minute=None, hour=None, day=None, month=None, weekday=None, tz=None
|
|
439
439
|
if force:
|
440
440
|
return func(force, verbose, now)
|
441
441
|
if tz:
|
442
|
-
now =
|
442
|
+
now = rh.convertToLocalTime(tz, now)
|
443
443
|
# lets create our when
|
444
444
|
if minute is not None and not periodicCheckListHas(minute, now.minute):
|
445
445
|
return -22
|
rest/errors.py
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
class RestError(Exception):
|
3
|
+
def __init__(self, reason, code=None):
|
4
|
+
self.reason = reason
|
5
|
+
self.code = code
|
6
|
+
|
7
|
+
def __repr__(self):
|
8
|
+
return self.reason
|
9
|
+
|
10
|
+
|
11
|
+
class PermissionDeniedException(RestError):
|
12
|
+
def __init__(self, reason="permission denied", code=401):
|
13
|
+
self.reason = reason
|
14
|
+
self.code = code
|
15
|
+
|
16
|
+
|
17
|
+
class RestValidationError(RestError):
|
18
|
+
def __init__(self, reason="rest data is not valid", code=123):
|
19
|
+
self.reason = reason
|
20
|
+
self.code = code
|
rest/helpers.py
CHANGED
@@ -54,6 +54,30 @@ def getActiveRequest():
|
|
54
54
|
return HELPER_CACHE.get_request()
|
55
55
|
|
56
56
|
|
57
|
+
def requestHasPerms(request, perms, group=None):
|
58
|
+
# third party auth models
|
59
|
+
if request.auth_model is not None:
|
60
|
+
if request.auth_model.hasPerm(perms):
|
61
|
+
return True, None, None
|
62
|
+
|
63
|
+
if not request.user.is_authenticated:
|
64
|
+
return False, "auth required", 401
|
65
|
+
|
66
|
+
if request.member.hasPerm(perms):
|
67
|
+
return True, None, None
|
68
|
+
if group is None and hasattr(request, "group"):
|
69
|
+
group = request.group
|
70
|
+
ms_perms = None
|
71
|
+
if group:
|
72
|
+
ms = request.member.getMembershipFor(group)
|
73
|
+
if ms and ms.hasPerm(perms):
|
74
|
+
return True, None, None
|
75
|
+
if ms:
|
76
|
+
ms_perms = ms.getPermissions()
|
77
|
+
|
78
|
+
# rest_helpers.log_error(F"PERMISSION DENIED for {request.member.username}, {perms}", str(group), ms_perms)
|
79
|
+
return False, "permission denied", 402
|
80
|
+
|
57
81
|
def importModule(name):
|
58
82
|
return importlib.import_module(name)
|
59
83
|
|
rest/models/__init__.py
ADDED