def save(self, *args, **kwargs): needs_geocode = False if self.id is None: # For new user, only set a few things: self.display_name = self.get_display_name() needs_geocode = True else: old_self = self.__class__.objects.get(id=self.id) if old_self.city != self.city or old_self.state != self.state or self.geocode is None: needs_geocode = True if old_self.display_name != self.display_name or old_self.first_name != self.first_name or old_self.last_name != self.last_name: self.display_name = self.get_display_name( ) # check if display name has changed if old_self.avatar and old_self.avatar != self.avatar: os.remove(old_self.avatar.path) if self.city and self.state and needs_geocode: geocode = get_geocode(self.city, self.state, street_address=self.street_address, zipcode=self.zip) if geocode and geocode != '620': self.geocode = ', '.join(geocode) if self.signature: self.signature = strip_tags(self.signature) if self.bio: self.bio_formatted = sanetize_text(self.bio) super(Profile, self).save(*args, **kwargs)
def save(self, *args, **kwargs): if not self.geocode: geocode = get_geocode(self.city, self.state, self.address, self.zipcode) if geocode: self.geocode = ', '.join(geocode) self.info_formatted = sanetize_text(self.info) if self.recap: self.recap_formatted = sanetize_text(self.recap) if not self.end_date: self.end_date = self.start_date super(Event, self).save(*args, **kwargs)
def save(self, *args, **kwargs): needs_geocode = False if self.id is None: # For new user, only set a few things: self.display_name = self.get_display_name() needs_geocode = True else: old_self = self.__class__.objects.get(id = self.id) if old_self.city != self.city or old_self.state != self.state or self.geocode is None: needs_geocode = True if old_self.display_name != self.display_name or old_self.first_name != self.first_name or old_self.last_name != self.last_name: self.display_name = self.get_display_name() # check if display name has changed if old_self.avatar and old_self.avatar != self.avatar: os.remove(old_self.avatar.path) if self.city and self.state and needs_geocode: geocode = get_geocode(self.city, self.state, street_address=self.street_address, zipcode=self.zip) if geocode and geocode != '620': self.geocode = ', '.join(geocode) if self.signature: self.signature = strip_tags(self.signature) super(Profile, self).save(*args, **kwargs)
def save(self, *args, **kwargs): geocode = get_geocode(self.city, self.state, self.address, self.zipcode) if geocode: self.geocode = ', '.join(geocode) super(Event, self).save(*args, **kwargs)