accrete 0.0.95__py3-none-any.whl → 0.0.97__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.
@@ -71,17 +71,19 @@
71
71
  </button>
72
72
  </div>
73
73
  {% endif %}
74
- <div class="control is-expanded">
75
- <button id="list-customization-order-trigger"
76
- class="button dropdown-button side-panel-action-content is-fullwidth"
77
- onclick="setDropDown(this)" data-dropdown-id="list-customization-order"
78
- >
79
- <span>{% translate 'Order' %}</span>
80
- <span class="icon is-small">
81
- <i class="fa fa-angle-down"></i>
82
- </span>
83
- </button>
84
- </div>
74
+ {% if order_selection %}
75
+ <div class="control is-expanded">
76
+ <button id="list-customization-order-trigger"
77
+ class="button dropdown-button side-panel-action-content is-fullwidth"
78
+ onclick="setDropDown(this)" data-dropdown-id="list-customization-order"
79
+ >
80
+ <span>{% translate 'Order' %}</span>
81
+ <span class="icon is-small">
82
+ <i class="fa fa-angle-down"></i>
83
+ </span>
84
+ </button>
85
+ </div>
86
+ {% endif %}
85
87
  </div>
86
88
  </div>
87
89
 
@@ -114,26 +116,28 @@
114
116
  </div>
115
117
  {% endif %}
116
118
 
117
- <div id="list-customization-order" class="dropdown is-flex-grow-1 pt-0" role="menu" data-dropdown-trigger-id="list-customization-order-trigger">
118
- <div class="dropdown-menu pt-0" style="width: 100%">
119
- <div class="dropdown-content">
120
- <div class="dropdown-item">
121
- <div class="field has-addons mr-1">
122
- <p class="control is-expanded">
123
- <input class="input is-small" type="text" aria-label="Query Input" style="height: 100%">
124
- </p>
125
- <p class="control">
126
- <button id="order-selection-reset" class="button is-small has-icon" style="box-shadow: none;">
127
- <span class="icon"><i class="fas fa-arrow-rotate-left"></i></span>
128
- </button>
129
- </p>
119
+ {% if order_selection %}
120
+ <div id="list-customization-order" class="dropdown is-flex-grow-1 pt-0" role="menu" data-dropdown-trigger-id="list-customization-order-trigger">
121
+ <div class="dropdown-menu pt-0" style="width: 100%">
122
+ <div class="dropdown-content">
123
+ <div class="dropdown-item">
124
+ <div class="field has-addons mr-1">
125
+ <p class="control is-expanded">
126
+ <input class="input is-small" type="text" aria-label="Query Input" style="height: 100%">
127
+ </p>
128
+ <p class="control">
129
+ <button id="order-selection-reset" class="button is-small has-icon" style="box-shadow: none;">
130
+ <span class="icon"><i class="fas fa-arrow-rotate-left"></i></span>
131
+ </button>
132
+ </p>
133
+ </div>
134
+ </div>
135
+ <div id="order-path-apply" hx-get="" hx-trigger="click" hx-replace-url="true"
136
+ hx-select-oob="#content,#order-path-apply,#list-pagination">
130
137
  </div>
131
- </div>
132
- <div id="order-path-apply" hx-get="" hx-trigger="click" hx-replace-url="true"
133
- hx-select-oob="#content,#order-path-apply,#list-pagination">
134
138
  </div>
135
139
  </div>
136
140
  </div>
137
- </div>
141
+ {% endif %}
138
142
  </div>
139
143
  </div>
accrete/managers.py CHANGED
@@ -21,12 +21,17 @@ class TenantManager(models.Manager, AnnotationManagerMixin):
21
21
  unique_fields=None,
22
22
  ):
23
23
  tenant = get_tenant()
24
- if tenant is None and not all(obj.tenant_id for obj in objs):
24
+ if tenant is None and any(obj.tenant_id in (False, None) for obj in objs):
25
25
  raise ValueError(
26
26
  'Tenant must be set for all objects when calling bulk_create'
27
27
  )
