def save(self, *args, **kwargs): # Calculate and save the normalized address if self.address_line_1 is not None: self.normalized_address = normalize_address_str(self.address_line_1) else: self.normalized_address = None return super(PropertyState, self).save(*args, **kwargs)
def forwards(apps, schema_editor): PropertyState = apps.get_model("seed", "PropertyState") TaxLotState = apps.get_model("seed", "TaxLotState") with transaction.atomic(): for index, p in enumerate( PropertyState.objects.filter(address_line_1__isnull=False)): if index % 1000 == 0: print('iterating ... %s' % index) p.normalized_address = normalize_address_str(p.address_line_1) p.save(update_fields=["normalized_address"]) for index, t in enumerate( TaxLotState.objects.filter(address_line_1__isnull=False)): if index % 1000 == 0: print('iterating ... %s' % index) t.normalized_address = normalize_address_str(t.address_line_1) t.save(update_fields=["normalized_address"])
def save(self, *args, **kwargs): # Calculate and save the normalized address if self.address_line_1 is not None: self.normalized_address = normalize_address_str(self.address_line_1) else: self.normalized_address = None # save a hash of the object to the database for quick lookup from seed.data_importer.tasks import hash_state_object self.hash_object = hash_state_object(self) return super(TaxLotState, self).save(*args, **kwargs)
def save(self, *args, **kwargs): # first check if the <unique id> isn't already in the database for the # organization - potential todo--move this to a unique constraint of the db. # TODO: Decide if we should allow the user to define what the unique ID is for the taxlot # if PropertyState.objects.filter(jurisdiction_tax_lot_id=self.jurisdiction_tax_lot_id, # organization=self.organization).exists(): # logger.error("PropertyState already exists for the same <unique id> and org") # return False # Calculate and save the normalized address if self.address_line_1 is not None: self.normalized_address = normalize_address_str(self.address_line_1) else: self.normalized_address = None return super(PropertyState, self).save(*args, **kwargs)
def run(self): result = normalize_address_str(message) self.assertEquals(expected, result)
def run(self): result = normalize_address_str(message) self.assertEquals(expected, result)