summaryrefslogtreecommitdiff
path: root/archaeological_files/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-08-03 17:53:55 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-07-08 09:58:48 +0200
commit6d307f63eab0b857e12605622d5a2be514543be9 (patch)
tree212c42601afb1658323c6609ea944cf1be5e361f /archaeological_files/models.py
parentf1ed669100d351b9b3751e16a159aacbf3a52895 (diff)
downloadIshtar-6d307f63eab0b857e12605622d5a2be514543be9.tar.bz2
Ishtar-6d307f63eab0b857e12605622d5a2be514543be9.zip
Preventive file: add fields - remove dynamic add (too buggy for now)
Diffstat (limited to 'archaeological_files/models.py')
-rw-r--r--archaeological_files/models.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/archaeological_files/models.py b/archaeological_files/models.py
index 51273a17e..79dabc84d 100644
--- a/archaeological_files/models.py
+++ b/archaeological_files/models.py
@@ -25,6 +25,7 @@ from django.conf import settings
from django.contrib.gis.db import models
from django.contrib.postgres.indexes import GinIndex
from django.core.cache import cache
+from django.core.validators import MinValueValidator, MaxValueValidator
from django.db.models import Q, Count, Sum
from django.db.models.signals import post_save, m2m_changed, post_delete
from django.core.urlresolvers import reverse
@@ -57,6 +58,7 @@ from ishtar_common.models import (
SearchVectorConfig,
DocumentItem,
CompleteIdentifierItem,
+ HierarchicalType,
)
from ishtar_common.models_common import HistoricalRecords, Department
@@ -279,6 +281,36 @@ if settings.COUNTRY == "fr":
post_delete.connect(post_save_cache, sender=SaisineType)
+class AgreementType(GeneralType):
+ class Meta:
+ verbose_name = _("Agreement type - France")
+ verbose_name_plural = _("Agreement types - France")
+ ordering = ("label",)
+
+
+post_save.connect(post_save_cache, sender=AgreementType)
+post_delete.connect(post_save_cache, sender=AgreementType)
+
+
+class OperationTypeForRoyalties(GeneralType):
+ increase_coefficient = models.FloatField(
+ _("Increase coefficient"), default=1)
+ increased_final_value = models.FloatField(
+ _("Increased final value"), default=1)
+ category = models.PositiveSmallIntegerField(
+ _("Category"), default=1, validators=[MinValueValidator(1),
+ MaxValueValidator(5)])
+
+ class Meta:
+ verbose_name = _("Operation type for royalties - France")
+ verbose_name_plural = _("Operation types for royalties - France")
+ ordering = ("id",)
+
+
+post_save.connect(post_save_cache, sender=OperationTypeForRoyalties)
+post_delete.connect(post_save_cache, sender=OperationTypeForRoyalties)
+
+
class File(
ClosedItem,
DocumentItem,
@@ -620,6 +652,16 @@ class File(
_("Execution report date"), blank=True, null=True
)
linear_meter = models.IntegerField(_("Linear meter"), blank=True, null=True)
+ type_of_agreement = models.ForeignKey(
+ AgreementType, blank=True, null=True,
+ on_delete=models.SET_NULL,
+ verbose_name=_("Type of agreement"),
+ )
+ operation_type_for_royalties = models.ForeignKey(
+ OperationTypeForRoyalties, blank=True, null=True,
+ on_delete=models.SET_NULL,
+ verbose_name=_("Operation type for royalties"),
+ )
# <-- preventive detail
documents = models.ManyToManyField(