simo 2.8.2__py3-none-any.whl → 2.8.3__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.

Potentially problematic release.


This version of simo might be problematic. Click here for more details.

Binary file
simo/users/models.py CHANGED
@@ -117,6 +117,7 @@ class InstanceUser(DirtyFieldsMixin, models.Model, OnChangeMixin):
117
117
  class Meta:
118
118
  unique_together = 'user', 'instance'
119
119
 
120
+
120
121
  def __str__(self):
121
122
  if self.role.instance:
122
123
  return f"{self.user} is {self.role.name} on {self.instance}"
@@ -223,6 +224,8 @@ class User(AbstractBaseUser, SimoAdminMixin):
223
224
  def __init__(self, *args, **kwargs):
224
225
  super().__init__(*args, **kwargs)
225
226
  self._is_active = None
227
+ self._instances = None
228
+ self._instance_roles = {}
226
229
 
227
230
  def __str__(self):
228
231
  return self.name
@@ -266,6 +269,8 @@ class User(AbstractBaseUser, SimoAdminMixin):
266
269
  return self.is_active and self.is_master
267
270
 
268
271
  def get_role(self, instance):
272
+ if instance.id in self._instance_roles:
273
+ return self._instance_roles[instance.id]
269
274
  cache_key = f'user-{self.id}_instance-{instance.id}_role'
270
275
  role = cache.get(cache_key)
271
276
  if role is None:
@@ -276,7 +281,8 @@ class User(AbstractBaseUser, SimoAdminMixin):
276
281
  ).first()
277
282
  if role:
278
283
  cache.set(cache_key, role, 20)
279
- return role
284
+ self._instance_roles[instance.id] = role
285
+ return self._instance_roles[instance.id]
280
286
 
281
287
  @property
282
288
  def role_id(self):
@@ -323,6 +329,9 @@ class User(AbstractBaseUser, SimoAdminMixin):
323
329
  if not self.is_active:
324
330
  return Instance.objects.none()
325
331
 
332
+ if self._instances is not None:
333
+ return self._instances
334
+
326
335
  cache_key = f'user-{self.id}_instances'
327
336
  instances = cache.get(cache_key)
328
337
  if instances is None:
@@ -336,7 +345,8 @@ class User(AbstractBaseUser, SimoAdminMixin):
336
345
  ], is_active=True)
337
346
  cache.set(cache_key, instances, 10)
338
347
 
339
- return instances
348
+ self._instances = instances
349
+ return self._instances
340
350
 
341
351
  @property
342
352
  def component_permissions(self):
@@ -347,6 +357,8 @@ class User(AbstractBaseUser, SimoAdminMixin):
347
357
 
348
358
  @property
349
359
  def is_active(self):
360
+ if self._is_active is not None:
361
+ return self._is_active
350
362
  cache_key = f'user-{self.id}_is_active'
351
363
  cached_value = cache.get(cache_key)
352
364
  if cached_value is None:
@@ -372,7 +384,8 @@ class User(AbstractBaseUser, SimoAdminMixin):
372
384
  self.instance_roles.filter(is_active=True).count()
373
385
  )
374
386
  cache.set(cache_key, cached_value, 20)
375
- return cached_value
387
+ self._is_active = cached_value
388
+ return self._is_active
376
389
 
377
390
 
378
391
  @is_active.setter
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simo
3
- Version: 2.8.2
3
+ Version: 2.8.3
4
4
  Summary: Smart Home on Steroids!
5
5
  Author-email: Simanas Venčkauskas <simanas@simo.io>
6
6
  Project-URL: Homepage, https://simo.io
@@ -30,7 +30,7 @@ simo/automation/__pycache__/__init__.cpython-312.pyc,sha256=rIs1rkBbUhjXjbUffmq2
30
30
  simo/automation/__pycache__/__init__.cpython-38.pyc,sha256=YmP0xAD-mxpQHgdTZeC64sXChA8TriMZD1jckNYi3xg,164
31
31
  simo/automation/__pycache__/app_widgets.cpython-312.pyc,sha256=6u8LsTpf32yn0L49eI4A0sVHlSwl6gOyPlReUwQKoOM,577
32
32
  simo/automation/__pycache__/app_widgets.cpython-38.pyc,sha256=7DfUA9V_1MiwrOe_ta-ts8dYY8xXb9UMg2_9A3XoRcs,523
33
- simo/automation/__pycache__/controllers.cpython-312.pyc,sha256=VvHAmaxfOKpyr9Dd256KXd_qxPCj_-hJYpRnpjXIAzk,14965
33
+ simo/automation/__pycache__/controllers.cpython-312.pyc,sha256=QV63g3UlpMAA-yCaZxoe1B2hVeDGobfOtBA0K1h66Os,15052
34
34
  simo/automation/__pycache__/controllers.cpython-38.pyc,sha256=CL-0Tq9B4-E36fYfWT1XEBTq1dkq1W8003f6MrBnQU0,8391
35
35
  simo/automation/__pycache__/forms.cpython-312.pyc,sha256=63rU0rWZk-Rz5qoMZiXl743WPc9NVm5d8bSd8w52T4E,12347
36
36
  simo/automation/__pycache__/forms.cpython-38.pyc,sha256=cpA5hA2Iz3JsPC0Dq01ki1I7S9c5DKRcXveHApI1dJo,7772
@@ -10741,7 +10741,7 @@ simo/users/auto_urls.py,sha256=RSUW3ai5LbMTknS8M7M5aOnG_YlFOVQrnNVNH-fkwlg,357
10741
10741
  simo/users/dynamic_settings.py,sha256=sEIsi4yJw3kH46Jq_aOkSuK7QTfQACGUE-lkyBogCaM,570
