diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-03-27 12:37:31 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-03-27 12:50:06 +0100 |
| commit | 1b1925afbcc381df1fbbb6f8b8488683f17378a4 (patch) | |
| tree | f2ab99fbad809aa9c6a398b6b5af5f1827d434f3 /ishtar_common/models.py | |
| parent | 41de8783a4307a305a09ae522db9cec53f4b43ca (diff) | |
| download | Ishtar-1b1925afbcc381df1fbbb6f8b8488683f17378a4.tar.bz2 Ishtar-1b1925afbcc381df1fbbb6f8b8488683f17378a4.zip | |
🗃️ sites - models: add relations between sites - minor relations between items refactoring
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 04defbd81..a6aab9416 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -874,6 +874,15 @@ class GeneralRelationType(GeneralType): return obj +class RecordRelationManager(models.Manager): + def get_by_natural_key(self, left_record, right_record, relation_type): + return self.get( + left_record__uuid=left_record, + right_record__uuid=right_record, + relation_type__txt_idx=relation_type, + ) + + class GeneralRecordRelations(Imported): class Meta: abstract = True @@ -882,8 +891,15 @@ class GeneralRecordRelations(Imported): def general_types(cls): return ["relation_type"] + def natural_key(self): + return ( + self.left_record.uuid, + self.right_record.uuid, + self.relation_type.txt_idx, + ) + def save(self, *args, **kwargs): - super(GeneralRecordRelations, self).save(*args, **kwargs) + super().save(*args, **kwargs) # after saving create the symmetric or the inverse relation |
