def addphone(self): userPhone = UserPhoneNumber(parent = self.userProfile, itemValue = self._checkNewItemByName(UserPhoneNumber, 'phone'), privacyType = self.getRequiredParameter('privacy'), itemType = self.getRequiredParameter('type')) userPhone.put() # Add permissions for this email in every outgoing group for persona in self.userProfile.personas: permitPhone = PermitPhoneNumber(parent = persona, userPhoneNumber = userPhone) permitPhone.put() self._updateAllVCards() self.sendJsonOK({'key': str(userPhone.key())})
def addpersona(self): personaName = self.getRequiredParameter('name') personaIndex = self.getRequiredParameter('index') # Error checking if personaName == "Public": raise AjaxError("Cannot create another public persona") if personaName == "Default": raise AjaxError("Cannot create another default private persona") try: # Check if the persona already exists persona = self._getPersonaByName(personaName) # Create a new Persona newPersona = Persona(parent = self.userProfile, name = personaName) newPersona.put() for email in self.userProfile.emails: permitEmail = PermitEmail(parent = newPersona, userEmail = email) permitEmail.put() for im in self.userProfile.ims: permitIM = PermitIM(parent = newPersona, userIM = im) permitIM.put() for www in self.userProfile.webpages: permitWebpage = PermitWebpage(parent = newPersona, userWebpage = www) permitWebpage.put() for phone in self.userProfile.phones: permitPhoneNumber = PermitPhoneNumber(parent = newPersona, userPhoneNumber = phone) permitPhoneNumber.put() for address in self.userProfile.addresses: permitAddress = PermitAddress(parent = newPersona, userAddress = address) permitAddress.put() # Generate the Persona's vCard and eTag: generateVCard(newPersona) self.sendContent('templates/Persona_Persona.html', activeEntry = "Personas", templateVariables = { 'persona': newPersona, 'companies': self._getCompanies(), 'nicknames': self._getNicknames(), 'photos': self._getPhotos(), 'userProfile': self.userProfile, 'personaIndex': personaIndex, }) except datastore_errors.BadKeyError: raise AjaxError("Persona with that name already exists")