28
- for obj in objs:
29
- obj.tenant_id = tenant.pk
28
+ if tenant is not None and any(obj.tenant_id != tenant.pk for obj in objs):
29
+ raise ValueError(
30
+ 'Objects must have set the same Tenant when calling bulk_create while a tenant is active'
31
+ )
32
+ elif tenant is not None:
33
+ for obj in objs:
34
+ obj.tenant_id = tenant.pk
30
35
  return super().bulk_create(
31
36
  objs, batch_size=batch_size, ignore_conflicts=ignore_conflicts,
32
37
  update_conflicts=update_conflicts, update_fields=update_fields,
accrete/middleware.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from django.utils.deprecation import MiddlewareMixin
2
2
  from django.conf import settings
3
3
  from django.http.response import HttpResponseRedirect, HttpResponsePermanentRedirect
4
- from accrete.tenant import set_tenant, set_member
4
+ from accrete.tenant import set_tenant, set_member, unscoped
5
5
 
6
6
  from .models import Tenant
7
7
 
@@ -35,10 +35,11 @@ class TenantMiddleware(MiddlewareMixin):
35
35
  return
36
36
 
37
37
  if request.user.is_authenticated:
38
- memberships = request.user.memberships.filter(
39
- is_active=True,
40
- tenant__is_active=True
41
- )
38
+ with unscoped():
39
+ memberships = request.user.memberships.filter(
40
+ is_active=True,
41
+ tenant__is_active=True
42
+ )
42
43
 
43
44
  if request.user.is_staff:
44
45
  tenant_id = self.get_tenant_id_from_request(request)
accrete/utils/log.py ADDED
@@ -0,0 +1,16 @@
1
+ import logging
2
+ from functools import wraps
3
+ from timeit import default_timer as timer
4
+
5
+ _logger = logging.getLogger(__name__)
6
+
7
+
8
+ def log_time(f):
9
+ @wraps(f)
10
+ def decorator(*args, **kwargs):
11
+ start = timer()
12
+ result = f(*args, **kwargs)
13
+ stop = timer()
14
+ _logger.info(f'{f.__module__}.{f.__name__} Duration: {(stop - start)} Seconds')
15
+ return result
16
+ return decorator
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: accrete
3
- Version: 0.0.95
3
+ Version: 0.0.97
4
4
  Summary: Django Shared Schema Multi Tenant
5
5
  Author-email: Benedikt Jilek <benedikt.jilek@pm.me>
6
6
  License: Copyright (c) 2023 Benedikt Jilek
@@ -4,8 +4,8 @@ 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=vODaKmWPvgfRoYXbQ_JD-pRjd2QWM_a9Gjkllrua0WE,1164
8
- accrete/middleware.py,sha256=IABs2pAV-kXjp3n5_Wsc7reXGjU5FhmCbvFB8cC4ZRM,3422
7
+ accrete/managers.py,sha256=R-n2WRezhTNE-EVvhNSJ6TSCroN_TAHAWSJ_SS2jxpk,1451
8
+ accrete/middleware.py,sha256=NhtT3YPq0EynAi4F81LLLUZd5rsWDjGVn1tkgUObT3M,3477
9
9
  accrete/models.py,sha256=xliEVR0XPW46ZDJn3-F46s54tG9dxz7BVLbkq1pC144,5434
10
10
  accrete/storage.py,sha256=z7pHdQFw0hFGrrbfqIh7KFxabQ_JGqoPebmiX9TLmeU,1254
11
11
  accrete/tenant.py,sha256=g3ZuTrQr2zqmIopNBRQeCmHEK2R3dlUme_hOV765J6U,1778
@@ -178,7 +178,7 @@ accrete/contrib/ui/templates/ui/form.html,sha256=uCtP16THdOuRfs3JdsjadIW0k9b2rN3
178
178
  accrete/contrib/ui/templates/ui/layout.html,sha256=qUACs0vR3xn5gjoJly_zexdw9XEzu_EdF2Is6y-CvJM,15649
179
179
  accrete/contrib/ui/templates/ui/list.html,sha256=ahN8SgF4kE3OEy6EBeDBdDQvuXx-CyIgbixYd-KdV4k,1751
180
180
  accrete/contrib/ui/templates/ui/table.html,sha256=8ELtgxoapCyNsvmGISAGXe712lG6AkP_nekb4OVLK3I,4481
181
- accrete/contrib/ui/templates/ui/partials/filter.html,sha256=2vmeL3980rMmkRnmVtZh9mBHe6S0PTMjaGIN1J6SpNM,7184
181
+ accrete/contrib/ui/templates/ui/partials/filter.html,sha256=fMxi5L1daqKElzZpHg8bItv0FlBjOkAEBxmT_OXgg4M,7434
182
182
  accrete/contrib/ui/templates/ui/partials/form_errors.html,sha256=C5ktasYff2xBTiWfM6QR8qaGKSyK9QufB3B9N77KGpg,1386
183
183
  accrete/contrib/ui/templates/ui/partials/header.html,sha256=wBiyo02mON3z7l4hJAPTAJn_vDhekYZ-a0g8TuW4RmY,7015
184
184
  accrete/contrib/ui/templates/ui/partials/modal.html,sha256=Lk7ViKJS99QLjGFHKna90j6VUo_U03IDAT1Rq__QVLU,1472
@@ -230,9 +230,10 @@ accrete/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
230
230
  accrete/utils/__init__.py,sha256=BZiTZDicA1--ruZUvI_bjvPUSwI4SxfqGJc9V5n9nQc,271
231
231
  accrete/utils/dates.py,sha256=apM6kt6JhGrKgoT0jfav1W-8AUVTxNc9xt3fJQ2n0JI,1492
232
232
  accrete/utils/forms.py,sha256=IvxbXNpSd4a-JBgsTJhs2GHe-DCRWX-xnVPRcoiCzbI,3104
233
+ accrete/utils/log.py,sha256=BH0MBDweAjx30wGBO4F3sFhbgkSoEs7T1lLLjlYZNnA,407
233
234
  accrete/utils/models.py,sha256=EEhv7-sQVtQD24PEb3XcDUAh3VVhVFoMMLyFrDjGEaI,706
234
235
  accrete/utils/views.py,sha256=iWZSYbd3qYMrV9wAsX26ofGb5wxn1N_nRrQ6s2lpp2I,4557
235
- accrete-0.0.95.dist-info/METADATA,sha256=04_9uE3qFheep7VKhxNoICWn5DlajVnm58iMv-e5Nhk,4952
236
- accrete-0.0.95.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
237
- accrete-0.0.95.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
238
- accrete-0.0.95.dist-info/RECORD,,
236
+ accrete-0.0.97.dist-info/METADATA,sha256=obrYnpP2ESdIu5uE0B0Wp6gjlJtUwf4sy2QUGv7ZSN4,4952
237
+ accrete-0.0.97.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
238
+ accrete-0.0.97.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
239
+ accrete-0.0.97.dist-info/RECORD,,