diff options
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 |
commit | f50d4f8d8cfff475451298f6dd14188fe971e0ef (patch) | |
tree | ad676b608551596a246cb4eb59cd44525fd2d080 /archaeological_operations/models.py | |
parent | 041ac7922da55ad24f8d324f076aef07400a1ef5 (diff) | |
download | Ishtar-f50d4f8d8cfff475451298f6dd14188fe971e0ef.tar.bz2 Ishtar-f50d4f8d8cfff475451298f6dd14188fe971e0ef.zip |
Serialization : configure restore - UUID for parcels
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 22 |
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): |