def POST(self, worldkey): world = world_exists(worldkey) self.can_access_world(world) i = web.input() trimmed = i.savename.strip() if trimmed == "" or trimmed is None: if hasattr(i, 'saveandgo'): return web.seeother("%s/go" % worldkey) elif hasattr(i, 'sofago'): return web.seeother("%s/go?s=1" % worldkey) else: return web.seeother("%s" % worldkey) savename = make_save_name(i.savename, self.page_user) new_save = SavePath(name=savename, user=self.page_user.key, publish=False) save_ftr = new_save.put_async() s = save_ftr.get_result() if hasattr(i, 'saveandgo'): return web.seeother("%s/save/%s" % (worldkey, s.integer_id())) elif hasattr(i, 'sofago'): return web.seeother("/%s/save/%s?s=1" % (worldkey, s.integer_id()))
def POST(self, worldkey, savekey): world = world_exists(worldkey) save = save_exists(savekey) self.redirect_if_not_exists(world, "/yours/saves") self.redirect_if_not_exists(save, "/yours/saves") #self.can_access_world(world) self.can_edit_save(save) if not world.publish: raise web.notfound() i = web.input() key = int(i.key) room_ftr = Room.get_by_id_async(key) save_ftr = SavePath.get_by_id_async(int(savekey)) room = room_ftr.get_result() thesave = save_ftr.get_result() new_texts = thesave.texts new_texts.append(room.key) thesave.texts = new_texts new_save_ftr = thesave.put_async() json = self.js_make_room_json(room) new_save_ftr.get_result() return json
def POST(self, save): save = SavePath.get_by_id(int(save)) self.can_modify_save(save) i = web.input() try: p = i.pub save.publish = True except AttributeError: save.publish = False save.put() web.seeother("/journey/%s" % save.key.id())
def GET(self, save): save = SavePath.get_by_id(int(save)) self.can_access_save(save) texts = [] ftrs = [] prev = None for text in save.texts: ftrs.append(text.get_async()) for ftr in ftrs: t = ftr.get_result() if prev is None or t.key != prev.key: texts.append(t) prev = t if self.page_user: access = save.user == self.page_user.key else: access = False return render().save(save, texts, access)