Пример #1
0
def createNewPersona(userProfile, personaName, userEmail):

    persona = Persona(parent = userProfile,
                    name = personaName)
    persona.put()

    permitEmail = PermitEmail(parent = persona,
                              userEmail = userEmail)
    permitEmail.put()

    generateVCard(persona)

    logging.info("New persona created, key = " + str(persona.key()))

    return persona.key()
Пример #2
0
    def addemail(self):

        email = self._checkNewItemByName(UserEmail, 'email')
        email = email.lower()

        userEmail = UserEmail(parent = self.userProfile,
                              itemValue = email,
                              privacyType = self.getRequiredParameter('privacy'),
                              primary = self.getRequiredBoolParameter('primary'))
        userEmail.put()

        # Add permissions for this email in every outgoing group
        for persona in self.userProfile.personas:
            permitEmail = PermitEmail(parent = persona,
                                      userEmail = userEmail)
            permitEmail.put()

        self._updateAllVCards()

        self.sendJsonOK({'key': str(userEmail.key())})
Пример #3
0
    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")