accrete 0.0.91__py3-none-any.whl → 0.0.92__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/annotation.py +6 -3
- accrete/managers.py +1 -1
- {accrete-0.0.91.dist-info → accrete-0.0.92.dist-info}/METADATA +1 -1
- {accrete-0.0.91.dist-info → accrete-0.0.92.dist-info}/RECORD +6 -6
- {accrete-0.0.91.dist-info → accrete-0.0.92.dist-info}/WHEEL +0 -0
- {accrete-0.0.91.dist-info → accrete-0.0.92.dist-info}/licenses/LICENSE +0 -0
accrete/annotation.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from django.db.models import Field
|
1
|
+
from django.db.models import Field, Subquery, OuterRef
|
2
2
|
from django.db.models.expressions import Func
|
3
3
|
from django.db.models.aggregates import Aggregate
|
4
4
|
|
@@ -34,10 +34,13 @@ class AnnotationModelMixin:
|
|
34
34
|
|
35
35
|
class AnnotationManagerMixin:
|
36
36
|
|
37
|
-
def get_annotations(self):
|
37
|
+
def get_annotations(self, queryset):
|
38
38
|
if not hasattr(self.model, 'get_annotations'):
|
39
39
|
return {}
|
40
40
|
return {
|
41
|
-
annotation['name']:
|
41
|
+
annotation['name']: Subquery(
|
42
|
+
queryset.annotate(**{
|
43
|
+
annotation['name']: annotation['annotation'].function
|
44
|
+
}).filter(pk=OuterRef('pk')).values(annotation['name'])[:1])
|
42
45
|
for annotation in self.model.get_annotations()
|
43
46
|
}
|
accrete/managers.py
CHANGED
@@ -9,7 +9,7 @@ class TenantManager(models.Manager, AnnotationManagerMixin):
|
|
9
9
|
queryset = super().get_queryset()
|
10
10
|
if tenant := get_tenant():
|
11
11
|
queryset = queryset.filter(tenant=tenant)
|
12
|
-
return queryset.annotate(**self.get_annotations())
|
12
|
+
return queryset.annotate(**self.get_annotations(queryset))
|
13
13
|
|
14
14
|
def bulk_create(
|
15
15
|
self,
|
@@ -1,10 +1,10 @@
|
|
1
1
|
accrete/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
accrete/admin.py,sha256=MUYUmCFlGYPowiXTbwl4_Q6Cq0-neiL53WW4P76JCLs,1174
|
3
|
-
accrete/annotation.py,sha256=
|
3
|
+
accrete/annotation.py,sha256=GCpTTX3fJH9w2vOOOydKcAALdEd1gRNjh_Ws9LkJ4aA,1355
|
4
4
|
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
|
-
accrete/managers.py,sha256=
|
7
|
+
accrete/managers.py,sha256=vODaKmWPvgfRoYXbQ_JD-pRjd2QWM_a9Gjkllrua0WE,1164
|
8
8
|
accrete/middleware.py,sha256=IABs2pAV-kXjp3n5_Wsc7reXGjU5FhmCbvFB8cC4ZRM,3422
|
9
9
|
accrete/models.py,sha256=xliEVR0XPW46ZDJn3-F46s54tG9dxz7BVLbkq1pC144,5434
|
10
10
|
accrete/storage.py,sha256=z7pHdQFw0hFGrrbfqIh7KFxabQ_JGqoPebmiX9TLmeU,1254
|
@@ -232,7 +232,7 @@ accrete/utils/dates.py,sha256=apM6kt6JhGrKgoT0jfav1W-8AUVTxNc9xt3fJQ2n0JI,1492
|
|
232
232
|
accrete/utils/forms.py,sha256=IvxbXNpSd4a-JBgsTJhs2GHe-DCRWX-xnVPRcoiCzbI,3104
|
233
233
|
accrete/utils/http.py,sha256=sUDwa9hpYAle7d0iJxIA5wQk2mK2BMENo7JyFBSPxKc,4475
|
234
234
|
accrete/utils/models.py,sha256=EEhv7-sQVtQD24PEb3XcDUAh3VVhVFoMMLyFrDjGEaI,706
|
235
|
-
accrete-0.0.
|
236
|
-
accrete-0.0.
|
237
|
-
accrete-0.0.
|
238
|
-
accrete-0.0.
|
235
|
+
accrete-0.0.92.dist-info/METADATA,sha256=qQWTwFVcTYzWGNz5a5Zl4IRkzL8oZRiLywbh4ueADSc,4952
|
236
|
+
accrete-0.0.92.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
237
|
+
accrete-0.0.92.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
|
238
|
+
accrete-0.0.92.dist-info/RECORD,,
|
File without changes
|
File without changes
|