Exemplo n.º 1
0
    def removepersona(self):
        
        try:
            persona = Persona.get(self.getRequiredParameter('key'))

        except datastore_errors.BadKeyError:
            raise AjaxError("Persona not found")
            
        # Check for errors
        if persona.name == "Public":  # cannot remove the public persona
            raise AjaxError("Cannot remove the public persona")
        if persona.name == "Default":  # cannot remove the default persona
            raise AjaxError("Cannot remove the default private persona")

        # Get all contacts that use this persona and assign them the default persona
        contacts = Contact.all(). \
                           ancestor(self.userProfile). \
                           filter("persona =", persona)
        defaultPersona = self._getPersonaByName("Default")
        for contact in contacts:
            contact.persona = defaultPersona
            contact.put()

        # Remove all children individual permits
        individualPermits = IndividualPermit.all().ancestor(persona)
        for individualPermit in individualPermits:
            individualPermit.delete()
        persona.delete()  # and the persona itself

        self.sendJsonOK()
Exemplo n.º 2
0
    def setindividualpermit(self):

        itemKey = self.getRequiredParameter('key')
        canView = self.getRequiredBoolParameter('canview')
        
        try:
            individualPermit = IndividualPermit.get(itemKey)
            individualPermit.canView = canView
            individualPermit.put()
                  
            generateVCard(individualPermit.parent())
            
            self.sendJsonOK()
            
        except datastore_errors.BadKeyError:
            raise AjaxError("Individual permit not found.")
Exemplo n.º 3
0
def deleteProfile(userProfileKey):

    userProfile = UserProfile.get(userProfileKey)    
    
    for e in CardDAVLogin.all().ancestor(userProfile):
        e.delete()
    for e in IndividualPermit.all().ancestor(userProfile):
        e.delete()
    for e in Persona.all().ancestor(userProfile):
        e.delete()
    for e in Psinque.all().ancestor(userProfile):
        e.delete()
    for e in Contact.all().ancestor(userProfile):
        e.delete()
    for e in Group.all().ancestor(userProfile):
        e.delete()
    for e in UserAddress.all().ancestor(userProfile):
        e.delete()
    for e in UserEmail.all().ancestor(userProfile):
        e.delete()
    for e in UserIM.all().ancestor(userProfile):
        e.delete()
    for e in UserPhoneNumber.all().ancestor(userProfile):
        e.delete()
    for e in UserPhoto.all().ancestor(userProfile):
        e.image.delete()
        e.delete()
    for e in UserNickname.all().ancestor(userProfile):
        e.delete()
    for e in UserCompany.all().ancestor(userProfile):
        e.delete()
    for e in UserWebpage.all().ancestor(userProfile):
        e.delete()
    
    if not userProfile.userSettings is None:
        userProfile.userSettings.delete()
        
    userProfile.delete()
    logging.info("User profile deleted")