def quick_save(self,*args,**kwargs): super(Tree, self).save(*args,**kwargs) set_environmental_summaries(self) #set new species counts if hasattr(self,'old_species') and self.old_species: self.old_species.save() if hasattr(self,'species') and self.species: self.species.save() self.plot.last_updated = self.last_updated self.plot.save()
def quick_save(self, *args, **kwargs): super(Tree, self).save(*args, **kwargs) set_environmental_summaries(self) #set new species counts if hasattr(self, 'old_species') and self.old_species: self.old_species.save() if hasattr(self, 'species') and self.species: self.species.save() self.plot.last_updated = self.last_updated self.plot.save()
def save(self, *args, **kwargs): self.validate() pnt = self.geometry n = Neighborhood.objects.filter(geometry__contains=pnt) z = ZipCode.objects.filter(geometry__contains=pnt) if n: oldns = self.neighborhoods new_nhoods = [] for nhood in n: if nhood: new_nhoods.append(nhood.id.__str__()) self.neighborhoods = " ".join(new_nhoods) else: self.neighborhoods = "" oldns = None if self.id: oldn = self.neighborhood.all() oldz = self.zipcode else: oldn = [] oldz = None super(Plot, self).save(*args,**kwargs) if n: self.neighborhood.clear() for nhood in n: if nhood: self.neighborhood.add(nhood) else: self.neighborhood.clear() if z: self.zipcode = z[0] else: self.zipcode = None if self.current_tree(): set_environmental_summaries(self.current_tree()) super(Plot, self).save(*args,**kwargs) if self.neighborhoods != oldns: done = [] if n: for nhood in n: if nhood.id in done: continue if self.current_tree(): self.current_tree().update_aggregate(AggregateNeighborhood, nhood) else: self.update_aggregate(AggregateNeighborhood, nhood) done.append(nhood.id) if oldn: for nhood in oldn: if nhood.id in done: continue if self.current_tree(): self.current_tree().update_aggregate(AggregateNeighborhood, nhood) else: self.update_aggregate(AggregateNeighborhood, nhood) done.append(nhood.id) if self.current_tree() and z and z[0] != oldz: if z: self.current_tree().update_aggregate(AggregateZipCode, z[0]) if oldz: self.current_tree().update_aggregate(AggregateZipCode, oldz)
def save(self, *args, **kwargs): self.validate() pnt = self.geometry n = Neighborhood.objects.filter(geometry__contains=pnt) z = ZipCode.objects.filter(geometry__contains=pnt) if n: oldns = self.neighborhoods new_nhoods = [] for nhood in n: if nhood: new_nhoods.append(nhood.id.__str__()) self.neighborhoods = " ".join(new_nhoods) else: self.neighborhoods = "" oldns = None if self.id: oldn = self.neighborhood.all() oldz = self.zipcode else: oldn = [] oldz = None super(Plot, self).save(*args, **kwargs) if n: self.neighborhood.clear() for nhood in n: if nhood: self.neighborhood.add(nhood) else: self.neighborhood.clear() if z: self.zipcode = z[0] else: self.zipcode = None if self.current_tree(): set_environmental_summaries(self.current_tree()) super(Plot, self).save(*args, **kwargs) if self.neighborhoods != oldns: done = [] if n: for nhood in n: if nhood.id in done: continue if self.current_tree(): self.current_tree().update_aggregate( AggregateNeighborhood, nhood) else: self.update_aggregate(AggregateNeighborhood, nhood) done.append(nhood.id) if oldn: for nhood in oldn: if nhood.id in done: continue if self.current_tree(): self.current_tree().update_aggregate( AggregateNeighborhood, nhood) else: self.update_aggregate(AggregateNeighborhood, nhood) done.append(nhood.id) if self.current_tree() and z and z[0] != oldz: if z: self.current_tree().update_aggregate(AggregateZipCode, z[0]) if oldz: self.current_tree().update_aggregate(AggregateZipCode, oldz)