def POST(self, world): cur_world = world_exists(world) self.redirect_if_not_create(cur_world) f = self.properties_form() form = CombinedForm([f], **self.formargs) if not f.validates(): access = cur_world.get_access_string(self.page_user) world_menu = self.get_or_put_menu(cur_world, access) section = render().section_properties(form) return render().admin( cur_world, section, world_menu, title="Add a new property to %s on Palimpsest" % cur_world.title, pre=["/js/showhide_form_fields.js"]) else: access = cur_world.get_access_string(self.page_user) try: if int(f.d.valid_values) == 0: valid_values = f.d.fixed_values else: valid_values = f.d.valid_values except ValueError: valid_values = f.d.valid_values if f.d.discrete == "True": discrete = True else: discrete = False if cur_world.is_mod(self.page_user): visible = True """ Flush menus and available properties for everyone so they get reset""" # TODO: Fix this memcache.delete("%s-admin" % cur_world.key.id()) memcache.delete("%s-closed" % cur_world.key.id()) else: visible = False new_property = Property(name=f.d.name, sorter=f.d.sorter, info=f.d.info, discrete=discrete, valid_values=valid_values, world=cur_world.key, added_by=self.page_user.key, visible=visible, rejected=False) new_property.put() self.set_menu(cur_world, access) memcache.delete("_properties-%s-global" % cur_world.key.id()) return web.seeother('/%s/property/%s' % (cur_world.key.id(), new_property.key.id()))
def POST(self, world): cur_world = world_exists(world) self.redirect_if_not_create(cur_world) f = self.properties_form() form = CombinedForm([f], **self.formargs) if not f.validates(): access = cur_world.get_access_string(self.page_user) world_menu = self.get_or_put_menu(cur_world, access) section = render().section_properties(form) return render().admin(cur_world, section, world_menu, title="Add a new property to %s on Palimpsest" % cur_world.title, pre=["/js/showhide_form_fields.js"]) else: access = cur_world.get_access_string(self.page_user) try: if int(f.d.valid_values) == 0: valid_values = f.d.fixed_values else: valid_values = f.d.valid_values except ValueError: valid_values = f.d.valid_values if f.d.discrete == "True": discrete = True else: discrete = False if cur_world.is_mod(self.page_user): visible = True """ Flush menus and available properties for everyone so they get reset""" # TODO: Fix this memcache.delete("%s-admin" % cur_world.key.id()) memcache.delete("%s-closed" % cur_world.key.id()) else: visible = False new_property = Property(name=f.d.name, sorter=f.d.sorter, info=f.d.info, discrete=discrete, valid_values=valid_values, world=cur_world.key, added_by=self.page_user.key, visible=visible, rejected=False ) new_property.put() self.set_menu(cur_world, access) memcache.delete("_properties-%s-global" % cur_world.key.id()) return web.seeother('/%s/property/%s' % (cur_world.key.id(), new_property.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()))
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()))