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.")
def setgeneral(self): try: persona = Persona.get(self.getRequiredParameter('key')) newName = self.request.get("name") if newName != "": persona.name = newName persona.canViewPrefix = self.getRequiredBoolParameter('prefix') persona.canViewGivenNames = self.getRequiredBoolParameter('givennames') persona.canViewRomanGivenNames = self.getRequiredBoolParameter('givennamesroman') persona.canViewFamilyNames = self.getRequiredBoolParameter('familynames') persona.canViewRomanFamilyNames = self.getRequiredBoolParameter('familynamesroman') persona.canViewSuffix = self.getRequiredBoolParameter('suffix') persona.canViewBirthday = self.getRequiredBoolParameter('birthday') persona.canViewGender = self.getRequiredBoolParameter('gender') company = self.request.get("company") if company != "None": persona.company = Key(company) else: persona.company = None nickname = self.request.get("nickname") if nickname != "None": persona.nickname = Key(nickname) else: persona.nickname = None photoKey = self.request.get("photo") if photoKey != "": photo = UserPhoto.get(photoKey) persona.picture = photo persona.put() generateVCard(persona) self.sendJsonOK() except datastore_errors.BadKeyError: raise AjaxError("Persona not found.")
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")
def _updateAllVCards(self): for persona in Persona.all().ancestor(self.userProfile): generateVCard(persona)