diff --git a/apps/note/models/transactions.py b/apps/note/models/transactions.py index 68249b81a4e21c307722722c64f360a5a4bf619a..a8fb3c2244bad2cf13cfb9002ac754ec0181b225 100644 --- a/apps/note/models/transactions.py +++ b/apps/note/models/transactions.py @@ -163,6 +163,12 @@ class Transaction(PolymorphicModel): When saving, also transfer money between two notes """ + if not self.source.is_active or not self.destination.is_active: + if 'force_insert' not in kwargs or not kwargs['force_insert']: + if 'force_update' not in kwargs or not kwargs['force_update']: + raise ValidationError(_("The transaction can't be saved since the source note " + "or the destination note is not active.")) + # If the aliases are not entered, we assume that the used alias is the name of the note if not self.source_alias: self.source_alias = str(self.source) @@ -171,7 +177,7 @@ class Transaction(PolymorphicModel): self.destination_alias = str(self.destination) if self.source.pk == self.destination.pk: - # When source == destination, no money is transfered + # When source == destination, no money is transferred super().save(*args, **kwargs) return diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index 095bcfc1926e3c82d553cf3099a598c1b8782f03..ba061c8b7c8695a15c5821b1445feef18bb8de91 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -272,7 +272,7 @@ "note", "alias" ], - "query": "[\"OR\", {\"note__in\": [\"NoteUser\", \"objects\", [\"filter\", {\"user__memberships__club__name\": \"Kfet\"}], [\"all\"]]}, {\"note__in\": [\"NoteClub\", \"objects\", [\"all\"]]}]", + "query": "[\"AND\", [\"OR\", {\"note__in\": [\"NoteUser\", \"objects\", [\"filter\", {\"user__memberships__club__name\": \"Kfet\"}], [\"all\"]]}, {\"note__in\": [\"NoteClub\", \"objects\", [\"all\"]]}], {\"note__is_active\": true}]", "type": "view", "mask": 1, "field": "",