Feat: Contact Form MySQL database created and hooked up to web app on form submission. \n Fix: Removal of ERP and otherwise deprecated database and server code..

This commit is contained in:
2025-03-21 11:12:03 +00:00
parent 63776954e1
commit 4f5037b504
477 changed files with 4298 additions and 102117 deletions

View File

View File

@@ -4,16 +4,17 @@ Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: App Routing
Feature: Core Routes
Feature: Core - Contact Routes
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.
Contact Page Controller.
"""
# IMPORTS
# internal
from business_objects.api import API
from datastores.datastore_base import DataStore_Base
from business_objects.project_hub.contact_form import Contact_Form
from parts_website.datastores.project_hub.datastore_contact_form import DataStore_Contact_Form
from forms.contact import Form_Contact
from helpers.helper_app import Helper_App
from models.model_view_contact import Model_View_Contact
@@ -35,19 +36,10 @@ import hashlib
import datetime
from altcha import ChallengeOptions, create_challenge, verify_solution
routes_core = Blueprint('routes_core', __name__)
routes_core_contact = Blueprint('routes_core_contact', __name__)
@routes_core.route(Model_View_Home.HASH_PAGE_HOME, methods=['GET'])
def home():
try:
model = Model_View_Home()
html_body = render_template('pages/core/_home.html', model = model)
except Exception as e:
return jsonify(error=str(e)), 403
return html_body
@routes_core.route(Model_View_Contact.HASH_PAGE_CONTACT, methods=['GET'])
@routes_core_contact.route(Model_View_Contact.HASH_PAGE_CONTACT, methods=['GET'])
def contact():
try:
form = Form_Contact()
@@ -64,7 +56,7 @@ def contact():
meta = None
)
@routes_core.route(Model_View_Contact.HASH_GET_ALTCHA_CHALLENGE, methods=['GET'])
@routes_core_contact.route(Model_View_Contact.HASH_GET_ALTCHA_CHALLENGE, methods=['GET'])
def create_altcha_challenge():
options = ChallengeOptions(
expires = datetime.datetime.now() + datetime.timedelta(hours=1),
@@ -81,7 +73,7 @@ def create_altcha_challenge():
"signature": challenge.signature,
})
@routes_core.route(Model_View_Contact.HASH_PAGE_CONTACT, methods=['POST'])
@routes_core_contact.route(Model_View_Contact.HASH_PAGE_CONTACT, methods=['POST'])
def contact_post():
try:
form = Form_Contact()
@@ -98,6 +90,13 @@ def contact_post():
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{receive_marketing_text}\nKind regards,\n{contact_name}\n{company_name}\n{email}"
mail.send(mailItem)
# save to database
datastore = DataStore_Contact_Form()
contact_form = Contact_Form.from_json(form.to_json())
datastore.save_contact_forms(
comment = contact_form.message
, contact_forms = [contact_form]
)
return redirect(url_for(Model_View_Contact.ENDPOINT_PAGE_CONTACT_SUCCESS))
except Exception as e:
return API.get_standard_response(
@@ -127,7 +126,7 @@ def contact_post():
meta = None
)
@routes_core.route(Model_View_Contact.HASH_PAGE_CONTACT_SUCCESS, methods=['GET'])
@routes_core_contact.route(Model_View_Contact.HASH_PAGE_CONTACT_SUCCESS, methods=['GET'])
def contact_success():
try:
model = Model_View_Contact_Success()

31
controllers/core/home.py Normal file
View File

@@ -0,0 +1,31 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: App Routing
Feature: Core - Home Routes
Description:
Home Page Controller.
"""
# internal
from business_objects.api import API
from models.model_view_home import Model_View_Home
# external
from flask import render_template, jsonify, Blueprint
routes_core_home = Blueprint('routes_core_home', __name__)
@routes_core_home.route(Model_View_Home.HASH_PAGE_HOME, methods=['GET'])
def home():
try:
model = Model_View_Home()
html_body = render_template('pages/core/_home.html', model = model)
except Exception as e:
return jsonify(error=str(e)), 403
return html_body

View File

View File

@@ -7,7 +7,7 @@ Technology: App Routing
Feature: Legal Routes
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.
Legal Section Controller.
"""
# IMPORTS
@@ -20,12 +20,8 @@ from models.model_view_accessibility_statement import Model_View_Accessibility_S
from models.model_view_retention_schedule import Model_View_Retention_Schedule
import lib.argument_validation as av
# external
from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session, Blueprint, current_app
from extensions import db, oauth
from urllib.parse import quote_plus, urlencode
from authlib.integrations.flask_client import OAuth
from authlib.integrations.base_client import OAuthError
from urllib.parse import quote, urlparse, parse_qs
from flask import render_template, Blueprint
routes_legal = Blueprint('routes_legal', __name__)