simo 2.5.21__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.
- simo/__pycache__/settings.cpython-38.pyc +0 -0
- simo/settings.py +2 -1
- simo/users/__pycache__/admin.cpython-38.pyc +0 -0
- simo/users/__pycache__/api.cpython-38.pyc +0 -0
- simo/users/__pycache__/managers.cpython-38.pyc +0 -0
- simo/users/__pycache__/models.cpython-38.pyc +0 -0
- simo/users/admin.py +5 -0
- simo/users/api.py +8 -8
- simo/users/auth_backends.py +6 -1
- simo/users/managers.py +1 -4
- simo/users/models.py +21 -17
- {simo-2.5.21.dist-info → simo-2.5.23.dist-info}/METADATA +1 -1
- {simo-2.5.21.dist-info → simo-2.5.23.dist-info}/RECORD +17 -17
- {simo-2.5.21.dist-info → simo-2.5.23.dist-info}/LICENSE.md +0 -0
- {simo-2.5.21.dist-info → simo-2.5.23.dist-info}/WHEEL +0 -0
- {simo-2.5.21.dist-info → simo-2.5.23.dist-info}/entry_points.txt +0 -0
- {simo-2.5.21.dist-info → simo-2.5.23.dist-info}/top_level.txt +0 -0
|
Binary file
|
simo/settings.py
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
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
|
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
|
-
|
|
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,
|
|
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 =
|
|
234
|
+
iu.last_seen_location = last_seen_location
|
|
232
235
|
iu.last_seen_speed_kmh = speed_kmh
|
|
233
|
-
iu.phone_on_charge =
|
|
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/auth_backends.py
CHANGED
|
@@ -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.
|
|
116
|
+
if user.get_dirty_fields():
|
|
117
|
+
user.save()
|
|
113
118
|
|
|
114
119
|
return user
|
simo/users/managers.py
CHANGED
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(
|
|
@@ -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
|
|
297
|
+
is_active=True
|
|
298
298
|
)
|
|
299
299
|
], is_active=True)
|
|
300
300
|
cache.set(cache_key, instances, 10)
|
|
@@ -306,26 +306,30 @@ 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):
|
|
311
|
-
|
|
312
|
-
if not instance:
|
|
313
|
-
cache_key = f'user-{self.id}_is_active'
|
|
314
|
-
else:
|
|
315
|
-
cache_key = f'user-{self.id}_is_active_instance-{instance.id}'
|
|
312
|
+
cache_key = f'user-{self.id}_is_active'
|
|
316
313
|
cached_value = cache.get(cache_key)
|
|
317
314
|
if cached_value is None:
|
|
318
|
-
if self.is_master
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
315
|
+
if self.is_master:
|
|
316
|
+
if not self.instance_roles.all().count():
|
|
317
|
+
# Master who have no roles on any instance are in GOD mode!
|
|
318
|
+
# It can not be disabled by anybody, nor it is seen by anybody. :)
|
|
319
|
+
cached_value = True
|
|
320
|
+
else:
|
|
321
|
+
# Masters who have roles on instances but are all disabled
|
|
322
|
+
# on all instances are then fully disabled
|
|
323
|
+
# Common scenario is - installer made smart home installation
|
|
324
|
+
# owner disabled installer once everything is done, so that
|
|
325
|
+
# installer no longer has any access to his home, however
|
|
326
|
+
# home owner can enable back installer at any time so that
|
|
327
|
+
# he could make any additional necessary changes.
|
|
328
|
+
cached_value = bool(
|
|
329
|
+
self.instance_roles.filter(is_active=True).count()
|
|
330
|
+
)
|
|
328
331
|
else:
|
|
332
|
+
# user is considered active if he is active on at least one instance
|
|
329
333
|
cached_value = bool(
|
|
330
334
|
self.instance_roles.filter(is_active=True).count()
|
|
331
335
|
)
|
|
@@ -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=
|
|
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=
|
|
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=
|
|
10446
|
-
simo/users/api.py,sha256=
|
|
10445
|
+
simo/users/admin.py,sha256=9P0iIGAep2R1AUvZnROsRULbxwCYK9pCfSJ2X4aLLBg,6965
|
|
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=
|
|
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=
|
|
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=
|
|
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=
|
|
10463
|
-
simo/users/__pycache__/api.cpython-38.pyc,sha256=
|
|
10462
|
+
simo/users/__pycache__/admin.cpython-38.pyc,sha256=xZ_PgvobRrbqSuNgR2z2ZNm1Ec7MlvswLp7wiUxw5KQ,7937
|
|
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=
|
|
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=
|
|
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.
|
|
10565
|
-
simo-2.5.
|
|
10566
|
-
simo-2.5.
|
|
10567
|
-
simo-2.5.
|
|
10568
|
-
simo-2.5.
|
|
10569
|
-
simo-2.5.
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|