Пример #1
0
    def addim(self):

        userIM = UserIM(parent = self.userProfile,
                        itemValue = db.IM(imTypes[self.getRequiredParameter('type')],
                                          self.getRequiredParameter('im')),
                        privacyType = self.getRequiredParameter('privacy'))
        userIM.put()

        # Add permissions for this email in every outgoing group
        for persona in self.userProfile.personas:
            permitIM = PermitIM(parent = persona,
                                userIM = userIM)
            permitIM.put()

        self._updateAllVCards()

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