def newProfile(userObject, phonenumber, address): profileObject = Profile(user=userObject) profileObject = timezone.now() profileObject.phoneNumber = phonenumber """start of possibly bad code - may need fixing depending on how frontend handles address and sends here (as of now assumes the address is a string) """ profileObject.address = address profileObject.shareZone = address[-5:] #slice end off of address string """end of possibly bad code """ profileObject.reputation = 50 #set reputation to 50 (default value) """default preference object should be assigned """ profileObject.preferences = '' """end of possibly bad code """ return profileObject
def save(self,commit = True): user = super(UserRegistrationForm, self).save(commit = False) newProfile = Profile() newProfile.phoneNumber = self.cleaned_data['phone_number'] newProfile.streetAddress = self.cleaned_data['street_address'] newProfile.sharezone = self.cleaned_data['zip_code'] newProfile.city = self.cleaned_data['city'] newProfile.state = self.cleaned_data['state'] newProfile.stateName = STATE_DICT[self.cleaned_data['state']] newProfile.emailNotifs = self.cleaned_data['email_notifications'] newProfile.textNotifs = self.cleaned_data['text_notifications'] newProfile.picture = '' newProfile.status = '' newProfile.reputation = 50 newProfile.preferences = '' newProfile.timeCreated = timezone.now() if commit: user.save() newProfile.user = user newProfile.save() return user
def save(self, commit=True): user = super(UserRegistrationForm, self).save(commit=False) newProfile = Profile() newProfile.phoneNumber = self.cleaned_data['phone_number'] newProfile.streetAddress = self.cleaned_data['street_address'] newProfile.sharezone = self.cleaned_data['zip_code'] newProfile.city = self.cleaned_data['city'] newProfile.state = self.cleaned_data['state'] newProfile.stateName = STATE_DICT[self.cleaned_data['state']] newProfile.emailNotifs = self.cleaned_data['email_notifications'] newProfile.textNotifs = self.cleaned_data['text_notifications'] newProfile.picture = '' newProfile.status = '' newProfile.reputation = 50 newProfile.preferences = '' newProfile.timeCreated = timezone.now() if commit: user.save() newProfile.user = user newProfile.save() return user