simo 2.5.21__py3-none-any.whl → 2.5.22__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/api.py CHANGED
@@ -204,10 +204,10 @@ class UserDeviceReport(InstanceMixin, viewsets.GenericViewSet):
204
204
  if request.META.get('HTTP_HOST', '').endswith('.simo.io'):
205
205
  relay = request.META.get('HTTP_HOST')
206
206
 
207
-
207
+ last_seen_location = None
208
208
  user_device.last_seen = timezone.now()
209
209
  if location:
210
- user_device.last_seen_location = ','.join(
210
+ last_seen_location = ','.join(
211
211
  [str(i) for i in location]
212
212
  ) if location else None
213
213
 
@@ -218,24 +218,24 @@ class UserDeviceReport(InstanceMixin, viewsets.GenericViewSet):
218
218
  ).exclude(id=user_device.id).update(is_primary=False)
219
219
  user_device.save()
220
220
 
221
+ phone_on_charge = False
222
+ if request.data.get('is_charging'):
223
+ phone_on_charge = True
221
224
  speed_kmh = request.data.get('speed', 0) * 3.6
222
225
  for iu in request.user.instance_roles.filter(is_active=True):
223
226
  if location:
224
227
  iu.at_home = haversine_distance(
225
- iu.instance.location, user_device.last_seen_location
228
+ iu.instance.location, last_seen_location
226
229
  ) < dynamic_settings['users__at_home_radius']
227
230
  elif not relay:
228
231
  iu.at_home = True
229
232
 
230
233
  iu.last_seen = user_device.last_seen
231
- iu.last_seen_location = user_device.last_seen_location
234
+ iu.last_seen_location = last_seen_location
232
235
  iu.last_seen_speed_kmh = speed_kmh
233
- iu.phone_on_charge = request.data.get('is_charging', False)
236
+ iu.phone_on_charge = phone_on_charge
234
237
  iu.save()
235
238
 
236
- phone_on_charge = False
237
- if request.data.get('is_charging'):
238
- phone_on_charge = True
239
239
  UserDeviceReportLog.objects.create(
240
240
  user_device=user_device, instance=self.instance,
241
241
  app_open=request.data.get('app_open', False),
simo/users/models.py CHANGED
@@ -294,7 +294,7 @@ class User(AbstractBaseUser, SimoAdminMixin):
294
294
  else:
295
295
  instances = Instance.objects.filter(id__in=[
296
296
  r.instance.id for r in self.instance_roles.filter(
297
- is_active=True, instance__isnull=False
297
+ is_active=True
298
298
  )
299
299
  ], is_active=True)
300
300
  cache.set(cache_key, instances, 10)
@@ -306,8 +306,10 @@ class User(AbstractBaseUser, SimoAdminMixin):
306
306
  role__in=self.roles.all()
307
307
  )
308
308
 
309
+
309
310
  @property
310
311
  def is_active(self):
312
+ # Things are getting messed up when no
311
313
  instance = get_current_instance()
312
314
  if not instance:
313
315
  cache_key = f'user-{self.id}_is_active'
@@ -315,15 +317,27 @@ class User(AbstractBaseUser, SimoAdminMixin):
315
317
  cache_key = f'user-{self.id}_is_active_instance-{instance.id}'
316
318
  cached_value = cache.get(cache_key)
317
319
  if cached_value is None:
318
- if self.is_master and not self.instance_roles.all():
319
- # Master who have no roles on any instance are in GOD mode!
320
- # It can not be disabled by anybody, nor it is seen by anybody. :)
321
- cached_value = True
320
+ if self.is_master:
321
+ if not self.instance_roles.all():
322
+ # Master who have no roles on any instance are in GOD mode!
323
+ # It can not be disabled by anybody, nor it is seen by anybody. :)
324
+ cached_value = True
325
+ else:
326
+ # Masters who have roles on instances but are all disabled
327
+ # on all instances are then fully disabled
328
+ # Common scenario is - installer made smart home installation
329
+ # owner disabled installer once everything is done, so that
330
+ # installer no longer has any access to his home, however
331
+ # home owner can enable back installer at any time so that
332
+ # he could make any additional necessary changes.
333
+ cached_value = bool(
334
+ self.instance_roles.filter(is_active=True).count()
335
+ )
322
336
  elif instance:
