diff options
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 |
commit | 4f63ed814f96bbc68c22c98b799c3911d62aa737 (patch) | |
tree | 1ac2de99841b7a28fee128a68700f59458594f14 /archaeological_operations | |
parent | b6d3f2dc4a24bb055b73b7c80815685572a83086 (diff) | |
download | Ishtar-4f63ed814f96bbc68c22c98b799c3911d62aa737.tar.bz2 Ishtar-4f63ed814f96bbc68c22c98b799c3911d62aa737.zip |
Geo: manage container and warehouse - manage geo save dependencies
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/migrations/0053_auto_20190218_1808.py | 147 | ||||
-rw-r--r-- | archaeological_operations/models.py | 71 |
2 files changed, 157 insertions, 61 deletions
diff --git a/archaeological_operations/migrations/0053_auto_20190218_1808.py b/archaeological_operations/migrations/0053_auto_20190218_1808.py new file mode 100644 index 000000000..0f553f131 --- /dev/null +++ b/archaeological_operations/migrations/0053_auto_20190218_1808.py @@ -0,0 +1,147 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2019-02-18 18:08 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import ishtar_common.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_operations', '0052_auto_20190206_1423'), + ] + + operations = [ + migrations.AddField( + model_name='archaeologicalsite', + 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='archaeologicalsite', + name='point_source_item', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Point source item'), + ), + migrations.AddField( + model_name='historicalarchaeologicalsite', + 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='historicalarchaeologicalsite', + name='point_source_item', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Point source item'), + ), + migrations.AddField( + model_name='historicaloperation', + 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='historicaloperation', + name='point_source_item', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Point source item'), + ), + migrations.AddField( + model_name='operation', + 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='operation', + name='point_source_item', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Point source item'), + ), + migrations.AlterField( + model_name='archaeologicalsite', + name='affmar_number', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Num\xe9ro AffMar'), + ), + migrations.AlterField( + model_name='archaeologicalsite', + name='drassm_number', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Num\xe9ro DRASSM'), + ), + migrations.AlterField( + model_name='archaeologicalsite', + name='main_image', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='main_image_sites', to='ishtar_common.Document', verbose_name='Image principale'), + ), + migrations.AlterField( + model_name='archaeologicalsite', + name='x', + field=models.FloatField(blank=True, null=True, verbose_name='X/Long'), + ), + migrations.AlterField( + model_name='archaeologicalsite', + name='y', + field=models.FloatField(blank=True, null=True, verbose_name='Y/Lat'), + ), + migrations.AlterField( + model_name='historicalarchaeologicalsite', + name='affmar_number', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Num\xe9ro AffMar'), + ), + migrations.AlterField( + model_name='historicalarchaeologicalsite', + name='drassm_number', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Num\xe9ro DRASSM'), + ), + migrations.AlterField( + model_name='historicalarchaeologicalsite', + name='x', + field=models.FloatField(blank=True, null=True, verbose_name='X/Long'), + ), + migrations.AlterField( + model_name='historicalarchaeologicalsite', + name='y', + field=models.FloatField(blank=True, null=True, verbose_name='Y/Lat'), + ), + migrations.AlterField( + model_name='historicaloperation', + name='drassm_code', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Code DRASSM'), + ), + migrations.AlterField( + model_name='historicaloperation', + 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='historicaloperation', + name='x', + field=models.FloatField(blank=True, null=True, verbose_name='X/Long'), + ), + migrations.AlterField( + model_name='historicaloperation', + name='y', + field=models.FloatField(blank=True, null=True, verbose_name='Y/Lat'), + ), + migrations.AlterField( + model_name='operation', + name='drassm_code', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Code DRASSM'), + ), + migrations.AlterField( + model_name='operation', + name='main_image', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='main_image_operations', to='ishtar_common.Document', verbose_name='Image principale'), + ), + migrations.AlterField( + model_name='operation', + 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='operation', + name='x', + field=models.FloatField(blank=True, null=True, verbose_name='X/Long'), + ), + migrations.AlterField( + model_name='operation', + name='y', + field=models.FloatField(blank=True, null=True, verbose_name='Y/Lat'), + ), + ] diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index b76e4841e..d79bce7f3 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -39,7 +39,7 @@ from ishtar_common.models import BaseHistorizedItem, Dashboard, \ post_delete_record_relation, post_save_cache, RelationItem, \ ShortMenuItem, SourceType, Town, ValueGetter, get_current_profile, \ document_attached_changed, HistoryModel, SearchAltName, \ - SpatialReferenceSystem + GeoItem from ishtar_common.utils import cached_label_changed, \ force_cached_label_changed, mode, m2m_historization_changed, post_save_geo @@ -107,7 +107,7 @@ post_save.connect(post_save_cache, sender=RecordQualityType) post_delete.connect(post_save_cache, sender=RecordQualityType) -class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, +class ArchaeologicalSite(BaseHistorizedItem, GeoItem, OwnPerms, ValueGetter, ShortMenuItem): SHOW_URL = 'show-site' TABLE_COLS = ['reference', 'name', 'towns_label', 'periods', 'remains'] @@ -262,32 +262,6 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, drassm_number = models.CharField(_(u"DRASSM number"), max_length=100, null=True, blank=True) - # gis - 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 = models.PointField(_(u"Point"), blank=True, null=True, dim=3) - point_2d = models.PointField(_(u"Point (2D)"), blank=True, null=True) - 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="sites", verbose_name=_(u"Documents"), blank=True) @@ -403,15 +377,15 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, q = self.towns.filter(center__isnull=False).annotate( centroid=Centroid(Union('center'))).all() if not q.count(): - return None - return q.all()[0].centroid + return + return q.all()[0].centroid, self._meta.verbose_name def get_town_polygons(self): q = self.towns.filter(limit__isnull=False).annotate( poly=Union('limit')).all() if not q.count(): - return None - return q.all()[0].poly + return + return q.all()[0].poly, self._meta.verbose_name def _get_base_image_path(self): return u"{}/{}".format(self.SLUG, self.reference) @@ -535,7 +509,7 @@ class OperationManager(models.GeoManager): return self.get(code_patriarche=txt_idx) -class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, +class Operation(ClosedItem, BaseHistorizedItem, GeoItem, OwnPerms, ValueGetter, ShortMenuItem, DashboardFormItem, RelationItem): SHOW_URL = 'show-operation' TABLE_COLS = ['year', 'towns_label', 'common_name', 'operation_type', @@ -946,31 +920,6 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, name_of_the_protagonist = models.TextField(_(u"Name of the protagonist"), blank=True, null=True) - # gis - 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 = models.PointField(_(u"Point"), blank=True, null=True, dim=3) - point_2d = models.PointField(_(u"Point (2D)"), blank=True, null=True) - 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) history = HistoricalRecords(bases=[HistoryModel]) class Meta: @@ -1141,15 +1090,15 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, q = self.towns.filter(center__isnull=False).annotate( centroid=Centroid(Union('center'))).all() if not q.count(): - return None - return q.all()[0].centroid + return + return q.all()[0].centroid, self._meta.verbose_name def get_town_polygons(self): q = self.towns.filter(limit__isnull=False).annotate( poly=Union('limit')).all() if not q.count(): return None - return q.all()[0].poly + return q.all()[0].poly, self._meta.verbose_name def context_record_relations_q(self): from archaeological_context_records.models \ |