diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-03-04 18:26:12 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-03-10 11:11:46 +0100 |
| commit | 25f41c5e951a403056c11ac36f52252ab2d5d85c (patch) | |
| tree | cc7e096ab1728394dc0ae2819c5357a2904e5c5b /archaeological_finds | |
| parent | 8df4e652186bb6942a6cd2f213514ac5614d690c (diff) | |
| download | Ishtar-25f41c5e951a403056c11ac36f52252ab2d5d85c.tar.bz2 Ishtar-25f41c5e951a403056c11ac36f52252ab2d5d85c.zip | |
🚧 Statement condition - document: models
Diffstat (limited to 'archaeological_finds')
| -rw-r--r-- | archaeological_finds/migrations/0148_statementcondition_documents.py | 25 | ||||
| -rw-r--r-- | archaeological_finds/models_finds.py | 4 | ||||
| -rw-r--r-- | archaeological_finds/models_treatments.py | 30 |
3 files changed, 56 insertions, 3 deletions
diff --git a/archaeological_finds/migrations/0148_statementcondition_documents.py b/archaeological_finds/migrations/0148_statementcondition_documents.py new file mode 100644 index 000000000..ecab258e5 --- /dev/null +++ b/archaeological_finds/migrations/0148_statementcondition_documents.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.21 on 2026-03-04 15:55 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0272_ishtarsiteprofile_statementcondition'), + ('archaeological_finds', '0147_data_migration_statement_condition'), + ] + + operations = [ + migrations.AddField( + model_name='statementcondition', + name='documents', + field=models.ManyToManyField(blank=True, related_name='statement_conditions', to='ishtar_common.document', verbose_name='Documents'), + ), + migrations.AddField( + model_name='statementcondition', + name='main_image', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='main_image_statement_conditions', to='ishtar_common.document', verbose_name='Main image'), + ), + ] diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index f6b0c42b8..360e18393 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -2203,7 +2203,7 @@ class Find( _("Comment on the material"), blank=True, default="" ) volume = models.FloatField(_("Volume (l)"), blank=True, null=True) - weight = models.FloatField(_("Weight"), blank=True, null=True) + weight = models.FloatField(_("Weight (g)"), blank=True, null=True) weight_unit = models.CharField( _("Weight unit"), max_length=4, blank=True, null=True, choices=WEIGHT_UNIT ) @@ -2913,7 +2913,7 @@ class Find( True, ), ] - if can_edit_find and not is_locked: + if can_edit_find and not is_locked and profile.statement_condition: actions += [ ( reverse("find-statement-condition-add", args=[self.pk]), diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index cd82ab57e..77f66fae8 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -1808,7 +1808,7 @@ class StatementCondition( width = models.FloatField(_("Width (cm)"), blank=True, null=True) height = models.FloatField(_("Height (cm)"), blank=True, null=True) volume = models.FloatField(_("Volume (l)"), blank=True, null=True) - weight = models.FloatField(_("Weight"), blank=True, null=True) + weight = models.FloatField(_("Weight (g)"), blank=True, null=True) diameter = models.FloatField(_("Diameter (cm)"), blank=True, null=True) circumference = models.FloatField(_("Circumference (cm)"), blank=True, null=True) thickness = models.FloatField(_("Thickness (cm)"), blank=True, null=True) @@ -1824,6 +1824,21 @@ class StatementCondition( dimensions_comment = models.TextField( _("Dimensions comment"), blank=True, default="" ) + # documents + documents = models.ManyToManyField( + Document, + related_name="statement_conditions", + verbose_name=_("Documents"), + blank=True, + ) + main_image = models.ForeignKey( + Document, + related_name="main_image_statement_conditions", + on_delete=models.SET_NULL, + verbose_name=_("Main image"), + blank=True, + null=True, + ) class Meta: verbose_name = _("Statement of condition") @@ -1834,6 +1849,19 @@ class StatementCondition( ] ADMIN_SECTION = _("Treatments") + def __str__(self): + lbl = f"{self.date} - {self.statement_condition_type}" + if self.campaign_number: + lbl += f" [{self.campaign_number}]" + lbl += f" - {self.find}" + return lbl + + def pk_str(self): + return str(self.pk) + + def _get_base_image_path(self): + return f"{self.SLUG}/{self.date.year}" + @property def is_last(self): return not self.__class__.objects.filter(date__gt=self.date).exists() |