323
337
  cached_value = bool(
324
338
  self.instance_roles.filter(
325
339
  instance=instance, is_active=True
326
- ).first()
340
+ ).count()
327
341
  )
328
342
  else:
329
343
  cached_value = bool(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.5.21
3
+ Version: 2.5.22
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
@@ -10443,14 +10443,14 @@ simo/notifications/migrations/__pycache__/0003_alter_notification_instance.cpyth
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
10445
  simo/users/admin.py,sha256=WDRJJtEkbYBQFtLg_5VOIlBV0eeJhgmrsFL51ttme0w,6760
10446
- simo/users/api.py,sha256=wMX7zknPSgEe4Rd-N6313SVFrx7QMwZXKZ1lX3qtMjI,12153
10446
+ simo/users/api.py,sha256=xe__HFxzOaKgrh75PFpP4nkSs5DvmJp8QvMDNhP5kLU,12127
10447
10447
  simo/users/apps.py,sha256=cq0A8-U1HALEwev0TicgFhr4CAu7Icz8rwq0HfOaL4E,207
10448
10448
  simo/users/auth_backends.py,sha256=1gy1-R1U8AOixJ3Ou2LTILjKOHTUxavm_zDiQtCAA9Q,4040
10449
10449
  simo/users/auto_urls.py,sha256=lcJvteBsbHQMJieZpDz-63tDYejLApqsW3CUnDakd7k,272
10450
10450
  simo/users/dynamic_settings.py,sha256=sEIsi4yJw3kH46Jq_aOkSuK7QTfQACGUE-lkyBogCaM,570
10451
10451
  simo/users/managers.py,sha256=Dm21Avmu38-h8MsZ5ljtpgKihMGUBU4hHGpiPvp4NtM,323
10452
10452
  simo/users/middleware.py,sha256=GMCrnWSc_2qCleyQIkfQGdL-pU-UTEcSg1wPvIKZ9uk,1210
10453
- simo/users/models.py,sha256=rWjhWDh7PdUTHIg8E7zZHeArxNCHdcrA4RwHkCaZgV0,18973
10453
+ simo/users/models.py,sha256=Ds7WOUVLxljsK_73qGcfnnyJO4EIBXY9GS9FcJGx1bs,19716
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
@@ -10460,14 +10460,14 @@ 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
10462
  simo/users/__pycache__/admin.cpython-38.pyc,sha256=5LEDivt0AydPmqk9PCKvlKRRtc3QBxA6hZgcy_8bEQU,7680
10463
- simo/users/__pycache__/api.cpython-38.pyc,sha256=2BBBoY8SwvTTL6-bCGjY-Dm8ao5NHRGyJ8WB7EPR9cw,10223
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
10468
  simo/users/__pycache__/managers.cpython-38.pyc,sha256=oAy5mRBI-FQWgx9xgQsHmCiknKqojuVY363mfEVK0i8,697
10469
10469
  simo/users/__pycache__/middleware.cpython-38.pyc,sha256=Tj4nVEAvxEW3xA63fBRiJWRJpz_M848ZOqbHioc_IPE,1149
10470
- simo/users/__pycache__/models.cpython-38.pyc,sha256=LJqRXBisLbNPzXU19iIZ81Zd6DQQGi-5woHjQlXvdXM,17578
10470
+ simo/users/__pycache__/models.cpython-38.pyc,sha256=E8JT94NAdffXhAWvuK2RG0kPO9YBtX4Cy7Ofs-wIFNw,17577
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.21.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10565
- simo-2.5.21.dist-info/METADATA,sha256=kpfxTB9swlXMBR86cbL_O3uyNJIOU0IB_1hn-RixSvA,1924
10566
- simo-2.5.21.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
10567
- simo-2.5.21.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10568
- simo-2.5.21.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10569
- simo-2.5.21.dist-info/RECORD,,
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,,
File without changes