From 21d0c85d27a00528e73a87a2de67d2e3f2b5a69f Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 21 May 2025 15:09:45 +0200 Subject: [PATCH] Fix Match sync config --- padelclub_backend/settings_app.py | 3 +-- sync/models/base.py | 6 +++--- sync/views.py | 10 +++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/padelclub_backend/settings_app.py b/padelclub_backend/settings_app.py index 42daeb4..4722911 100644 --- a/padelclub_backend/settings_app.py +++ b/padelclub_backend/settings_app.py @@ -42,10 +42,9 @@ SYNC_APPS = { } SYNC_MODEL_CHILDREN_SHARING = { - 'Match': {'team_scores', 'team_registration', 'player_registrations'} + 'Match': ['team_scores', 'team_registration', 'player_registrations'] } - STRIPE_CURRENCY = 'eur' # Add managers who should receive internal emails SHOP_MANAGERS = [ diff --git a/sync/models/base.py b/sync/models/base.py index 5d57e5b..1eef92f 100644 --- a/sync/models/base.py +++ b/sync/models/base.py @@ -35,7 +35,7 @@ class BaseModel(models.Model): for child in children: if (child.one_to_many or child.one_to_one) and child.auto_created: model_name = child.related_model.__name__ - print(f'>>> add children for {model_name}') + # print(f'>>> add children for {model_name}') related_objects[model_name] = getattr(self, child.name).all() return related_objects @@ -58,7 +58,7 @@ class BaseModel(models.Model): # Get the parent instance using the related name parent_instance = getattr(self, field.get_accessor_name()) if parent_instance: - print(f'>>> add parent for OneToOneRel : {model_name}') + # print(f'>>> add parent for OneToOneRel : {model_name}') parents[model_name] = parent_instance # Also check for direct foreign key relationships that might represent parent relationships @@ -66,7 +66,7 @@ class BaseModel(models.Model): model_name = field.related_model.__name__ parent_instance = getattr(self, field.name) if parent_instance: - print(f'>>> add parent for ForeignKey : {model_name}') + # print(f'>>> add parent for ForeignKey : {model_name}') parents[model_name] = parent_instance return parents diff --git a/sync/views.py b/sync/views.py index d6b4697..0fc7779 100644 --- a/sync/views.py +++ b/sync/views.py @@ -31,10 +31,10 @@ def add_children_hierarchy(instance, models_dict): relationships = sync_models[instance.__class__.__name__] # 'Match': {'team_scores', 'team_registration', 'player_registrations'} - # print(f'relationships = {relationships}') + print(f'relationships = {relationships}') current = [instance] for relationship in relationships: - # print(f'relationship = {relationship}') + print(f'> relationship = {relationship}') values = [] for item in current: value = getattr(item, relationship) @@ -353,20 +353,20 @@ class LogProcessingResult: revocations = defaultdict(list) revocations_parents_organizer = HierarchyOrganizer() - print(f'*** process_revocations: {len(self.revoke_info)}') + # print(f'*** process_revocations: {len(self.revoke_info)}') # First, collect all revocations for model_name, items in self.revoke_info.items(): revocations[model_name].extend(items) - print(f'*** process_revocations for {model_name}') + # print(f'*** process_revocations for {model_name}') # Process parent hierarchies for each revoked item model = model_registry.get_model(model_name) for item in items: try: instance = model.objects.get(id=item['model_id']) - print(f'*** process revoked item parents of {model_name} : {item['model_id']}') + # print(f'*** process revoked item parents of {model_name} : {item['model_id']}') add_parents_with_hierarchy_organizer(instance, revocations_parents_organizer) except model.DoesNotExist: pass