示例#1
0
    def POST(self, world):
        cur_world = world_exists(world)
        self.redirect_if_not_create(cur_world)

        i = web.input(long=[], lat=[], prop_name=[], prop_val=[])
        coord = []
        new = []
        access = cur_world.get_access_string(self.page_user)
        form = self.text_form()

        if not form.validates():
            world_menu = self.get_or_put_menu(cur_world, access)
            return self.reset_text_page(cur_world, form, access, world_menu)
        else:

            if cur_world.is_mod(self.page_user):
                visible = True
                """ Flush menus for everyone so they get reset"""
                mrpc = memcache.create_rpc()
                m = flush_caches("", cur_world, mrpc)
                try:
                    m.get_result()
                except AssertionError:  # There were no caches to flush - is this even the problem?
                    pass
            else:
                visible = False

            new_text = Room(world=cur_world.key,
                            name=form.d.name,
                            short_desc=form.d.short_desc,
                            long_desc=form.d.long_desc,
                            added_by=self.page_user.key,
                            latitudes=i.lat,
                            longitudes=i.long,
                            visible=visible,
                            rejected=False)
            new_text.put()

            for index, name in enumerate(i.prop_name):
                p = Property.get_by_id(int(name))
                new.append(PropertyValue())
                new[index].value = i.prop_val[index]
                new[index].of_property = p.key
                new[index].room = new_text.key
                new[index].added_by = self.page_user.key
                new[index].visible = visible

            valftrs = ndb.put_multi_async(new)
            self.set_menu(cur_world, access)

            for ftr in valftrs:
                ftr.get_result()

            return web.seeother('/%s/text/%s' %
                                (cur_world.key.id(), new_text.key.id()))
    def POST(self, world):
        cur_world = world_exists(world)
        self.redirect_if_not_create(cur_world)

        i = web.input(long=[], lat=[], prop_name=[], prop_val=[])
        coord = []
        new = []
        access = cur_world.get_access_string(self.page_user)
        form = self.text_form()

        if not form.validates():
            world_menu = self.get_or_put_menu(cur_world, access)
            return self.reset_text_page(cur_world, form, access, world_menu)
        else:

            if cur_world.is_mod(self.page_user):
                visible = True
                """ Flush menus for everyone so they get reset"""
                mrpc = memcache.create_rpc()
                m = flush_caches("", cur_world, mrpc)
                try:
                    m.get_result()
                except AssertionError: # There were no caches to flush - is this even the problem?
                    pass
            else:
                visible = False

            new_text = Room(world = cur_world.key,
                            name=form.d.name,
                            short_desc=form.d.short_desc,
                            long_desc=form.d.long_desc,
                            added_by=self.page_user.key,
                            latitudes=i.lat,
                            longitudes=i.long,
                            visible=visible,
                            rejected=False
                        )
            new_text.put()

            for index, name in enumerate(i.prop_name):
                p = Property.get_by_id(int(name))
                new.append(PropertyValue())
                new[index].value = i.prop_val[index]
                new[index].of_property = p.key
                new[index].room = new_text.key
                new[index].added_by = self.page_user.key
                new[index].visible = visible

            valftrs = ndb.put_multi_async(new)
            self.set_menu(cur_world, access)

            for ftr in valftrs:
                ftr.get_result()

            return web.seeother('/%s/text/%s' % (cur_world.key.id(), new_text.key.id()))
示例#3
0
    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
示例#4
0
    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
示例#5
0
    def POST(self, worldkey):
        world = world_exists(worldkey)
        self.redirect_if_not_exists("/")
        self.can_access_world(world)

        i = web.input()
        key = int(i.key)
        room = Room.get_by_id(key)

        return self.js_make_room_json(room)
示例#6
0
    def POST(self, worldkey):
        world = world_exists(worldkey)
        self.redirect_if_not_exists("/")
        self.can_access_world(world)

        i = web.input()
        key = int(i.key)
        room = Room.get_by_id(key)

        return self.js_make_room_json(room)