def save(self): #Give it a passkey if necessary if not self.passkey: from core.functions import generate_passkey self.passkey = generate_passkey(25) #Geocode that shit! if not self.lat or not self.lng: self.geocode_for_point() #If it's the first save, give it an easy slug if not self.slug: self.slug = slugify("%s %s" % (self.address1, str(self.zip))) if not self.location: self.set_location() super(Property, self).save() #Now, check to make sure that the slug isn't duplicate if(Property.objects.filter(slug=self.slug).count() > 1): #Existing slug found. import random self.slug = slugify("%s-%i" % (self.slug, random.randrange(1000000,9999999))) super(Property, self).save() #Now, send the confirm email to the user if they have not received one yet. if not self.verified: from core.functions import send_email send_email(extra_context = {'name':self.email, 'property':self, 'recipeient':self.email, 'subject':"Almost! Confirm your listing."})
def make_passkey(): from core.functions import generate_passkey return generate_passkey(50)