summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-07 20:03:23 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-07 20:03:23 +0200
commit25dea210c2bf0f6680b8b6e6eef5cc34da93797c (patch)
treead676b608551596a246cb4eb59cd44525fd2d080 /archaeological_operations/models.py
parent1bc05fe8c33817b7eb16f8fdc49407f23daa9af9 (diff)
downloadIshtar-25dea210c2bf0f6680b8b6e6eef5cc34da93797c.tar.bz2
Ishtar-25dea210c2bf0f6680b8b6e6eef5cc34da93797c.zip
Serialization : configure restore - UUID for parcels
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py22
1 files changed, 3 insertions, 19 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index b6686aa21..c2e4e618b 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -2203,19 +2203,6 @@ def strip_zero(value):
return value
-class ParcelManager(models.Manager):
- def get_by_natural_key(self, associated_file, operation, year, town_insee,
- town_year, section, parcel_number):
- q = {"year": year, "town__numero_insee": town_insee,
- "town__year": town_year,
- "section": section, "parcel_number": parcel_number}
- if associated_file:
- q['associated_file__external_id'] = associated_file
- if operation:
- q['operation__code_patriarche'] = operation
- return self.get(**q)
-
-
class Parcel(LightHistorizedItem):
EXTERNAL_ID_KEY = 'parcel_external_id'
BASE_SEARCH_VECTORS = [
@@ -2224,8 +2211,9 @@ class Parcel(LightHistorizedItem):
SearchVectorConfig("cached_label"),
]
PARENT_SEARCH_VECTORS = ['operation']
- objects = ParcelManager()
+ objects = UUIDModelManager()
+ uuid = models.UUIDField(default=uuid.uuid4)
associated_file = models.ForeignKey(
'archaeological_files.File',
related_name='parcels', verbose_name=_("File"),
@@ -2266,11 +2254,7 @@ class Parcel(LightHistorizedItem):
return self.short_label
def natural_key(self):
- return (
- self.associated_file.external_id if self.associated_file else '',
- self.operation.code_patriarche if self.operation else '',
- self.year, self.town.numero_insee, self.town.year, self.section,
- self.parcel_number)
+ return (self.uuid, )
"""
def merge(self, parcel):