Intervention relations enhancements

* refactors model relation to compensation and payment by applying 1-n instead of n-n
This commit is contained in:
mipel committed 2021-07-23 09:36:43 +02:00
1 parent 82be1511db
commit d618c1c14a
2 files changed
+18 -3

No files matched your search

+16
View File
@@ -12,6 +12,7 @@ from django.utils import timezone
from django.utils.timezone import now
from compensation.settings import COMPENSATION_IDENTIFIER_LENGTH, COMPENSATION_IDENTIFIER_TEMPLATE
from intervention.models import Intervention
from konova.models import BaseObject, BaseResource, Geometry
from konova.utils.generators import generate_random_string
from organisation.models import Organisation
@@ -29,6 +30,13 @@ class Payment(BaseResource):
blank=True,
help_text="Refers to german money transfer 'Verwendungszweck'",
)
intervention = models.ForeignKey(
Intervention,
null=True,
blank=True,
on_delete=models.CASCADE,
related_name='payments'
)
class CompensationControl(BaseResource):
@@ -81,6 +89,14 @@ class Compensation(BaseObject):
geometry = models.ForeignKey(Geometry, null=True, blank=True, on_delete=models.SET_NULL)
documents = models.ManyToManyField("konova.Document", blank=True)
intervention = models.ForeignKey(
Intervention,
on_delete=models.CASCADE,
null=True,
blank=True,
related_name='compensations'
)
# Users having access on this object
users = models.ManyToManyField(User)