Esempio n. 1
0
 def delete(self, winery_id, wine_id, userwine_id, tasting_id):
     tasting_key = ndb.Key(Winery, int(winery_id), Wine, int(wine_id),
                           UserWine, int(userwine_id), WineTasting, int(tasting_id))
     tasting = tasting_key.get()
     tasting.delete()
     Event.delete(self.request.remote_addr, "WineTasting", tasting_key)
     json_response(self, {"success": True})
Esempio n. 2
0
 def delete(self, winery_id, wine_id, userwine_id, tasting_id):
     tasting_key = ndb.Key(Winery, int(winery_id), Wine, int(wine_id),
                           UserWine, int(userwine_id), WineTasting,
                           int(tasting_id))
     tasting = tasting_key.get()
     tasting.delete()
     Event.delete(self.request.remote_addr, "WineTasting", tasting_key)
     json_response(self, {"success": True})
Esempio n. 3
0
    def delete(self, cellar_id):
        cellar_key = ndb.Key(WineCellar, int(cellar_id))
        cellar = cellar_key.get()
        if not cellar:
            self.response.write("404 Not Found")
            self.response.status = "404 Not Found"
            return

        if not User.has_access(cellar_key):
            self.response.write("403 Forbidden")
            self.response.status = "403 Forbidden"
            return

        qry = WineBottle.query(ancestor=cellar.key)
        results = qry.fetch(MAX_RESULTS)
        for bottle in results:
            bottle.delete()

        cellar.delete()
        user = User.get_current_user()
        user.cellar = None
        user.put()
        Event.delete(self.request.remote_addr, "WineCellar", cellar_key)
        json_response(self, {"success": True})
Esempio n. 4
0
    def delete(self, cellar_id):
        cellar_key = ndb.Key(WineCellar, int(cellar_id))
        cellar = cellar_key.get()
        if not cellar:
            self.response.write("404 Not Found")
            self.response.status = "404 Not Found"
            return

        if not User.has_access(cellar_key):
            self.response.write("403 Forbidden")
            self.response.status = "403 Forbidden"
            return

        qry = WineBottle.query(ancestor=cellar.key)
        results = qry.fetch(MAX_RESULTS)
        for bottle in results:
            bottle.delete()

        cellar.delete()
        user = User.get_current_user()
        user.cellar = None
        user.put()
        Event.delete(self.request.remote_addr, "WineCellar", cellar_key)
        json_response(self, {"success": True})