summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-12-01 13:41:18 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:21 +0100
commitbabba00f09b77972cc35fcea59b31d4615685ab7 (patch)
treeb691a089838807ed00ecf9a9c38a19c27bf35ace /archaeological_context_records
parent5015e03c0ceabe8ca8a7884e7178bfd246d77788 (diff)
downloadIshtar-babba00f09b77972cc35fcea59b31d4615685ab7.tar.bz2
Ishtar-babba00f09b77972cc35fcea59b31d4615685ab7.zip
Context records: add surface
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/forms.py5
-rw-r--r--archaeological_context_records/migrations/0107_auto_20201201_1336.py25
-rw-r--r--archaeological_context_records/models.py6
-rw-r--r--archaeological_context_records/templates/ishtar/sheet_contextrecord.html8
4 files changed, 44 insertions, 0 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index 054c5254e..e1b49bbe3 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -247,6 +247,11 @@ class RecordFormGeneral(CustomForm, ManageOldType):
widget=forms.Textarea, required=False)
excavation_technic = forms.ChoiceField(
label=_(u"Excavation technique"), choices=[], required=False)
+ surface = forms.IntegerField(
+ required=False, widget=widgets.AreaWidget,
+ label=_(u"Total surface (m2)"),
+ validators=[validators.MinValueValidator(0),
+ validators.MaxValueValidator(999999999)])
length = forms.FloatField(label=_(u"Length (m)"), required=False)
width = forms.FloatField(label=_(u"Width (m)"), required=False)
thickness = forms.FloatField(label=_(u"Thickness (m)"), required=False)
diff --git a/archaeological_context_records/migrations/0107_auto_20201201_1336.py b/archaeological_context_records/migrations/0107_auto_20201201_1336.py
new file mode 100644
index 000000000..bee8d07b5
--- /dev/null
+++ b/archaeological_context_records/migrations/0107_auto_20201201_1336.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.27 on 2020-12-01 13:36
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_context_records', '0106_views_related_cr'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='contextrecord',
+ name='surface',
+ field=models.IntegerField(blank=True, null=True, verbose_name='Surface (m2)'),
+ ),
+ migrations.AddField(
+ model_name='historicalcontextrecord',
+ name='surface',
+ field=models.IntegerField(blank=True, null=True, verbose_name='Surface (m2)'),
+ ),
+ ]
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 8a1011084..715e6286c 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -559,6 +559,7 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem,
depth = models.FloatField(_("Depth (m)"), blank=True, null=True)
depth_of_appearance = models.FloatField(
_("Depth of appearance (m)"), blank=True, null=True)
+ surface = models.IntegerField(_("Surface (m2)"), blank=True, null=True)
location = models.TextField(
_("Location"), blank=True, null=True,
help_text=_("A short description of the location of the context "
@@ -647,6 +648,11 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem,
def __str__(self):
return self.short_label or ""
+ @property
+ def surface_ha(self):
+ if self.surface:
+ return self.surface / 10000.0
+
def public_representation(self):
dct = super(ContextRecord, self).public_representation()
dct.update({
diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
index e15a07f70..bcfb8db97 100644
--- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
+++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
@@ -130,6 +130,14 @@
{% field_flex_full "Comment on datings" item.datings_comment "<pre>" "</pre>" has_image %}
{% field_flex_full "Description" item.description "<pre>" "</pre>" has_image %}
{% field_flex_full "Comment" item.comment "<pre>" "</pre>" has_image %}
+ {% if item.surface %}
+ <dl class="col-12 col-md-6 col-lg-3 flex-wrap">
+ <dt>{%trans "Surface"%}</dt>
+ <dd>
+ {{ item.surface }} m<sup>2</sup> ({{ item.surface_ha }} ha)
+ </dd>
+ </dl>
+ {% endif %}
{% field_flex "Length (m)" item.length '' '' has_image %}
{% field_flex "Width (m)" item.width '' '' has_image %}
{% field_flex "Diameter (m)" item.diameter '' '' has_image %}