def post(self): data = request.get_json() vendor = VendorModule(email=data["email"]) if vendor.find_by_email(): vendor.update_vendor_info(data), 200 else: return 400
def get(self): pic_list = [] role = get_jwt_claims()['role'] if role != 'user': vendor = VendorModule(id=get_jwt_identity()) creator_name = vendor.find_by_id()['username'] picObj = PictureModule(creator_name=creator_name) pics = list(picObj.find_by_creator_name()) for pic in pics: pic_list.append(pic) return make_response(json_util.dumps(pic_list, ensure_ascii=False).encode('utf8'), 200) else: return {"msg": "Forbidden"}, 403
def post(self): account_list = [] status = request.get_json()["status"] accounts = VendorModule.filter_by_status(status) for account in accounts: account_list.append(account) return make_response(json_util.dumps(account_list, ensure_ascii=False).encode('utf8'), 200)
def post(self): claims = get_jwt_claims() if claims['role'] != 'user': data = picture_schema.load(request.get_json()) creator_id = get_jwt_identity() creator = VendorModule(id=creator_id).find_by_id() pic = PictureModule(creator_name=creator["username"], **data) pic.id = pic.get_maxium_pics trigger_data = { "id": pic.id, "title": pic.title, "creator_name": pic.creator_name, "status": pic.status, "price": pic.price, "category": pic.category, "admin_confirmation": pic.admin_confirmation, "created_at": pic.created_at, "artist": pic.artist } response_pic = picture_schema.dump(pic) pic_creation = pic.save_pic_to_db(response_pic, trigger_data) else: return {"msg": "Forbidden"}, 403
def post(self): data = vendor_schema.load(request.get_json()) vendor = VendorModule(**data) if (vendor.find_by_username()): return {"msg": "TÊN ĐĂNG NHẬP ĐÃ TỒN TẠI"}, 400 if (vendor.find_by_email()): return {"msg": "EMAIL ĐÃ TỒN TẠI"}, 400 token = generate_confirmation_token(vendor.email) confirm_url = url_for('userregister', token=token, _external=True) email_confirmation = q.enqueue(Mail.send_mail_confirmation_to_user, args=( vendor.email, confirm_url,), result_ttl=0) vendor.id = vendor.find_maxium_user() vendor.password = vendor.hash_password trigger_data = { "id": vendor.id, "username": vendor.username, "email": vendor.email, "tel": vendor.tel, "role": vendor.role, "status": vendor.status, } email_confirmation = q.enqueue(vendor.save_to_database, args=( vendor_schema.dump(vendor), trigger_data,), result_ttl=0) return {"msg": "XÁC THỰC EMAIL ĐỂ KÍCH HOẠT TÀI KHOẢN"}, 201
def post(self): data = vendor_schema.load(request.get_json()) vendor = VendorModule(**data) current_vendor = vendor.find_by_email() if current_vendor and vendor.verify_password(): if current_vendor["status"] != "pending approval" and current_vendor["role"] == 'artist' or current_vendor["role"] == 'collector': accessToken = access_token( current_vendor["id"], True) refreshToken = refresh_token( current_vendor["id"]) return { "access_token": accessToken, "refresh_token": refreshToken }, 200 return {'msg': 'Opps, BẠN KHÔNG THỂ ĐĂNG NHẬP'}, 401 return {'msg': 'TÀI KHOẢN/MẬT KHẨU KHÔNG ĐÚNG'}, 401
def put(self): claims = get_jwt_claims() creator_id = get_jwt_identity() if claims["role"] != 'user': data = picture_schema.load(request.get_json()) creator = VendorModule(id=creator_id).find_by_id() picture = PictureModule(**data) picture.creator_name = creator['username'] pic_resource = picture.find_by_id() if picture.imageURL == '': picture.imageURL = pic_resource['imageURL'] result = picture_schema.dump(picture) picture.update_picture_to_db(result, creator['role']) return {"msg": "Updated successfully"}, 200 else: return {"msg": "Forbidden"}, 403
def get(self, _id): vendor = VendorModule(id=_id) response = vendor.find_by_id() return make_response(json_util.dumps(response), 200)
def get(self): data = VendorModule.get_vendor_information() return make_response(json_util.dumps(data, ensure_ascii=False).encode('utf8'), 200)
def post(self): user = VendorModule(**request.get_json()) current_user = user.vendor_approval()
def get(self): account_num = VendorModule.get_pending_approval() return make_response(json_util.dumps(account_num), 200)
def get(self): account_list = [] accounts = list(VendorModule.find_all_account()) for account in accounts: account_list.append(account) return make_response(json_util.dumps(account_list, ensure_ascii=False).encode('utf8'), 200)