accrete 0.0.59__py3-none-any.whl → 0.0.60__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.
- accrete/urls.py +8 -0
- accrete/views.py +34 -19
- {accrete-0.0.59.dist-info → accrete-0.0.60.dist-info}/METADATA +1 -1
- {accrete-0.0.59.dist-info → accrete-0.0.60.dist-info}/RECORD +6 -5
- {accrete-0.0.59.dist-info → accrete-0.0.60.dist-info}/WHEEL +0 -0
- {accrete-0.0.59.dist-info → accrete-0.0.60.dist-info}/licenses/LICENSE +0 -0
accrete/urls.py
ADDED
accrete/views.py
CHANGED
@@ -1,31 +1,15 @@
|
|
1
|
+
import os
|
1
2
|
from functools import wraps
|
3
|
+
from django.http import HttpResponse, HttpResponseNotFound
|
2
4
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
3
5
|
from django.contrib.auth.views import login_required
|
4
6
|
from django.core.exceptions import ImproperlyConfigured
|
5
7
|
from django.shortcuts import redirect
|
6
8
|
from django.conf import settings
|
9
|
+
from accrete.tenant import get_tenant
|
7
10
|
from . import config
|
8
11
|
|
9
12
|
|
10
|
-
def tenant_required(
|
11
|
-
redirect_field_name: str = None,
|
12
|
-
login_url: str = None
|
13
|
-
):
|
14
|
-
def decorator(f):
|
15
|
-
@wraps(f)
|
16
|
-
@login_required(
|
17
|
-
redirect_field_name=redirect_field_name,
|
18
|
-
login_url=login_url
|
19
|
-
)
|
20
|
-
def _wrapped_view(request, *args, **kwargs):
|
21
|
-
tenant = request.tenant
|
22
|
-
if not tenant:
|
23
|
-
return redirect(config.ACCRETE_TENANT_NOT_SET_URL)
|
24
|
-
return f(request, *args, **kwargs)
|
25
|
-
return _wrapped_view
|
26
|
-
return decorator
|
27
|
-
|
28
|
-
|
29
13
|
class TenantRequiredMixin(LoginRequiredMixin):
|
30
14
|
|
31
15
|
tenant_missing_url = None
|
@@ -80,3 +64,34 @@ class TenantRequiredMixin(LoginRequiredMixin):
|
|
80
64
|
f"{cls_name}.get_member_not_authorized_url()."
|
81
65
|
)
|
82
66
|
return url
|
67
|
+
|
68
|
+
|
69
|
+
def tenant_required(
|
70
|
+
redirect_field_name: str = None,
|
71
|
+
login_url: str = None
|
72
|
+
):
|
73
|
+
def decorator(f):
|
74
|
+
@wraps(f)
|
75
|
+
@login_required(
|
76
|
+
redirect_field_name=redirect_field_name,
|
77
|
+
login_url=login_url
|
78
|
+
)
|
79
|
+
def _wrapped_view(request, *args, **kwargs):
|
80
|
+
tenant = request.tenant
|
81
|
+
if not tenant:
|
82
|
+
return redirect(config.ACCRETE_TENANT_NOT_SET_URL)
|
83
|
+
return f(request, *args, **kwargs)
|
84
|
+
return _wrapped_view
|
85
|
+
return decorator
|
86
|
+
|
87
|
+
|
88
|
+
@tenant_required()
|
89
|
+
def get_tenant_file(request, tenant_id, filepath):
|
90
|
+
tenant = get_tenant()
|
91
|
+
if tenant.id != tenant_id:
|
92
|
+
return HttpResponseNotFound()
|
93
|
+
filepath = f'{settings.MEDIA_ROOT}/{tenant_id}/{filepath}'
|
94
|
+
if not os.path.exists(filepath):
|
95
|
+
return HttpResponseNotFound()
|
96
|
+
with open(filepath, 'rb') as f:
|
97
|
+
return HttpResponse(f)
|
@@ -10,7 +10,8 @@ accrete/models.py,sha256=grvRNXg0ZYAJU3KAIX-svuZXeXlfqP4qEJ00nlbV594,5145
|
|
10
10
|
accrete/storage.py,sha256=z7pHdQFw0hFGrrbfqIh7KFxabQ_JGqoPebmiX9TLmeU,1254
|
11
11
|
accrete/tenant.py,sha256=g3ZuTrQr2zqmIopNBRQeCmHEK2R3dlUme_hOV765J6U,1778
|
12
12
|
accrete/tests.py,sha256=Agltbzwwh5htvq_Qi9vqvxutzmg_GwgPS_N19xJZRlw,7197
|
13
|
-
accrete/
|
13
|
+
accrete/urls.py,sha256=goDFR-yhOlLLy7AMi9pmh2aBkxdtZtwXNg6mwI2zPhU,227
|
14
|
+
accrete/views.py,sha256=fFvga5kniVYCV5J7PIYKPNK4EWAXX3I1eEw22y0A1_E,3432
|
14
15
|
accrete/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
16
|
accrete/contrib/sequence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
17
|
accrete/contrib/sequence/admin.py,sha256=mTjab5cVklRUIQcSrsUo-_JgtXEsSdcFj_gfWhlStS4,273
|
@@ -221,7 +222,7 @@ accrete/utils/dates.py,sha256=apM6kt6JhGrKgoT0jfav1W-8AUVTxNc9xt3fJQ2n0JI,1492
|
|
221
222
|
accrete/utils/forms.py,sha256=Lll-DvAhKZDw72XeuCtb4wxQEJNFp7lQWh_Z1GyH3Zk,3049
|
222
223
|
accrete/utils/http.py,sha256=mAtQRgADv7zu1_j7A-EKVyb-oqa5a21i4Gd0QfjzGV0,3540
|
223
224
|
accrete/utils/models.py,sha256=EEhv7-sQVtQD24PEb3XcDUAh3VVhVFoMMLyFrDjGEaI,706
|
224
|
-
accrete-0.0.
|
225
|
-
accrete-0.0.
|
226
|
-
accrete-0.0.
|
227
|
-
accrete-0.0.
|
225
|
+
accrete-0.0.60.dist-info/METADATA,sha256=EmTPYxeLQvtOr0nPLX-AcCzbzJViET1tufDFhgqPfak,4892
|
226
|
+
accrete-0.0.60.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
227
|
+
accrete-0.0.60.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
|
228
|
+
accrete-0.0.60.dist-info/RECORD,,
|
File without changes
|
File without changes
|