diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-08-03 17:53:55 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-10-25 12:06:02 +0200 |
commit | bfb1078d8a00d344d9ed65057516e792141ae3f9 (patch) | |
tree | 6e6223fd9f8033d727ae2c19bf700c4dd6afb0b6 /archaeological_files/models.py | |
parent | 718b7a8a7109278003cf487a4a9069fe5314cce3 (diff) | |
download | Ishtar-bfb1078d8a00d344d9ed65057516e792141ae3f9.tar.bz2 Ishtar-bfb1078d8a00d344d9ed65057516e792141ae3f9.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.py | 42 |
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( |