def maintain_user(): dao = BaseDao() error = None if request.method == 'POST': id = request.form['user_id'] username = request.form['username'] password = request.form['password'] usergroup = request.form['usergroup'] isUpdate = False sql = None if id =='': last_id_result = dao.excute_query(query_sql.QUERY_FIND_LAST_USER_ID) id = last_id_result[0]['id'] +1 sql = insert_update_sql.UPSERT_USER else: isUpdate = True sql = insert_update_sql.UPDATE_USER params = {'id':id, 'username':username, 'password':password, 'usergroup':usergroup} result = dao.excute_upsert(sql, params) return str(result.rowcount) else: user_id = request.args.get('id') user = None if user_id is not None: user = dao.excute_query( query_sql.QUERY_FIND_USER_BY_ID, {'id': user_id} )[0] return render_template('admin/user.html', user=user)
def maintain_property(): dao = BaseDao() error = None trans_types = property.list_trans_type() property_owners = property.find_property_owner() district_list = find_district() estate_list = find_estate() if request.method == 'POST': id = request.form['property_id'] if id =='': last_id_result = dao.excute_query(query_sql.QUERY_FIND_LAST_PROPERTY) id = last_id_result[0]['id'] +1 district = request.form['district'] estate = request.form['estate'] block = request.form['block'] floor = request.form['floor'] flat = request.form['flat'] area = request.form['area'] bedrooms = request.form['bedrooms'] hascarpark = request.form['hascarpark'] selling_price = request.form['selling_price'] rental_price = request.form['rental_price'] trans_type = request.form['type'] owner = request.form['owner'] if selling_price is None or selling_price == '': selling_price = 0 if rental_price is None or rental_price == '': rental_price = 0 params = {'id':id, 'district_id':district, 'estate_id':estate, 'block':block, 'floor':floor, 'flat':flat, 'gross_floor_area':area, 'number_of_bedrooms':bedrooms, 'provide_car_park':hascarpark, 'selling_price':selling_price, 'rental_price':rental_price, 'trans_type':trans_type, 'owner_id':owner} result = dao.excute_upsert(insert_update_sql.UPSERT_PROPERTY, params) return str(result.rowcount) else: property_id = request.args.get('id') property_result = None if property_id is not None: property_result = dao.excute_query( query_sql.QUERY_FIND_PROPERTY_BY_ID, {'id': property_id} )[0] return render_template('admin/property.html', property=property_result, trans_types=trans_types, districts=district_list, estates=estate_list, property_owners=property_owners)
def delete_user(): dao = BaseDao() id = request.form['id'] params = {'id':id} result = dao.excute_upsert(insert_update_sql.DELETE_HKPUSER, params) return str(result.rowcount)
def delete_property(): dao = BaseDao() id = request.form['id'] params = {'id': id} result = dao.excute_upsert(insert_update_sql.DELETE_PROPERTY, params) return str(result.rowcount)