|
48 | 48 | from .relations.relation_manager import RelationManager, RelationUpdates |
49 | 49 | from .relations.typing import FieldUpdateElement, ListUpdateElement |
50 | 50 | from .util.action_type import ActionType |
51 | | -from .util.assert_belongs_to_meeting import assert_belongs_to_meeting |
52 | 51 | from .util.typing import ActionData, ActionResultElement, ActionResults |
53 | 52 |
|
54 | 53 | HISTORY_MODELS = list( |
@@ -697,54 +696,6 @@ def validate_fields(self, instance: dict[str, Any]) -> dict[str, Any]: |
697 | 696 | raise ActionException(str(e)) |
698 | 697 | return instance |
699 | 698 |
|
700 | | - def validate_relation_fields(self, instance: dict[str, Any]) -> None: |
701 | | - """ |
702 | | - Validates all relation fields according to the model definition. |
703 | | - """ |
704 | | - for field in self.model.get_relation_fields(): |
705 | | - if not field.equal_fields or field.own_field_name not in instance: |
706 | | - continue |
707 | | - |
708 | | - fields = [field.own_field_name] |
709 | | - for equal_field in field.equal_fields: |
710 | | - if not (own_equal_field_value := instance.get(equal_field)): |
711 | | - fqid = fqid_from_collection_and_id( |
712 | | - self.model.collection, instance["id"] |
713 | | - ) |
714 | | - db_instance = self.datastore.get( |
715 | | - fqid, |
716 | | - [equal_field], |
717 | | - ) |
718 | | - if not (own_equal_field_value := db_instance.get(equal_field)): |
719 | | - raise ActionException( |
720 | | - f"{fqid} has no value for the field {equal_field}" |
721 | | - ) |
722 | | - for instance_field in fields: |
723 | | - fqids = transform_to_fqids( |
724 | | - instance[instance_field], field.get_target_collection() |
725 | | - ) |
726 | | - if equal_field == "meeting_id": |
727 | | - assert_belongs_to_meeting( |
728 | | - self.datastore, fqids, own_equal_field_value |
729 | | - ) |
730 | | - else: |
731 | | - for fqid in fqids: |
732 | | - related_instance = self.datastore.get( |
733 | | - fqid, |
734 | | - [equal_field], |
735 | | - ) |
736 | | - if str(related_instance.get(equal_field)) != str( |
737 | | - own_equal_field_value |
738 | | - ): |
739 | | - raise ActionException( |
740 | | - f"The relation {field.own_field_name} requires the following " |
741 | | - f"fields to be equal:\n" |
742 | | - f"{field.own_collection}/{instance['id']}/{equal_field}: " |
743 | | - f"{own_equal_field_value}\n" |
744 | | - f"{fqid}/{equal_field}: " |
745 | | - f"{related_instance.get(equal_field)}" |
746 | | - ) |
747 | | - |
748 | 699 | def apply_instance( |
749 | 700 | self, instance: dict[str, Any], fqid: FullQualifiedId | None = None |
750 | 701 | ) -> None: |
|
0 commit comments