simo 2.5.22__py3-none-any.whl → 2.5.23__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/settings.py CHANGED
@@ -207,7 +207,8 @@ CACHES = {
207
207
  "LOCATION": "redis://127.0.0.1:6379/%d" % REDIS_DB['default_cache'],
208
208
  "OPTIONS": {
209
209
  "CLIENT_CLASS": "django_redis.client.DefaultClient",
210
- }
210
+ },
211
+ "TIMEOUT": 300
211
212
  },
212
213
  }
213
214
 
Binary file
simo/users/admin.py CHANGED
@@ -4,6 +4,7 @@ from django.utils.safestring import mark_safe
4
4
  from django.contrib import messages
5
5
  from django.contrib.auth.admin import UserAdmin as OrgUserAdmin
6
6
  from django.contrib import admin
7
+ from simo.core.middleware import get_current_instance
7
8
  from .models import (
8
9
  PermissionsRole, ComponentPermission, User, UserDevice, UserDeviceReportLog,
9
10
  InstanceInvitation, InstanceUser, Fingerprint
@@ -58,6 +59,10 @@ class InstanceUserAdmin(admin.ModelAdmin):
58
59
  'at_home', 'last_seen', 'last_seen_speed_kmh', 'phone_on_charge',
59
60
  )
60
61
 
62
+ def get_queryset(self, request):
63
+ instance = get_current_instance()
64
+ return super().get_queryset(request).filter(instance=instance)
65
+
61
66
 
62
67
  class InstanceUserInline(admin.TabularInline):
63
68
  model = InstanceUser
@@ -99,6 +99,10 @@ class SSOBackend(ModelBackend):
99
99
  user=user, instance=invitation.instance,
100
100
  defaults={'role': invitation.role}
101
101
  )
102
+ user.is_active = True
103
+
104
+ if not user.is_active:
105
+ return
102
106
 
103
107
  if user_data.get('name'):
104
108
  user.name = user_data['name']
@@ -109,6 +113,7 @@ class SSOBackend(ModelBackend):
109
113
  user.avatar.save(
110
114
  os.path.basename(user.avatar_url), io.BytesIO(resp.content)
111
115
  )
112
- user.save()
116
+ if user.get_dirty_fields():
117
+ user.save()
113
118
 
114
119
  return user
simo/users/managers.py CHANGED
@@ -6,7 +6,4 @@ class ActiveInstanceManager(models.Manager):
6
6
 
7
7
  def get_queryset(self):
8
8
  qs = super().get_queryset()
9
- instance = get_current_instance()
10
- if instance:
11
- return qs.filter(instance=instance)
12
- return qs
9
+ return qs.filter(instance__is_active=True)
simo/users/models.py CHANGED
@@ -154,7 +154,7 @@ def post_instance_user_save(sender, instance, created, **kwargs):
154
154
  dynamic_settings['core__needs_mqtt_acls_rebuild'] = True
155
155
 
156
156
 
157
- class User(AbstractBaseUser, SimoAdminMixin):
157
+ class User(DirtyFieldsMixin, AbstractBaseUser, SimoAdminMixin):
158
158
  name = models.CharField(_('name'), max_length=150)
159
159
  email = models.EmailField(_('email address'), unique=True)
