diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-22 16:44:40 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-04-24 19:38:56 +0200 |
commit | 2af3c31880b78d1b0110a168a9809c2c48111e40 (patch) | |
tree | 5b24e0c2251385e2237c5fed80d7354dceba2943 /archaeological_context_records | |
parent | 81a1008c26d0cc7cfdcbea14464746a7106d0e85 (diff) | |
download | Ishtar-2af3c31880b78d1b0110a168a9809c2c48111e40.tar.bz2 Ishtar-2af3c31880b78d1b0110a168a9809c2c48111e40.zip |
Manage X, Y, Z fields for context records, operations and sites
Diffstat (limited to 'archaeological_context_records')
-rw-r--r-- | archaeological_context_records/forms.py | 16 | ||||
-rw-r--r-- | archaeological_context_records/migrations/0038_auto_20190122_1550.py | 87 | ||||
-rw-r--r-- | archaeological_context_records/models.py | 29 |
3 files changed, 128 insertions, 4 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index ae25e0abe..7566dcc71 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -33,7 +33,7 @@ from archaeological_context_records import models from ishtar_common.forms import FinalForm, FormSet, \ reverse_lazy, get_form_selection, TableSelect, ManageOldType, CustomForm, \ - FieldType, CustomFormSearch, IshtarForm, HistorySelect + FieldType, CustomFormSearch, IshtarForm, FormHeader, HistorySelect from ishtar_common.forms_common import get_town_field from archaeological_operations.forms import OperationSelect, ParcelField, \ RecordRelationsForm as OpeRecordRelationsForm, RecordRelationsFormSetBase @@ -135,6 +135,7 @@ class RecordFormSelection(CustomFormSearch): class RecordFormGeneral(CustomForm, ManageOldType): + HEADERS = {} form_label = _("General") form_admin_name = _(u"Context record - 020 - General") form_slug = "contextrecord-020-general" @@ -182,6 +183,19 @@ class RecordFormGeneral(CustomForm, ManageOldType): label=_(u"Location"), widget=forms.Textarea, required=False, validators=[validators.MaxLengthValidator(200)]) + HEADERS['x'] = FormHeader(_(u"Coordinates")) + x = forms.FloatField(label=_(u"X"), required=False) + estimated_error_x = forms.FloatField(label=_(u"Estimated error for X"), + required=False) + y = forms.FloatField(label=_(u"Y"), required=False) + estimated_error_y = forms.FloatField(label=_(u"Estimated error for Y"), + required=False) + z = forms.FloatField(label=_(u"Z"), required=False) + estimated_error_z = forms.FloatField(label=_(u"Estimated error for Z"), + required=False) + spatial_reference_system = forms.ChoiceField( + label=_(u"Spatial Reference System"), required=False, choices=[]) + TYPES = [ FieldType('unit', models.Unit), FieldType('excavation_technic', models.ExcavationTechnicType), diff --git a/archaeological_context_records/migrations/0038_auto_20190122_1550.py b/archaeological_context_records/migrations/0038_auto_20190122_1550.py new file mode 100644 index 000000000..c7777dfd8 --- /dev/null +++ b/archaeological_context_records/migrations/0038_auto_20190122_1550.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2019-01-22 15:50 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0084_ishtarsiteprofile_use_town_for_geo'), + ('archaeological_context_records', '0037_auto_20190118_1203'), + ] + + operations = [ + migrations.AddField( + model_name='contextrecord', + name='estimated_error_x', + field=models.FloatField(blank=True, null=True, verbose_name='Erreur estim\xe9e pour X'), + ), + migrations.AddField( + model_name='contextrecord', + name='estimated_error_y', + field=models.FloatField(blank=True, null=True, verbose_name='Erreur estim\xe9e pour Y'), + ), + migrations.AddField( + model_name='contextrecord', + name='estimated_error_z', + field=models.FloatField(blank=True, null=True, verbose_name='Erreur estim\xe9e pour Z'), + ), + migrations.AddField( + model_name='contextrecord', + name='spatial_reference_system', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.SpatialReferenceSystem', verbose_name='Syst\xe8me de r\xe9f\xe9rence spatiale'), + ), + migrations.AddField( + model_name='contextrecord', + name='x', + field=models.FloatField(blank=True, null=True, verbose_name='X'), + ), + migrations.AddField( + model_name='contextrecord', + name='y', + field=models.FloatField(blank=True, null=True, verbose_name='Y'), + ), + migrations.AddField( + model_name='contextrecord', + name='z', + field=models.FloatField(blank=True, null=True, verbose_name='Z'), + ), + migrations.AddField( + model_name='historicalcontextrecord', + name='estimated_error_x', + field=models.FloatField(blank=True, null=True, verbose_name='Erreur estim\xe9e pour X'), + ), + migrations.AddField( + model_name='historicalcontextrecord', + name='estimated_error_y', + field=models.FloatField(blank=True, null=True, verbose_name='Erreur estim\xe9e pour Y'), + ), + migrations.AddField( + model_name='historicalcontextrecord', + name='estimated_error_z', + field=models.FloatField(blank=True, null=True, verbose_name='Erreur estim\xe9e pour Z'), + ), + migrations.AddField( + model_name='historicalcontextrecord', + name='spatial_reference_system', + field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='ishtar_common.SpatialReferenceSystem'), + ), + migrations.AddField( + model_name='historicalcontextrecord', + name='x', + field=models.FloatField(blank=True, null=True, verbose_name='X'), + ), + migrations.AddField( + model_name='historicalcontextrecord', + name='y', + field=models.FloatField(blank=True, null=True, verbose_name='Y'), + ), + migrations.AddField( + model_name='historicalcontextrecord', + name='z', + field=models.FloatField(blank=True, null=True, verbose_name='Z'), + ), + ] diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index cb6dbc635..89526076a 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -27,14 +27,15 @@ from django.utils.translation import ugettext_lazy as _, pgettext, \ activate, pgettext_lazy, deactivate from django.utils.text import slugify -from ishtar_common.utils import cached_label_changed, m2m_historization_changed +from ishtar_common.utils import cached_label_changed, \ + m2m_historization_changed, post_save_point from ishtar_common.models import Document, GeneralType, \ BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \ GeneralRelationType, GeneralRecordRelations, post_delete_record_relation,\ post_save_cache, ValueGetter, BulkUpdatedItem, ExternalIdManager, \ RelationItem, Town, get_current_profile, document_attached_changed, \ - HistoryModel, SearchAltName + HistoryModel, SearchAltName, SpatialReferenceSystem from archaeological_operations.models import Operation, Period, Parcel, \ ArchaeologicalSite @@ -470,6 +471,18 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, verbose_name=_(u"Excavation technique")) related_context_records = models.ManyToManyField( 'ContextRecord', through='RecordRelations', blank=True) + x = models.FloatField(_(u'X'), blank=True, null=True) + y = models.FloatField(_(u'Y'), blank=True, null=True) + z = models.FloatField(_(u'Z'), blank=True, null=True) + estimated_error_x = models.FloatField(_(u'Estimated error for X'), + blank=True, null=True) + estimated_error_y = models.FloatField(_(u'Estimated error for Y'), + blank=True, null=True) + estimated_error_z = models.FloatField(_(u'Estimated error for Z'), + blank=True, null=True) + spatial_reference_system = models.ForeignKey( + SpatialReferenceSystem, verbose_name=_(u"Spatial Reference System"), + blank=True, null=True) point_2d = models.PointField(_(u"Point (2D)"), blank=True, null=True) point = models.PointField(_(u"Point (3D)"), blank=True, null=True, dim=3) multi_polygon = models.MultiPolygonField(_(u"Multi polygon"), blank=True, @@ -510,6 +523,11 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, def __unicode__(self): return self.short_label + def get_town_centroid(self): + if self.town: + return self.town.center + return self.operation.get_town_centroid() + @classmethod def cached_label_bulk_update(cls, operation_id=None, parcel_id=None, transaction_id=None): @@ -732,7 +750,12 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, self.save() -post_save.connect(cached_label_changed, sender=ContextRecord) +def context_record_post_save(sender, **kwargs): + cached_label_changed(sender=sender, **kwargs) + post_save_point(sender=sender, **kwargs) + + +post_save.connect(context_record_post_save, sender=ContextRecord) m2m_changed.connect(document_attached_changed, sender=ContextRecord.documents.through) |