diff --git a/rsconcept/backend/apps/oss/models/OperationSchemaCached.py b/rsconcept/backend/apps/oss/models/OperationSchemaCached.py index 8356cbf8..dcf6a526 100644 --- a/rsconcept/backend/apps/oss/models/OperationSchemaCached.py +++ b/rsconcept/backend/apps/oss/models/OperationSchemaCached.py @@ -318,16 +318,16 @@ class OperationSchemaCached: mapping={} ) - def after_create_attribution(self, schemaID: int, associations: list[Attribution], + def after_create_attribution(self, schemaID: int, attributions: list[Attribution], exclude: Optional[list[int]] = None) -> None: ''' Trigger cascade resolutions when Attribution is created. ''' operation = self.cache.get_operation(schemaID) - self.engine.on_inherit_attribution(operation.pk, associations, exclude) + self.engine.on_inherit_attribution(operation.pk, attributions, exclude) - def before_delete_attribution(self, schemaID: int, associations: list[Attribution]) -> None: + def before_delete_attribution(self, schemaID: int, attributions: list[Attribution]) -> None: ''' Trigger cascade resolutions when Attribution is deleted. ''' operation = self.cache.get_operation(schemaID) - self.engine.on_delete_attribution(operation.pk, associations) + self.engine.on_delete_attribution(operation.pk, attributions) def _on_add_substitutions(self, schema: Optional[RSFormCached], added: list[Substitution]) -> None: ''' Trigger cascade resolutions when Constituenta substitution is added. ''' diff --git a/rsconcept/backend/apps/oss/models/PropagationEngine.py b/rsconcept/backend/apps/oss/models/PropagationEngine.py index eb517116..32e1a0b1 100644 --- a/rsconcept/backend/apps/oss/models/PropagationEngine.py +++ b/rsconcept/backend/apps/oss/models/PropagationEngine.py @@ -185,7 +185,7 @@ class PropagationEngine: self.on_before_substitute(child_operation.pk, new_substitutions) child_schema.substitute(new_substitutions) - def on_delete_attribution(self, operationID: int, associations: list[Attribution]) -> None: + def on_delete_attribution(self, operationID: int, attributions: list[Attribution]) -> None: ''' Trigger cascade resolutions when Attribution is deleted. ''' children = self.cache.extend_graph.outputs[operationID] if not children: @@ -198,7 +198,7 @@ class PropagationEngine: continue deleted: list[Attribution] = [] - for attr in associations: + for attr in attributions: new_container = self.cache.get_inheritor(attr.container_id, child_id) new_attribute = self.cache.get_inheritor(attr.attribute_id, child_id) if new_container is None or new_attribute is None: @@ -211,7 +211,7 @@ class PropagationEngine: deleted.append(deleted_assoc[0]) if deleted: self.on_delete_attribution(child_id, deleted) - Attribution.objects.filter(pk__in=[assoc.pk for assoc in deleted]).delete() + Attribution.objects.filter(pk__in=[attrib.pk for attrib in deleted]).delete() def on_delete_inherited(self, operation: int, target: list[int]) -> None: ''' Trigger cascade resolutions when Constituenta inheritance is deleted. ''' diff --git a/rsconcept/backend/apps/oss/models/PropagationFacade.py b/rsconcept/backend/apps/oss/models/PropagationFacade.py index f14cefc6..e5c38c9c 100644 --- a/rsconcept/backend/apps/oss/models/PropagationFacade.py +++ b/rsconcept/backend/apps/oss/models/PropagationFacade.py @@ -82,20 +82,20 @@ class PropagationFacade: OperationSchemaCached(host).before_delete_cst(item.pk, ids) @staticmethod - def after_create_attribution(sourceID: int, associations: list[Attribution], + def after_create_attribution(sourceID: int, attributions: list[Attribution], exclude: Optional[list[int]] = None) -> None: ''' Trigger cascade resolutions when Attribution is created. ''' hosts = _get_oss_hosts(sourceID) for host in hosts: if exclude is None or host.pk not in exclude: - OperationSchemaCached(host).after_create_attribution(sourceID, associations) + OperationSchemaCached(host).after_create_attribution(sourceID, attributions) @staticmethod def before_delete_attribution(sourceID: int, - associations: list[Attribution], + attributions: list[Attribution], exclude: Optional[list[int]] = None) -> None: ''' Trigger cascade resolutions before Attribution is deleted. ''' hosts = _get_oss_hosts(sourceID) for host in hosts: if exclude is None or host.pk not in exclude: - OperationSchemaCached(host).before_delete_attribution(sourceID, associations) + OperationSchemaCached(host).before_delete_attribution(sourceID, attributions) diff --git a/rsconcept/backend/apps/rsform/serializers/data_access.py b/rsconcept/backend/apps/rsform/serializers/data_access.py index a161c5d6..78f534c9 100644 --- a/rsconcept/backend/apps/rsform/serializers/data_access.py +++ b/rsconcept/backend/apps/rsform/serializers/data_access.py @@ -228,10 +228,10 @@ class RSFormSerializer(StrictModelSerializer): 'id': oss.pk, 'alias': oss.alias }) - for assoc in Attribution.objects.filter(container__schema=instance).only('container_id', 'attribute_id'): + for attrib in Attribution.objects.filter(container__schema=instance).only('container_id', 'attribute_id'): result['attribution'].append({ - 'container': assoc.container_id, - 'attribute': assoc.attribute_id + 'container': attrib.container_id, + 'attribute': attrib.attribute_id }) return result @@ -304,9 +304,9 @@ class RSFormSerializer(StrictModelSerializer): Attribution.objects.filter(container__schema=instance).delete() attributions_to_create: list[Attribution] = [] - for assoc in data.get('attribution', []): - old_container_id = assoc['container'] - old_attribute_id = assoc['attribute'] + for attrib in data.get('attribution', []): + old_container_id = attrib['container'] + old_attribute_id = attrib['attribute'] container_id = id_map.get(old_container_id) attribute_id = id_map.get(old_attribute_id) if container_id and attribute_id: diff --git a/rsconcept/backend/apps/rsform/tests/s_views/t_attribtuions.py b/rsconcept/backend/apps/rsform/tests/s_views/t_attribtuions.py index 50b04fbb..55e66246 100644 --- a/rsconcept/backend/apps/rsform/tests/s_views/t_attribtuions.py +++ b/rsconcept/backend/apps/rsform/tests/s_views/t_attribtuions.py @@ -45,10 +45,10 @@ class TestAttributionsEndpoints(EndpointTester): self.executeBadData(data, item=self.unowned_id) response = self.executeCreated(data, item=self.owned_id) - associations = response.data['attribution'] - self.assertEqual(len(associations), 1) - self.assertEqual(associations[0]['container'], self.n1.pk) - self.assertEqual(associations[0]['attribute'], self.x1.pk) + attributions = response.data['attribution'] + self.assertEqual(len(attributions), 1) + self.assertEqual(attributions[0]['container'], self.n1.pk) + self.assertEqual(attributions[0]['attribute'], self.x1.pk) @decl_endpoint('/api/rsforms/{item}/create-attribution', method='post') @@ -94,7 +94,7 @@ class TestAttributionsEndpoints(EndpointTester): attribute=self.n1 ) response = self.executeOK(data, item=self.owned_id) - associations = response.data['attribution'] - self.assertEqual(len(associations), 1) - self.assertEqual(associations[0]['container'], self.n2.pk) - self.assertEqual(associations[0]['attribute'], self.n1.pk) + attributions = response.data['attribution'] + self.assertEqual(len(attributions), 1) + self.assertEqual(attributions[0]['container'], self.n2.pk) + self.assertEqual(attributions[0]['attribute'], self.n1.pk) diff --git a/rsconcept/backend/apps/rsform/views/rsforms.py b/rsconcept/backend/apps/rsform/views/rsforms.py index 0d958133..5fc17a8f 100644 --- a/rsconcept/backend/apps/rsform/views/rsforms.py +++ b/rsconcept/backend/apps/rsform/views/rsforms.py @@ -346,7 +346,7 @@ class RSFormViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retr }) PropagationFacade.before_delete_attribution(item.pk, target) - m.Attribution.objects.filter(pk__in=[assoc.pk for assoc in target]).delete() + m.Attribution.objects.filter(pk__in=[attrib.pk for attrib in target]).delete() item.save(update_fields=['time_update']) return Response( @@ -376,7 +376,7 @@ class RSFormViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retr target = list(m.Attribution.objects.filter(container=serializer.validated_data['target'])) if target: PropagationFacade.before_delete_attribution(item.pk, target) - m.Attribution.objects.filter(pk__in=[assoc.pk for assoc in target]).delete() + m.Attribution.objects.filter(pk__in=[attrib.pk for attrib in target]).delete() item.save(update_fields=['time_update']) return Response( diff --git a/rsconcept/frontend/src/features/rsform/backend/rsform-loader.ts b/rsconcept/frontend/src/features/rsform/backend/rsform-loader.ts index b0de25e0..72a13e19 100644 --- a/rsconcept/frontend/src/features/rsform/backend/rsform-loader.ts +++ b/rsconcept/frontend/src/features/rsform/backend/rsform-loader.ts @@ -110,11 +110,11 @@ export class RSFormLoader { parent.spawn_alias.push(cst.alias); } }); - this.schema.attribution.forEach(assoc => { - const container = this.cstByID.get(assoc.container)!; - container.attributes.push(assoc.attribute); - this.full_graph.addEdge(container.id, assoc.attribute); - this.association_graph.addEdge(container.id, assoc.attribute); + this.schema.attribution.forEach(attrib => { + const container = this.cstByID.get(attrib.container)!; + container.attributes.push(attrib.attribute); + this.full_graph.addEdge(container.id, attrib.attribute); + this.association_graph.addEdge(container.id, attrib.attribute); }); } diff --git a/rsconcept/frontend/src/features/rsform/backend/types.ts b/rsconcept/frontend/src/features/rsform/backend/types.ts index 3c85dff3..fe7a4129 100644 --- a/rsconcept/frontend/src/features/rsform/backend/types.ts +++ b/rsconcept/frontend/src/features/rsform/backend/types.ts @@ -97,7 +97,7 @@ export type ISubstitutionsDTO = z.infer; /** Represents data for creating or deleting an Attribution. */ export type IAttribution = z.infer; -/** Represents data for clearing all associations for a target constituenta. */ +/** Represents data for clearing all attributions for a target constituenta. */ export type IAttributionTargetDTO = z.infer; /** Represents Constituenta list. */ diff --git a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/form-constituenta.tsx b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/form-constituenta.tsx index 0e8ad8fb..4c40a286 100644 --- a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/form-constituenta.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/form-constituenta.tsx @@ -112,7 +112,7 @@ export function FormConstituenta({ disabled, id, toggleReset, schema, activeCst, [activeCst, localParse] ); - const associations = useMemo( + const attributions = useMemo( () => activeCst.attributes.map(id => schema.cstByID.get(id)!), [activeCst.attributes, schema.cstByID] ); @@ -291,7 +291,7 @@ export function FormConstituenta({ disabled, id, toggleReset, schema, activeCst,