Compare commits
No commits in common. "5703458586198c178f5b5f6561ccb3ca04bba8c7" and "4899bfedc21b23fdd9bc36be2b50cc3548ae9a42" have entirely different histories.
5703458586
...
4899bfedc2
@ -1,4 +1,5 @@
|
||||
from flask import Flask
|
||||
from flask_cors import CORS
|
||||
from flask_mail import Mail
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
|
||||
@ -19,4 +20,12 @@ def create_app(cfg=config):
|
||||
|
||||
app.register_blueprint(bp_api)
|
||||
|
||||
CORS(
|
||||
app,
|
||||
resources={r'/api/*': {
|
||||
'methods': ['POST', 'OPTIONS'],
|
||||
'allow_origins': app.config['CORS_ALLOWED_ORIGINS'].split(','),
|
||||
'allow_headers': app.config['CORS_ALLOWED_HEADERS'].split(','),
|
||||
}})
|
||||
|
||||
return app
|
||||
|
@ -8,13 +8,6 @@ from app.api import bp
|
||||
from app import mail
|
||||
|
||||
|
||||
@bp.after_request
|
||||
def after(response):
|
||||
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||
response.headers["Access-Control-Allow-Headers"] = "*"
|
||||
return response
|
||||
|
||||
|
||||
@bp.route("/rfq", methods=["POST"])
|
||||
def send_rfq():
|
||||
payload = request.json
|
||||
@ -32,36 +25,16 @@ def send_rfq():
|
||||
resp = jsonify(error="missing body")
|
||||
return make_response(resp, 400)
|
||||
|
||||
if "configuration" not in payload:
|
||||
resp = jsonify(error="missing configuration")
|
||||
return make_response(resp, 400)
|
||||
|
||||
recipient = current_app.config["MAIL_RECIPIENT"]
|
||||
|
||||
msg = Message(
|
||||
"[ORDER HARDWARE - RFQ from %s]" % payload['email'],
|
||||
reply_to=recipient,
|
||||
sender=payload["email"],
|
||||
recipients=[recipient])
|
||||
|
||||
msg.body = payload["body"]
|
||||
msg.html = payload["body"]
|
||||
|
||||
msg_client_confirmation = Message(
|
||||
"[M-Labs - Order Hardware]",
|
||||
reply_to=recipient,
|
||||
sender=recipient,
|
||||
recipients=[payload["email"]])
|
||||
msg_client_confirmation.body = "Hello! We've received your request and " \
|
||||
"will be in contact soon. " \
|
||||
"Here is a reminder of your configuration: {}" \
|
||||
"Thank you!".format(payload["configuration"])
|
||||
msg_client_confirmation.html = "Hello!<br />" \
|
||||
"We've received your request and will be in contact soon.<br />" \
|
||||
"Here is a reminder of your configuration: {}<br /><br />" \
|
||||
"Thank you!".format(payload["configuration"])
|
||||
|
||||
with mail.connect() as conn:
|
||||
conn.send(msg)
|
||||
conn.send(msg_client_confirmation)
|
||||
mail.send(msg)
|
||||
|
||||
return jsonify("ok")
|
||||
|
@ -16,3 +16,6 @@ MAIL_USERNAME = getenv("FLASK_MAIL_USERNAME")
|
||||
MAIL_PASSWORD = getenv("FLASK_MAIL_PASSWORD")
|
||||
|
||||
MAIL_RECIPIENT = getenv("FLASK_MAIL_RECIPIENT")
|
||||
|
||||
CORS_ALLOWED_ORIGINS = getenv("FLASK_CORS_ORIGINS")
|
||||
CORS_ALLOWED_HEADERS = getenv("FLASK_CORS_ALLOW_HEADERS")
|
||||
|
@ -1,6 +1,7 @@
|
||||
blinker==1.4
|
||||
click==7.1.1
|
||||
Flask==1.1.2
|
||||
Flask-Cors==3.0.7
|
||||
Flask-Mail==0.9.1
|
||||
itsdangerous==1.1.0
|
||||
Jinja2==2.11.1
|
||||
|
@ -1220,7 +1220,9 @@ class OrderForm extends React.PureComponent {
|
||||
value="Show configurations"
|
||||
onClick={onClickShow} />
|
||||
|
||||
<input className="btn btn-primary w-100 m-0 ml-sm-2" type="submit" value={`${isProcessing ? 'Processing ...' : 'Request quote'}`} />
|
||||
<input className="btn btn-primary w-100 m-0 ml-sm-2" style={Object.assign({}, isProcessingComplete ? {
|
||||
'backgroundColor': 'gray',
|
||||
} : {})} disabled={isProcessingComplete} type="submit" value={`${isProcessing ? 'Processing ...' : 'Request quote'}`} />
|
||||
</div>
|
||||
{/*This will open an email window. Send the email to make your request.*/}
|
||||
</form>
|
||||
@ -1860,7 +1862,6 @@ class Shop extends React.PureComponent {
|
||||
axios.post(data.API_RFQ, {
|
||||
email,
|
||||
body,
|
||||
configuration: JSON.stringify(crate),
|
||||
headers: {'X-MLABS-OH': 'rlebcleu'}
|
||||
}).then(response => {
|
||||
this.setState({
|
||||
|
5
static/js/shop.min.js
vendored
5
static/js/shop.min.js
vendored
@ -1274,6 +1274,10 @@ function (_React$PureComponent9) {
|
||||
onClick: onClickShow
|
||||
}), React.createElement("input", {
|
||||
className: "btn btn-primary w-100 m-0 ml-sm-2",
|
||||
style: Object.assign({}, isProcessingComplete ? {
|
||||
'backgroundColor': 'gray'
|
||||
} : {}),
|
||||
disabled: isProcessingComplete,
|
||||
type: "submit",
|
||||
value: "".concat(isProcessing ? 'Processing ...' : 'Request quote')
|
||||
}))));
|
||||
@ -1895,7 +1899,6 @@ function (_React$PureComponent12) {
|
||||
axios.post(data.API_RFQ, {
|
||||
email: email,
|
||||
body: body,
|
||||
configuration: JSON.stringify(crate),
|
||||
headers: {
|
||||
'X-MLABS-OH': 'rlebcleu'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user