def post(self): parser = reqparse.RequestParser() parser.add_argument('name', location='form', required=True) parser.add_argument('bank_account_name', location='form', required=True) parser.add_argument('bank_account_number', location='form', required=True) parser.add_argument('bank_account_detail', location='form', required=True) parser.add_argument('picture', type=werkzeug.datastructures.FileStorage, location='files') data = parser.parse_args() img_picture = data['picture'] upload_image = UploadToFirebase() link_picture = upload_image.UploadImage(img_picture, 'category_picture') payment_method = PaymentMethods(data['name'], data['bank_account_name'], data['bank_account_number'], data['bank_account_detail'], link_picture) db.session.add(payment_method) db.session.commit() app.logger.debug('DEBUG : %s', payment_method) return marshal(payment_method, PaymentMethods.response_field), 200, { 'Content-Type': 'application/json' }
def patch(self, id): parser = reqparse.RequestParser() parser.add_argument('name', location='form') parser.add_argument('icon', type=werkzeug.datastructures.FileStorage, location='files') data = parser.parse_args() qry = ProductTypes.query.get(id) if qry is None: return {'status': 'NOT_FOUND'}, 404 if data['name'] is not None and data["name"] != "": qry.name = data['name'] else: qry.name = qry.name img_icon = data['icon'] if img_icon.filename != "": upload_image = UploadToFirebase() link = upload_image.UploadImage(img_icon, 'category_icon') qry.icon = link else: qry.icon = qry.icon qry.updated_at = datetime.now() db.session.commit() return marshal(qry, ProductTypes.response_field), 200
def patch(self, id): parser = reqparse.RequestParser() parser.add_argument('name', location='form') parser.add_argument('bank_account_name', location='form') parser.add_argument('bank_account_number', location='form') parser.add_argument('bank_account_detail', location='form') parser.add_argument('picture', type=werkzeug.datastructures.FileStorage, location='files') data = parser.parse_args() qry = PaymentMethods.query.get(id) if qry is None: return {'status': 'NOT_FOUND'}, 404 if data['name'] is not None and data["name"] != "": qry.name = data['name'] else: qry.name = qry.name if data['bank_account_name'] is not None and data[ "bank_account_name"] != "": qry.bank_account_name = data['bank_account_name'] else: qry.bank_account_name = qry.bank_account_name if data['bank_account_number'] is not None and data[ "bank_account_number"] != "": qry.bank_account_number = data['bank_account_number'] else: qry.bank_account_number = qry.bank_account_number if data['bank_account_detail'] is not None and data[ "bank_account_detail"] != "": qry.bank_account_detail = data['bank_account_detail'] else: qry.bank_account_detail = qry.bank_account_detail img_picture = data['picture'] if img_picture.filename != "": upload_image = UploadToFirebase() link = upload_image.UploadImage(img_picture, 'category_picture') qry.picture = link else: qry.picture = qry.picture qry.updated_at = datetime.now() db.session.commit() return marshal(qry, PaymentMethods.response_field), 200
def post(self): parser = reqparse.RequestParser() parser.add_argument('name', location='form', required=True) parser.add_argument('icon', type=werkzeug.datastructures.FileStorage, location='files') data = parser.parse_args() img_icon = data['icon'] upload_image = UploadToFirebase() link = upload_image.UploadImage(img_icon, 'category_icon') product_type = ProductTypes(data['name'], link) db.session.add(product_type) db.session.commit() app.logger.debug('DEBUG : %s', product_type) return marshal(product_type, ProductTypes.response_field), 200, { 'Content-Type': 'application/json' }
def post(self): parser = reqparse.RequestParser() parser.add_argument('ads_spot_id', location='form', required=True) parser.add_argument('name', location='files', type=werkzeug.datastructures.FileStorage, required=True) parser.add_argument('description', location='form', required=True) data = parser.parse_args() img_icon = data['name'] upload_image = UploadToFirebase() link = upload_image.UploadImage(img_icon, 'ads_spot') ads_image = AdsImages(data["ads_spot_id"], link, data["description"]) db.session.add(ads_image) db.session.commit() app.logger.debug('DEBUG : %s', ads_image) return marshal(ads_image, AdsImages.response_field), 200, { 'Content-Type': 'application/json' }
def patch(self): parser = reqparse.RequestParser() parser.add_argument('name', location='form') parser.add_argument('phone', location='form') parser.add_argument('email', location='form') parser.add_argument('address', location='form') parser.add_argument('profil_pict', type=werkzeug.datastructures.FileStorage, location='files') parser.add_argument('KTP_number', location='form') parser.add_argument('KTP_pict', type=werkzeug.datastructures.FileStorage, location='files') args = parser.parse_args() claims = get_jwt_claims() qry = Users.query.get(claims['id']) if qry is None: return {'status': 'NOT_FOUND'}, 404 if args['name'] is not None and args["name"] != "": qry.name = args['name'] else: qry.name = qry.name if args['phone'] is not None and args["phone"] != "": qry.phone = args['phone'] else: qry.phone = qry.phone if args['email'] is not None and args["email"] != "": qry.email = args['email'] else: qry.email = qry.email if args['address'] is not None and args["address"] != "": qry.address = args['address'] else: qry.address = qry.address img_profil = args['profil_pict'] if img_profil.filename != "": upload_image = UploadToFirebase() link = upload_image.UploadImage(img_profil, 'user_profil_pict') qry.profil_pict = link else: qry.profil_pict = qry.profil_pict if args['KTP_number'] is not None and args["KTP_number"] != "": qry.KTP_number = args['KTP_number'] else: qry.KTP_number = qry.KTP_number img_ktp = args['KTP_pict'] if img_ktp.filename != "": upload_image = UploadToFirebase() link = upload_image.UploadImage(img_ktp, 'user_KTP_pict') qry.KTP_pict = link else: qry.KTP_pict = qry.KTP_pict qry.updated_at = datetime.now() db.session.commit() return marshal(qry, Users.response_fields), 200
def patch(self): parser = reqparse.RequestParser() parser.add_argument('publisher_name', location='form') parser.add_argument('address', location='form') parser.add_argument('publisher_pict', location='files', type=werkzeug.datastructures.FileStorage) parser.add_argument('company_sertificate', location='files', type=werkzeug.datastructures.FileStorage) parser.add_argument('npwp_number', location='form') parser.add_argument('npwp_pict', location='files', type=werkzeug.datastructures.FileStorage) parser.add_argument('bank_account_name', location='form') parser.add_argument('bank_account_number', location='form') parser.add_argument('bank_account_detail', location='form') args = parser.parse_args() claims = get_jwt_claims() qry = Publishers.query.filter_by(user_id=claims['id']).first() if qry is None: return {'status': 'NOT_FOUND'}, 404 if args['publisher_name'] is not None and args["publisher_name"] != "": qry.publisher_name = args['publisher_name'] else: qry.publisher_name = qry.publisher_name if args['address'] is not None and args["address"] != "": qry.address = args['address'] else: qry.address = qry.address publisher_pict = args['publisher_pict'] if publisher_pict.filename != "": upload_image = UploadToFirebase() link_publisher_pict = upload_image.UploadImage( publisher_pict, 'user_publisher_pict') qry.publisher_pict = link_publisher_pict else: qry.publisher_pict = qry.publisher_pict company_sertificate = args['company_sertificate'] if company_sertificate.filename != "": upload_image = UploadToFirebase() link_company_sertificate = upload_image.UploadImage( company_sertificate, 'user_company_sertificate') qry.company_sertificate = link_company_sertificate else: qry.company_sertificate = qry.company_sertificate if args['npwp_number'] is not None and args["npwp_number"] != "": qry.npwp_number = args['npwp_number'] else: qry.npwp_number = qry.npwp_number npwp_pict = args['npwp_pict'] if npwp_pict.filename != "": upload_image = UploadToFirebase() link_npwp_pict = upload_image.UploadImage(npwp_pict, 'user_npwp_pict') qry.npwp_pict = link_npwp_pict else: qry.npwp_pict = qry.npwp_pict if args['bank_account_name'] is not None and args[ "bank_account_name"] != "": qry.bank_account_name = args['bank_account_name'] else: qry.bank_account_name = qry.bank_account_name if args['bank_account_number'] is not None and args[ "bank_account_number"] != "": qry.bank_account_number = args['bank_account_number'] else: qry.bank_account_number = qry.bank_account_number if args['bank_account_detail'] is not None and args[ "bank_account_detail"] != "": qry.bank_account_detail = args['bank_account_detail'] else: qry.bank_account_detail = qry.bank_account_detail qry.updated_at = datetime.now() db.session.commit() return marshal(qry, Publishers.response_fields), 200
def post(self): parser = reqparse.RequestParser() parser.add_argument('publisher_name', location='form', required=True) parser.add_argument('address', location='form', required=True) parser.add_argument('publisher_pict', location='files', type=werkzeug.datastructures.FileStorage, required=True) parser.add_argument('company_sertificate', location='files', type=werkzeug.datastructures.FileStorage, required=True) parser.add_argument('npwp_number', location='form', required=True) parser.add_argument('npwp_pict', location='files', type=werkzeug.datastructures.FileStorage, required=True) parser.add_argument('bank_account_name', location='form', required=True) parser.add_argument('bank_account_number', location='form', required=True) parser.add_argument('bank_account_detail', location='form', required=True) data = parser.parse_args() claims = get_jwt_claims() user_id = claims['id'] qry = Publishers.query.filter_by(user_id=user_id).first() if qry is not None: return {"Status": "You are already a publisher"}, 404 publisher_pict = data['publisher_pict'] company_sertificate = data['company_sertificate'] npwp_pict = data['npwp_pict'] upload_image = UploadToFirebase() link_publisher_pict = upload_image.UploadImage(publisher_pict, 'user_publisher_pict') link_company_sertificate = upload_image.UploadImage( company_sertificate, 'user_company_sertificate') link_npwp_pict = upload_image.UploadImage(npwp_pict, 'user_npwp_pict') publisher = Publishers(claims["id"], data['publisher_name'], data['address'], link_publisher_pict, link_company_sertificate, data['npwp_number'], link_npwp_pict, data['bank_account_name'], data['bank_account_number'], data['bank_account_detail']) db.session.add(publisher) db.session.commit() app.logger.debug('DEBUG : %s', publisher) return marshal(publisher, Publishers.response_fields), 200, { 'Content-Type': 'application/json' }