def on_put(self, req, resp, id):
        jobj = req.context['doc']
        username = req.context["user"]
        jobj["_id"] = id
        self._validate_doc(jobj, username)

        existing_doc = self.db.get_doc(DB_FRIEND_GROUPS, id)
        if username != existing_doc["group_owner"]:
            raise falcon.HTTPForbidden("Permission denied", "You are not the owner of the group")
        merge_private(jobj, existing_doc)
        resp.body = self.db.save_doc(DB_FRIEND_GROUPS, jobj)
Esempio n. 2
0
    def on_put(self, req, resp, event_id=None):
        jobj = req.context['doc']
        username = req.context["user"]
        jobj["_id"] = event_id
        self._validate_doc(jobj, username)

        existing_doc = self.db.get_doc(DB_EVENTS, event_id)
        if username != existing_doc["creator"]:
            raise falcon.HTTPForbidden("Permission denied", "You are not the creator of this event")

        # Get fields used by other routes from existing doc
        merge_private(jobj, existing_doc)
        jobj["suggestions"] = existing_doc["suggestions"]
        jobj["comments"] = existing_doc["comments"]

        resp.body = self.db.save_doc(DB_EVENTS, jobj)