summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/migrations/0040_auto_20190206_1423.py35
-rw-r--r--archaeological_context_records/models.py17
2 files changed, 50 insertions, 2 deletions
diff --git a/archaeological_context_records/migrations/0040_auto_20190206_1423.py b/archaeological_context_records/migrations/0040_auto_20190206_1423.py
new file mode 100644
index 000000000..b3c5a6837
--- /dev/null
+++ b/archaeological_context_records/migrations/0040_auto_20190206_1423.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.10 on 2019-02-06 14:23
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_context_records', '0039_auto_20190122_1550'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='contextrecord',
+ name='multi_polygon_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Multi-polygon source'),
+ ),
+ migrations.AddField(
+ model_name='contextrecord',
+ name='point_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Point source'),
+ ),
+ migrations.AddField(
+ model_name='historicalcontextrecord',
+ name='multi_polygon_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Multi-polygon source'),
+ ),
+ migrations.AddField(
+ model_name='historicalcontextrecord',
+ name='point_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Point source'),
+ ),
+ ]
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 89526076a..4b41fddb7 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -28,7 +28,7 @@ from django.utils.translation import ugettext_lazy as _, pgettext, \
from django.utils.text import slugify
from ishtar_common.utils import cached_label_changed, \
- m2m_historization_changed, post_save_point
+ m2m_historization_changed, post_save_geo
from ishtar_common.models import Document, GeneralType, \
BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \
@@ -485,8 +485,16 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
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)
@@ -528,6 +536,11 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
return self.town.center
return self.operation.get_town_centroid()
+ def get_town_polygons(self):
+ if self.town:
+ return self.town.limit
+ return self.operation.get_town_polygon()
+
@classmethod
def cached_label_bulk_update(cls, operation_id=None, parcel_id=None,
transaction_id=None):
@@ -752,7 +765,7 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
def context_record_post_save(sender, **kwargs):
cached_label_changed(sender=sender, **kwargs)
- post_save_point(sender=sender, **kwargs)
+ post_save_geo(sender=sender, **kwargs)
post_save.connect(context_record_post_save, sender=ContextRecord)