10742
10742
  simo/users/managers.py,sha256=OHgEP85MBtdkdYxdstBd8RavTBT8F_2WyDxUJ9aCqqM,246
10743
10743
  simo/users/middleware.py,sha256=tNPmnzo0eTrJ25SLHP7NotqYKI2cKnmv8hf6v5DLOWo,427
10744
- simo/users/models.py,sha256=6Y05Z5IiARr-Dti_xRjQTxi2ji62M387mN-VVzxMGSY,20069
10744
+ simo/users/models.py,sha256=EUsYX8PtPgRkpmCZXg0mRkYHV6e69TqGB-UkbZGe5Cw,20549
10745
10745
  simo/users/permissions.py,sha256=IwtYS8yQdupWbYKR9VimSRDV3qCJ2jXP57Lyjpb2EQM,242
10746
10746
  simo/users/serializers.py,sha256=REgXD9Af6nTRu_wUm1dt5YoCB6C_KNDaPqHZj726zZ0,2497
10747
10747
  simo/users/sso_urls.py,sha256=gQOaPvGMYFD0NCVSwyoWO-mTEHe5j9sbzV_RK7kdvp0,251
@@ -10753,7 +10753,7 @@ simo/users/__pycache__/__init__.cpython-312.pyc,sha256=n0GE5zxjujBUkv1t1CswZ9Gby
10753
10753
  simo/users/__pycache__/__init__.cpython-38.pyc,sha256=VFoDJE_SKKaPqqYaaBYd1Ndb1hjakkTo_u0EG_XJ1GM,211
10754
10754
  simo/users/__pycache__/admin.cpython-312.pyc,sha256=lTVuZQwkuw1bzSn0A0kt-8H6ruKas_YPb_61AxSYSoo,11465
10755
10755
  simo/users/__pycache__/admin.cpython-38.pyc,sha256=uL8TwAipkatZxanvQtBKKcOv8Fm3UvinBxsP0okrOZg,8443
10756
- simo/users/__pycache__/api.cpython-312.pyc,sha256=dk3jAqiRRkTJdzBc7E1Bgfnu74t_aJ6TuDLHJmQ8znU,18739
10756
+ simo/users/__pycache__/api.cpython-312.pyc,sha256=p8nEOe95slqWK0QxhAkmXXbyPiZd-0VcA-ejvFcS6Mo,18333
10757
10757
  simo/users/__pycache__/api.cpython-38.pyc,sha256=zZ4DfNktgeVvLAtMpaPUv7AoAgbKr7SCt-4ghJk1zp4,10386
10758
10758
  simo/users/__pycache__/apps.cpython-312.pyc,sha256=yLvyvcBuRr6jfIxwiA9sjQOE4VyHVUKl5FUVDPXuAkM,707
10759
10759
  simo/users/__pycache__/apps.cpython-38.pyc,sha256=dgbWL8CxzzISJQTmq_4IztPJ2UzykNVdqA2Ae1PmeGk,605
@@ -10767,7 +10767,7 @@ simo/users/__pycache__/managers.cpython-312.pyc,sha256=A9-yF1dilDc1H_-BtrIw9USpH
10767
10767
  simo/users/__pycache__/managers.cpython-38.pyc,sha256=O0Y8ABp42RAosrbODmYsPMaj9AyOPyJ-aqzuO0Qpi2s,679
10768
10768
  simo/users/__pycache__/middleware.cpython-312.pyc,sha256=9pkiIkMriu0ExLK479hyPfaN-DOfp6WErqQlrZY1Mvk,927
10769
10769
  simo/users/__pycache__/middleware.cpython-38.pyc,sha256=Tj4nVEAvxEW3xA63fBRiJWRJpz_M848ZOqbHioc_IPE,1149
10770
- simo/users/__pycache__/models.cpython-312.pyc,sha256=j4-HII44-P4ExB7UVZGtOT8IYz6jbRa4hnDsCRglbUU,29020
10770
+ simo/users/__pycache__/models.cpython-312.pyc,sha256=DownCK4FLYKjE-QMM1-ciZ0koLzwsnc_RFgyq5sIi8k,29596
10771
10771
  simo/users/__pycache__/models.cpython-38.pyc,sha256=qNtAn_eWVmRTWhTxN8GtCc549dcJsTdaF7Uk19yNMgg,18330
10772
10772
  simo/users/__pycache__/permissions.cpython-312.pyc,sha256=NCaxeIz4qmG_mF18lKTYXqOSUvJkFLnUZjfYIQFUCkU,718
10773
10773
  simo/users/__pycache__/permissions.cpython-38.pyc,sha256=ez5NxoL_JUeeH6GsKhvFreuA3FCBgGf9floSypdXUtM,633
@@ -10924,9 +10924,9 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10924
10924
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10925
10925
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10926
10926
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10927
- simo-2.8.2.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10928
- simo-2.8.2.dist-info/METADATA,sha256=AhDqWH1SoeS6j6V0KlUk-QMeuzbVjZouP_a_fJRr_ZI,2008
10929
- simo-2.8.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10930
- simo-2.8.2.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10931
- simo-2.8.2.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10932
- simo-2.8.2.dist-info/RECORD,,
10927
+ simo-2.8.3.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10928
+ simo-2.8.3.dist-info/METADATA,sha256=e73yT_ZPrUBSQ9WeaC3C_Ha7RqPRz8oRME8ayRXL1X4,2008
10929
+ simo-2.8.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10930
+ simo-2.8.3.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10931
+ simo-2.8.3.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10932
+ simo-2.8.3.dist-info/RECORD,,
File without changes