Fix: Cleanup \n 1. Remove PostgreSQL \n 2. Remove comments from Python \n 3. Remove non-demo ERP Python code \n 4. Remove deprecated Python code
This commit is contained in:
@@ -59,18 +59,15 @@ def contact_post():
|
||||
try:
|
||||
form = Form_Contact()
|
||||
if form.validate_on_submit():
|
||||
# Handle form submission
|
||||
email = form.email.data
|
||||
CC = form.CC.data # not in use
|
||||
# CC = form.CC.data # not in use
|
||||
name = form.name.data
|
||||
message = form.message.data
|
||||
# send email
|
||||
mailItem = Message("PARTS Website Contact Us Message", recipients=[current_app.config['MAIL_CONTACT_PUBLIC']])
|
||||
mailItem.body = f"Dear Lord Edward Middleton-Smith,\n\n{message}\n\nKind regards,\n{name}\n{email}"
|
||||
mail.send(mailItem)
|
||||
return "Submitted."
|
||||
return "Invalid. Failed to submit."
|
||||
# html_body = render_template('pages/core/_contact.html', model = model)
|
||||
except Exception as e:
|
||||
return jsonify(error=str(e)), 403
|
||||
|
||||
@@ -88,7 +85,6 @@ def admin_home():
|
||||
try:
|
||||
model = Model_View_Admin_Home()
|
||||
if not model.is_user_logged_in:
|
||||
# return redirect(url_for('routes_user.login', callback = Model_View_Admin_Home.HASH_PAGE_ADMIN_HOME))
|
||||
return redirect(url_for('routes_core.home'))
|
||||
if not (model.user.can_admin_store or model.user.can_admin_user):
|
||||
return redirect(url_for('routes_core.home'))
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: App General
|
||||
Feature: App
|
||||
|
||||
Description:
|
||||
Initializes the Flask application, sets the configuration based on the environment, and defines two routes (/ and /about) that render templates with the specified titles.
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
from helpers.helper_app import Helper_App
|
||||
import os
|
||||
import stripe
|
||||
import json
|
||||
from flask import Flask, render_template, render_template_string, jsonify, request, send_from_directory, redirect
|
||||
from dotenv import load_dotenv, find_dotenv
|
||||
|
||||
|
||||
# VARIABLE INSTANTIATION
|
||||
key_secret = os.environ.get("KEY_SECRET_STRIPE")
|
||||
key_public = os.environ.get("KEY_PUBLIC_STRIPE") # 'pk_test_51OGrxlL7BuLKjoMpfpfw7bSmZZK1MhqMoQ5VhW2jUj7YtoEejO4vqnxKPiqTHHuh9U4qqkywbPCSI9TpFKtr4SYH007KHMWs68'
|
||||
|
||||
# METHODS
|
||||
def create_product_price():
|
||||
Helper_App.console_log(f'stripe.api_key = {stripe.api_key}')
|
||||
starter_subscription = stripe.Product.create(
|
||||
name="Starter Subscription",
|
||||
description="$12/Month subscription",
|
||||
)
|
||||
|
||||
starter_subscription_price = stripe.Price.create(
|
||||
unit_amount=1200,
|
||||
currency="usd",
|
||||
recurring={"interval": "month"},
|
||||
product=starter_subscription['id'],
|
||||
)
|
||||
|
||||
# Save these identifiers
|
||||
Helper_App.console_log(f"Success! Here is your starter subscription product id: {starter_subscription.id}")
|
||||
Helper_App.console_log(f"Success! Here is your starter subscription price id: {starter_subscription_price.id}")
|
||||
|
||||
return starter_subscription_price.id
|
||||
|
||||
def get_file_str(f_address):
|
||||
f = open(f_address)
|
||||
return f.read()
|
||||
|
||||
# Ensure environment variables are set.
|
||||
price = os.getenv('PRICE')
|
||||
if price is None or price == 'price_12345' or price == '':
|
||||
Helper_App.console_log('You must set a Price ID in .env. Please see the README.')
|
||||
exit(0)
|
||||
|
||||
# For sample support and debugging, not required for production:
|
||||
stripe.set_app_info(
|
||||
'stripe-samples/checkout-one-time-payments',
|
||||
version='0.0.1',
|
||||
url='https://github.com/stripe-samples/checkout-one-time-payments')
|
||||
|
||||
# stripe.api_version = '2020-08-27'
|
||||
stripe.api_key = key_secret # os.getenv('KEY_SECRET_STRIPE')
|
||||
|
||||
app_dir = str(os.path.abspath(os.path.join(
|
||||
__file__, "..", "..")))
|
||||
static_dir = str(os.path.abspath(os.path.join(
|
||||
app_dir, os.getenv("STATIC_DIR"))))
|
||||
app = Flask(__name__, static_folder=static_dir,
|
||||
static_url_path="", template_folder=static_dir)
|
||||
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
def get_example():
|
||||
# return render_template(f'{app_dir}\\templates\\_home.html') # f'{app_dir}\\templates\\layout.html')
|
||||
# return render_template_string(get_file_str(f'{app_dir}\\templates\\_home.html')) # f'{app_dir}\\templates\\layout.html')
|
||||
return render_template('../templates/_home.html')
|
||||
|
||||
|
||||
@app.route('/config', methods=['GET'])
|
||||
def get_publishable_key():
|
||||
price = stripe.Price.retrieve(os.getenv('PRICE'))
|
||||
return jsonify({
|
||||
'publicKey': key_public, # os.getenv('KEY_PUBLIC_STRIPE'),
|
||||
'unitAmount': price['unit_amount'],
|
||||
'currency': price['currency']
|
||||
})
|
||||
|
||||
# Fetch the Checkout Session to display the JSON result on the success page
|
||||
@app.route('/checkout-session', methods=['GET'])
|
||||
def get_checkout_session():
|
||||
id = request.args.get('sessionId')
|
||||
checkout_session = stripe.checkout.Session.retrieve(id)
|
||||
return jsonify(checkout_session)
|
||||
|
||||
|
||||
@app.route('/create-checkout-session', methods=['POST'])
|
||||
def create_checkout_session():
|
||||
quantity = request.form.get('quantity', 1)
|
||||
domain_url = os.getenv('DOMAIN')
|
||||
|
||||
try:
|
||||
# Create new Checkout Session for the order
|
||||
# Other optional params include:
|
||||
# [billing_address_collection] - to display billing address details on the page
|
||||
# [customer] - if you have an existing Stripe Customer ID
|
||||
# [payment_intent_data] - lets capture the payment later
|
||||
# [customer_email] - lets you prefill the email input in the form
|
||||
# [automatic_tax] - to automatically calculate sales tax, VAT and GST in the checkout page
|
||||
# For full details see https://stripe.com/docs/api/checkout/sessions/create
|
||||
|
||||
# ?session_id={CHECKOUT_SESSION_ID} means the redirect will have the session ID set as a query param
|
||||
checkout_session = stripe.checkout.Session.create(
|
||||
success_url=domain_url + '/success.html?session_id={CHECKOUT_SESSION_ID}',
|
||||
cancel_url=domain_url + '/canceled.html',
|
||||
mode='payment',
|
||||
# automatic_tax={'enabled': True},
|
||||
line_items=[{
|
||||
'price': os.getenv('PRICE'),
|
||||
'quantity': quantity,
|
||||
}]
|
||||
)
|
||||
return redirect(checkout_session.url, code=303)
|
||||
except Exception as e:
|
||||
return jsonify(error=str(e)), 403
|
||||
|
||||
|
||||
@app.route('/webhook', methods=['POST'])
|
||||
def webhook_received():
|
||||
# You can use webhooks to receive information about asynchronous payment events.
|
||||
# For more about our webhook events check out https://stripe.com/docs/webhooks.
|
||||
webhook_secret = os.getenv('STRIPE_WEBHOOK_SECRET')
|
||||
request_data = json.loads(request.data)
|
||||
|
||||
if webhook_secret:
|
||||
# Retrieve the event by verifying the signature using the raw body and secret if webhook signing is configured.
|
||||
signature = request.headers.get('stripe-signature')
|
||||
try:
|
||||
event = stripe.Webhook.construct_event(
|
||||
payload=request.data, sig_header=signature, secret=webhook_secret)
|
||||
data = event['data']
|
||||
except Exception as e:
|
||||
return e
|
||||
# Get the type of webhook event sent - used to check the status of PaymentIntents.
|
||||
event_type = event['type']
|
||||
else:
|
||||
data = request_data['data']
|
||||
event_type = request_data['type']
|
||||
data_object = data['object']
|
||||
|
||||
Helper_App.console_log('event ' + event_type)
|
||||
|
||||
if event_type == 'checkout.session.completed':
|
||||
Helper_App.console_log('🔔 Payment succeeded!')
|
||||
|
||||
return jsonify({Model_View_Base.FLAG_STATUS: Model_View_Base.FLAG_SUCCESS})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# stripe.api_key = key_secret
|
||||
|
||||
# create_product_price()
|
||||
|
||||
# Setup Stripe python client library.
|
||||
load_dotenv(find_dotenv())
|
||||
app.run(port=4242, debug=True)
|
||||
@@ -39,7 +39,6 @@ def products():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Store_Product(form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
# return redirect(url_for('routes_user.login', data = jsonify({ Model_View_Store_Product.FLAG_CALLBACK: Model_View_Store_Product.HASH_PAGE_STORE_PRODUCTS })))
|
||||
return redirect(url_for('routes_core.home'))
|
||||
return render_template('pages/store/_products.html', model = model)
|
||||
|
||||
@@ -54,7 +53,6 @@ def save_product():
|
||||
Model_View_Store_Product.FLAG_STATUS: Model_View_Store_Product.FLAG_FAILURE,
|
||||
Model_View_Store_Product.FLAG_MESSAGE: f'Filters form invalid.\n{form_filters.errors}'
|
||||
})
|
||||
# filters_form = Filters_Product.from_form(form_filters)
|
||||
Helper_App.console_log(f'form_filters: {form_filters}')
|
||||
|
||||
products = data[Model_View_Store_Product.FLAG_PRODUCT]
|
||||
@@ -66,7 +64,6 @@ def save_product():
|
||||
objsProduct = []
|
||||
for product in products:
|
||||
objsProduct.append(Product.from_json(product))
|
||||
# model_save = Model_View_Store_Product() # filters_product=filters_form)
|
||||
Helper_App.console_log(f'objsProduct={objsProduct}')
|
||||
save_errors = Model_View_Store_Product.save_products(data.get('comment', 'No comment'), objsProduct)
|
||||
|
||||
|
||||
@@ -31,31 +31,14 @@ routes_store_product_category = Blueprint('routes_store_product_category', __nam
|
||||
@routes_store_product_category.route(Model_View_Store_Product_Category.HASH_PAGE_STORE_PRODUCT_CATEGORIES, methods=['GET'])
|
||||
def categories():
|
||||
Helper_App.console_log('categories')
|
||||
# data = Helper_App.get_request_data(request)
|
||||
try:
|
||||
form_filters = Filters_Product_Category.from_json(request.args)
|
||||
except Exception as e:
|
||||
Helper_App.console_log(f'Error: {e}')
|
||||
form_filters = Filters_Product_Category()
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
"""
|
||||
filters = Filters_Product_Category.get_default()
|
||||
have_changed_filters = False
|
||||
arg_filter_is_not_empty = request.args.get(Model_View_Store_Product_Category.FLAG_IS_NOT_EMPTY, None)
|
||||
have_changed_filters = have_changed_filters or arg_filter_is_not_empty is None
|
||||
Helper_App.console_log(f'arg_filter_is_not_empty={arg_filter_is_not_empty}')
|
||||
filters.is_not_empty = filters.is_not_empty if arg_filter_is_not_empty is None else av.input_bool(arg_filter_is_not_empty, 'is_not_empty', 'filter_category')
|
||||
arg_filter_active = request.args.get(Model_View_Store_Product_Category.FLAG_ACTIVE, None)
|
||||
have_changed_filters = have_changed_filters or arg_filter_active is None
|
||||
Helper_App.console_log(f'arg_filter_active={arg_filter_active}')
|
||||
filters.active = filters.active if arg_filter_active is None else av.input_bool(arg_filter_active, 'active', 'filter_category')
|
||||
if have_changed_filters:
|
||||
Helper_App.console_log('redirecting')
|
||||
return redirect(url_for('routes_store_product_category.categories', **filters.to_json()))
|
||||
"""
|
||||
model = Model_View_Store_Product_Category(form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
# return redirect(url_for('routes_user.login', data = jsonify({ Model_View_Store_Product_Category.FLAG_CALLBACK: Model_View_Store_Product_Category.HASH_PAGE_STORE_PRODUCT_CATEGORIES })))
|
||||
return redirect(url_for('routes_core.home'))
|
||||
return render_template('pages/store/_product_categories.html', model = model)
|
||||
|
||||
@@ -69,7 +52,6 @@ def save_category():
|
||||
Model_View_Store_Product_Category.FLAG_STATUS: Model_View_Store_Product_Category.FLAG_FAILURE,
|
||||
Model_View_Store_Product_Category.FLAG_MESSAGE: f'Filters form invalid.\n{form_filters.errors}'
|
||||
})
|
||||
# filters_form = Filters_Product_Category.from_form(form_filters)
|
||||
|
||||
categories = data[Model_View_Store_Product_Category.FLAG_PRODUCT_CATEGORY]
|
||||
if len(categories) == 0:
|
||||
@@ -80,7 +62,6 @@ def save_category():
|
||||
objsCategory = []
|
||||
for category in categories:
|
||||
objsCategory.append(Product_Category.from_json(category))
|
||||
# model_save = Model_View_Store_Product_Category() # filters_product=filters_form)
|
||||
Helper_App.console_log(f'objsCategory={objsCategory}')
|
||||
errors = Model_View_Store_Product_Category.save_categories(data.get('comment', 'No comment'), objsCategory)
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ routes_store_product_permutation = Blueprint('routes_store_product_permutation',
|
||||
def permutations():
|
||||
Helper_App.console_log('permutations')
|
||||
data = request.args
|
||||
# Helper_App.console_log(f'data={data}\nrequest.args={request.args}\nrequest.form={request.form}\nrequest.data={request.data}\nrequest.values={request.values}\nrequest.headers={request.headers}')
|
||||
try:
|
||||
form_filters = Filters_Product_Permutation.from_json(data)
|
||||
except Exception as e:
|
||||
@@ -43,7 +42,6 @@ def permutations():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Store_Product_Permutation(form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
# return redirect(url_for('routes_user.login', data = jsonify({ Model_View_Store_Product_Permutation.FLAG_CALLBACK: Model_View_Store_Product_Permutation.HASH_PAGE_STORE_PRODUCT_PERMUTATIONS })))
|
||||
return redirect(url_for('routes_core.home'))
|
||||
return render_template('pages/store/_product_permutations.html', model = model)
|
||||
|
||||
@@ -58,7 +56,6 @@ def save_permutation():
|
||||
Model_View_Store_Product_Permutation.FLAG_STATUS: Model_View_Store_Product_Permutation.FLAG_FAILURE,
|
||||
Model_View_Store_Product_Permutation.FLAG_MESSAGE: f'Filters form invalid.\n{form_filters.errors}'
|
||||
})
|
||||
# filters_form = Filters_Product_Permutation.from_form(form_filters)
|
||||
Helper_App.console_log(f'form_filters: {form_filters}')
|
||||
|
||||
permutations = data[Model_View_Store_Product_Permutation.FLAG_PRODUCT_PERMUTATION]
|
||||
@@ -70,7 +67,6 @@ def save_permutation():
|
||||
objsPermutation = []
|
||||
for permutation in permutations:
|
||||
objsPermutation.append(Product_Permutation.from_json(permutation))
|
||||
# model_save = Model_View_Store_Product_Permutation() # filters_product=filters_form)
|
||||
Helper_App.console_log(f'objsPermutation={objsPermutation}')
|
||||
Model_View_Store_Product_Permutation.save_permutations(data.get('comment', 'No comment'), objsPermutation)
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ def save_product_variation():
|
||||
Model_View_Store_Product_Variation.FLAG_STATUS: Model_View_Store_Product_Variation.FLAG_FAILURE,
|
||||
Model_View_Store_Product_Variation.FLAG_MESSAGE: f'Filters form invalid.\n{form_filters.errors}'
|
||||
})
|
||||
# filters_form = Filters_Product_Variation.from_form(form_filters)
|
||||
Helper_App.console_log(f'form_filters: {form_filters}')
|
||||
|
||||
product_variation_types = data[Model_View_Store_Product_Variation.FLAG_PRODUCT_VARIATION_TYPE]
|
||||
@@ -67,7 +66,6 @@ def save_product_variation():
|
||||
objs_product_variation_type = []
|
||||
for product_variation_type in product_variation_types:
|
||||
objs_product_variation_type.append(Product_Variation_Type.from_json(product_variation_type))
|
||||
# model_save = Model_View_Store_Product_Variation() # filters_product_variation=filters_form)
|
||||
Helper_App.console_log(f'objs_product_variation_type={objs_product_variation_type}')
|
||||
save_errors = Model_View_Store_Product_Variation.save_product_variations(data.get('comment', 'No comment'), objs_product_variation_type)
|
||||
|
||||
|
||||
@@ -39,8 +39,6 @@ def stock_items():
|
||||
Helper_App.console_log(f'form_filters={form_filters}')
|
||||
model = Model_View_Store_Stock_Item(form_filters)
|
||||
if not model.is_user_logged_in:
|
||||
# return redirect(url_for('routes_user.login', data = jsonify({ Model_View_Store_Stock_Item.FLAG_CALLBACK: Model_View_Store_Stock_Item.HASH_PAGE_STORE_STOCK_ITEMS })))
|
||||
# return requests.post(f"{current_app.config['URL_HOST']}{url_for('routes_user.login')}", json={ Model_View_Store_Stock_Item.FLAG_CALLBACK: Model_View_Store_Stock_Item.HASH_PAGE_STORE_STOCK_ITEMS })
|
||||
return redirect(url_for('routes_core.home'))
|
||||
return render_template('pages/store/_stock_items.html', model = model, datetime = datetime)
|
||||
|
||||
@@ -50,28 +48,6 @@ def save_stock_item():
|
||||
data = Helper_App.get_request_data(request)
|
||||
try:
|
||||
form_filters = Filters_Stock_Item.from_json(data[Model_View_Store_Stock_Item.FLAG_FORM_FILTERS])
|
||||
"""
|
||||
if not form_filters.validate_on_submit():
|
||||
error_keys = list(form_filters.errors.keys())
|
||||
try:
|
||||
error_keys.remove(Stock_Item.ATTR_ID_PRODUCT_CATEGORY)
|
||||
""
|
||||
if not av.val_int(form_filters.id_product_category.data):
|
||||
form_filters.errors[Stock_Item.ATTR_ID_PRODUCT_CATEGORY] = ['Invalid category.']
|
||||
""
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
error_keys.remove(Stock_Item.ATTR_ID_PRODUCT)
|
||||
except:
|
||||
pass
|
||||
if error_keys:
|
||||
return jsonify({
|
||||
Model_View_Store_Stock_Item.FLAG_STATUS: Model_View_Store_Stock_Item.FLAG_FAILURE,
|
||||
Model_View_Store_Stock_Item.FLAG_MESSAGE: f'Form invalid.\n{form_filters.errors}'
|
||||
})
|
||||
"""
|
||||
# filters_form = Filters_Stock_Item.from_form(form_filters)
|
||||
Helper_App.console_log(f'form_filters: {form_filters}')
|
||||
|
||||
stock_items = data[Model_View_Store_Stock_Item.FLAG_STOCK_ITEM]
|
||||
@@ -84,7 +60,6 @@ def save_stock_item():
|
||||
objs_stock_item = []
|
||||
for stock_item in stock_items:
|
||||
objs_stock_item.append(Stock_Item.from_json(stock_item))
|
||||
# model_save = Model_View_Store_Stock_Item() # filters_product=filters_form)
|
||||
Helper_App.console_log(f'objs_stock_item={objs_stock_item}')
|
||||
save_errors = Model_View_Store_Stock_Item.save_stock_items(data.get('comment', 'No comment'), objs_stock_item)
|
||||
if len(save_errors) > 0:
|
||||
|
||||
@@ -116,7 +116,7 @@ def login():
|
||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||
|
||||
|
||||
@routes_user.route("/login_callback") # <path:subpath>/<code>
|
||||
@routes_user.route("/login_callback")
|
||||
@handle_db_disconnect
|
||||
def login_callback():
|
||||
Helper_App.console_log('login_callback')
|
||||
@@ -128,25 +128,13 @@ def login_callback():
|
||||
error_text = f'Error: {error_state}: {error_description}'
|
||||
Helper_App.console_log(error_text)
|
||||
return login()
|
||||
# Helper_App.console_log(f'code: {code}')
|
||||
token = None
|
||||
try:
|
||||
token = oauth.auth0.authorize_access_token()
|
||||
except Exception as e:
|
||||
# Log the error for debugging
|
||||
Helper_App.console_log(f"Error: {str(e)}")
|
||||
session[current_app.config['ID_TOKEN_USER']] = token
|
||||
# import user id
|
||||
"""
|
||||
Helper_App.console_log(f'str(type(token)) = {str(type(token))}')
|
||||
Helper_App.console_log(f'token = {token}')
|
||||
userinfo = token.get('userinfo')
|
||||
Helper_App.console_log(f'user info: {userinfo}')
|
||||
# id_user = token.get('sub')
|
||||
id_user = userinfo.get('sub')
|
||||
Helper_App.console_log(f'user ID: {id_user}')
|
||||
"""
|
||||
user = User.from_json_auth0(token) # datastore_user.get_user_auth0()
|
||||
user = User.from_json_auth0(token)
|
||||
Helper_App.console_log(f'user: {user}')
|
||||
filters = Parameters_User.from_user(user)
|
||||
datastore_user = DataStore_User()
|
||||
@@ -168,13 +156,10 @@ def login_callback():
|
||||
Helper_App.console_log('hash is none')
|
||||
state = request.args.get('state')
|
||||
Helper_App.console_log(f'state: {state}')
|
||||
hash_callback = state # .get('hash_callback')
|
||||
hash_callback = state
|
||||
Helper_App.console_log(f'hash_callback: {hash_callback}')
|
||||
except:
|
||||
Helper_App.console_log("get hash callback failed")
|
||||
# id_user = get_id_user()
|
||||
# add user to database
|
||||
# DataStore_Store().add_new_user(id_user) # this is part of get basket - should occur on page load
|
||||
|
||||
Helper_App.console_log(f'user session: {session[Model_View_Base.FLAG_USER]}')
|
||||
return redirect(f"{current_app.config['URL_HOST']}{hash_callback}")
|
||||
@@ -188,38 +173,15 @@ def logout():
|
||||
{
|
||||
"returnTo": url_for("routes_user.logout_callback", _external=True),
|
||||
"client_id": current_app.config['ID_AUTH0_CLIENT'],
|
||||
}# ,
|
||||
# quote_via=quote_plus,
|
||||
}
|
||||
)
|
||||
Helper_App.console_log(f"Redirecting to {url_logout}")
|
||||
return redirect(url_logout)
|
||||
|
||||
@routes_user.route("/logout_callback") # <path:subpath>/<code>
|
||||
@routes_user.route("/logout_callback")
|
||||
@handle_db_disconnect
|
||||
def logout_callback():
|
||||
return redirect(url_for('routes_core.home'))
|
||||
try:
|
||||
session[current_app.ID_TOKEN_USER] = None
|
||||
user = User()
|
||||
try:
|
||||
hash_callback = token.get('hash_callback')
|
||||
if hash_callback is None:
|
||||
Helper_App.console_log('hash is none')
|
||||
state = request.args.get('state')
|
||||
Helper_App.console_log(f'state: {state}')
|
||||
hash_callback = state # .get('hash_callback')
|
||||
Helper_App.console_log(f'hash_callback: {hash_callback}')
|
||||
except:
|
||||
Helper_App.console_log("get hash callback failed")
|
||||
# id_user = get_id_user()
|
||||
# add user to database
|
||||
# DataStore_Store().add_new_user(id_user) # this is part of get basket - should occur on page load
|
||||
|
||||
Helper_App.console_log(f'user session: {session[Model_View_Base.FLAG_USER]}')
|
||||
return redirect(f'{current_app.URL_HOST}{hash_callback}')
|
||||
except Exception as e:
|
||||
return jsonify({Model_View_Base.FLAG_STATUS: Model_View_Base.FLAG_FAILURE, Model_View_Base.FLAG_MESSAGE: f'Controller error.\n{e}'})
|
||||
|
||||
|
||||
@routes_user.route("/user")
|
||||
def user():
|
||||
@@ -235,7 +197,6 @@ def user():
|
||||
break
|
||||
model.users = [model.user]
|
||||
if not model.is_user_logged_in:
|
||||
# return redirect(url_for('routes_user.login', data = jsonify({ Model_View_User.FLAG_CALLBACK: Model_View_User.HASH_PAGE_USER_ACCOUNT })))
|
||||
return redirect(url_for('routes_core.home'))
|
||||
html_body = render_template('pages/user/_user.html', model = model)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user