def post(self): res = datalayer.get_all('desks') data.desks = [] for row in res: data.desks.append(row['desk']) response = {'status': 'ok', 'desks': data.desks} self.write(json_encode(response))
def post(self): cid = json_decode(self.get_argument('cid')) con = {'cid': int(cid)} res = datalayer.delete('category', con) if res: response = {'status': 'ok'} data.category = datalayer.get_all('category') else: response = {'status': 'err'} self.finish(json_encode(response))
def post(self): fid = json_decode(self.get_argument('fid')) name = json_decode(self.get_argument('name')) role = json_decode(self.get_argument('role')) password = json_decode(self.get_argument('passwd')) datalayer.insert('faculty', { 'fid': fid, 'name': name, 'role': role, 'password': password }) data.faculty = datalayer.get_all('faculty') response = {'status': 'ok'} self.finish(json_encode(response))
def post(self): desk = json_decode(self.get_argument('desk')) desk = desk.upper() res = datalayer.get_all('desks') data.desks = [] for row in res: data.desks.append(row['desk']) if desk in data.desks: path = os.path.dirname(__file__) + '/static/desks/' + desk + '.png' os.remove(path) data.desks.remove(desk) datalayer.delete('desks', {'desk': desk}) response = {'status': 'ok'} self.write(json_encode(response))
def post(self): desk = json_decode(self.get_argument('desk')) desk = desk.upper() res = datalayer.insert('desks', {'desk': desk}) if res: path = os.path.dirname(__file__) + '/static/desks/' + desk + '.png' img = qrcode.make(desk) img.save(path) res = datalayer.get_all('desks') data.desks = [] for row in res: data.desks.append(row['desk']) response = {'status': 'ok'} self.write(json_encode(response))
def post(self): did = int(json_decode(self.get_argument('did'))) res = datalayer.get('diet', {'did': did}) print res if res and res[0]: picture = res[0]['picture'] full_path = os.path.join(os.path.dirname(__file__), 'static/pictures/' + picture) os.remove(full_path) datalayer.delete('diet', {'did': did}) data.diet = datalayer.get_all('diet') response = {'status': 'ok'} self.finish(json_encode(response)) return response = {'status': 'err'} self.finish(json_encode(response))
def post(self): cid = json_decode(self.get_argument('cid')) name = json_decode(self.get_argument('name')) order = json_decode(self.get_argument('order')) desc = json_decode(self.get_argument('desc')) row = { 'cid': int(cid), 'name': name, 'ord': int(order), 'description': desc } res = datalayer.insert('category', row) data.category = datalayer.get_all('category') if res: response = {'status': 'ok'} else: response = {'status': 'err'} self.finish(json_encode(response))
def post(self): #attention to variable type did = int(self.get_argument('did')) name = str(self.get_argument('name')) price = float(self.get_argument('price')) base = float(self.get_argument('base')) cid = int(self.get_argument('cid')) order = int(self.get_argument('order')) desc = str(self.get_argument('desc')) picture = '' if self.request.files: metas = self.request.files['picture'] for meta in metas: file_name = meta['filename'] content = meta['body'] ext = os.path.splitext(file_name)[-1] picture = str(uuid.uuid4()) + ext full_path = os.path.join(os.path.dirname(__file__), 'static/pictures/' + picture) with open(full_path, 'wb') as f: f.write(content) # store into database res = datalayer.insert( 'diet', { 'did': did, 'name': name, 'price': price, 'base': base, 'cid': cid, 'ord': order, 'description': desc, 'picture': picture }) if res is None and picture: os.remove( os.path.join(os.path.dirname(__file__), 'static/pictures/' + picture)) data.diet = datalayer.get_all('diet') response = {'status': 'ok'} self.finish(json_encode(response))
def post(self): data.faculty = datalayer.get_all('faculty') response = {'status': 'ok', 'faculty': data.faculty} self.finish(json_encode(response))
def post(self): fid = json_decode(self.get_argument('fid')) datalayer.delete('faculty', {'fid': fid}) data.faculty = datalayer.get_all('faculty') response = {'status': 'ok'} self.finish(json_encode(response))
def post(self): res = datalayer.get_all('diet') response = {'status': 'ok', 'diet': res} self.finish(json_encode(response))