|
|
|
|
@ -8,7 +8,7 @@ from authentication.models import Device |
|
|
|
|
from django.contrib.auth import get_user_model |
|
|
|
|
|
|
|
|
|
from .ws_sender import websocket_sender |
|
|
|
|
from .registry import device_registry, related_users_registry |
|
|
|
|
from .registry import device_registry, related_users_registry, model_registry |
|
|
|
|
|
|
|
|
|
import logging |
|
|
|
|
import traceback |
|
|
|
|
@ -53,8 +53,10 @@ def synchronization_notifications(sender, instance, created=False, **kwargs): |
|
|
|
|
# some classes are excluded in settings_app.py: SYNC_APPS |
|
|
|
|
if not isinstance(instance, BaseModel) and not isinstance(instance, User): |
|
|
|
|
return |
|
|
|
|
# if isinstance(instance, DataAccess): |
|
|
|
|
# return |
|
|
|
|
|
|
|
|
|
model_name = instance.__class__.__name__ |
|
|
|
|
if model_registry.get_model(model_name) is None: |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
process_foreign_key_changes(sender, instance, **kwargs) |
|
|
|
|
@ -100,7 +102,6 @@ def save_model_log_if_possible(instance, signal, created): |
|
|
|
|
else: |
|
|
|
|
operation = ModelOperation.DELETE |
|
|
|
|
|
|
|
|
|
model_name = instance.__class__.__name__ |
|
|
|
|
store_id = None |
|
|
|
|
if isinstance(instance, SideStoreModel): |
|
|
|
|
store_id = instance.store_id |
|
|
|
|
@ -111,6 +112,7 @@ def save_model_log_if_possible(instance, signal, created): |
|
|
|
|
# user_ids = [user.id for user in users] |
|
|
|
|
# # print(f'users to notify: {user_ids}') |
|
|
|
|
# instance._users_to_notify = user_ids # save this for the post_save signal |
|
|
|
|
model_name = instance.__class__.__name__ |
|
|
|
|
save_model_log(users, operation, model_name, instance.id, store_id) |
|
|
|
|
|
|
|
|
|
else: |
|
|
|
|
|