diff --git a/__pycache__/app.cpython-311.pyc b/__pycache__/app.cpython-311.pyc index a2994b7e..5d9b7c48 100644 Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ diff --git a/__pycache__/config.cpython-311.pyc b/__pycache__/config.cpython-311.pyc index bed9d752..7adbb684 100644 Binary files a/__pycache__/config.cpython-311.pyc and b/__pycache__/config.cpython-311.pyc differ diff --git a/app.py b/app.py index 24eb2953..67edba02 100644 --- a/app.py +++ b/app.py @@ -37,6 +37,7 @@ from business_objects.product import Product_Filters from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session from flask_cors import CORS from flask_sqlalchemy import SQLAlchemy +from flask_mail import Mail, Message import stripe import json from dotenv import load_dotenv, find_dotenv @@ -87,6 +88,8 @@ oauth.register( ) # session[app.ID_TOKEN_USER] = {'userinfo': {'sub': ''}} +mail = Mail(app) + # METHODS @@ -107,7 +110,9 @@ def contact(): name = form.name.data msg = form.msg.data # send email - pass + mailItem = Message("PARTS Website Contact Us Message", recipients=[app.config['MAIL_DEFAULT_SENDER']]) + mailItem.body = f"Dear Lord Edward Middleton-Smith,\n\n{msg}\n\nKind regards,\n{name}\n{email}" + mail.send(mailItem) return render_template('_page_contact.html', model=Model_View_Contact(db, get_info_user(), app, form)) @@ -651,6 +656,17 @@ def get_info_user(): except: return {'sub': ''} +""" +@app.route('/send-email', methods=['GET']) +def send_email(): + try: + msg = Message("Flask Mail test", recipients=[app.config['MAIL_DEFAULT_SENDER']]) + msg.body = "Dear Lord Edward Middleton-Smith,\n\nThis is a test email sent from Flask.\n\nKind regards,\nBot" + mail.send(msg) + except: + return "Error" + return "Email sent" +""" # Onload if __name__ == '__main__': diff --git a/config.py b/config.py index e7978608..25d29489 100644 --- a/config.py +++ b/config.py @@ -25,7 +25,7 @@ class Config: ID_AUTH0_CLIENT_SECRET = os.getenv('ID_AUTH0_CLIENT_SECRET') DOMAIN_AUTH0 = os.getenv('DOMAIN_AUTH0') ID_TOKEN_USER = 'user' - is_included_VAT = True + # is_included_VAT = True """ KEY_IS_INCLUDED_VAT = 'is_included_VAT' code_currency = 1 @@ -35,8 +35,14 @@ class Config: KEY_ID_CURRENCY = 'id_currency' KEY_ID_REGION_DELIVERY = 'id_region_delivery' """ - id_currency = 1 - id_region_delivery = 1 + # id_currency = 1 + # id_region_delivery = 1 + MAIL_SERVER = 'smtp.gmail.com' + MAIL_PORT = 587 + MAIL_USE_TLS = True + MAIL_USERNAME = 'edward.middletonsmith@gmail.com' + MAIL_PASSWORD = os.getenv('MAIL_PASSWORD') + MAIL_DEFAULT_SENDER = 'edward.middletonsmith@gmail.com' class DevelopmentConfig(Config): DEBUG = True diff --git a/models/__pycache__/model_view_base.cpython-311.pyc b/models/__pycache__/model_view_base.cpython-311.pyc index c2ad9d7a..7668a70a 100644 Binary files a/models/__pycache__/model_view_base.cpython-311.pyc and b/models/__pycache__/model_view_base.cpython-311.pyc differ diff --git a/models/__pycache__/model_view_contact.cpython-311.pyc b/models/__pycache__/model_view_contact.cpython-311.pyc index 20fb1aef..01d67098 100644 Binary files a/models/__pycache__/model_view_contact.cpython-311.pyc and b/models/__pycache__/model_view_contact.cpython-311.pyc differ diff --git a/models/model_view_base.py b/models/model_view_base.py index 2eb49113..60be4752 100644 --- a/models/model_view_base.py +++ b/models/model_view_base.py @@ -64,6 +64,7 @@ class Model_View_Base(ABC): HASH_PAGE_STORE_HOME = '/store' HASH_PAGE_STORE_PRODUCT = '/store/product' ID_BUTTON_HAMBURGER = 'btnHamburger' + ID_FORM_CONTACT = 'formContact' ID_FORM_CURRENCY = 'formCurrency' ID_FORM_DELIVERY_REGION = 'formDeliveryRegion' ID_FORM_IS_INCLUDED_VAT = 'formIsIncludedVAT' diff --git a/models/model_view_contact.py b/models/model_view_contact.py index fd88b7bb..4962d131 100644 --- a/models/model_view_contact.py +++ b/models/model_view_contact.py @@ -23,13 +23,16 @@ from lib import argument_validation as av from flask_wtf import FlaskForm from abc import abstractproperty - # VARIABLE INSTANTIATION # CLASSES class Model_View_Contact(Model_View_Base): # Attributes + ID_EMAIL = 'email' + ID_MESSAGE = 'msg' + ID_NAME = 'name' + @property def title(self): return 'Contact' diff --git a/requirements.txt b/requirements.txt index 1a531f8e..968a69d8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,6 +16,7 @@ mysqlclient # DOMAIN_AUTH0=dev-nwak2066ef6h8ixn.us.auth0.com # SQLALCHEMY_DATABASE_URI = 'mysql://username:password@localhost/dbname' # Replace 'username', 'password', 'localhost', and 'dbname' with your actual database credentials +# MAIL_PASSWORD=uifv utsy yzxy hpnm # run with: # python -m flask run diff --git a/static/css/contact.css b/static/css/contact.css index 3f35c8b4..93fd8108 100644 --- a/static/css/contact.css +++ b/static/css/contact.css @@ -1,3 +1,13 @@ + +#pageBody > .card:first-of-type{ + top: 0; + flex-grow: 1; +} +#pageBody > .card:last-of-type { +} +#pageBody > .card:not(:first-of-type) { +} + /* .content > a { display: flex; diff --git a/static/css/home.css b/static/css/home.css index 36bdc651..b02945af 100644 --- a/static/css/home.css +++ b/static/css/home.css @@ -1,3 +1,14 @@ + +.page-body > * { + height: 100%; +} +#pageBody > * :first-child{ + margin-top: 25vh; +} +#pageBody > * :last-child { + margin-bottom: 35vh; +} + .img-demo { max-width: 50%; min-width: 500px; diff --git a/static/css/shared.css b/static/css/shared.css index dfe81c2f..bcf5f251 100644 --- a/static/css/shared.css +++ b/static/css/shared.css @@ -33,26 +33,34 @@ body { max-height: 100%; } +/* +h1, h2, h3, h4, h5, p, a, label { + display: flex; + margin: 0; + padding: 0; +} +*/ + h1 { - font-size: 4vh; + font-size: 36px; } h2 { - font-size: 2.4vh; + font-size: 22px; } h3 { - font-size: 2vh; + font-size: 18px; margin: 1vh; } h4 { - font-size: 1.5vh; + font-size: 13px; margin: 1vh; } h5 { - font-size: 1.25vh; + font-size: 11px; margin: 1vh; } @@ -136,12 +144,19 @@ h5 { .page-body { height: 75vh !important; + top: 15vh; + bottom: 5vh; padding: 0; margin: 0; border: 0; align-items: center; align-content: center; justify-content: center; + display: flex; + flex-direction: column; + align-items: stretch; + overflow-y: auto; + overflow-x: hidden; } .page-body > * { @@ -151,7 +166,6 @@ h5 { justify-content: center; text-align: center; width: 100%; - height: 100%; align-self: center; font-size: 20px; } @@ -160,15 +174,15 @@ h5 { align-self: center; padding-top: 1vh; padding-bottom: 1vh; - color: white; /* var(--c_purple_dark); */ + color: var(--c_purple_dark); } -#pageBody > * :first-child{ - margin-top: 25vh; +#pageBody > .card { + height: fit-content; + margin-top: 1vh; } -#pageBody > * :last-child { - margin-bottom: 35vh; +#pageBody > .card:last-of-type { + margin-bottom: 1vh; } - /* Create two unequal columns that floats next to each other * /* Left column * .leftcolumn { @@ -245,7 +259,7 @@ img.header-logo { /* Add a card effect for articles */ .card { - background-color: white; + background-color: var(--c_purple_pastel); padding: 0; margin: 0; display: flex !important; @@ -254,7 +268,8 @@ img.header-logo { justify-content: center; text-align: center; border-radius: 4vh; - min-width: fit-content; + /* min-width: fit-content; */ + position: relative; } .card.subcard { @@ -305,14 +320,8 @@ img.header-logo { padding: 0; text-align: center; margin: 0; - /* - background: var(--c_purple_light); - border-top-right-radius: 2.5vh; - border-top-left-radius: 2.5vh; - border-bottom-right-radius: 0; - border-bottom-right-radius: 0; - */ height: 10vh !important; + overflow-y: auto; } .footer > h4, h5 { @@ -362,8 +371,8 @@ img.header-logo { .container-input > input, .container-input > textarea { border: 2px solid var(--c_purple); - max-width: 50%; - min-width: 40%; + max-width: 66%; + min-width: 20%; padding: 1vh; } @@ -422,7 +431,16 @@ button, .btn-submit, input[type="submit"] { } .hamburger { - + border: 2px solid var(--c_purple_dark); + border-radius: 4px; +} +.hamburger:first-child { + border-top-left-radius: 12px; + border-top-right-radius: 12px; +} +.hamburger:last-child { + border-bottom-left-radius: 12px; + border-bottom-right-radius: 12px; } .hamburger > * { diff --git a/static/js/contact.js b/static/js/contact.js index f0cff237..14aa627c 100644 --- a/static/js/contact.js +++ b/static/js/contact.js @@ -3,3 +3,19 @@ var _loading = true; function hookupPageContact() { _loading = false; } + +function stylePageContact() { + let elementEmail = $(idEmail); + let elementName = $(idName); + let elementMessage = $(idMessage); + + elementEmail.css({ + width: "50%" + }); + elementName.css({ + width: "40%" + }); + elementMessage.css({ + width: "66%" + }); +} \ No newline at end of file diff --git a/templates/_page_contact.html b/templates/_page_contact.html index d2d1e34c..c67db85c 100644 --- a/templates/_page_contact.html +++ b/templates/_page_contact.html @@ -4,11 +4,11 @@ {% block page_body %} - +
-
+

Complete the form or find our details below.

+
@@ -139,7 +139,7 @@