summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-02-19 17:36:25 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-04-24 19:38:56 +0200
commit4f63ed814f96bbc68c22c98b799c3911d62aa737 (patch)
tree1ac2de99841b7a28fee128a68700f59458594f14 /archaeological_context_records
parentb6d3f2dc4a24bb055b73b7c80815685572a83086 (diff)
downloadIshtar-4f63ed814f96bbc68c22c98b799c3911d62aa737.tar.bz2
Ishtar-4f63ed814f96bbc68c22c98b799c3911d62aa737.zip
Geo: manage container and warehouse - manage geo save dependencies
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/migrations/0043_auto_20190218_1808.py83
-rw-r--r--archaeological_context_records/models.py51
2 files changed, 106 insertions, 28 deletions
diff --git a/archaeological_context_records/migrations/0043_auto_20190218_1808.py b/archaeological_context_records/migrations/0043_auto_20190218_1808.py
new file mode 100644
index 000000000..7cc1a89b6
--- /dev/null
+++ b/archaeological_context_records/migrations/0043_auto_20190218_1808.py
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.10 on 2019-02-18 18:08
+from __future__ import unicode_literals
+
+import django.contrib.gis.db.models.fields
+from django.db import migrations, models
+import django.db.models.deletion
+import ishtar_common.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_context_records', '0042_auto_20190206_1423'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='contextrecord',
+ name='multi_polygon_source_item',
+ field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Multi polygon source item'),
+ ),
+ migrations.AddField(
+ model_name='contextrecord',
+ name='point_source_item',
+ field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Point source item'),
+ ),
+ migrations.AddField(
+ model_name='historicalcontextrecord',
+ name='multi_polygon_source_item',
+ field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Multi polygon source item'),
+ ),
+ migrations.AddField(
+ model_name='historicalcontextrecord',
+ name='point_source_item',
+ field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Point source item'),
+ ),
+ migrations.AlterField(
+ model_name='contextrecord',
+ name='main_image',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='main_image_context_records', to='ishtar_common.Document', verbose_name='Image principale'),
+ ),
+ migrations.AlterField(
+ model_name='contextrecord',
+ name='point',
+ field=django.contrib.gis.db.models.fields.PointField(blank=True, dim=3, null=True, srid=4326, verbose_name='Point'),
+ ),
+ migrations.AlterField(
+ model_name='contextrecord',
+ name='relation_image',
+ field=models.FileField(blank=True, help_text='La taille maximale support\xe9e pour le fichier est de 100 Mo.', null=True, upload_to=ishtar_common.models.get_image_path, verbose_name='Image des relations (SVG g\xe9n\xe9r\xe9)'),
+ ),
+ migrations.AlterField(
+ model_name='contextrecord',
+ name='x',
+ field=models.FloatField(blank=True, null=True, verbose_name='X/Long'),
+ ),
+ migrations.AlterField(
+ model_name='contextrecord',
+ name='y',
+ field=models.FloatField(blank=True, null=True, verbose_name='Y/Lat'),
+ ),
+ migrations.AlterField(
+ model_name='historicalcontextrecord',
+ name='point',
+ field=django.contrib.gis.db.models.fields.PointField(blank=True, dim=3, null=True, srid=4326, verbose_name='Point'),
+ ),
+ migrations.AlterField(
+ model_name='historicalcontextrecord',
+ name='relation_image',
+ field=models.TextField(blank=True, help_text='La taille maximale support\xe9e pour le fichier est de 100 Mo.', max_length=100, null=True, verbose_name='Image des relations (SVG g\xe9n\xe9r\xe9)'),
+ ),
+ migrations.AlterField(
+ model_name='historicalcontextrecord',
+ name='x',
+ field=models.FloatField(blank=True, null=True, verbose_name='X/Long'),
+ ),
+ migrations.AlterField(
+ model_name='historicalcontextrecord',
+ name='y',
+ field=models.FloatField(blank=True, null=True, verbose_name='Y/Lat'),
+ ),
+ ]
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 71551a49d..a2793ac67 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -35,7 +35,7 @@ from ishtar_common.models import Document, GeneralType, \
GeneralRelationType, GeneralRecordRelations, post_delete_record_relation,\
post_save_cache, ValueGetter, BulkUpdatedItem, ExternalIdManager, \
RelationItem, Town, get_current_profile, document_attached_changed, \
- HistoryModel, SearchAltName, SpatialReferenceSystem
+ HistoryModel, SearchAltName, GeoItem
from archaeological_operations.models import Operation, Period, Parcel, \
ArchaeologicalSite
@@ -269,7 +269,7 @@ class CRBulkView(object):
"""
-class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
+class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, GeoItem,
OwnPerms, ValueGetter, ShortMenuItem, RelationItem):
SHOW_URL = 'show-contextrecord'
SLUG = 'contextrecord'
@@ -471,30 +471,7 @@ 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)
- point_source = models.CharField(
- _(u"Point source"),
- choices=(('T', _(u"Town")), ('P', _(u"Precise"))), max_length=1,
- blank=True, null=True)
- multi_polygon = models.MultiPolygonField(_(u"Multi polygon"), blank=True,
- null=True)
- multi_polygon_source = models.CharField(
- _(u"Multi-polygon source"),
- choices=(('T', _(u"Town")), ('P', _(u"Precise"))), max_length=1,
- blank=True, null=True)
+
documents = models.ManyToManyField(
Document, related_name='context_records', verbose_name=_(u"Documents"),
blank=True)
@@ -533,14 +510,32 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
def get_town_centroid(self):
if self.town:
- return self.town.center
+ return self.town.center, self._meta.verbose_name
+ if self.archaeological_site:
+ centroid = self.archaeological_site.get_town_centroid()
+ if centroid:
+ return centroid
return self.operation.get_town_centroid()
def get_town_polygons(self):
if self.town:
- return self.town.limit
+ return self.town.limit, self._meta.verbose_name
+ if self.archaeological_site:
+ polys = self.archaeological_site.get_town_centroid()
+ if polys:
+ return polys
return self.operation.get_town_polygons()
+ def get_precise_points(self):
+ precise_points = super(ContextRecord, self).get_precise_points()
+ if precise_points:
+ return precise_points
+ if self.archaeological_site:
+ precise_points = self.archaeological_site.get_precise_points()
+ if precise_points:
+ return precise_points
+ return self.operation.get_precise_points()
+
@classmethod
def cached_label_bulk_update(cls, operation_id=None, parcel_id=None,
transaction_id=None):