Beispiel #1
0
    def addwww(self):

        userWebpage = UserWebpage(parent = self.userProfile,
                                  itemValue = self.getRequiredParameter('www'),
                                  privacyType = self.getRequiredParameter('privacy'),
                                  itemType = self.getRequiredParameter('type'))
        userWebpage.put()

        # Add permissions for this email in every outgoing group
        for persona in self.userProfile.personas:
            permitWebpage = PermitWebpage(parent = persona,
                                          userWebpage = userWebpage)
            permitWebpage.put()

        self._updateAllVCards()

        self.sendJsonOK({'key': str(userWebpage.key())})
Beispiel #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")