accrete 0.0.58__py3-none-any.whl → 0.0.59__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/contrib/ui/filter.py +6 -1
- accrete/middleware.py +7 -5
- accrete/storage.py +37 -0
- {accrete-0.0.58.dist-info → accrete-0.0.59.dist-info}/METADATA +1 -1
- {accrete-0.0.58.dist-info → accrete-0.0.59.dist-info}/RECORD +7 -6
- {accrete-0.0.58.dist-info → accrete-0.0.59.dist-info}/WHEEL +0 -0
- {accrete-0.0.58.dist-info → accrete-0.0.59.dist-info}/licenses/LICENSE +0 -0
accrete/contrib/ui/filter.py
CHANGED
@@ -158,7 +158,9 @@ class Filter:
|
|
158
158
|
'PositiveSmallIntegerField': self.int_param,
|
159
159
|
'DateTimeField': self.date_time_param,
|
160
160
|
'DateField': self.date_param,
|
161
|
-
'ForeignKey': self.foreign_key_param
|
161
|
+
'ForeignKey': self.foreign_key_param,
|
162
|
+
'FileField': self.file_param,
|
163
|
+
'ImageField': self.file_param
|
162
164
|
}
|
163
165
|
|
164
166
|
def parse_choices(self, choices):
|
@@ -269,6 +271,9 @@ class Filter:
|
|
269
271
|
return self.null_param(key, value)
|
270
272
|
return ''
|
271
273
|
|
274
|
+
def file_param(self, key, value):
|
275
|
+
return self.null_param(key, value)
|
276
|
+
|
272
277
|
def null_param(self, key, value):
|
273
278
|
options = self.parse_choices([
|
274
279
|
('true', _('True')),
|
accrete/middleware.py
CHANGED
@@ -82,10 +82,12 @@ class HtmxRedirectMiddleware(MiddlewareMixin):
|
|
82
82
|
@staticmethod
|
83
83
|
def process_response(request, response):
|
84
84
|
is_htmx = request.headers.get('HX-Request', 'false') == 'true'
|
85
|
-
|
86
|
-
response
|
87
|
-
)
|
88
|
-
|
89
|
-
|
85
|
+
if not is_htmx:
|
86
|
+
return response
|
87
|
+
is_redirect = isinstance(response, HttpResponseRedirect)
|
88
|
+
is_permanent_redirect = isinstance(response, HttpResponsePermanentRedirect)
|
89
|
+
if is_redirect or is_permanent_redirect:
|
90
90
|
response.status_code = 200
|
91
|
+
header = 'HX-Location' if is_redirect else 'HX-Redirect'
|
92
|
+
response[header] = response['Location']
|
91
93
|
return response
|
accrete/storage.py
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
import os
|
2
|
+
from urllib.parse import urljoin
|
3
|
+
from django.core.files.storage import FileSystemStorage
|
4
|
+
from django.utils.encoding import filepath_to_uri
|
5
|
+
from django.utils.deconstruct import deconstructible
|
6
|
+
from django.conf import settings
|
7
|
+
from accrete.tenant import get_tenant
|
8
|
+
|
9
|
+
|
10
|
+
@deconstructible(path="django.core.files.storage.FileSystemStorage")
|
11
|
+
class TenantFileSystemStorage(FileSystemStorage):
|
12
|
+
|
13
|
+
@property
|
14
|
+
def base_location(self):
|
15
|
+
tenant = get_tenant()
|
16
|
+
base_dir = f'{settings.MEDIA_ROOT}/{tenant.id}'
|
17
|
+
os.makedirs(os.path.dirname(base_dir), exist_ok=True)
|
18
|
+
return base_dir
|
19
|
+
|
20
|
+
@property
|
21
|
+
def location(self):
|
22
|
+
return os.path.abspath(self.base_location)
|
23
|
+
|
24
|
+
@property
|
25
|
+
def base_url(self):
|
26
|
+
if self._base_url is not None and not self._base_url.endswith("/"):
|
27
|
+
self._base_url += "/"
|
28
|
+
res = self._value_or_setting(self._base_url, f'{settings.MEDIA_URL.strip("/")}/{get_tenant().id}')
|
29
|
+
return res
|
30
|
+
|
31
|
+
def url(self, name):
|
32
|
+
if self.base_url is None:
|
33
|
+
raise ValueError("This file is not accessible via a URL.")
|
34
|
+
url = filepath_to_uri(name)
|
35
|
+
if url is not None:
|
36
|
+
url = url.lstrip("/")
|
37
|
+
return urljoin(f'/{self.base_url}/', url)
|
@@ -5,8 +5,9 @@ accrete/apps.py,sha256=F7ynMLHJr_6bRujWtZVUzCliY2CGKiDvyUmL4F68L2E,146
|
|
5
5
|
accrete/config.py,sha256=eJUbvyBO3DvAD6xkVKjTAzlXy7V7EK9bVyb91girfUs,299
|
6
6
|
accrete/forms.py,sha256=2vUh80qNvPDD8Zl3agKBSJEQeY7bXVLOx_SAB34wf8E,1359
|
7
7
|
accrete/managers.py,sha256=CaIJLeBry4NYIXaVUrdUjp7zx4sEWgv-1-ssI1m-EOs,1156
|
8
|
-
accrete/middleware.py,sha256=
|
8
|
+
accrete/middleware.py,sha256=IABs2pAV-kXjp3n5_Wsc7reXGjU5FhmCbvFB8cC4ZRM,3422
|
9
9
|
accrete/models.py,sha256=grvRNXg0ZYAJU3KAIX-svuZXeXlfqP4qEJ00nlbV594,5145
|
10
|
+
accrete/storage.py,sha256=z7pHdQFw0hFGrrbfqIh7KFxabQ_JGqoPebmiX9TLmeU,1254
|
10
11
|
accrete/tenant.py,sha256=g3ZuTrQr2zqmIopNBRQeCmHEK2R3dlUme_hOV765J6U,1778
|
11
12
|
accrete/tests.py,sha256=Agltbzwwh5htvq_Qi9vqvxutzmg_GwgPS_N19xJZRlw,7197
|
12
13
|
accrete/views.py,sha256=9-sgCFe_CyG-wllAcIOLujyueiq66C-zg0U7Uf5Y2wU,2954
|
@@ -37,7 +38,7 @@ accrete/contrib/ui/admin.py,sha256=suMo4x8I3JBxAFBVIdE-5qnqZ6JAZV0FESABHOSc-vg,6
|
|
37
38
|
accrete/contrib/ui/apps.py,sha256=E0ao2ox6PQ3ldfeR17FXJUUJuGiWjm2DPCxHbPXGzls,152
|
38
39
|
accrete/contrib/ui/context.py,sha256=tb4x_G4VsIa1LKIWl-CvLVtEd_DCbrClA-0Wmnne9bc,8363
|
39
40
|
accrete/contrib/ui/elements.py,sha256=0F5q0-XLdAWQjdYLMQt6RXqz4xPD_ECrhs0kcBfYkvo,1856
|
40
|
-
accrete/contrib/ui/filter.py,sha256=
|
41
|
+
accrete/contrib/ui/filter.py,sha256=UAIkUNKu2nVQLafwZlkQu4PDfOPyFM61e_mE7OWRhYs,12410
|
41
42
|
accrete/contrib/ui/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
42
43
|
accrete/contrib/ui/urls.py,sha256=TUBlz_CGs9InTZoxM78GSnucA73I8knoh_obt12RUHM,186
|
43
44
|
accrete/contrib/ui/views.py,sha256=WpBKMsxFFG8eG4IN7TW_TPE6i3OFF7gnLDTK7JMKti8,191
|
@@ -220,7 +221,7 @@ accrete/utils/dates.py,sha256=apM6kt6JhGrKgoT0jfav1W-8AUVTxNc9xt3fJQ2n0JI,1492
|
|
220
221
|
accrete/utils/forms.py,sha256=Lll-DvAhKZDw72XeuCtb4wxQEJNFp7lQWh_Z1GyH3Zk,3049
|
221
222
|
accrete/utils/http.py,sha256=mAtQRgADv7zu1_j7A-EKVyb-oqa5a21i4Gd0QfjzGV0,3540
|
222
223
|
accrete/utils/models.py,sha256=EEhv7-sQVtQD24PEb3XcDUAh3VVhVFoMMLyFrDjGEaI,706
|
223
|
-
accrete-0.0.
|
224
|
-
accrete-0.0.
|
225
|
-
accrete-0.0.
|
226
|
-
accrete-0.0.
|
224
|
+
accrete-0.0.59.dist-info/METADATA,sha256=na4Zyia9GVHueWMmrOaC1E1sbJmsfLGkEaPVlVzzuzo,4892
|
225
|
+
accrete-0.0.59.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
226
|
+
accrete-0.0.59.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
|
227
|
+
accrete-0.0.59.dist-info/RECORD,,
|
File without changes
|
File without changes
|