def add_data(self, gson_uid): post_data = self.get_post_data() geojson_str = post_data['geojson'] out_dic = self.parse_geojson(geojson_str) if gson_uid == 'draw' or gson_uid == '': uid = tools.get_uu4d() while MJson.get_by_id(uid): uid = tools.get_uu4d() return_dic = {'uid': uid} elif len(gson_uid) == 4: uid = gson_uid return_dic = {'uid': ''} cur_info = MJson.get_by_id(uid) if cur_info.user_id == self.userinfo.uid: pass else: return_dic['status'] = 0 return json.dump(return_dic, self) else: return try: MJson.add_or_update_json(uid, self.userinfo.uid, out_dic, post_data, version=2) return_dic['status'] = 1 except: self.set_status(400) return_dic['status'] = 0 return json.dump(return_dic, self)
def j_add(self, uid=''): post_data = self.get_post_data() print(post_data) geojson_str = post_data['geojson'] # out_dic = self.parse_geojson(geojson_str) if uid: pass else: uid = 'x' + tools.get_uu4d()[1:] while MJson.get_by_id(uid): uid = 'x' + tools.get_uu4d()[1:] return_dic = {'uid': uid} # MJson.add_or_update_json(uid, self.userinfo.uid, out_dic) # return_dic['status'] = 1 # return json.dump(return_dic, self) try: MJson.add_or_update_json(uid, '', geojson_str, post_data) return_dic['status'] = 1 return json.dump(return_dic, self) except: self.set_status(400) return_dic['status'] = 0 return json.dump(return_dic, self)
def update_meta(self, gson_uid): post_data = self.get_post_data() out_dic = post_data['geojson'] uid = gson_uid return_dic = {'uid': ''} cur_info = MJson.get_by_id(uid) if cur_info.user_id == self.userinfo.uid: pass else: return False MJson.add_or_update_json(uid, self.userinfo.uid, out_dic, post_data) self.redirect('/geojson/')