def load_voterinfo(booth_id): logging.info("loading voterinfo for booth id %s", booth_id) booth = db.select("booth", where="id=$booth_id", vars=locals())[0] search = voterlib.get_voter_search(booth.state) result = db.select("voter", what="voterid", where="name is NULL and booth_id=$booth_id", vars=locals()).list() data = (search.get_voter_info(row.voterid) for row in result) for row in data: if not row: continue db.update("voter", where="voterid=$epic_no", vars=row, serial_number=row.get('slno_inpart'), name=row.get('name'), name2=row.get('name_v1'), rel_name=row.get('rln_name'), rel_name2=row.get('rln_name_v1'), gender=row.get('gender'), age=row.get('age'), address=row.get('house_no'))
def load_voterinfo(booth_id): logging.info("loading voterinfo for booth id %s", booth_id) booth = db.select("booth", where="id=$booth_id", vars=locals())[0] search = voterlib.get_voter_search(booth.state) result = db.select("voter", what="voterid", where="name is NULL and booth_id=$booth_id", vars=locals()).list() data = (search.get_voter_info(row.voterid) for row in result) for row in data: if not row: continue db.update( "voter", where="voterid=$epic_no", vars=row, serial_number=row.get("slno_inpart"), name=row.get("name"), name2=row.get("name_v1"), rel_name=row.get("rln_name"), rel_name2=row.get("rln_name_v1"), gender=row.get("gender"), age=row.get("age"), address=row.get("house_no"), )
def GET(self, state=None, ac=None, pb=None): i = web.input(offset=0, limit=100) where = self.construct_where(state=state, ac=ac, pb=pb) # ensure voter info is loaded # self.POST(state=state, ac=ac, pb=pb) offset = int(i.offset) limit = int(i.limit) where += " AND voter.booth_id = booth.id" what = "state, ac, pb, voterid, name, address, serial_number as serial, age, gender, rel_name" order = "state, ac, pb, serial" result = db.select("voter, booth", what=what, where=where, order=order, offset=offset, limit=limit).list() web.header("content-type", "application/json") return json.dumps(result)
def POST(self, state=None, ac=None, pb=None): where = self.construct_where(state=state, ac=ac, pb=pb) + " AND name is NULL" result = db.select("voter, booth", what="voterid", where=where, limit=100).list() data = [voterlib.get_voter_info(row.voterid) for row in result] with db.transaction(): for row in data: print row db.update( "voter", where="voterid=$epic_no", vars=row, serial_number=row["slno_inpart"], name=row["name"], name2=row["name_v1"], rel_name=row["rln_name"], rel_name2=row["rln_name_v1"], gender=row["gender"], age=row["age"], address=row["house_no"], )
def GET(self, state=None, ac=None, pb=None): i = web.input(offset=0, limit=100) where = self.construct_where(state=state, ac=ac, pb=pb) # ensure voter info is loaded #self.POST(state=state, ac=ac, pb=pb) offset = int(i.offset) limit = int(i.limit) where += " AND voter.booth_id = booth.id" what = "state, ac, pb, voterid, name, address, serial_number as serial, age, gender, rel_name" order = "state, ac, pb, serial" result = db.select("voter, booth", what=what, where=where, order=order, offset=offset, limit=limit).list() web.header("content-type", "application/json") return json.dumps(result)
def POST(self, state=None, ac=None, pb=None): where = self.construct_where(state=state, ac=ac, pb=pb) + " AND name is NULL" result = db.select("voter, booth", what="voterid", where=where, limit=100).list() data = [voterlib.get_voter_info(row.voterid) for row in result] with db.transaction(): for row in data: print row db.update("voter", where="voterid=$epic_no", vars=row, serial_number=row['slno_inpart'], name=row['name'], name2=row['name_v1'], rel_name=row['rln_name'], rel_name2=row['rln_name_v1'], gender=row['gender'], age=row['age'], address=row['house_no'])