def changegroup(self): try: contact = Contact.get(self.getRequiredParameter("contact")) except datastore_errors.BadKeyError: raise AjaxError("Contact does not exist") # oldGroup = contact.group try: persona = Group.get(self.getRequiredParameter("persona")) except datastore_errors.BadKeyError: raise AjaxError("Group does not exist") # First we check if this psinque is not already asigned to that group contact.group = group contact.put() # oldGroupSize = Contact.all(keys_only = True). \ # filter("group =", oldGroup). \ # count(1) # if oldGroupSize == 0: # olfGroup.delete() self.sendJsonOK()
def getVCard(contactID): # This is 3 Datastore fetches: Contact, Psinque, Persona logging.info("Getting vCard for Contact " + contactID) contact = Contact.get(contactID) persona = contact.incoming.persona if persona.vcardNeedsUpdating: reallyGenerateVCard(persona) return [persona.vcard, persona.vcardMTime, persona.vcardMD5]
def _getContact(self): # Find contact on this end contact = Contact.get(self.getRequiredParameter("key")) if contact is None: raise AjaxError("Contact not found") if contact.parent().key() != self.userProfile.key(): raise AjaxError("You cannot modify contacts that do not belong to you") return contact
def changepersona(self): try: contact = Contact.get(self.getRequiredParameter("contact")) except datastore_errors.BadKeyError: raise AjaxError("Contact does not exist") try: persona = Persona.get(self.getRequiredParameter("persona")) except datastore_errors.BadKeyError: raise AjaxError("Persona does not exist") if contact.persona == persona: self.sendJsonOK() return contact.persona = persona contact.put() if persona.public: if contact.outgoing: contact.outgoing.private = False contact.outgoing.put() Notifications.notifyDowngradedPsinque(contact.outgoing) if contact.friendsContact: contact.friendsContact.status = "public" contact.friendsContact.put() if contact.outgoing: contact.outgoing.persona = persona contact.outgoing.put() self.sendJsonOK()