160
160
  avatar = ThumbnailerImageField(
@@ -309,16 +309,11 @@ class User(AbstractBaseUser, SimoAdminMixin):
309
309
 
310
310
  @property
311
311
  def is_active(self):
312
- # Things are getting messed up when no
313
- instance = get_current_instance()
314
- if not instance:
315
- cache_key = f'user-{self.id}_is_active'
316
- else:
317
- cache_key = f'user-{self.id}_is_active_instance-{instance.id}'
312
+ cache_key = f'user-{self.id}_is_active'
318
313
  cached_value = cache.get(cache_key)
319
314
  if cached_value is None:
320
315
  if self.is_master:
321
- if not self.instance_roles.all():
316
+ if not self.instance_roles.all().count():
322
317
  # Master who have no roles on any instance are in GOD mode!
323
318
  # It can not be disabled by anybody, nor it is seen by anybody. :)
324
319
  cached_value = True
@@ -333,13 +328,8 @@ class User(AbstractBaseUser, SimoAdminMixin):
333
328
  cached_value = bool(
334
329
  self.instance_roles.filter(is_active=True).count()
335
330
  )
336
- elif instance:
337
- cached_value = bool(
338
- self.instance_roles.filter(
339
- instance=instance, is_active=True
340
- ).count()
341
- )
342
331
  else:
332
+ # user is considered active if he is active on at least one instance
343
333
  cached_value = bool(
344
334
  self.instance_roles.filter(is_active=True).count()
345
335
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.5.22
3
+ Version: 2.5.23
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
@@ -2,13 +2,13 @@ simo/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
2
  simo/asgi.py,sha256=L8CUVZLM32IMzWDZ4IShdDN-m69t7oxAUeHods4-xNM,822
3
3
  simo/celeryc.py,sha256=eab7_e9rw0c__DCeoUFUh_tjAGVlulxVrk75BaJf57Q,1512
4
4
  simo/conf.py,sha256=H2BhXAV8MEDVXF8AbkaLSfR4ULd-9_bS4bnhE5sE5fg,112
5
- simo/settings.py,sha256=BcirAAKau1KiJ5qKTD0ni8hTk3jHAASBcUCBNZPGNCk,6962
5
+ simo/settings.py,sha256=tB7rqHA1QHyb4c_nNNnGD_JkqCWmz7XbS_N3Qq5YacY,6986
6
6
  simo/urls.py,sha256=fRmAsNQ_pzFloimLmxNeDcR6hHRJ3rOoZ3kGy8zOQ_A,2402
7
7
  simo/__pycache__/__init__.cpython-38.pyc,sha256=j81de0BqHMr6bs0C7cuYrXl7HwtK_vv8hDEtAdSwDJc,153
8
8
  simo/__pycache__/asgi.cpython-38.pyc,sha256=5W_YSKOIrRd6NQQuJDuA3Yuj688GzirXVVOyLe8wJIQ,845
9
9
  simo/__pycache__/celeryc.cpython-38.pyc,sha256=eSRoaKwfYlxVaxAiwqpQ2ndEcx7W-VpZtbxRFSV8UYg,1653
10
10
  simo/__pycache__/conf.cpython-38.pyc,sha256=MYP2yk3ULxiYwZsZR6tCLjKnU-z03A3avzQzIn66y3k,273
11
- simo/__pycache__/settings.cpython-38.pyc,sha256=Mi9iweMgAZ16ppKmiK0eFSDYsrY6XRHFpXXHK8is-Pc,6110
11
+ simo/__pycache__/settings.cpython-38.pyc,sha256=KxcUZqNnr1y6QxvcBLoLm_sk-vwbLsJHPvSD6XadAMs,6128
12
12
  simo/__pycache__/urls.cpython-38.pyc,sha256=u0x6EqT8S1YfDOSPgbI8Kf-RDlveY9OV-EDXMYKAQ7w,2125
13
13
  simo/__pycache__/wsgi.cpython-38.pyc,sha256=TpRxO7VM_ql31hbKphVdanydC5RI1nHB4l0QA2pdWxo,322
14
14
  simo/backups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -10442,15 +10442,15 @@ simo/notifications/migrations/__pycache__/0002_notification_instance.cpython-38.
10442
10442
  simo/notifications/migrations/__pycache__/0003_alter_notification_instance.cpython-38.pyc,sha256=awhD1F9RyK_706zVNM5io3WT_konFkKQgL7D5MkONwk,851
10443
10443
  simo/notifications/migrations/__pycache__/__init__.cpython-38.pyc,sha256=YMBRHVon2nWDtIUbghckjnC12sIg_ykPWhV5aM0tto4,178
10444
10444
  simo/users/__init__.py,sha256=6a7uBpCWB_DR7p54rbHusc0xvi1qfT1ZCCQGb6TiBh8,52
10445
- simo/users/admin.py,sha256=WDRJJtEkbYBQFtLg_5VOIlBV0eeJhgmrsFL51ttme0w,6760
10445
+ simo/users/admin.py,sha256=9P0iIGAep2R1AUvZnROsRULbxwCYK9pCfSJ2X4aLLBg,6965
10446
10446
  simo/users/api.py,sha256=xe__HFxzOaKgrh75PFpP4nkSs5DvmJp8QvMDNhP5kLU,12127
10447
10447
  simo/users/apps.py,sha256=cq0A8-U1HALEwev0TicgFhr4CAu7Icz8rwq0HfOaL4E,207
10448
- simo/users/auth_backends.py,sha256=1gy1-R1U8AOixJ3Ou2LTILjKOHTUxavm_zDiQtCAA9Q,4040
10448
+ simo/users/auth_backends.py,sha256=EErYrGti3TIlYH9Bxj0UFs5EKsbYMV4FP4wGfpdHtts,4165
10449
10449
  simo/users/auto_urls.py,sha256=lcJvteBsbHQMJieZpDz-63tDYejLApqsW3CUnDakd7k,272
10450
10450
  simo/users/dynamic_settings.py,sha256=sEIsi4yJw3kH46Jq_aOkSuK7QTfQACGUE-lkyBogCaM,570
10451
- simo/users/managers.py,sha256=Dm21Avmu38-h8MsZ5ljtpgKihMGUBU4hHGpiPvp4NtM,323
10451
+ simo/users/managers.py,sha256=OHgEP85MBtdkdYxdstBd8RavTBT8F_2WyDxUJ9aCqqM,246
10452
10452
  simo/users/middleware.py,sha256=GMCrnWSc_2qCleyQIkfQGdL-pU-UTEcSg1wPvIKZ9uk,1210
10453
- simo/users/models.py,sha256=Ds7WOUVLxljsK_73qGcfnnyJO4EIBXY9GS9FcJGx1bs,19716
10453
+ simo/users/models.py,sha256=KcIanqB8xvgvTO_jAUJpoN6JSRJha_DhIDSs4lniFXA,19402
10454
10454
  simo/users/permissions.py,sha256=IwtYS8yQdupWbYKR9VimSRDV3qCJ2jXP57Lyjpb2EQM,242
10455
10455
  simo/users/serializers.py,sha256=zzw1KONTnaTNBaU0r4rNVxJ827KzD6Z5LuQt27ZsQ98,2516
10456
10456
  simo/users/sso_urls.py,sha256=gQOaPvGMYFD0NCVSwyoWO-mTEHe5j9sbzV_RK7kdvp0,251
@@ -10459,15 +10459,15 @@ simo/users/tasks.py,sha256=HJAqiyWGsaN3wSfquU0UyQ20jL-njXeaaTOdDT3TQ3s,979
10459
10459
  simo/users/utils.py,sha256=1HGSZyHRqQvdJ4RtAiZDg1juvgG8aOlrGXR7CcvsyQc,1886
10460
10460
  simo/users/views.py,sha256=dOQVvmlHG7ihWKJLFUBcqKOA0UDctlMKR0pTc36JZqg,3487
10461
10461
  simo/users/__pycache__/__init__.cpython-38.pyc,sha256=VFoDJE_SKKaPqqYaaBYd1Ndb1hjakkTo_u0EG_XJ1GM,211
10462
- simo/users/__pycache__/admin.cpython-38.pyc,sha256=5LEDivt0AydPmqk9PCKvlKRRtc3QBxA6hZgcy_8bEQU,7680
10462
+ simo/users/__pycache__/admin.cpython-38.pyc,sha256=xZ_PgvobRrbqSuNgR2z2ZNm1Ec7MlvswLp7wiUxw5KQ,7937
10463
10463
  simo/users/__pycache__/api.cpython-38.pyc,sha256=laiJ17ZN-Bj8fL-AjKpcjPm0hOVEd83vYkOqxfmHa7c,10218
10464
10464
  simo/users/__pycache__/apps.cpython-38.pyc,sha256=dgbWL8CxzzISJQTmq_4IztPJ2UzykNVdqA2Ae1PmeGk,605
10465
10465
  simo/users/__pycache__/auth_backends.cpython-38.pyc,sha256=n5nx2QSXNj2idzRcGE6bAagMN-8qxoCs580H1EFZXls,3105
10466
10466
  simo/users/__pycache__/auto_urls.cpython-38.pyc,sha256=K-3sz2h-cEitoflSmZk1t0eUg5mQMMGLNZFREVwG7_o,430
10467
10467
  simo/users/__pycache__/dynamic_settings.cpython-38.pyc,sha256=6F8JBjZkHykySnmZjNEzjS0ijbmPdcp9yUAZ5kqq_Fo,864
10468
- simo/users/__pycache__/managers.cpython-38.pyc,sha256=oAy5mRBI-FQWgx9xgQsHmCiknKqojuVY363mfEVK0i8,697
10468
+ simo/users/__pycache__/managers.cpython-38.pyc,sha256=O0Y8ABp42RAosrbODmYsPMaj9AyOPyJ-aqzuO0Qpi2s,679
10469
10469
  simo/users/__pycache__/middleware.cpython-38.pyc,sha256=Tj4nVEAvxEW3xA63fBRiJWRJpz_M848ZOqbHioc_IPE,1149
10470
- simo/users/__pycache__/models.cpython-38.pyc,sha256=E8JT94NAdffXhAWvuK2RG0kPO9YBtX4Cy7Ofs-wIFNw,17577
10470
+ simo/users/__pycache__/models.cpython-38.pyc,sha256=RDZ7bjfjTQV0rJxEVM8dfaxD5oKmoOWViAtIPpQmNQg,17472
10471
10471
  simo/users/__pycache__/permissions.cpython-38.pyc,sha256=ez5NxoL_JUeeH6GsKhvFreuA3FCBgGf9floSypdXUtM,633
10472
10472
  simo/users/__pycache__/serializers.cpython-38.pyc,sha256=Dy8RAcwNkNSXoJHvLp8fozURyHCtucqpSPyqZtbnMZc,3732
10473
10473
  simo/users/__pycache__/sso_urls.cpython-38.pyc,sha256=uAwDozpOmrhUald-8tOHANILXkH7-TI8fNYXOtPkSY8,402
@@ -10561,9 +10561,9 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10561
10561
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10562
10562
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10563
10563
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10564
- simo-2.5.22.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10565
- simo-2.5.22.dist-info/METADATA,sha256=KaAMA15RMBlsmAnbx_HODBYLnPYZXG66HDn17nQ_gE4,1924
10566
- simo-2.5.22.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
10567
- simo-2.5.22.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10568
- simo-2.5.22.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10569
- simo-2.5.22.dist-info/RECORD,,
10564
+ simo-2.5.23.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10565
+ simo-2.5.23.dist-info/METADATA,sha256=-vWzMgKAjan4BPPOY4e0LcmrR0BJljvaEH9uf52c1ks,1924
10566
+ simo-2.5.23.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
10567
+ simo-2.5.23.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10568
+ simo-2.5.23.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10569
+ simo-2.5.23.dist-info/RECORD,,
File without changes