コード例 #1
0
ファイル: Psinques.py プロジェクト: kradecki/psinque
    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()