def post(self, special_day_id=None): user = users.get_current_user() if user and is_trusted_user(user): self.response.headers['Content-Type'] = 'application/json; charset=utf-8' try: day = SpecialDay.get(self.request.get("specialdayid")) if day: new_thing = self.request.get("newthing") thing = SpecialThing(day=day, thing=new_thing, user=user) thing.put() self.response.out.write(simplejson.dumps({ "status": True, "message": "Sweet! Your special thing was added." })) else: raise except: self.response.out.write(simplejson.dumps({ "status": False, "message": "Damn! There was a problem adding your special thing. \ Please try again." })) else: self.redirect("/")
def get_special_things(day): return [t for t in SpecialThing.gql('where day = :day order by date_added desc', day=day)]