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

8
app.py
View File

@@ -17,8 +17,9 @@ Initializes the Flask application, sets the configuration based on the environme
# IMPORTS
# internal
from config import app_config, Config
from controllers.core import routes_core
from controllers.legal import routes_legal
from controllers.core.contact import routes_core_contact
from controllers.core.home import routes_core_home
from controllers.legal.legal import routes_legal
from extensions import db, csrf, mail, oauth
from helpers.helper_app import Helper_App
# external
@@ -106,7 +107,8 @@ with app.app_context():
)
app.register_blueprint(routes_core)
app.register_blueprint(routes_core_home)
app.register_blueprint(routes_core_contact)
app.register_blueprint(routes_legal)

View File

@@ -1,106 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: Address Business Object
Description:
Business object for address
"""
# internal
import lib.argument_validation as av
from business_objects.base import Base
from business_objects.region import Region
from extensions import db
from helpers.helper_app import Helper_App
# external
from typing import ClassVar
from flask import jsonify
class Address(db.Model, Base):
FLAG_ADDRESS_LINE_1: ClassVar[str] = 'address_line_1'
FLAG_ADDRESS_LINE_2: ClassVar[str] = 'address_line_2'
FLAG_CITY: ClassVar[str] = 'city'
FLAG_COUNTY: ClassVar[str] = 'county'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Base.ATTR_ID_ADDRESS
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_POSTCODE
__tablename__ = 'Shop_Address'
id_address = db.Column(db.Integer, primary_key=True)
id_region = db.Column(db.Integer)
postcode = db.Column(db.String(20))
address_line_1 = db.Column(db.String(256))
address_line_2 = db.Column(db.String(256))
city = db.Column(db.String(256))
county = db.Column(db.String(256))
active = db.Column(db.Boolean)
# region = None
def __init__(self):
super().__init__()
Base.__init__(self)
self.region = None
@classmethod
def from_DB_storage_location(cls, query_row):
address = cls()
address.id_address = query_row[2]
address.id_region = query_row[3]
return address
@classmethod
def from_DB_plant(cls, query_row):
address = cls()
address.id_address = query_row[1]
address.id_region = query_row[2]
return address
@classmethod
def from_DB_stock_item(cls, query_row):
address = cls()
address.id_address = query_row[6]
address.id_region = query_row[7]
return address
@classmethod
def from_DB_supplier(cls, query_row):
address = cls()
address.id_address = query_row[1]
address.postcode = query_row[2]
return address
def __repr__(self):
return f'''
{self.ATTR_ID_ADDRESS}: {self.id_address}
{self.FLAG_REGION}: {self.region}
{self.FLAG_POSTCODE}: {self.postcode}
{self.FLAG_ADDRESS_LINE_1}: {self.address_line_1}
{self.FLAG_ADDRESS_LINE_2}: {self.address_line_2}
{self.FLAG_CITY}: {self.city}
{self.FLAG_COUNTY}: {self.county}
{self.FLAG_ACTIVE}: {self.active}
'''
def to_json(self):
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_ADDRESS: self.id_address,
self.FLAG_REGION: None if self.region is None else self.region.to_json(),
self.FLAG_POSTCODE: self.postcode,
self.FLAG_ADDRESS_LINE_1: self.address_line_1,
self.FLAG_ADDRESS_LINE_2: self.address_line_2,
self.FLAG_CITY: self.city,
self.FLAG_COUNTY: self.county,
self.FLAG_ACTIVE: 1 if av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json') else 0
}
def to_json_str(self):
return jsonify(self.to_json())
@classmethod
def from_json(cls, json):
address = cls()
address.id_address = json[cls.ATTR_ID_ADDRESS],
address.region = Region.from_json(json[cls.FLAG_REGION]),
address.postcode = json[cls.FLAG_POSTCODE],
address.address_line_1 = json[cls.FLAG_ADDRESS_LINE_1],
address.address_line_2 = json.get(cls.FLAG_ADDRESS_LINE_2, ''),
address.city = json[cls.FLAG_CITY],
address.county = json[cls.FLAG_COUNTY],
address.active = json[cls.FLAG_ACTIVE]
return address

View File

@@ -7,7 +7,7 @@ Technology: Business Objects
Feature: Base Business Object
Description:
Abstract business object
Abstract base class for all business objects in app
"""
# internal
@@ -67,6 +67,7 @@ class Base():
FLAG_VALUE_LOCAL_VAT_EXCL: ClassVar[str] = 'value_local_vat_excl'
FLAG_VALUE_LOCAL_VAT_INCL: ClassVar[str] = 'value_local_vat_incl'
FLAG_WEBSITE: ClassVar[str] = 'website'
ID_USER_GUEST: ClassVar[int] = 3
"""
NAME_ATTR_OPTION_TEXT: ClassVar[str] = 'name-attribute-option-text'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = 'name-attribute-option-value'

View File

@@ -1,147 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: Product Business Object
Description:
Business object for product
"""
# internal
from business_objects.store.store_base import Store_Base
from extensions import db
from lib import argument_validation as av
# external
from typing import ClassVar
# CLASSES
"""
class Currency_Enum(Enum):
GBP = 1
def text(self):
return Currency_Enum.Currency_Enum_Text(self)
def Currency_Enum_Text(currency):
av.val_instance(currency, 'currency', 'Currency_Enum_Text', Currency_Enum)
if currency == Currency_Enum.GBP:
return 'GBP'
else:
# return 'Unknown'
raise ValueError("Unknown Currency Enum.")
def get_member_by_text(text):
for member in Resolution_Level_Enum.__members__.values():
if member.name == text:
return member
raise ValueError("Unknown Currency Enum.")
# return Resolution_Level_Enum.HIGH
"""
class Currency(db.Model, Store_Base):
FLAG_FACTOR_FROM_GBP: ClassVar[str] = 'factor-from-GBP'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_CURRENCY
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
id_currency = db.Column(db.Integer, primary_key=True)
code = db.Column(db.String(50))
name = db.Column(db.String(255))
symbol = db.Column(db.String(50))
factor_from_GBP = db.Column(db.Float)
display_order = db.Column(db.Integer)
active = db.Column(db.Boolean)
@classmethod
def from_DB_currency(cls, query_row):
_m = 'Currency.from_DB_currency'
v_arg_type = 'class attribute'
currency = cls()
currency.id_currency = query_row[0]
currency.code = query_row[1]
currency.name = query_row[2]
currency.symbol = query_row[3]
currency.factor_from_GBP = query_row[4]
currency.display_order = query_row[5]
currency.active = av.input_bool(query_row[6], 'active', _m, v_arg_type=v_arg_type)
return currency
@classmethod
def from_DB_get_many_product_catalogue_product_permutation(cls, query_row):
currency = cls()
currency.id_currency = query_row[6]
currency.code = query_row[7]
currency.symbol = query_row[8]
return currency
@classmethod
def from_DB_get_many_product_price_and_discount_and_delivery_region(cls, query_row):
currency = cls()
return currency
@classmethod
def from_DB_stock_item(cls, query_row):
currency = cls()
currency.id_currency = query_row[12]
currency.code = query_row[13]
currency.symbol = query_row[14]
return currency
@classmethod
def from_DB_supplier(cls, query_row):
currency = cls()
currency.id_currency = query_row[1]
currency.code = query_row[2]
currency.symbol = query_row[3]
return currency
@classmethod
def from_DB_supplier_purchase_order(cls, query_row):
currency = cls()
currency.id_currency = query_row[3]
currency.code = query_row[4]
currency.symbol = query_row[5]
return currency
@classmethod
def from_DB_manufacturing_purchase_order(cls, query_row):
currency = cls()
currency.id_currency = query_row[1]
currency.code = query_row[2]
currency.symbol = query_row[3]
return currency
def __repr__(self):
return f'''
id: {self.id_currency}
name: {self.name}
code: {self.code}
symbol: {self.symbol}
factor from GBP: {self.factor_from_GBP}
display_order: {self.display_order}
active: {self.active}
'''
def to_json(self):
return {
**self.get_shared_json_attributes(self),
self.NAME_ATTR_OPTION_TEXT: self.FLAG_NAME,
self.NAME_ATTR_OPTION_VALUE: self.ATTR_ID_CURRENCY,
self.ATTR_ID_CURRENCY: self.id_currency,
self.FLAG_CODE: self.code,
self.FLAG_NAME: self.name,
self.FLAG_SYMBOL: self.symbol,
self.FLAG_FACTOR_FROM_GBP: self.factor_from_GBP,
self.FLAG_DISPLAY_ORDER: self.display_order,
self.FLAG_ACTIVE: self.active,
}
@classmethod
def from_json(cls, json_currency, key_suffix = ''):
currency = cls()
currency.id_currency = json_currency[f'{cls.ATTR_ID_CURRENCY}{key_suffix}']
currency.code = json_currency.get(f'{cls.FLAG_CODE}{key_suffix}')
currency.name = json_currency.get(f'{cls.FLAG_NAME}{key_suffix}')
currency.symbol = json_currency.get(f'{cls.FLAG_SYMBOL}{key_suffix}')
currency.factor_from_GBP = json_currency.get(f'{cls.FLAG_FACTOR_FROM_GBP}{key_suffix}')
currency.display_order = json_currency.get(f'{cls.FLAG_DISPLAY_ORDER}{key_suffix}')
currency.active = json_currency.get(f'{cls.FLAG_ACTIVE}{key_suffix}')
return currency
def to_json_option(self):
return {
'value': self.id_currency,
'text': self.name
}

View File

@@ -7,7 +7,7 @@ Technology: Business Objects
Feature: Database Base Business Objects
Description:
Abstract business object for database objects
Abstract base class for database objects
"""
# internal
@@ -22,32 +22,7 @@ from sqlalchemy.ext.declarative import DeclarativeMeta
# from flask_sqlalchemy import SQLAlchemy
class Get_Many_Parameters_Base(BaseModel, metaclass=ABCMeta):
# a_id_user: int
def __init__(self, **kwargs): # , a_id_user
super().__init__(**kwargs) # a_id_user=a_id_user,
@classmethod
@abstractmethod
def get_default(cls): # , id_user
pass
def to_json(self):
return self.dict()
"""
@classmethod
@abstractmethod
def from_json(cls, json):
pass
"""
"""
@classmethod
@abstractmethod
def from_form(cls, form):
pass
"""
# db = SQLAlchemy()
# Base = declarative_base()
class SQLAlchemy_ABCMeta(db.Model.__class__, ABCMeta):
pass
@@ -63,10 +38,6 @@ class SQLAlchemy_ABC(db.Model, metaclass=SQLAlchemy_ABCMeta):
@classmethod
def from_json(cls, json):
pass
"""
def to_json_option(self):
pass
"""
def to_temporary_record(self):
pass
def to_object_with_missing_attributes(self, excluded_attributes):

View File

@@ -23,16 +23,13 @@ from typing import ClassVar
class Access_Level(db.Model, Base):
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Base.ATTR_ID_ACCESS_LEVEL
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME
__tablename__ = 'Shop_Access_Level_Temp'
__tablename__ = 'PH_Access_Level_Temp'
id_access_level = db.Column(db.Integer, primary_key=True)
code = db.Column(db.String(50))
name = db.Column(db.String(255))
description = db.Column(db.String(4000))
priority = db.Column(db.Integer)
display_order = db.Column(db.Integer)
active = db.Column(db.Boolean)
created_on = db.Column(db.DateTime)
created_by = db.Column(db.Integer)
def __init__(self):
super().__init__()
Base.__init__(self)

View File

View File

@@ -0,0 +1,136 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: Contact_Form Business Object
"""
# internal
from business_objects.base import Base
from business_objects.db_base import SQLAlchemy_ABC
import lib.argument_validation as av
from extensions import db
from helpers.helper_app import Helper_App
# external
from dataclasses import dataclass
from typing import ClassVar
class Contact_Form(SQLAlchemy_ABC, Base):
FLAG_ALTCHA: ClassVar[str] = 'altcha'
FLAG_CONTACT_FORM: ClassVar[str] = 'contact-form'
FLAG_NAME_COMPANY: ClassVar[str] = 'name-company'
FLAG_NAME_CONTACT: ClassVar[str] = 'name-contact'
FLAG_MESSAGE: ClassVar[str] = 'message'
FLAG_RECEIVE_MARKETING_COMMUNICATIONS: ClassVar[str] = 'receive-marketing-communications'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = FLAG_CONTACT_FORM
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_EMAIL
__tablename__ = 'PH_Contact_Form'
__table_args__ = { 'extend_existing': True }
id_contact_form = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(255))
name_contact = db.Column(db.String(255))
name_company = db.Column(db.String(255))
message = db.Column(db.Text)
receive_marketing_communications = db.Column(db.Boolean)
active = db.Column(db.Boolean)
created_on = db.Column(db.DateTime)
def __init__(self):
self.id_contact_form = 0
self.is_new = False
super().__init__()
def from_DB_Contact_Form(query_row):
_m = 'Contact_Form.from_DB_Contact_Form'
contact_form = Contact_Form()
contact_form.id_contact_form = query_row[0]
contact_form.email = query_row[1]
contact_form.name_contact = query_row[2]
contact_form.name_company = query_row[3]
contact_form.message = query_row[4]
contact_form.receive_marketing_communications = av.input_bool(query_row[5], 'receive_marketing_communications', _m)
contact_form.active = av.input_bool(query_row[6], 'active', _m)
contact_form.created_on = query_row[7]
return contact_form
@classmethod
def from_json(cls, json):
_m = 'Contact_Form.from_json'
contact_form = cls()
if json is None: return Contact_Form
Helper_App.console_log(f'{_m}\njson: {json}')
contact_form.id_contact_form = -1
contact_form.email = json[cls.FLAG_EMAIL]
contact_form.name_contact = json[cls.FLAG_NAME_CONTACT]
contact_form.name_company = json[cls.FLAG_NAME_COMPANY]
contact_form.message = json[cls.FLAG_MESSAGE]
contact_form.receive_marketing_communications = json[cls.FLAG_RECEIVE_MARKETING_COMMUNICATIONS]
contact_form.active = json[cls.FLAG_ACTIVE]
contact_form.created_on = json.get(cls.FLAG_CREATED_ON, None)
Helper_App.console_log(f'Contact_Form: {contact_form}')
return contact_form
def to_json(self):
as_json = {
self.FLAG_CONTACT_FORM: self.id_contact_form
, self.FLAG_EMAIL: self.email
, self.FLAG_NAME_CONTACT: self.name_contact
, self.FLAG_NAME_COMPANY: self.name_company
, self.FLAG_MESSAGE: self.message
, self.FLAG_RECEIVE_MARKETING_COMMUNICATIONS: self.receive_marketing_communications
, self.FLAG_ACTIVE: self.active
, self.FLAG_CREATED_ON: self.created_on
}
Helper_App.console_log(f'as_json: {as_json}')
return as_json
def __repr__(self):
return f'''
{self.__class__.__name__}(
{self.FLAG_CONTACT_FORM}: {self.id_contact_form}
{self.FLAG_EMAIL}: {self.email}
{self.FLAG_NAME_CONTACT}: {self.name_contact}
{self.FLAG_NAME_COMPANY}: {self.name_company}
{self.FLAG_MESSAGE}: {self.message}
{self.FLAG_RECEIVE_MARKETING_COMMUNICATIONS}: {self.receive_marketing_communications}
{self.FLAG_ACTIVE}: {self.active}
{self.FLAG_CREATED_ON}: {self.created_on}
)
'''
class Contact_Form_Temp(db.Model, Base):
__tablename__ = 'PH_Contact_Form_Temp'
__table_args__ = { 'extend_existing': True }
id_temp = db.Column(db.Integer, primary_key=True)
id_contact_form = db.Column(db.Integer)
email = db.Column(db.String(255))
name_contact = db.Column(db.String(255))
name_company = db.Column(db.String(255))
message = db.Column(db.Text)
receive_marketing_communications = db.Column(db.Boolean)
active = db.Column(db.Boolean)
created_on = db.Column(db.DateTime)
guid: str = db.Column(db.String(36))
def __init__(self):
super().__init__()
@classmethod
def from_contact_form(cls, contact_form):
_m = 'Contact_Form_Temp.from_Contact_Form'
temp = cls()
temp.id_contact_form = contact_form.id_contact_form
temp.email = contact_form.email
temp.name_contact = contact_form.name_contact
temp.name_company = contact_form.name_company
temp.message = contact_form.message
temp.receive_marketing_communications
temp.active = contact_form.active
temp.created_on = contact_form.created_on
return temp

View File

@@ -0,0 +1,133 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: User Business Object
"""
# internal
from business_objects.base import Base
from business_objects.db_base import SQLAlchemy_ABC
import lib.argument_validation as av
from forms.forms import Form_Contact
from extensions import db
from helpers.helper_app import Helper_App
# external
from dataclasses import dataclass
from typing import ClassVar
class User(SQLAlchemy_ABC, Base):
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Base.ATTR_ID_USER
NAME_ATTR_OPTION_TEXT: ClassVar[str] = 'email'
__tablename__ = 'PH_User'
__table_args__ = { 'extend_existing': True }
id_user = db.Column(db.Integer, primary_key=True)
id_user_auth0 = db.Column(db.String(255))
firstname = db.Column(db.String(255))
surname = db.Column(db.String(255))
email = db.Column(db.String(255))
is_email_verified = db.Column(db.Boolean)
is_super_user = db.Column(db.Boolean)
is_new = db.Column(db.Boolean)
def __init__(self):
self.id_user = 0
self.is_new = False
super().__init__()
def from_DB_user(query_row):
_m = 'User.from_DB_user'
user = User()
user.id_user = query_row[0]
user.id_user_auth0 = query_row[1]
user.firstname = query_row[2]
user.surname = query_row[3]
user.email = query_row[4]
user.is_email_verified = av.input_bool(query_row[5], 'is_email_verified', _m)
user.is_super_user = av.input_bool(query_row[9], 'is_super_user', _m)
user.is_new = av.input_bool(query_row[12], 'is_new', _m)
return user
@staticmethod
def from_json(json):
_m = 'User.from_json'
user = User()
if json is None: return user
Helper_App.console_log(f'{_m}\njson: {json}')
user.id_user = json['id_user']
user.id_user_auth0 = json['id_user_auth0']
user.firstname = json['firstname']
user.surname = json['surname']
user.email = json['email']
user.is_email_verified = av.input_bool(json['is_email_verified'], 'is_email_verified', _m)
user.is_super_user = av.input_bool(json['is_super_user'], 'is_super_user', _m)
Helper_App.console_log(f'user: {user}')
return user
@staticmethod
def from_json_auth0(json):
_m = 'User.from_json_auth0'
user = User()
if json is None: return user
Helper_App.console_log(f'{_m}\njson: {json}')
user_info = json['userinfo']
user.id_user = None
user.id_user_auth0 = user_info['sub']
user.firstname = None
user.surname = None
user.email = user_info['email']
user.is_email_verified = av.input_bool(user_info['email_verified'], 'is_email_verified', _m)
user.is_super_user = None
Helper_App.console_log(f'user: {user}')
return user
def to_json(self):
as_json = {
'id_user': self.id_user,
'id_user_auth0': self.id_user_auth0,
'firstname': self.firstname,
'surname': self.surname,
'email': self.email,
'is_email_verified': self.is_email_verified,
'is_super_user': self.is_super_user
}
Helper_App.console_log(f'as_json: {as_json}')
return as_json
def __repr__(self):
return f'''
id_user: {self.id_user}
id_user_auth0: {self.id_user_auth0}
firstname: {self.firstname}
surname: {self.surname}
email: {self.email}
is_email_verified: {self.is_email_verified}
is_super_user: {self.is_super_user}
'''
def get_is_logged_in(self):
return (self.id_user > 0 and self.id_user != Base.ID_USER_GUEST)
class User_Temp(db.Model, Base):
__tablename__ = 'Shop_User_Temp'
__table_args__ = { 'extend_existing': True }
id_user = db.Column(db.Integer, primary_key=True)
id_user_auth0 = db.Column(db.String(255))
firstname = db.Column(db.String(255))
surname = db.Column(db.String(255))
email = db.Column(db.String(255))
is_email_verified = db.Column(db.Boolean)
is_super_user = db.Column(db.Boolean)
id_currency_default = db.Column(db.Integer)
id_region_default = db.Column(db.Integer)
is_included_VAT_default = db.Column(db.Boolean)
# is_logged_in: bool
def __init__(self):
self.id_user = 0
super().__init__()

View File

@@ -1,86 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: Address Region Business Object
Description:
Business object for address region
"""
# internal
import lib.argument_validation as av
from business_objects.base import Base
from extensions import db
from helpers.helper_app import Helper_App
# external
from typing import ClassVar
class Region(db.Model, Base):
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Base.ATTR_ID_REGION
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME
__tablename__ = 'Shop_Region'
id_region = db.Column(db.Integer, primary_key=True)
code = db.Column(db.String(50))
name = db.Column(db.String(200))
active = db.Column(db.Boolean)
# region = None
def __init__(self):
super().__init__()
Base.__init__(self)
@classmethod
def from_DB_stock_item(cls, query_row):
region = cls()
region.id_region = query_row[7]
return region
@classmethod
def from_DB_supplier(cls, query_row):
region = cls()
region.id_region = query_row[2]
region.name = query_row[3]
return region
def __repr__(self):
return f'''
{self.ATTR_ID_REGION}: {self.id_region}
{self.FLAG_CODE}: {self.code}
{self.FLAG_NAME}: {self.name}
{self.FLAG_ACTIVE}: {self.active}
'''
def to_json(self):
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_REGION: self.id_region,
self.FLAG_CODE: self.code,
self.FLAG_NAME: self.name,
self.FLAG_ACTIVE: 1 if av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json') else 0
}
@classmethod
def from_json(cls, json):
plant = cls()
plant.id_region = json[cls.ATTR_ID_REGION]
plant.code = json[cls.FLAG_CODE]
plant.name = json[cls.FLAG_NAME]
plant.active = json[cls.FLAG_ACTIVE]
return plant
@classmethod
def from_DB_get_many_product_catalogue(cls, query_row):
region = cls()
region.id_region = query_row[0]
region.name = query_row[1]
region.code = query_row[2]
# self.display_order = query_row[3]
return region
@classmethod
def from_DB_region(cls, query_row):
region = cls()
region.id_region = query_row[0]
region.code = query_row[1]
region.name = query_row[2]
region.active = av.input_bool(query_row[3], cls.FLAG_ACTIVE, f'{cls.__name__}.from_DB_region')
return region

View File

@@ -7,7 +7,7 @@ Technology: Business Objects
Feature: SQL Error Business Object
Description:
Business object for SQL errors
Business object for SQL errors returned by Get Many Stored Procedures
"""
# internal
@@ -22,11 +22,9 @@ import locale
from flask_sqlalchemy import SQLAlchemy
# VARIABLE INSTANTIATION
db = SQLAlchemy()
# CLASSES
class SQL_Error(db.Model):
display_order = db.Column(db.Integer, primary_key=True)
id_type = db.Column(db.Integer)

View File

@@ -1,109 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: Unit of Measurement Business Object
"""
# internal
from business_objects.base import Base
from business_objects.db_base import SQLAlchemy_ABC, Get_Many_Parameters_Base
from extensions import db
# from forms.forms import Form_Filters_User
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from dataclasses import dataclass
from typing import ClassVar
class Unit_Measurement(SQLAlchemy_ABC, Base):
ATTR_ID_UNIT_MEASUREMENT: ClassVar[str] = 'id_unit_measurement'
FLAG_IS_BASE_UNIT: ClassVar[str] = 'is_base_unit'
FLAG_IS_UNIT_OF_DISTANCE: ClassVar[str] = 'is_unit_of_distance'
FLAG_IS_UNIT_OF_MASS: ClassVar[str] = 'is_unit_of_mass'
FLAG_IS_UNIT_OF_TIME: ClassVar[str] = 'is_unit_of_time'
FLAG_IS_UNIT_OF_VOLUME: ClassVar[str] = 'is_unit_of_volume'
FLAG_NAME_PLURAL: ClassVar[str] = 'name_plural'
FLAG_NAME_SINGULAR: ClassVar[str] = 'name_singular'
FLAG_SYMBOL: ClassVar[str] = 'symbol'
FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX: ClassVar[str] = 'symbol_is_suffix_not_prefix'
# KEY_UNIT_MEASUREMENT: ClassVar[str] = 'unit_of_measurement'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = ATTR_ID_UNIT_MEASUREMENT
NAME_ATTR_OPTION_TEXT: ClassVar[str] = FLAG_NAME_SINGULAR
id_unit_measurement = db.Column(db.Integer, primary_key=True)
name_singular = db.Column(db.String(255))
name_plural = db.Column(db.String(256))
symbol = db.Column(db.String(50))
symbol_is_suffix_not_prefix = db.Column(db.Boolean)
is_base_unit = db.Column(db.Boolean)
is_unit_of_distance = db.Column(db.Boolean)
is_unit_of_mass = db.Column(db.Boolean)
is_unit_of_time = db.Column(db.Boolean)
is_unit_of_volume = db.Column(db.Boolean)
active = db.Column(db.Boolean)
def from_DB_unit_measurement(query_row):
_m = 'Unit_Measurement.from_DB_unit_measurement'
unit = Unit_Measurement()
unit.id_unit_measurement = query_row[0]
unit.name_singular = query_row[1]
unit.name_plural = query_row[2]
unit.symbol = query_row[3]
unit.symbol_is_suffix_not_prefix = av.input_bool(query_row[4], 'symbol_is_suffix_not_prefix', _m)
unit.is_base_unit = av.input_bool(query_row[5], 'is_base_unit', _m)
unit.is_unit_of_distance = av.input_bool(query_row[6], 'is_unit_of_distance', _m)
unit.is_unit_of_mass = av.input_bool(query_row[7], 'is_unit_of_mass', _m)
unit.is_unit_of_time = av.input_bool(query_row[8], 'is_unit_of_time', _m)
unit.is_unit_of_volume = av.input_bool(query_row[9], 'is_unit_of_volume', _m)
unit.active = av.input_bool(query_row[10], 'active', _m)
return unit
def to_json(self):
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_UNIT_MEASUREMENT: self.id_unit_measurement,
self.FLAG_NAME_SINGULAR: self.name_singular,
self.FLAG_NAME_PLURAL: self.name_plural,
self.FLAG_SYMBOL: self.symbol,
self.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX: self.symbol_is_suffix_not_prefix,
self.FLAG_IS_BASE_UNIT: self.is_base_unit,
self.FLAG_IS_UNIT_OF_DISTANCE: self.is_unit_of_distance,
self.FLAG_IS_UNIT_OF_MASS: self.is_unit_of_mass,
self.FLAG_IS_UNIT_OF_TIME: self.is_unit_of_time,
self.FLAG_IS_UNIT_OF_VOLUME: self.is_unit_of_volume,
self.FLAG_ACTIVE: self.active,
}
@classmethod
def from_json(cls, json):
unit = cls()
unit.id_unit_measurement = json[cls.ATTR_ID_UNIT_MEASUREMENT]
unit.name_singular = json[cls.FLAG_NAME_SINGULAR]
unit.name_plural = json[cls.FLAG_NAME_PLURAL]
unit.symbol = json[cls.FLAG_SYMBOL]
unit.symbol_is_suffix_not_prefix = json[cls.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX]
unit.is_base_unit = json[cls.FLAG_IS_BASE_UNIT]
unit.is_unit_of_distance = json[cls.FLAG_IS_UNIT_OF_DISTANCE]
unit.is_unit_of_mass = json[cls.FLAG_IS_UNIT_OF_MASS]
unit.is_unit_of_time = json[cls.FLAG_IS_UNIT_OF_TIME]
unit.is_unit_of_volume = json[cls.FLAG_IS_UNIT_OF_VOLUME]
unit.active = json[cls.FLAG_ACTIVE]
return unit
def __repr__(self):
return f'''
id_unit_of_measurement: {self.id_unit_measurement},
name_singular: {self.name_singular},
name_plural: {self.name_plural},
symbol: {self.symbol},
symbol_is_suffix_not_prefix: {self.symbol_is_suffix_not_prefix},
is_base_unit: {self.is_base_unit},
is_unit_of_distance: {self.is_unit_of_distance},
is_unit_of_mass: {self.is_unit_of_mass},
is_unit_of_time: {self.is_unit_of_time},
is_unit_of_volume: {self.is_unit_of_volume},
active: {self.active}
'''

View File

@@ -1,293 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: User Business Object
"""
# internal
from business_objects.base import Base
from business_objects.db_base import Get_Many_Parameters_Base
import lib.argument_validation as av
from forms.forms import Form_Filters_User
from extensions import db
from helpers.helper_app import Helper_App
# external
from dataclasses import dataclass
from typing import ClassVar
class User(db.Model, Base):
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Base.ATTR_ID_USER
NAME_ATTR_OPTION_TEXT: ClassVar[str] = 'email'
__tablename__ = 'Shop_User'
__table_args__ = { 'extend_existing': True }
id_user = db.Column(db.Integer, primary_key=True)
id_user_auth0 = db.Column(db.String(255))
firstname = db.Column(db.String(255))
surname = db.Column(db.String(255))
email = db.Column(db.String(255))
is_email_verified = db.Column(db.Boolean)
is_super_user = db.Column(db.Boolean)
id_currency_default = db.Column(db.Integer)
id_region_default = db.Column(db.Integer)
is_included_VAT_default = db.Column(db.Boolean)
can_admin_store = db.Column(db.Boolean)
can_admin_user = db.Column(db.Boolean)
is_new = db.Column(db.Boolean)
# is_logged_in: bool
def __init__(self):
self.id_user = 0
self.is_logged_in = False
self.is_new = False
super().__init__()
self.currency_default = None
self.region_default = None
def from_DB_user(query_row):
_m = 'User.from_DB_user'
user = User()
user.id_user = query_row[0]
user.id_user_auth0 = query_row[1]
user.firstname = query_row[2]
user.surname = query_row[3]
user.email = query_row[4]
user.is_email_verified = av.input_bool(query_row[5], 'is_email_verified', _m)
user.id_currency_default = query_row[6]
user.id_region_default = query_row[7]
user.is_included_VAT_default = av.input_bool(query_row[8], 'is_included_VAT_default', _m)
user.is_super_user = av.input_bool(query_row[9], 'is_super_user', _m)
user.can_admin_store = av.input_bool(query_row[10], 'can_admin_store', _m)
user.can_admin_user = av.input_bool(query_row[11], 'can_admin_user', _m)
user.is_logged_in = (user.id_user is not None and user.id_user > 0)
user.is_new = av.input_bool(query_row[12], 'is_new', _m)
return user
@staticmethod
def from_json(json):
_m = 'User.from_json'
user = User()
if json is None: return user
Helper_App.console_log(f'{_m}\njson: {json}')
user.id_user = json['id_user']
user.id_user_auth0 = json['id_user_auth0']
user.firstname = json['firstname']
user.surname = json['surname']
user.email = json['email']
user.is_email_verified = av.input_bool(json['is_email_verified'], 'is_email_verified', _m)
user.is_super_user = av.input_bool(json['is_super_user'], 'is_super_user', _m)
user.id_currency_default = json['id_currency_default']
user.id_region_default = json['id_region_default']
user.is_included_VAT_default = av.input_bool(json['is_included_VAT_default'], 'is_included_VAT_default', _m)
user.can_admin_store = av.input_bool(json['can_admin_store'], 'can_admin_store', _m)
user.can_admin_user = av.input_bool(json['can_admin_user'], 'can_admin_user', _m)
user.is_logged_in = (user.id_user_auth0 is not None)
Helper_App.console_log(f'user: {user}')
return user
# Helper_App.console_log(f'user: {user}')
@staticmethod
def from_json_auth0(json):
_m = 'User.from_json_auth0'
user = User()
if json is None: return user
Helper_App.console_log(f'{_m}\njson: {json}')
user_info = json['userinfo']
user.id_user = None
user.id_user_auth0 = user_info['sub']
user.firstname = None
user.surname = None
user.email = user_info['email']
user.is_email_verified = av.input_bool(user_info['email_verified'], 'is_email_verified', _m)
user.is_super_user = None
user.id_currency_default = None
user.id_region_default = None
user.is_included_VAT_default = None
user.can_admin_store = None
user.can_admin_user = None
user.is_logged_in = (user.id_user_auth0 is not None and user.id_user_auth0 != '')
Helper_App.console_log(f'user: {user}')
return user
def to_json(self):
as_json = {
'id_user': self.id_user,
'id_user_auth0': self.id_user_auth0,
'firstname': self.firstname,
'surname': self.surname,
'email': self.email,
'is_email_verified': self.is_email_verified,
'is_super_user': self.is_super_user,
'id_currency_default': self.id_currency_default,
'id_region_default': self.id_region_default,
'is_included_VAT_default': self.is_included_VAT_default,
'can_admin_store': self.can_admin_store,
'can_admin_user': self.can_admin_user
}
Helper_App.console_log(f'as_json: {as_json}')
return as_json
def __repr__(self):
return f'''
id_user: {self.id_user}
id_user_auth0: {self.id_user_auth0}
firstname: {self.firstname}
surname: {self.surname}
email: {self.email}
is_email_verified: {self.is_email_verified}
is_super_user: {self.is_super_user}
id_currency_default: {self.id_currency_default}
id_region_default: {self.id_region_default}
is_included_VAT_default: {self.is_included_VAT_default}
can_admin_store: {self.can_admin_store}
can_admin_user: {self.can_admin_user}
'''
class Parameters_User(Get_Many_Parameters_Base):
get_all_user: bool
get_inactive_user: bool
ids_user: str
ids_user_auth0: str
@staticmethod
def from_form(form):
av.val_instance(form, 'form', 'Parameters_User.from_form', Form_Filters_User)
get_inactive = av.input_bool(form.active.data, "active", "Parameters_User.from_form")
id_user = '' if form.id_user.data is None else form.id_user.data
return Parameters_User(
get_all_user = (id_user == ''),
get_inactive_user = get_inactive,
ids_user = id_user,
ids_user_auth0 = '',
)
@staticmethod
def from_user(user):
av.val_instance(user, 'user', 'Parameters_User.from_user', User)
return Parameters_User(
get_all_user = ((user.id_user is None or user.id_user == 0) and user.id_user_auth0 is None),
get_inactive_user = False,
ids_user = '' if user.id_user is None else str(user.id_user),
ids_user_auth0 = user.id_user_auth0,
)
@staticmethod
def get_default():
return Parameters_User(
get_all_user = False,
get_inactive_user = False,
ids_user = '',
ids_user_auth0 = ''
)
""" User_Eval
@dataclass
class User_Filters():
ids_user: str
get_inactive_users: bool
ids_permission: str
ids_access_level: str
ids_product: str
def to_json(self):
return {
**self.get_shared_json_attributes(self),
'a_ids_user': self.ids_user,
'a_get_inactive_users': self.get_inactive_users,
'a_ids_permission': self.ids_permission,
'a_ids_access_level': self.ids_access_level,
'a_ids_product': self.ids_product,
}
@staticmethod
def from_form(form):
av.val_instance(form, 'form', 'User_Filters.from_form', Form_Filters_User)
get_inactive = av.input_bool(form.active.data, "active", "User_Filters.from_form")
return User_Filters(
ids_user = form.id_user.data,
get_inactive_users = get_inactive,
ids_permission = form.ids_permission.data,
ids_access_level = form.ids_access_level.data,
ids_product = form.ids_product.data,
)
@staticmethod
def get_default(datastore_store):
is_user_logged_in, id_user = datastore_store.get_login_user()
return User_Filters(
ids_user = id_user,
get_inactive_users = False,
ids_permission = '',
ids_access_level = '',
ids_product = '',
)
"""
class User_Permission_Evaluation(db.Model):
id_evaluation = db.Column(db.Integer, primary_key=True)
guid = db.Column(db.String(255))
id_user = db.Column(db.Integer)
id_permission_required = db.Column(db.Integer)
priority_access_level_required = db.Column(db.Integer)
id_product = db.Column(db.Integer)
is_super_user = db.Column(db.Boolean)
priority_access_level_user = db.Column(db.Integer)
can_view = db.Column(db.Boolean)
can_edit = db.Column(db.Boolean)
can_admin = db.Column(db.Boolean)
def from_DB_user_eval(query_row):
user_permission_evaluation = User_Permission_Evaluation()
user_permission_evaluation.id_evaluation = query_row[0]
user_permission_evaluation.guid = query_row[1]
user_permission_evaluation.id_user = query_row[2]
user_permission_evaluation.id_permission_required = query_row[3]
user_permission_evaluation.priority_access_level_required = query_row[4]
user_permission_evaluation.id_product = query_row[5]
user_permission_evaluation.is_super_user = query_row[6]
user_permission_evaluation.priority_access_level_user = query_row[7]
user_permission_evaluation.can_view = query_row[8]
user_permission_evaluation.can_edit = query_row[9]
user_permission_evaluation.can_admin = query_row[10]
return user_permission_evaluation
def __repr__(self):
return f'''
id_evaluation: {self.id_evaluation}
guid: {self.guid}
id_user: {self.id_user}
id_permission_required: {self.id_permission_required}
priority_access_level_required: {self.priority_access_level_required}
id_product: {self.id_product}
is_super_user: {self.is_super_user}
priority_access_level_user: {self.priority_access_level_user}
can_view: {self.can_view}
can_edit: {self.can_edit}
can_admin: {self.can_admin}
'''
class User_Temp(db.Model, Base):
__tablename__ = 'Shop_User_Temp'
__table_args__ = { 'extend_existing': True }
id_user = db.Column(db.Integer, primary_key=True)
id_user_auth0 = db.Column(db.String(255))
firstname = db.Column(db.String(255))
surname = db.Column(db.String(255))
email = db.Column(db.String(255))
is_email_verified = db.Column(db.Boolean)
is_super_user = db.Column(db.Boolean)
id_currency_default = db.Column(db.Integer)
id_region_default = db.Column(db.Integer)
is_included_VAT_default = db.Column(db.Boolean)
# is_logged_in: bool
def __init__(self):
self.id_user = 0
self.is_logged_in = False
super().__init__()

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__)

View File

@@ -13,11 +13,8 @@ Datastore for Store
# internal
# from routes import bp_home
import lib.argument_validation as av
from business_objects.access_level import Access_Level
from business_objects.region import Region
from business_objects.sql_error import SQL_Error
from business_objects.unit_measurement import Unit_Measurement
from business_objects.user import User, Parameters_User, User_Permission_Evaluation
from business_objects.project_hub.user import User
# from helpers.helper_db_mysql import Helper_DB_MySQL
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
from extensions import db
@@ -25,52 +22,26 @@ from forms.access_level import Filters_Access_Level
from forms.unit_measurement import Filters_Unit_Measurement
from helpers.helper_app import Helper_App
# external
# from abc import ABC, abstractmethod, abstractproperty
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import text
import stripe
import os
from flask import Flask, session, current_app
from pydantic import BaseModel, ConfigDict
from typing import ClassVar
from datetime import datetime
import time
from sqlalchemy.exc import OperationalError
# db = SQLAlchemy()
class DataStore_Base(BaseModel):
# Global constants
# Attributes
"""
app: Flask = None
db: SQLAlchemy = None
session: object = None
"""
# model_config = ConfigDict(arbitrary_types_allowed=True)
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Constructor
"""
self.db = db
self.app = current_app
with self.app.app_context():
self.session = session
"""
@staticmethod
def db_procedure_execute(proc_name, argument_dict_list = None):
# Argument validation
_m = 'DataStore_Base.db_procedure_execute'
av.val_str(proc_name, 'proc_name', _m)
has_arguments = not str(type(argument_dict_list)) == "<class 'NoneType'>"
if has_arguments:
# av.val_list_instances(argument_dict_list, 'argument_dict_list', _m, dict)
pass
# Methods
proc_string = f'CALL {proc_name}('
has_arguments = not str(type(argument_dict_list)) == "<class 'NoneType'>"
if has_arguments:
arg_keys = list(argument_dict_list.keys())
for i in range(len(arg_keys)):
@@ -79,9 +50,6 @@ class DataStore_Base(BaseModel):
proc_string = text(proc_string)
Helper_App.console_log(f'{_m}\nproc_string: {proc_string}\nargs: {argument_dict_list}')
# with self.db.session.begin() as session:
# conn = Helper_DB_MySQL(self.app).get_db_connection()
if has_arguments:
result = db.session.execute(proc_string, argument_dict_list)
else:
@@ -94,60 +62,14 @@ class DataStore_Base(BaseModel):
def db_cursor_clear(cursor):
while cursor.nextset():
Helper_App.console_log(f'new result set: {cursor.fetchall()}')
@staticmethod
def get_user_session():
Helper_App.console_log('DataStore_Base.get_user_session')
user = User.from_json(session.get(User.FLAG_USER))
if user.is_logged_in:
filters_user = Parameters_User.get_default()
filters_user.ids_user = user.id_user
users = DataStore_Base.get_many_user(filters_user)
if user.id_user <= 0:
user.id_user = 3
return user
@classmethod
def get_many_user(cls, filters=None):
_m = 'DataStore_Store_Base.get_many_access_level'
user = User.from_json(session.get(User.FLAG_USER))
if filters is None:
filters_user = Parameters_User.get_default()
filters_user.ids_user = user.id_user if user.is_logged_in else None
av.val_instance(filters, 'filters', _m, Parameters_User)
argument_dict = filters.to_json()
argument_dict = {
'a_id_user': user.id_user,
'a_id_user_auth0': user.id_user_auth0,
**argument_dict,
'a_debug': 0,
}
Helper_App.console_log(f'argument_dict: {argument_dict}')
Helper_App.console_log('executing p_get_many_user')
result = cls.db_procedure_execute('p_get_many_user', argument_dict)
cursor = result.cursor
Helper_App.console_log('data received')
# users
result_set_1 = cursor.fetchall()
Helper_App.console_log(f'raw users: {result_set_1}')
users = []
for row in result_set_1:
new_user = User.from_DB_user(row)
users.append(new_user)
# Errors
cursor.nextset()
result_set_e = cursor.fetchall()
Helper_App.console_log(f'raw errors: {result_set_e}')
errors = []
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # (row[0], row[1])
for error in errors:
Helper_App.console_log(f"Error [{error.code}]: {error.msg}")
DataStore_Base.db_cursor_clear(cursor)
cursor.close()
return users, errors
@staticmethod
def upload_bulk(permanent_table_name, records, batch_size):
@@ -190,81 +112,3 @@ class DataStore_Base(BaseModel):
except Exception as e:
db.session.rollback()
raise e
@classmethod
def get_many_access_level(cls, filters=None):
_m = 'DataStore_Store_Base.get_many_access_level'
if filters is None:
filters = Filters_Access_Level()
av.val_instance(filters, 'filters', _m, Filters_Access_Level)
argument_dict = filters.to_json()
result = cls.db_procedure_execute('p_shop_get_many_access_level', argument_dict)
cursor = result.cursor
result_set_1 = cursor.fetchall()
access_levels = []
for row in result_set_1:
new_access_level = Access_Level.from_DB_access_level(row)
access_levels.append(new_access_level)
# Errors
cursor.nextset()
result_set_e = cursor.fetchall()
errors = []
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # (row[0], row[1])
for error in errors:
Helper_App.console_log(f"Error [{error.code}]: {error.msg}")
DataStore_Base.db_cursor_clear(cursor)
cursor.close()
return access_levels, errors
@classmethod
def get_many_unit_measurement(cls, filters=None):
_m = 'DataStore_Store_Base.get_many_unit_measurement'
if filters is None:
filters = Filters_Unit_Measurement()
av.val_instance(filters, 'filters', _m, Filters_Unit_Measurement)
argument_dict = filters.to_json()
result = cls.db_procedure_execute('p_shop_get_many_unit_measurement', argument_dict)
cursor = result.cursor
result_set_1 = cursor.fetchall()
units = []
for row in result_set_1:
new_unit = Unit_Measurement.from_DB_unit_measurement(row)
units.append(new_unit)
# Errors
cursor.nextset()
result_set_e = cursor.fetchall()
errors = []
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # (row[0], row[1])
for error in errors:
Helper_App.console_log(f"Error [{error.code}]: {error.msg}")
DataStore_Base.db_cursor_clear(cursor)
cursor.close()
return units, errors
@classmethod
def get_many_region(cls, get_inactive = False):
_m = 'DataStore_Store_Base.get_many_region'
_m_db_region = 'p_shop_get_many_region'
argument_dict_list_region = {
'a_get_inactive_region': 1 if get_inactive else 0
}
result = cls.db_procedure_execute(_m_db_region, argument_dict_list_region)
cursor = result.cursor
result_set_1 = cursor.fetchall()
regions = []
for row in result_set_1:
region = Region.from_DB_region(row)
regions.append(region)
DataStore_Base.db_cursor_clear(cursor)
cursor.close()
return regions

View File

@@ -1,147 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: DataStores
Feature: User DataStore
Description:
Datastore for Users
"""
# internal
# from routes import bp_home
import lib.argument_validation as av
from business_objects.sql_error import SQL_Error
from business_objects.user import User, Parameters_User, User_Permission_Evaluation
from datastores.datastore_base import DataStore_Base
from helpers.helper_app import Helper_App
from helpers.helper_db_mysql import Helper_DB_MySQL
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
from extensions import db
# external
# from abc import ABC, abstractmethod, abstractproperty
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import text
import stripe
import os
from flask import Flask, session, current_app
from pydantic import BaseModel, ConfigDict
from typing import ClassVar
from datetime import datetime
db = SQLAlchemy()
class DataStore_User(DataStore_Base):
# Global constants
# Attributes
def __init__(self):
super().__init__()
def edit_user(self):
_m = 'DataStore_User.edit_user'
argument_dict_list = {
'a_id_user': self.info_user.get('sub'),
'a_name': self.info_user.get('name'),
'a_email': self.info_user.get('email'),
'a_email_verified': 1 if self.info_user.get('email_verified') == 'True' else 0
}
result = self.db_procedure_execute('p_shop_edit_user', argument_dict_list)
cursor = result.cursor
result_set_1 = cursor.fetchall()
# Errors
cursor.nextset()
result_set_e = cursor.fetchall()
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # [SQL_Error(row[0], row[1]) for row in result_set_2]
for error in errors:
Helper_App.console_log(f"Error [{error.code}]: {error.msg}")
DataStore_User.db_cursor_clear(cursor)
return (result_set_1[0][1] == b'\x01')
def get_many_user(self, user_filters, user=None):
_m = 'DataStore_User.get_many_user'
av.val_instance(user_filters, 'user_filters', _m, Parameters_User)
guid = Helper_DB_MySQL.create_guid()
if user is None:
user = self.get_user_session()
argument_dict_list = {
# 'a_guid': guid
'a_id_user': user.id_user
, 'a_id_user_auth0': user.id_user_auth0
, **user_filters.to_json()
, 'a_debug': 0
}
result = self.db_procedure_execute('p_get_many_user', argument_dict_list)
cursor = result.cursor
result_set = cursor.fetchall()
users = []
if len(result_set) > 0:
for row in result_set:
Helper_App.console_log(f'row: {row}')
user = User.from_DB_user(row)
users.append(user)
Helper_App.console_log(f'user {str(type(user))}: {user}')
errors = []
cursor.nextset()
result_set_e = cursor.fetchall()
Helper_App.console_log(f'raw errors: {result_set_e}')
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # [SQL_Error(row[0], row[1]) for row in result_set_e]
for error in errors:
Helper_App.console_log(f"Error [{error.code}]: {error.msg}")
DataStore_User.db_cursor_clear(cursor)
return users, errors
def get_many_user(self, user_filters, user=None):
_m = 'DataStore_User.get_many_user'
av.val_instance(user_filters, 'user_filters', _m, Parameters_User)
guid = Helper_DB_MySQL.create_guid()
if user is None:
user = self.get_user_session()
argument_dict_list = {
# 'a_guid': guid
'a_id_user': user.id_user
, 'a_id_user_auth0': user.id_user_auth0
, **user_filters.to_json()
, 'a_debug': 0
}
result = self.db_procedure_execute('p_get_many_user', argument_dict_list)
cursor = result.cursor
result_set = cursor.fetchall()
users = []
if len(result_set) > 0:
for row in result_set:
Helper_App.console_log(f'row: {row}')
user = User.from_DB_user(row)
users.append(user)
Helper_App.console_log(f'user {str(type(user))}: {user}')
Helper_App.console_log(f'type users: {str(type(users))}\n type user 0: {str(type(None if len(users) == 0 else users[0]))}')
# error_list, cursor = self.get_error_list_from_cursor(cursor)
errors = []
cursor.nextset()
result_set_e = cursor.fetchall()
Helper_App.console_log(f'raw errors: {result_set_e}')
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # [SQL_Error(row[0], row[1]) for row in result_set_e]
for error in errors:
Helper_App.console_log(f"Error [{error.code}]: {error.msg}")
DataStore_User.db_cursor_clear(cursor)
return users, errors

View File

@@ -0,0 +1,113 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: DataStores
Feature: User DataStore
Description:
Datastore for Users
"""
# internal
# from routes import bp_home
import lib.argument_validation as av
from business_objects.sql_error import SQL_Error
from parts_website.business_objects.project_hub.contact_form import Contact_Form, Contact_Form_Temp
from datastores.datastore_base import DataStore_Base
from helpers.helper_app import Helper_App
from helpers.helper_db_mysql import Helper_DB_MySQL
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
from extensions import db
# external
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
db = SQLAlchemy()
class DataStore_Contact_Form(DataStore_Base):
def __init__(self):
super().__init__()
@classmethod
def get_many_contact_form(cls):
_m = f'{cls.__qualname__}.get_many_contact_form'
user = cls.get_user_session()
argument_dict = {
'a_id_user': user.id_user
, 'a_debug': 0
}
Helper_App.console_log(f'argument_dict: {argument_dict}')
result = cls.db_procedure_execute('p_ph_get_many_contact_form', argument_dict)
cursor = result.cursor
# Contact_Forms
result_set_1 = cursor.fetchall()
Helper_App.console_log(f'raw contact_forms: {result_set_1}')
contact_forms = []
contact_form_indexes = {}
for row in result_set_1:
new_contact_form = Contact_Form.from_DB_contact_form(row)
contact_form_indexes[new_contact_form.id_contact_form] = len(contact_forms)
contact_forms.append(new_contact_form)
# Errors
cursor.nextset()
result_set_e = cursor.fetchall()
Helper_App.console_log(f'raw errors: {result_set_e}')
errors = []
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e]
for error in errors:
Helper_App.console_log(f"Error [{error.code}]: {error.msg}")
cls.db_cursor_clear(cursor)
return contact_forms, errors
@classmethod
def save_contact_forms(cls, comment, contact_forms):
_m = f'{cls}.save_contact_forms'
av.val_str(comment, 'comment', _m)
guid = Helper_DB_MySQL.create_guid_str()
now = datetime.now()
user = cls.get_user_session()
Helper_App.console_log(f'saving contact forms: {contact_forms}')
rows = []
for contact_form in contact_forms:
row = Contact_Form_Temp.from_contact_form(contact_form)
row.guid = guid
rows.append(row)
cls.upload_bulk(Contact_Form_Temp.__tablename__, rows, 1000)
Helper_App.console_log('Contact Forms uploaded')
argument_dict_list = {
'a_comment': comment,
'a_guid': guid,
'a_id_user': user.id_user,
'a_debug': 0
}
result = cls.db_procedure_execute('p_ph_save_contact_form', argument_dict_list)
Helper_App.console_log('Contact Forms saved')
# Errors
cursor = result.cursor
cursor.nextset()
result_set_e = cursor.fetchall()
errors = []
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e]
for error in errors:
Helper_App.console_log(f"Error [{error.code}]: {error.msg}")
cls.db_cursor_clear(cursor)
return errors

View File

@@ -12,7 +12,8 @@ Defines Flask-WTF form for handling user input on Contact Us page.
# IMPORTS
# internal
# from business_objects.store.product_category import Filters_Product_Category # circular
from business_objects.base import Base
from business_objects.project_hub.contact_form import Contact_Form
# from models.model_view_store import Model_View_Store # circular
from models.model_view_base import Model_View_Base
from forms.base import Form_Base
@@ -85,3 +86,15 @@ class Form_Contact(FlaskForm):
# altcha = HiddenField('ALTCHA') # , validators=[validate_altcha]
altcha = ALTCHAField('Verify you are human')
submit = SubmitField('Send Message')
def to_json(self):
return {
Base.FLAG_EMAIL: self.email.data
, Contact_Form.FLAG_NAME_CONTACT: self.contact_name.data
, Contact_Form.FLAG_NAME_COMPANY: self.company_name.data
, Contact_Form.FLAG_MESSAGE: self.message.data
, Contact_Form.FLAG_RECEIVE_MARKETING_COMMUNICATIONS: self.receive_marketing.data
, Contact_Form.FLAG_ALTCHA: self.altcha.data
, Base.FLAG_ACTIVE: True
, Base.FLAG_CREATED_ON: None
}

View File

@@ -18,9 +18,10 @@ Base data model for views
# internal
# from routes import bp_home
from business_objects.base import Base
from business_objects.user import User, Parameters_User
from business_objects.project_hub.user import User
from parts_website.business_objects.project_hub.contact_form import Contact_Form
from datastores.datastore_base import DataStore_Base
from datastores.datastore_user import DataStore_User
from parts_website.datastores.project_hub.datastore_contact_form import DataStore_Contact_Form
from forms.access_level import Filters_Access_Level
from forms.forms import Form_Is_Included_VAT, Form_Delivery_Region, Form_Currency
from forms.unit_measurement import Filters_Unit_Measurement
@@ -35,37 +36,26 @@ from typing import ClassVar
class Model_View_Base(BaseModel, ABC):
# Global constants
# ATTR_FOR: ClassVar[str] = 'for'
ATTR_ID_ACCESS_LEVEL: ClassVar[str] = Base.ATTR_ID_ACCESS_LEVEL
ATTR_ID_ADDRESS: ClassVar[str] = Base.ATTR_ID_ADDRESS
ATTR_ID_CURRENCY: ClassVar[str] = Base.ATTR_ID_CURRENCY
ATTR_ID_REGION: ClassVar[str] = Base.ATTR_ID_REGION
ATTR_TEXT_COLLAPSED: ClassVar[str] = 'textCollapsed'
ATTR_TEXT_EXPANDED: ClassVar[str] = 'textExpanded'
ATTR_VALUE_CURRENT: ClassVar[str] = 'current-value'
ATTR_VALUE_PREVIOUS: ClassVar[str] = 'previous-value'
COMPANY_ADDRESS_SHORT: ClassVar[str] = '53 Alfred Green Close, Rugby, United Kingdom, CV22 6DN'
COMPANY_NUMBER: ClassVar[str] = '13587499'
ENDPOINT_GET_ALTCHA_CHALLENGE: ClassVar[str] = 'routes_core.create_altcha_challenge'
ENDPOINT_GET_ALTCHA_CHALLENGE: ClassVar[str] = 'routes_core_contact.create_altcha_challenge'
ENDPOINT_PAGE_ACCESSIBILITY_REPORT: ClassVar[str] = 'routes_legal.accessibility_report'
ENDPOINT_PAGE_ACCESSIBILITY_STATEMENT: ClassVar[str] = 'routes_legal.accessibility_statement'
ENDPOINT_PAGE_CONTACT: ClassVar[str] = 'routes_core.contact'
ENDPOINT_PAGE_CONTACT_SUCCESS: ClassVar[str] = 'routes_core.contact_success'
ENDPOINT_PAGE_CONTACT: ClassVar[str] = 'routes_core_contact.contact'
ENDPOINT_PAGE_CONTACT_SUCCESS: ClassVar[str] = 'routes_core_contact.contact_success'
ENDPOINT_PAGE_DATA_RETENTION_SCHEDULE: ClassVar[str] = 'routes_legal.retention_schedule'
ENDPOINT_PAGE_ERROR_NO_PERMISSION: ClassVar[str] = 'routes_core.error_no_permission'
ENDPOINT_PAGE_HOME: ClassVar[str] = 'routes_core.home'
ENDPOINT_PAGE_HOME: ClassVar[str] = 'routes_core_home.home'
ENDPOINT_PAGE_LICENSE: ClassVar[str] = 'routes_legal.license'
ENDPOINT_PAGE_PRIVACY_POLICY: ClassVar[str] = 'routes_legal.privacy_policy'
ENDPOINT_POST_CONTACT_FORM: ClassVar[str] = 'routes_core.contact_post'
FLAG_ACCESS_LEVEL: ClassVar[str] = 'access_level'
FLAG_ACCESS_LEVEL_REQUIRED: ClassVar[str] = Base.FLAG_ACCESS_LEVEL_REQUIRED
ENDPOINT_POST_CONTACT_FORM: ClassVar[str] = 'routes_core_contact.contact_post'
FLAG_ACTIVE: ClassVar[str] = Base.FLAG_ACTIVE
FLAG_ADD: ClassVar[str] = 'add'
# FLAG_ADD_DELETE: ClassVar[str] = 'add-delete'
FLAG_ADDRESS: ClassVar[str] = Base.FLAG_ADDRESS
FLAG_ADDRESS_LINE_1: ClassVar[str] = Base.FLAG_ADDRESS_LINE_1
FLAG_ADDRESS_LINE_2: ClassVar[str] = Base.FLAG_ADDRESS_LINE_2
FLAG_BOOL_FALSE: ClassVar[str] = 'false'
FLAG_BOOL_TRUE: ClassVar[str] = 'true'
FLAG_BUTTON: ClassVar[str] = 'button'
@@ -75,28 +65,24 @@ class Model_View_Base(BaseModel, ABC):
FLAG_CALLBACK: ClassVar[str] = 'callback'
FLAG_CAPTCHA: ClassVar[str] = 'captcha'
FLAG_CARD: ClassVar[str] = 'card'
FLAG_CITY: ClassVar[str] = Base.FLAG_CITY
FLAG_CLOSE_TEMPORARY_ELEMENT: ClassVar[str] = 'button-temporary-element-close'
FLAG_CODE: ClassVar[str] = Base.FLAG_CODE
FLAG_COLLAPSED: ClassVar[str] = 'collapsed'
FLAG_COLLAPSIBLE: ClassVar[str] = 'collapsible'
FLAG_COLUMN: ClassVar[str] = 'column'
FLAG_COMMENT: ClassVar[str] = 'comment'
# FLAG_CONTACT_US: ClassVar[str] = 'button-contact'
FLAG_CONTAINER: ClassVar[str] = 'container'
FLAG_CONTAINER_CHECKBOX: ClassVar[str] = 'container-checkbox'
FLAG_CONTAINER_ICON_AND_LABEL: ClassVar[str] = 'container-icon-label'
FLAG_CONTAINER_INPUT: ClassVar[str] = 'container-input'
FLAG_COUNTY: ClassVar[str] = Base.FLAG_COUNTY
FLAG_CSRF_TOKEN: ClassVar[str] = 'X-CSRFToken'
FLAG_CURRENCY: ClassVar[str] = 'currency'
FLAG_DATA: ClassVar[str] = 'data'
FLAG_DATE_FROM: ClassVar[str] = Base.FLAG_DATE_FROM
FLAG_DATE_TO: ClassVar[str] = Base.FLAG_DATE_TO
FLAG_DELETE: ClassVar[str] = 'delete'
FLAG_DESCRIPTION: ClassVar[str] = Base.FLAG_DESCRIPTION
FLAG_DETAIL: ClassVar[str] = 'detail'
FLAG_DIALOG: ClassVar[str] = 'dialog' # try <dialog> element
FLAG_DIALOG: ClassVar[str] = 'dialog'
FLAG_DIRTY: ClassVar[str] = 'dirty'
FLAG_DISPLAY_ORDER: ClassVar[str] = Base.FLAG_DISPLAY_ORDER
FLAG_EDIT: ClassVar[str] = 'edit'
@@ -104,17 +90,15 @@ class Model_View_Base(BaseModel, ABC):
FLAG_ERROR: ClassVar[str] = 'error'
FLAG_EXPANDED: ClassVar[str] = 'expanded'
FLAG_FAILURE: ClassVar[str] = 'failure'
FLAG_FAX: ClassVar[str] = Base.FLAG_FAX
FLAG_FILTER: ClassVar[str] = 'filter'
FLAG_FORM: ClassVar[str] = 'form'
FLAG_FORM_FILTERS: ClassVar[str] = 'form-filters'
FLAG_HAMBURGER: ClassVar[str] = 'hamburger'
FLAG_IMAGE_LOGO: ClassVar[str] = 'image-logo'
FLAG_INITIALISED: ClassVar[str] = 'initialised'
FLAG_IS_INCLUDED_VAT: ClassVar[str] = 'is_included_VAT'
FLAG_LEFT_HAND_STUB: ClassVar[str] = 'lhs'
FLAG_LOGO: ClassVar[str] = 'logo'
FLAG_MESSAGE: ClassVar[str] = 'message'
FLAG_MESSAGE: ClassVar[str] = Contact_Form.FLAG_MESSAGE
FLAG_MODAL: ClassVar[str] = 'modal'
FLAG_NAME: ClassVar[str] = Base.FLAG_NAME
FLAG_NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME_ATTR_OPTION_TEXT
@@ -125,8 +109,6 @@ class Model_View_Base(BaseModel, ABC):
FLAG_NAV_HOME: ClassVar[str] = 'navHome'
FLAG_OVERLAY: ClassVar[str] = 'overlay'
FLAG_PAGE_BODY: ClassVar[str] = 'page-body'
FLAG_PHONE_NUMBER: ClassVar[str] = Base.FLAG_PHONE_NUMBER
FLAG_POSTCODE: ClassVar[str] = Base.FLAG_POSTCODE
FLAG_RIGHT_HAND_SIDE: ClassVar[str] = 'rhs'
FLAG_ROW: ClassVar[str] = 'row'
FLAG_ROW_NEW: ClassVar[str] = 'row-new'
@@ -136,7 +118,6 @@ class Model_View_Base(BaseModel, ABC):
FLAG_SLIDER: ClassVar[str] = 'slider'
FLAG_STATUS: ClassVar[str] = 'status'
FLAG_SUBMIT: ClassVar[str] = 'submit'
FLAG_SUBMITTED: ClassVar[str] = 'submitted'
FLAG_SUCCESS: ClassVar[str] = 'success'
FLAG_TEMPORARY_ELEMENT: ClassVar[str] = 'temporary-element'
FLAG_USER: ClassVar[str] = User.FLAG_USER
@@ -195,9 +176,9 @@ class Model_View_Base(BaseModel, ABC):
self.is_page_store = False
Helper_App.console_log(f'session: {self.session}')
datastore_user = DataStore_User()
self.user = datastore_user.get_user_session()
self.is_user_logged_in = self.user.is_logged_in
datastore_base = DataStore_Base()
self.user = datastore_base.get_user_session()
self.is_user_logged_in = self.user.get_is_logged_in()
# Helper_App.console_log(f'model_view_base init end - model.user: {self.user}')
def output_bool(self, boolean):

View File

@@ -11,6 +11,7 @@ Data model for contact view
"""
# internal
from business_objects.project_hub.contact_form import Contact_Form
from models.model_view_base import Model_View_Base
# from routes import bp_home
from lib import argument_validation as av
@@ -22,11 +23,6 @@ from pydantic import BaseModel
from typing import ClassVar
class Model_View_Contact(Model_View_Base):
FLAG_ALTCHA_WIDGET: ClassVar[str] = 'altcha-widget'
FLAG_COMPANY_NAME: ClassVar[str] = 'company_name'
FLAG_CONTACT_NAME: ClassVar[str] = 'contact_name'
FLAG_RECEIVE_MARKETING: ClassVar[str] = 'receive_marketing'
ID_CONTACT_FORM: ClassVar[str] = 'contact-form'
form_contact: Form_Contact

View File

@@ -1,40 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: User View Model
Description:
Data model for user view
"""
# internal
from datastores.datastore_user import DataStore_User
from models.model_view_base import Model_View_Base
# from routes import bp_home
# external
from typing import ClassVar
class Model_View_User(Model_View_Base):
FLAG_ERROR_OAUTH: ClassVar[str] = 'error'
FLAG_ERROR_DESCRIPTION_OAUTH: ClassVar[str] = 'error_description'
FLAG_FIRSTNAME: ClassVar[str] = 'firstname'
FLAG_SURNAME: ClassVar[str] = 'surname'
FLAG_STATE_OAUTH: ClassVar[str] = 'state'
# Attributes
currencies: list = None
regions: list = None
users: list = None
@property
def title(self):
return 'User'
def __init__(self, hash_page_current=Model_View_Base.HASH_PAGE_USER_ACCOUNT):
# Constructor
super().__init__(hash_page_current=hash_page_current, form_filters_old = None)
datastore_user = DataStore_User()
self.currencies = datastore_user.get_many_currency()
self.regions = datastore_user.get_many_region()

BIN
packages-microsoft-prod.deb Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,337 +1,71 @@
/* Clear Store DataBase */
USE partsltd_prod;
-- Permanent Temp Tables
DROP TABLE IF EXISTS partsltd_prod.tmp_ph_Calc_User;
DROP TABLE IF EXISTS partsltd_prod.tmp_core_Msg_Error;
DROP TABLE IF EXISTS partsltd_prod.tmp_ph_User;
DROP TABLE IF EXISTS partsltd_prod.tmp_ph_User_Role_Link;
-- Drop dependencies
DROP TABLE IF EXISTS tmp_Shop_Calc_User;
DROP TABLE IF EXISTS tmp_Product_Calc_User;
DROP TABLE IF EXISTS tmp_Product_p_Shop_User_Eval;
DROP TABLE IF EXISTS tmp_Msg_Error;
DROP TABLE IF EXISTS tmp_Currency;
DROP TABLE IF EXISTS tmp_Delivery_Option;
DROP TABLE IF EXISTS tmp_Delivery_Region;
DROP TABLE IF EXISTS tmp_Region;
DROP TABLE IF EXISTS tmp_Price;
DROP TABLE IF EXISTS tmp_Shop_User;
DROP TABLE IF EXISTS tmp_Shop_Order;
DROP TABLE IF EXISTS tmp_Shop_Product;
DROP TABLE IF EXISTS tmp_Product;
DROP TABLE IF EXISTS tmp_Product_Permutation;
DROP TABLE IF EXISTS tmp_Permutation_Variation_Link;
DROP TABLE IF EXISTS tmp_Permutation;
DROP TABLE IF EXISTS tmp_Shop_Product_p_shop_calc_user;
DROP TABLE IF EXISTS tmp_Shop_Product_p_Shop_Calc_User;
DROP TABLE IF EXISTS tmp_Shop_Image;
DROP TABLE IF EXISTS tmp_Image;
DROP TABLE IF EXISTS tmp_Product_Image;
DROP TABLE IF EXISTS tmp_Shop_Variation;
DROP TABLE IF EXISTS tmp_Variation;
DROP TABLE IF EXISTS tmp_Variation_Type;
DROP TABLE IF EXISTS tmp_Shop_Discount;
DROP TABLE IF EXISTS tmp_Discount;
DROP TABLE IF EXISTS tmp_Shop_Category;
DROP TABLE IF EXISTS tmp_Category;
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
DROP TABLE IF EXISTS tmp_Product_Category;
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Region_Link;
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Link;
DROP TABLE IF EXISTS tmp_User_Role_Link;
DROP TABLE IF EXISTS tmp_Shop_Basket;
DROP TABLE IF EXISTS tmp_Shop_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Shop_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Shop_Supplier;
DROP TABLE IF EXISTS tmp_Supplier;
DROP TABLE IF EXISTS tmp_Supplier_Address;
DROP TABLE IF EXISTS tmp_Shop_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Shop_Manufacturing_Purchase_Order;
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TABLE IF EXISTS tmp_Shop_Customer;
DROP TABLE IF EXISTS tmp_Shop_Customer_Sale_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Shop_Customer_Sale_Order;
DROP TABLE IF EXISTS tmp_Get_Variation_From_Csv_Variations;
-- Permanent Tables
DROP TABLE IF EXISTS partsltd_prod.PH_Contact_Form_Temp;
DROP TABLE IF EXISTS partsltd_prod.PH_Contact_Form_Audit;
DROP TABLE IF EXISTS partsltd_prod.PH_Contact_Form;
DROP TABLE IF EXISTS partsltd_prod.PH_Contact_Form_Change_Set;
-- Delete old tables
DROP TABLE IF EXISTS Split_Temp;
DROP TABLE IF EXISTS Split_Key_Value_Pair_Csv_Temp;
DROP TABLE IF EXISTS Split_Key_Value_Pair_Temp;
DROP TABLE IF EXISTS partsltd_prod.PH_Calc_User_Temp;
DROP TABLE IF EXISTS Shop_User_Eval_Temp;
DROP TABLE IF EXISTS Shop_Calc_User_Temp;
DROP TABLE IF EXISTS partsltd_prod.PH_User_Role_Link_Audit;
DROP TABLE IF EXISTS partsltd_prod.PH_User_Role_Link;
DROP TABLE IF EXISTS Shop_Customer_Sales_Order_Product_Link_Temp;
DROP TABLE IF EXISTS Shop_Customer_Sales_Order_Product_Link_Audit;
DROP TABLE IF EXISTS Shop_Customer_Sales_Order_Product_Link;
DROP TABLE IF EXISTS partsltd_prod.PH_Role_Permission_Link_Audit;
DROP TABLE IF EXISTS partsltd_prod.PH_Role_Permission_Link;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Audit;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS partsltd_prod.PH_Role_Audit;
DROP TABLE IF EXISTS partsltd_prod.PH_Role;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Product_Link_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Product_Link_Audit;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS partsltd_prod.PH_User_Temp;
DROP TABLE IF EXISTS partsltd_prod.PH_User_Audit;
DROP TABLE IF EXISTS partsltd_prod.PH_User;
DROP TABLE IF EXISTS Shop_Stock_Item_Temp;
DROP TABLE IF EXISTS Shop_Stock_Item_Audit;
DROP TABLE IF EXISTS Shop_Stock_Item;
DROP TABLE IF EXISTS partsltd_prod.PH_Permission_Audit;
DROP TABLE IF EXISTS partsltd_prod.PH_Permission;
DROP TABLE IF EXISTS Shop_Customer_Sales_Order_Audit;
DROP TABLE IF EXISTS Shop_Customer_Sales_Order;
DROP TABLE IF EXISTS partsltd_prod.PH_Permission_Group_Audit;
DROP TABLE IF EXISTS partsltd_prod.PH_Permission_Group;
DROP TABLE IF EXISTS Shop_Customer_Temp;
DROP TABLE IF EXISTS Shop_Customer_Audit;
DROP TABLE IF EXISTS Shop_Customer;
DROP TABLE IF EXISTS partsltd_prod.PH_Access_Level_Audit;
DROP TABLE IF EXISTS partsltd_prod.PH_Access_Level;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Temp;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Audit;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order;
DROP TABLE IF EXISTS partsltd_prod.PH_User_Change_Set;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Audit;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order;
DROP TABLE IF EXISTS partsltd_prod.CORE_Split_Key_Value_Pair_Csv_Temp;
DROP TABLE IF EXISTS partsltd_prod.CORE_Split_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Address_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Address_Audit;
DROP TABLE IF EXISTS Shop_Supplier_Address;
DROP TABLE IF EXISTS partsltd_prod.CORE_Msg_Error_Type;
DROP TABLE IF EXISTS Shop_Supplier_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Audit;
DROP TABLE IF EXISTS Shop_Supplier;
-- Stored Procedures
DROP PROCEDURE IF EXISTS partsltd_prod.p_ph_test_get_many_contact_form;
DROP PROCEDURE IF EXISTS partsltd_prod.p_ph_get_many_contact_form;
DROP PROCEDURE IF EXISTS partsltd_prod.p_ph_test_save_contact_form;
DROP PROCEDURE IF EXISTS partsltd_prod.p_ph_save_contact_form;
DROP TABLE IF EXISTS Shop_User_Order_Product_Link_Audit;
DROP TABLE IF EXISTS Shop_User_Order_Product_Link;
DROP PROCEDURE IF EXISTS partsltd_prod.p_ph_clear_calc_user;
DROP PROCEDURE IF EXISTS partsltd_prod.p_ph_calc_user;
DROP TABLE IF EXISTS Shop_User_Order_Audit;
DROP TABLE IF EXISTS Shop_User_Order;
DROP PROCEDURE IF EXISTS partsltd_prod.p_core_clear_split_key_value_pair_csv;
DROP PROCEDURE IF EXISTS partsltd_prod.p_core_split_key_value_pair_csv;
DROP PROCEDURE IF EXISTS partsltd_prod.p_core_clear_split;
DROP PROCEDURE IF EXISTS partsltd_prod.p_core_split;
DROP PROCEDURE IF EXISTS partsltd_prod.p_clear_split_key_value_pair_csv;
DROP PROCEDURE IF EXISTS partsltd_prod.p_split_key_value_pair_csv;
DROP PROCEDURE IF EXISTS partsltd_prod.p_clear_split;
DROP PROCEDURE IF EXISTS partsltd_prod.p_split;
DROP TABLE IF EXISTS Shop_User_Order_Status_Audit;
DROP TABLE IF EXISTS Shop_User_Order_Status;
DROP TABLE IF EXISTS Shop_User_Basket_Audit;
DROP TABLE IF EXISTS Shop_User_Basket;
DROP TABLE IF EXISTS Shop_User_Address_Audit;
DROP TABLE IF EXISTS Shop_User_Address;
DROP TABLE IF EXISTS Shop_User_Role_Link_Audit;
DROP TABLE IF EXISTS Shop_User_Role_Link;
DROP TABLE IF EXISTS Shop_User_Temp;
DROP TABLE IF EXISTS Shop_User_Audit;
DROP TABLE IF EXISTS Shop_User;
DROP TABLE IF EXISTS Shop_Role_Permission_Link_Audit;
DROP TABLE IF EXISTS Shop_Role_Permission_Link;
DROP TABLE IF EXISTS Shop_Role_Audit;
DROP TABLE IF EXISTS Shop_Role;
DROP TABLE IF EXISTS Shop_Permission_Audit;
DROP TABLE IF EXISTS Shop_Permission;
DROP TABLE IF EXISTS Shop_Permission_Group_Audit;
DROP TABLE IF EXISTS Shop_Permission_Group;
DROP TABLE IF EXISTS Shop_Discount_Region_Currency_Link_Audit;
DROP TABLE IF EXISTS Shop_Discount_Region_Currency_Link;
DROP TABLE IF EXISTS Shop_Discount_Audit;
DROP TABLE IF EXISTS Shop_Discount;
DROP TABLE IF EXISTS Shop_Product_Permutation_Delivery_Option_Link_Audit;
DROP TABLE IF EXISTS Shop_Product_Permutation_Delivery_Option_Link;
DROP TABLE IF EXISTS Shop_Product_Delivery_Option_Link_Audit;
DROP TABLE IF EXISTS Shop_Product_Delivery_Option_Link;
DROP TABLE IF EXISTS Shop_Delivery_Option_Audit;
DROP TABLE IF EXISTS Shop_Delivery_Option;
DROP TABLE IF EXISTS Shop_Product_Image_Audit;
DROP TABLE IF EXISTS Shop_Product_Image;
DROP TABLE IF EXISTS Shop_Image_Audit;
DROP TABLE IF EXISTS Shop_Image;
DROP TABLE IF EXISTS Shop_Product_Price_Temp;
DROP TABLE IF EXISTS Shop_Product_Price_Audit;
DROP TABLE IF EXISTS Shop_Product_Price;
DROP TABLE IF EXISTS Shop_Product_Currency_Region_Link_Audit;
DROP TABLE IF EXISTS Shop_Product_Currency_Region_Link;
DROP TABLE IF EXISTS Shop_Product_Currency_Link_Audit;
DROP TABLE IF EXISTS Shop_Product_Currency_Link;
DROP TABLE IF EXISTS Shop_Product_Variation_Link_Audit;
DROP TABLE IF EXISTS Shop_Product_Variation_Link;
DROP TABLE IF EXISTS Shop_Product_Permutation_Variation_Link_Temp;
DROP TABLE IF EXISTS Shop_Product_Permutation_Variation_Link_Audit;
DROP TABLE IF EXISTS Shop_Product_Permutation_Variation_Link;
DROP TABLE IF EXISTS Shop_Variation_Temp;
DROP TABLE IF EXISTS Shop_Variation_Audit;
DROP TABLE IF EXISTS Shop_Variation;
DROP TABLE IF EXISTS Shop_Product_Variation_Type_Link_Audit;
DROP TABLE IF EXISTS Shop_Product_Variation_Type_Link;
DROP TABLE IF EXISTS Shop_Product_Variation_Temp;
DROP TABLE IF EXISTS Shop_Product_Variation;
DROP TABLE IF EXISTS Shop_Variation_Type_Temp;
DROP TABLE IF EXISTS Shop_Variation_Type_Audit;
DROP TABLE IF EXISTS Shop_Variation_Type;
DROP TABLE IF EXISTS Shop_Product_Variation_Type_Temp;
DROP TABLE IF EXISTS Shop_Product_Variation_Type;
DROP TABLE IF EXISTS Shop_Product_Permutation_Temp;
DROP TABLE IF EXISTS Shop_Product_Permutation_Audit;
DROP TABLE IF EXISTS Shop_Product_Permutation;
DROP TABLE IF EXISTS Shop_Interval_Recurrence_Audit;
DROP TABLE IF EXISTS Shop_Interval_Recurrence;
DROP TABLE IF EXISTS Shop_Product_Audit;
DROP TABLE IF EXISTS Shop_Product;
DROP TABLE IF EXISTS Shop_Product_Temp;
DROP TABLE IF EXISTS Shop_Product_Category_Temp;
DROP TABLE IF EXISTS Shop_Product_Category_Audit;
DROP TABLE IF EXISTS Shop_Product_Category;
DROP TABLE IF EXISTS Shop_Category_Audit;
DROP TABLE IF EXISTS Shop_Category;
DROP TABLE IF EXISTS Shop_Tax_Or_Surcharge_Temp;
DROP TABLE IF EXISTS Shop_Tax_Or_Surcharge_Audit;
DROP TABLE IF EXISTS Shop_Tax_Or_Surcharge;
DROP TABLE IF EXISTS Shop_Currency_Temp;
DROP TABLE IF EXISTS Shop_Currency_Audit;
DROP TABLE IF EXISTS Shop_Currency;
DROP TABLE IF EXISTS Shop_Storage_Location_Branch_Temp;
DROP TABLE IF EXISTS Shop_Storage_Location_Branch_Audit;
DROP TABLE IF EXISTS Shop_Storage_Location_Branch;
DROP TABLE IF EXISTS Shop_Storage_Location_Temp;
DROP TABLE IF EXISTS Shop_Storage_Location_Audit;
DROP TABLE IF EXISTS Shop_Storage_Location;
DROP TABLE IF EXISTS Shop_Plant_Temp;
DROP TABLE IF EXISTS Shop_Plant_Audit;
DROP TABLE IF EXISTS Shop_Plant;
DROP TABLE IF EXISTS Shop_Address_Audit;
DROP TABLE IF EXISTS Shop_Address;
DROP TABLE IF EXISTS Shop_Delivery_Region_Branch_Audit;
DROP TABLE IF EXISTS Shop_Delivery_Region_Branch;
DROP TABLE IF EXISTS Shop_Region_Branch_Temp;
DROP TABLE IF EXISTS Shop_Region_Branch_Audit;
DROP TABLE IF EXISTS Shop_Region_Branch;
DROP TABLE IF EXISTS Shop_Delivery_Region_Audit;
DROP TABLE IF EXISTS Shop_Delivery_Region;
DROP TABLE IF EXISTS Shop_Region_Temp;
DROP TABLE IF EXISTS Shop_Region_Audit;
DROP TABLE IF EXISTS Shop_Region;
DROP TABLE IF EXISTS Shop_Unit_Measurement_Conversion_Audit;
DROP TABLE IF EXISTS Shop_Unit_Measurement_Conversion;
DROP TABLE IF EXISTS Shop_Unit_Measurement_Audit;
DROP TABLE IF EXISTS Shop_Unit_Measurement;
DROP TABLE IF EXISTS Shop_Image_Type_Audit;
DROP TABLE IF EXISTS Shop_Image_Type;
DROP TABLE IF EXISTS Shop_General_Audit;
DROP TABLE IF EXISTS Shop_General;
DROP TABLE IF EXISTS File_Type_Audit;
DROP TABLE IF EXISTS File_Type;
DROP TABLE IF EXISTS Msg_Error_Type;
DROP TABLE IF EXISTS Shop_Msg_Error_Type;
DROP TABLE IF EXISTS Shop_Access_Level_Audit;
DROP TABLE IF EXISTS Shop_Access_Level;
DROP TABLE IF EXISTS Shop_Sales_And_Purchasing_Change_Set;
DROP TABLE IF EXISTS Shop_User_Change_Set;
DROP TABLE IF EXISTS Shop_Product_Change_Set;
-- Procedures
DROP PROCEDURE IF EXISTS p_split;
DROP PROCEDURE IF EXISTS p_clear_split_temp;
DROP PROCEDURE IF EXISTS p_split_key_value_pair_csv;
DROP PROCEDURE IF EXISTS p_clear_split_key_value_csv_temp;
DROP PROCEDURE IF EXISTS p_clear_split_key_value_pair_csv_temp;
DROP PROCEDURE IF EXISTS p_debug_timing_reporting;
DROP PROCEDURE IF EXISTS p_validate_guid;
DROP PROCEDURE IF EXISTS p_validate_guid_test;
DROP FUNCTION IF EXISTS fn_shop_get_product_permutation_name;
DROP PROCEDURE IF EXISTS p_shop_calc_user;
DROP PROCEDURE IF EXISTS p_shop_calc_user;
DROP PROCEDURE IF EXISTS p_shop_clear_user_eval_temp;
DROP PROCEDURE IF EXISTS p_shop_clear_calc_user;
DROP PROCEDURE IF EXISTS p_shop_get_many_access_level;
DROP PROCEDURE IF EXISTS p_shop_get_many_unit_measurement;
DROP PROCEDURE IF EXISTS p_shop_get_many_region;
DROP PROCEDURE IF EXISTS p_shop_get_many_plant;
DROP PROCEDURE IF EXISTS p_shop_get_many_storage_location;
DROP PROCEDURE IF EXISTS p_shop_get_many_currency;
DROP PROCEDURE IF EXISTS p_shop_save_category;
DROP PROCEDURE IF EXISTS p_shop_save_category_test;
DROP PROCEDURE IF EXISTS p_shop_save_product_category;
DROP PROCEDURE IF EXISTS p_shop_save_product_category_test;
DROP PROCEDURE IF EXISTS p_shop_save_product;
DROP PROCEDURE IF EXISTS p_shop_save_product_test;
DROP PROCEDURE IF EXISTS p_shop_calc_product_permutation;
DROP PROCEDURE IF EXISTS p_shop_clear_calc_product_permutation;
DROP PROCEDURE IF EXISTS p_shop_get_many_product;
DROP PROCEDURE IF EXISTS p_shop_get_many_stripe_product_new;
DROP PROCEDURE IF EXISTS p_shop_save_permutation;
DROP PROCEDURE IF EXISTS p_shop_save_product_permutation;
DROP PROCEDURE IF EXISTS p_shop_save_product_permutation_test;
DROP PROCEDURE IF EXISTS p_shop_save_product_variation;
DROP PROCEDURE IF EXISTS p_shop_save_product_variation_test;
DROP PROCEDURE IF EXISTS p_shop_get_many_product_variation;
DROP FUNCTION IF EXISTS fn_shop_get_id_product_permutation_from_variation_csv_list;
DROP FUNCTION IF EXISTS fn_shop_get_product_variations_from_id_csv_list;
DROP FUNCTION IF EXISTS fn_shop_get_product_permutation_variations_csv;
DROP PROCEDURE IF EXISTS p_shop_save_stock_item;
DROP PROCEDURE IF EXISTS p_shop_save_stock_item_test;
DROP PROCEDURE IF EXISTS p_shop_get_many_stock_item;
DROP PROCEDURE IF EXISTS p_shop_get_many_product_price_and_discount_and_delivery_option;
DROP PROCEDURE IF EXISTS p_shop_get_many_product_price_and_discount_and_delivery_option;
DROP PROCEDURE IF EXISTS p_shop_get_many_stripe_price_new;
DROP PROCEDURE IF EXISTS p_shop_save_user;
DROP PROCEDURE IF EXISTS p_shop_edit_user;
DROP PROCEDURE IF EXISTS p_shop_get_many_user;
DROP PROCEDURE IF EXISTS p_get_many_user;
DROP PROCEDURE IF EXISTS p_shop_get_many_user_basket;
DROP PROCEDURE IF EXISTS p_shop_edit_user_basket;
DROP PROCEDURE IF EXISTS p_shop_save_supplier;
DROP PROCEDURE IF EXISTS p_shop_save_supplier_test;
DROP PROCEDURE IF EXISTS p_shop_get_many_supplier;
DROP PROCEDURE IF EXISTS p_shop_save_supplier_purchase_order;
DROP PROCEDURE IF EXISTS p_shop_save_supplier_purchase_order_test;
DROP PROCEDURE IF EXISTS p_shop_get_many_supplier_purchase_order;
DROP PROCEDURE IF EXISTS p_shop_save_manufacturing_purchase_order;
DROP PROCEDURE IF EXISTS p_shop_save_manufacturing_purchase_order_test;
DROP PROCEDURE IF EXISTS p_shop_get_many_manufacturing_purchase_order;
DROP PROCEDURE IF EXISTS p_shop_save_customer;
DROP PROCEDURE IF EXISTS p_shop_get_many_customer;
DROP PROCEDURE IF EXISTS p_shop_save_customer_sales_order;
DROP PROCEDURE IF EXISTS p_shop_get_many_customer_sales_order;
DROP PROCEDURE IF EXISTS partsltd_prod.p_core_debug_timing_reporting;
DROP PROCEDURE IF EXISTS partsltd_prod.p_debug_timing_reporting;
DROP PROCEDURE IF EXISTS partsltd_prod.p_core_validate_guid;
DROP PROCEDURE IF EXISTS partsltd_prod.p_core_validate_guid_test;

View File

@@ -0,0 +1,16 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'CORE_Msg_Error_Type'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.CORE_Msg_Error_Type (
id_type INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, code VARCHAR(50) NOT NULL
, name VARCHAR(500) NOT NULL
, description VARCHAR(1000)
);

View File

@@ -1,13 +0,0 @@
-- Product Change Sets
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Change_Set';
CREATE TABLE Shop_Product_Change_Set (
id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
comment VARCHAR(500),
updated_last_on DATETIME,
updated_last_by VARCHAR(100)
);

View File

@@ -1,12 +0,0 @@
-- Split Staging
-- USE partsltd_prod;
-- DROP TABLE IF EXISTS Split_Temp;
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Split_Temp';
CREATE TABLE Split_Temp (
guid BINARY(36) NOT NULL
, display_order INT NOT NULL
, substring VARCHAR(4000) NOT NULL
);

View File

@@ -1,13 +0,0 @@
-- User Change Sets
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_User_Change_Set';
CREATE TABLE IF NOT EXISTS Shop_User_Change_Set (
id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
comment VARCHAR(500),
updated_last_on DATETIME,
updated_last_by VARCHAR(100)
);

View File

@@ -1,13 +0,0 @@
-- Split Key Value Pair CSV Staging
-- USE partsltd_prod;
-- DROP TABLE IF EXISTS Split_Temp;
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Split_Key_Value_Pair_Csv_Temp';
CREATE TABLE Split_Key_Value_Pair_Csv_Temp (
guid BINARY(36) NOT NULL
, id INT NOT NULL
, key_column VARCHAR(4000) NULL
, value_column VARCHAR(4000) NULL
);

View File

@@ -1,13 +0,0 @@
-- Sales And Purchasing Change Sets
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Sales_And_Purchasing_Change_Set';
CREATE TABLE Shop_Sales_And_Purchasing_Change_Set (
id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
comment VARCHAR(500),
updated_last_on DATETIME,
updated_last_by VARCHAR(100)
);

View File

@@ -1,23 +0,0 @@
-- Access Levels
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Access_Level';
CREATE TABLE IF NOT EXISTS Shop_Access_Level (
id_access_level INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
code VARCHAR(50),
name VARCHAR(255),
priority INT NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Access_Level_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_User_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Access Level Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Access_Level_Audit';
CREATE TABLE IF NOT EXISTS Shop_Access_Level_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_access_level INT NOT NULL,
CONSTRAINT FK_Shop_Access_Level_Audit_id_access_level
FOREIGN KEY (id_access_level)
REFERENCES Shop_Access_Level(id_access_level)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Access_Level_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_User_Change_Set(id_change_set)
);

View File

@@ -1,13 +0,0 @@
-- Error Message Type
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Msg_Error_Type';
CREATE TABLE IF NOT EXISTS Shop_Msg_Error_Type (
id_type INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
code VARCHAR(50) NOT NULL,
name VARCHAR(500) NOT NULL,
description VARCHAR(1000)
);

View File

@@ -1,17 +0,0 @@
-- File Types
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'File_Type';
CREATE TABLE IF NOT EXISTS File_Type (
id_type INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
code VARCHAR(50),
name VARCHAR(100),
extension VARCHAR(50),
created_on DATETIME,
created_by INT,
updated_last_on DATETIME,
updated_last_by VARCHAR(100)
);

View File

@@ -1,22 +0,0 @@
-- File Type Audit
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'File_Type_Audit';
CREATE TABLE IF NOT EXISTS File_Type_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_type INT NOT NULL,
CONSTRAINT FK_File_Type_Audit_id_type
FOREIGN KEY (id_type)
REFERENCES File_Type(id_type)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
created_on DATETIME,
created_by INT,
updated_last_on DATETIME,
updated_last_by VARCHAR(100)
);

View File

@@ -1,17 +0,0 @@
-- Generic / shared properties
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_General';
CREATE TABLE IF NOT EXISTS Shop_General (
id_general INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
quantity_max FLOAT,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT CHK_Shop_General_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Shop General Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_General_Audit';
CREATE TABLE IF NOT EXISTS Shop_General_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_general INT NOT NULL,
CONSTRAINT FK_Shop_General_Audit_id_general
FOREIGN KEY (id_general)
REFERENCES Shop_General(id_general)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_General_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,27 +0,0 @@
-- Image Types
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Image_Type';
CREATE TABLE IF NOT EXISTS Shop_Image_Type (
id_type INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
/*
id_type_file INT NOT NULL,
CONSTRAINT FK_Shop_Image_Type_id_type_file
FOREIGN KEY (id_type_file)
REFERENCES File_Type(id_type),
*/
code VARCHAR(50),
name VARCHAR(255),
name_plural VARCHAR(256),
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Image_Type_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Image Type Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Image_Type_Audit';
CREATE TABLE IF NOT EXISTS Shop_Image_Type_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_type INT NOT NULL,
CONSTRAINT FK_Shop_Image_Type_Audit_id_type
FOREIGN KEY (id_type)
REFERENCES Shop_Image_Type(id_type)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Image_Type_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,15 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'CORE_Split_Temp'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.CORE_Split_Temp (
guid BINARY(36) NOT NULL
, display_order INT NOT NULL
, substring VARCHAR(4000) NOT NULL
);

View File

@@ -0,0 +1,16 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'CORE_Split_Key_Value_Pair_Csv_Temp'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.CORE_Split_Key_Value_Pair_Csv_Temp (
guid BINARY(36) NOT NULL
, id INT NOT NULL
, key_column VARCHAR(4000) NULL
, value_column VARCHAR(4000) NULL
);

View File

@@ -0,0 +1,16 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_User_Change_Set'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_User_Change_Set (
id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, comment VARCHAR(500)
, updated_last_on DATETIME
, id_user_updated_last_by INT
);

View File

@@ -1,18 +0,0 @@
-- Regions
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Region';
CREATE TABLE IF NOT EXISTS Shop_Region (
id_region INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
code VARCHAR(50) NOT NULL,
name VARCHAR(200) NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Region_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Region Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Region_Audit';
CREATE TABLE IF NOT EXISTS Shop_Region_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_region INT NOT NULL,
CONSTRAINT FK_Shop_Region_Audit_id_region
FOREIGN KEY (id_region)
REFERENCES Shop_Region(id_region)
ON UPDATE RESTRICT,
name_field VARCHAR(64) NOT NULL,
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Region_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,20 +0,0 @@
-- Region Temp
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Region_Temp';
CREATE TABLE IF NOT EXISTS Shop_Region_Temp (
id_region INT NOT NULL PRIMARY KEY,
code VARCHAR(50) NOT NULL,
name VARCHAR(200) NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Region_Temp_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,29 +0,0 @@
-- Region Branchs
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Region_Branch';
CREATE TABLE IF NOT EXISTS Shop_Region_Branch (
id_branch INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_region_parent INT NOT NULL,
CONSTRAINT FK_Shop_Region_Branch_id_region_parent
FOREIGN KEY (id_region_parent)
REFERENCES Shop_Region(id_region)
ON UPDATE RESTRICT,
id_region_child INT NOT NULL,
CONSTRAINT FK_Shop_Region_Branch_id_region_child
FOREIGN KEY (id_region_child)
REFERENCES Shop_Region(id_region)
ON UPDATE RESTRICT,
-- depth INT NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Region_Branch_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,20 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Access_Level'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Access_Level (
id_access_level INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, code VARCHAR(50)
, name VARCHAR(255)
, priority INT NOT NULL
, display_order INT NOT NULL
, active BIT NOT NULL DEFAULT 1
);

View File

@@ -1,22 +0,0 @@
-- Region Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Region_Branch_Audit';
CREATE TABLE IF NOT EXISTS Shop_Region_Branch_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_branch INT NOT NULL,
CONSTRAINT FK_Shop_Region_Branch_Audit_id_branch
FOREIGN KEY (id_branch)
REFERENCES Shop_Region_Branch(id_branch)
ON UPDATE RESTRICT,
name_field VARCHAR(64) NOT NULL,
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Region_Branch_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,15 +0,0 @@
-- Region Branch Temp
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Region_Branch_Temp';
CREATE TABLE IF NOT EXISTS Shop_Region_Branch_Temp (
id_branch INT NOT NULL PRIMARY KEY,
id_region_parent INT NOT NULL,
id_region_child INT NOT NULL,
-- depth INT NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL
);

View File

@@ -1,31 +0,0 @@
-- Addresses
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Address';
CREATE TABLE Shop_Address (
id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_region INT NOT NULL
, CONSTRAINT FK_Shop_Address_id_region
FOREIGN KEY (id_region)
REFERENCES partsltd_prod.Shop_Region(id_region)
/*
, id_supplier INT NULL
, CONSTRAINT FK_Shop_Address_id_supplier
FOREIGN KEY (id_supplier)
REFERENCES partsltd_prod.Shop_Supplier(id_supplier)
*/
, postcode VARCHAR(20) NOT NULL
, address_line_1 VARCHAR(256) NOT NULL
, address_line_2 VARCHAR(256) NOT NULL
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, created_by INT
, id_change_set INT
, CONSTRAINT FK_Shop_Address_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.Shop_User_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Plant
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Plant';
CREATE TABLE IF NOT EXISTS Shop_Plant (
id_plant INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
code VARCHAR(50) NOT NULL,
name VARCHAR(500) NOT NULL,
id_address INT NOT NULL,
CONSTRAINT FK_Shop_Plant_id_address
FOREIGN KEY (id_address)
REFERENCES Shop_Address(id_address),
id_user_manager INT NOT NULL,
active BIT NOT NULL DEFAULT 1,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Plant_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,21 +0,0 @@
-- Address Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Address_Audit';
CREATE TABLE IF NOT EXISTS Shop_Address_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_address INT NOT NULL,
CONSTRAINT FK_Shop_Address_Audit_id_address
FOREIGN KEY (id_address)
REFERENCES Shop_Address(id_address)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Address_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_User_Change_Set(id_change_set)
ON UPDATE RESTRICT
);

View File

@@ -1,22 +0,0 @@
-- Plant Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Plant_Audit';
CREATE TABLE IF NOT EXISTS Shop_Plant_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_plant INT NOT NULL,
CONSTRAINT FK_Shop_Plant_Audit_id_plant
FOREIGN KEY (id_plant)
REFERENCES Shop_Plant(id_plant)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Plant_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,17 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Permission_Group'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Permission_Group (
id_group INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, code VARCHAR(50)
, name VARCHAR(255)
, display_order INT NOT NULL
, active BIT NOT NULL DEFAULT 1
);

View File

@@ -1,16 +0,0 @@
-- Plant Temp
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Plant_Temp';
CREATE TABLE IF NOT EXISTS Shop_Plant_Temp (
id_plant INT NOT NULL PRIMARY KEY
, code VARCHAR(50) NOT NULL
, name VARCHAR(500) NOT NULL
, id_address INT NOT NULL
, id_user_manager INT NOT NULL
, active BIT NOT NULL DEFAULT 1
, guid BINARY(36) NOT NULL
);

View File

@@ -1,23 +0,0 @@
-- Storage Location
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Storage_Location';
CREATE TABLE IF NOT EXISTS Shop_Storage_Location (
id_location INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_plant INT NOT NULL,
CONSTRAINT FK_Shop_Storage_Location_id_plant
FOREIGN KEY (id_plant)
REFERENCES Shop_Plant(id_plant),
code VARCHAR(50) NOT NULL,
name VARCHAR(500) NOT NULL,
active BIT NOT NULL DEFAULT 1,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Storage_Location_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Storage Location Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Storage_Location_Audit';
CREATE TABLE IF NOT EXISTS Shop_Storage_Location_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_location INT NOT NULL,
CONSTRAINT FK_Shop_Storage_Location_Audit_id_location
FOREIGN KEY (id_location)
REFERENCES Shop_Storage_Location(id_location)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Storage_Location_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,13 +0,0 @@
-- Storage Location Temp
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Storage_Location_Temp';
CREATE TABLE IF NOT EXISTS Shop_Storage_Location (
id_location INT NOT NULL PRIMARY KEY,
code VARCHAR(50) NOT NULL,
name VARCHAR(500) NOT NULL,
active BIT NOT NULL DEFAULT 1
);

View File

@@ -0,0 +1,25 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Permission'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Permission (
id_permission INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, code VARCHAR(50)
, name VARCHAR(255)
, id_permission_group INT NOT NULL
, CONSTRAINT FK_PH_Permission_id_permission_group
FOREIGN KEY (id_permission_group)
REFERENCES partsltd_prod.PH_Permission_Group(id_group)
, id_access_level_required INT NOT NULL
, CONSTRAINT FK_PH_Permission_id_access_level_required
FOREIGN KEY (id_access_level_required)
REFERENCES partsltd_prod.PH_Access_Level(id_access_level)
, display_order INT NOT NULL
, active BIT NOT NULL DEFAULT 1
);

View File

@@ -1,29 +0,0 @@
-- Storage Location Branch
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Storage_Location_Branch';
CREATE TABLE IF NOT EXISTS Shop_Storage_Location_Branch (
id_branch INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_location_parent INT NOT NULL,
CONSTRAINT FK_Shop_Storage_Location_Branch_id_location_parent
FOREIGN KEY (id_location_parent)
REFERENCES Shop_Storage_Location(id_location)
ON UPDATE RESTRICT,
id_location_child INT NOT NULL,
CONSTRAINT FK_Shop_Storage_Location_Branch_id_location_child
FOREIGN KEY (id_location_child)
REFERENCES Shop_Storage_Location(id_location)
ON UPDATE RESTRICT,
-- depth INT NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Storage_Location_Branch_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Storage Location Branch Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Storage_Location_Branch_Audit';
CREATE TABLE IF NOT EXISTS Shop_Storage_Location_Branch_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_branch INT NOT NULL,
CONSTRAINT FK_Shop_Storage_Location_Branch_Audit_id_branch
FOREIGN KEY (id_branch)
REFERENCES Shop_Storage_Location_Branch(id_branch)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Storage_Location_Branch_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,15 +0,0 @@
-- Storage Location Branch Temp
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Storage_Location_Branch_Temp';
CREATE TABLE IF NOT EXISTS Shop_Storage_Location_Branch_Temp (
id_branch INT NOT NULL PRIMARY KEY,
id_location_parent INT NOT NULL,
id_location_child INT NOT NULL,
-- depth INT NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL
);

View File

@@ -1,23 +0,0 @@
-- Currencies
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Currency';
CREATE TABLE IF NOT EXISTS Shop_Currency (
id_currency INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
code VARCHAR(50) NOT NULL,
name VARCHAR(255) NOT NULL,
symbol VARCHAR(50) NOT NULL,
factor_from_GBP FLOAT NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Currency_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
ON UPDATE RESTRICT
);

View File

@@ -0,0 +1,29 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_User'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_User (
id_user INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_user_auth0 VARCHAR(200)
, firstname VARCHAR(255)
, surname VARCHAR(255)
, email VARCHAR(254)
, is_email_verified BIT NOT NULL DEFAULT 0
, is_super_user BIT NOT NULL DEFAULT 0
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, id_user_created_by INT
, CONSTRAINT FK_PH_User_id_user_created_by
FOREIGN KEY (id_user_created_by)
REFERENCES partsltd_prod.PH_User(id_user)
, id_change_set INT
, CONSTRAINT FK_PH_User_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_User_Change_Set(id_change_set)
);

View File

@@ -1,23 +0,0 @@
-- Currency Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Currency_Audit';
CREATE TABLE IF NOT EXISTS Shop_Currency_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_currency INT NOT NULL,
CONSTRAINT FK_Shop_Currency_Audit_id_currency
FOREIGN KEY (id_currency)
REFERENCES Shop_Currency(id_currency)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Currency_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_User_Change_Set(id_change_set)
ON UPDATE RESTRICT
);

View File

@@ -1,16 +0,0 @@
-- Currency Temp
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Currency_Temp';
CREATE TABLE IF NOT EXISTS Shop_Currency_Temp (
id_currency INT NOT NULL PRIMARY KEY,
code VARCHAR(50) NOT NULL,
name VARCHAR(255) NOT NULL,
symbol VARCHAR(1) NOT NULL,
factor_from_GBP FLOAT NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL
);

View File

@@ -0,0 +1,24 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_User_Audit'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_User_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_user INT NOT NULL
, CONSTRAINT FK_PH_User_Audit_id_user
FOREIGN KEY (id_user)
REFERENCES partsltd_prod.PH_User(id_user)
, name_field VARCHAR(50) NOT NULL
, value_prev VARCHAR(500)
, value_new VARCHAR(500)
, id_change_set INT NOT NULL
, CONSTRAINT FK_PH_User_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_User_Change_Set(id_change_set)
);

View File

@@ -1,38 +0,0 @@
-- Taxes and Surcharges
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Tax_Or_Surcharge';
CREATE TABLE Shop_Tax_Or_Surcharge (
id_tax INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
code VARCHAR(50) NOT NULL,
name VARCHAR(200) NOT NULL,
id_region_buyer INT NOT NULL,
CONSTRAINT FK_Shop_Tax_Or_Surcharge_id_region_buyer
FOREIGN KEY (id_region_buyer)
REFERENCES Shop_Region(id_region),
id_region_seller INT NOT NULL,
CONSTRAINT FK_Shop_Tax_Or_Surcharge_id_region_seller
FOREIGN KEY (id_region_seller)
REFERENCES Shop_Region(id_region),
id_currency INT,
CONSTRAINT FK_Shop_Tax_Or_Surcharge_id_currency
FOREIGN KEY (id_currency)
REFERENCES Shop_Currency(id_currency)
ON UPDATE RESTRICT,
fixed_fee FLOAT NOT NULL DEFAULT 0,
multiplier FLOAT NOT NULL DEFAULT 1 CHECK (multiplier > 0),
apply_fixed_fee_before_multiplier BIT DEFAULT 1,
quantity_min FLOAT NOT NULL DEFAULT 0,
quantity_max FLOAT NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Tax_Or_Surcharge_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,22 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_User_Temp'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_User_Temp (
id_temp INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_user INT NOT NULL
, id_user_auth0 VARCHAR(200)
, firstname VARCHAR(255)
, surname VARCHAR(255)
, email VARCHAR(254)
, is_email_verified BIT
, is_super_user BIT
, active BIT
, guid BINARY(36) NOT NULL
);

View File

@@ -1,23 +0,0 @@
-- Tax Or Surcharge Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Tax_Or_Surcharge_Audit';
CREATE TABLE IF NOT EXISTS Shop_Tax_Or_Surcharge_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_tax INT NOT NULL,
CONSTRAINT FK_Shop_Tax_Or_Surcharge_Audit_id_discount
FOREIGN KEY (id_tax)
REFERENCES Shop_Tax_Or_Surcharge(id_tax)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Tax_Or_Surcharge_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
ON UPDATE RESTRICT
);

View File

@@ -0,0 +1,26 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Role'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Role (
id_role INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, code VARCHAR(50)
, name VARCHAR(255)
, display_order INT NOT NULL
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, id_user_created_by INT
, CONSTRAINT FK_PH_Role_id_user_created_by
FOREIGN KEY (id_user_created_by)
REFERENCES partsltd_prod.PH_User(id_user)
, id_change_set INT
, CONSTRAINT FK_PH_Role_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_User_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Taxes and Surcharges Temp
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Tax_Or_Surcharge_Temp';
CREATE TABLE Shop_Tax_Or_Surcharge_Temp (
id_tax INT NOT NULL PRIMARY KEY,
code VARCHAR(50) NOT NULL,
name VARCHAR(200) NOT NULL,
id_region_buyer INT NOT NULL,
id_region_seller INT NOT NULL,
id_currency INT,
fixed_fee FLOAT NOT NULL DEFAULT 0,
multiplier FLOAT NOT NULL DEFAULT 1 CHECK (multiplier > 0),
apply_fixed_fee_before_multiplier BIT DEFAULT 1,
quantity_min FLOAT NOT NULL DEFAULT 0,
quantity_max FLOAT NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL
);

View File

@@ -0,0 +1,24 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Role_Audit'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Role_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_role INT NOT NULL
, CONSTRAINT FK_PH_Role_Audit_id_role
FOREIGN KEY (id_role)
REFERENCES partsltd_prod.PH_Role(id_role)
, name_field VARCHAR(50) NOT NULL
, value_prev VARCHAR(500)
, value_new VARCHAR(500)
, id_change_set INT NOT NULL
, CONSTRAINT FK_PH_Role_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_User_Change_Set(id_change_set)
);

View File

@@ -1,26 +0,0 @@
-- Unit of Measurement
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Unit_Measurement';
CREATE TABLE IF NOT EXISTS Shop_Unit_Measurement (
id_unit_measurement INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name_singular VARCHAR(255) NOT NULL,
name_plural VARCHAR(256) NOT NULL,
symbol VARCHAR(50) NOT NULL,
symbol_is_suffix_not_prefix BIT NOT NULL DEFAULT 1,
is_base_unit BIT NOT NULL DEFAULT 0,
is_unit_of_distance BIT NOT NULL DEFAULT 0,
is_unit_of_mass BIT NOT NULL DEFAULT 0,
is_unit_of_time BIT NOT NULL DEFAULT 0,
is_unit_of_volume BIT NOT NULL DEFAULT 0,
active BIT NOT NULL DEFAULT 1,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Unit_Measurement_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Unit of Measurement Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Unit_Measurement_Audit';
CREATE TABLE IF NOT EXISTS Shop_Unit_Measurement_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_unit_measurement INT NOT NULL,
CONSTRAINT FK_Shop_Unit_Measurement_Audit_id_unit_measurement
FOREIGN KEY (id_unit_measurement)
REFERENCES Shop_Unit_Measurement(id_unit_measurement)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Unit_Measurement_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,35 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Role_Permission_Link'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Role_Permission_Link (
id_link INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_role INT NOT NULL
, CONSTRAINT FK_PH_Role_Permission_Link_id_role
FOREIGN KEY (id_role)
REFERENCES partsltd_prod.PH_Role(id_role)
, id_permission INT NOT NULL
, CONSTRAINT FK_PH_Role_Permission_Link_id_permission
FOREIGN KEY (id_permission)
REFERENCES partsltd_prod.PH_Permission(id_permission)
, id_access_level INT NOT NULL
, CONSTRAINT FK_PH_Role_Permission_Link_id_access_level
FOREIGN KEY (id_access_level)
REFERENCES partsltd_prod.PH_Access_Level(id_access_level)
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, id_user_created_by INT
, CONSTRAINT FK_PH_Role_Permission_Link_id_user_created_by
FOREIGN KEY (id_user_created_by)
REFERENCES partsltd_prod.PH_User(id_user)
, id_change_set INT
, CONSTRAINT FK_PH_Role_Permission_Link_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_User_Change_Set(id_change_set)
);

View File

@@ -1,23 +0,0 @@
-- Unit of Measurement Conversion
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Unit_Measurement_Conversion';
CREATE TABLE IF NOT EXISTS Shop_Unit_Measurement_Conversion (
id_conversion INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
id_unit_derived INT NOT NULL,
id_unit_base INT NOT NULL,
multiplier_unit_base FLOAT NOT NULL,
increment_unit_base FLOAT NOT NULL,
apply_multiplier_before_increment BIT NOT NULL DEFAULT 1,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Unit_Measurement_Conversion_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,23 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Role_Permission_Link_Audit';
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Role_Permission_Link_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_link INT NOT NULL
, CONSTRAINT FK_PH_Role_Permission_Link_Audit_id_link
FOREIGN KEY (id_link)
REFERENCES partsltd_prod.PH_Role_Permission_Link(id_link)
, name_field VARCHAR(50) NOT NULL
, value_prev VARCHAR(500)
, value_new VARCHAR(500)
, id_change_set INT NOT NULL
, CONSTRAINT FK_PH_Role_Permission_Link_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_User_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Unit of Measurement Conversion Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Unit_Measurement_Conversion_Audit';
CREATE TABLE IF NOT EXISTS Shop_Unit_Measurement_Conversion_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_conversion INT NOT NULL,
CONSTRAINT FK_Shop_Unit_Measurement_Conversion_Audit_id_conversion
FOREIGN KEY (id_conversion)
REFERENCES Shop_Unit_Measurement_Conversion(id_conversion)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Unit_Measurement_Conversion_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,31 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_User_Role_Link'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_User_Role_Link (
id_link INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_user INT NOT NULL
, CONSTRAINT FK_PH_User_Role_Link_id_user
FOREIGN KEY (id_user)
REFERENCES partsltd_prod.PH_User(id_user)
, id_role INT NOT NULL
, CONSTRAINT FK_PH_User_Role_Link_id_role
FOREIGN KEY (id_role)
REFERENCES partsltd_prod.PH_Role(id_role)
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, id_user_created_by INT
, CONSTRAINT FK_PH_User_Role_Link_id_user_created_by
FOREIGN KEY (id_user_created_by)
REFERENCES partsltd_prod.PH_User(id_user)
, id_change_set INT
, CONSTRAINT FK_PH_User_Role_Link_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_User_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,24 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_User_Role_Link_Audit'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_User_Role_Link_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_link INT NOT NULL
, CONSTRAINT FK_PH_User_Role_Link_Audit_id_link
FOREIGN KEY (id_link)
REFERENCES partsltd_prod.PH_User_Role_Link(id_link)
, name_field VARCHAR(50) NOT NULL
, value_prev VARCHAR(500)
, value_new VARCHAR(500)
, id_change_set INT NOT NULL
, CONSTRAINT FK_PH_User_Role_Link_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_User_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,22 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Calc_User_Temp'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Calc_User_Temp (
guid BINARY(36) NOT NULL
, id_user INT
, id_permission_required INT NOT NULL
, CONSTRAINT FK_PH_Calc_User_Temp_id_permission_required
FOREIGN KEY (id_permission_required)
REFERENCES partsltd_prod.PH_Permission (id_permission)
, priority_access_level_required INT NOT NULL
, is_super_user BIT
, priority_access_level_user INT
, has_access BIT
);

View File

@@ -0,0 +1,19 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Contact_Form_Change_Set'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Contact_Form_Change_Set (
id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, comment VARCHAR(500)
, updated_last_on DATETIME
, id_user_updated_last_by INT
, CONSTRAINT FK_PH_Role_id_user_updated_last_by
FOREIGN KEY (id_user_updated_last_by)
REFERENCES partsltd_prod.PH_User(id_user)
);

View File

@@ -1,24 +0,0 @@
-- Categories
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Category';
CREATE TABLE IF NOT EXISTS Shop_Product_Category (
id_category INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, code VARCHAR(50)
, name VARCHAR(255)
, description VARCHAR(4000)
, active BIT NOT NULL DEFAULT 1
, display_order INT NOT NULL
, id_access_level_required INT NOT NULL
, CONSTRAINT FK_Shop_Product_Category_id_access_level_required
FOREIGN KEY (id_access_level_required)
REFERENCES Shop_Access_Level(id_access_level)
, created_on DATETIME
, created_by INT NOT NULL
, id_change_set INT
, CONSTRAINT FK_Shop_Product_Category_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,28 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Contact_Form'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Contact_Form (
id_contact_form INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, email VARCHAR(255) NOT NULL
, name_contact VARCHAR(255) NOT NULL
, name_company VARCHAR(255) NOT NULL
, message TEXT NOT NULL
, receive_marketing_communications BIT NOT NULL DEFAULT 0
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, id_user_created_by INT
, CONSTRAINT FK_PH_Contact_Form_id_user_created_by
FOREIGN KEY (id_user_created_by)
REFERENCES partsltd_prod.PH_User(id_user)
, id_change_set INT
, CONSTRAINT FK_PH_Contact_Form_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_Contact_Form_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Category Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Category_Audit';
CREATE TABLE IF NOT EXISTS Shop_Product_Category_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_category INT NOT NULL,
CONSTRAINT FK_Shop_Product_Category_Audit_id_category
FOREIGN KEY (id_category)
REFERENCES Shop_Product_Category(id_category)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Product_Category_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,24 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Contact_Form_Audit'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Contact_Form_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_contact_form INT NOT NULL
, CONSTRAINT FK_PH_Contact_Form_Audit_id_contact_form
FOREIGN KEY (id_contact_form)
REFERENCES partsltd_prod.PH_Contact_Form(id_contact_form)
, name_field VARCHAR(50) NOT NULL
, value_prev TEXT
, value_new TEXT
, id_change_set INT NOT NULL
, CONSTRAINT FK_PH_Contact_Form_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.PH_Contact_Form_Change_Set(id_change_set)
);

View File

@@ -1,21 +0,0 @@
-- Categories Temp
-- DROP TABLE Shop_Product_Category_Temp;
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Category_Temp';
CREATE TABLE IF NOT EXISTS Shop_Product_Category_Temp (
id_temp INT NOT NULL PRIMARY KEY AUTO_INCREMENT
, id_category INT NOT NULL
, code VARCHAR(50) NOT NULL
, name VARCHAR(255) NOT NULL
, description VARCHAR(4000) NULL
, id_access_level_required INT NOT NULL DEFAULT 1
, display_order INT NOT NULL
, active BIT NULL
, can_view BIT NULL
, can_edit BIT NULL
, can_admin BIT NULL
, guid BINARY(36) NOT NULL
);

View File

@@ -0,0 +1,21 @@
USE partsltd_prod;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'partsltd_prod'
AND TABLE_NAME = 'PH_Contact_Form_Temp'
;
CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Contact_Form_Temp (
id_temp INT NOT NULL PRIMARY KEY AUTO_INCREMENT
, id_contact_form INT
, email VARCHAR(255)
, name_contact VARCHAR(255)
, name_company VARCHAR(255)
, message TEXT
, receive_marketing_communications BIT
, active BIT
, guid BINARY(36)
);

View File

@@ -1,48 +0,0 @@
-- Products
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product';
CREATE TABLE IF NOT EXISTS Shop_Product (
id_product INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
-- description VARCHAR(4000),
id_category INT NOT NULL,
has_variations BIT NOT NULL,
/*
price_GBP_full FLOAT,
price_GBP_min FLOAT,
-- ratio_discount_overall FLOAT NOT NULL DEFAULT 0,
CONSTRAINT FK_Shop_Product_id_category
FOREIGN KEY (id_category)
REFERENCES Shop_Product_Category(id_category)
ON UPDATE RESTRICT,
latency_manuf INT,
quantity_min FLOAT,
quantity_max FLOAT,
quantity_step FLOAT,
quantity_stock FLOAT,
is_subscription BIT,
id_unit_measurement_interval_recurrence INT,
CONSTRAINT FK_Shop_Product_id_unit_measurement_interval_recurrence
FOREIGN KEY (id_unit_measurement_interval_recurrence)
REFERENCES Shop_Interval_Recurrence(id_interval),
count_interval_recurrence INT,
*/
id_access_level_required INT NOT NULL,
CONSTRAINT FK_Shop_Product_id_access_level_required
FOREIGN KEY (id_access_level_required)
REFERENCES Shop_Access_Level(id_access_level),
-- id_stripe_product VARCHAR(100),
-- id_stripe_price VARCHAR(100) NOT NULL,
active BIT NOT NULL DEFAULT 1,
display_order INT NOT NULL,
created_on DATETIME NOT NULL,
created_by INT NOT NULL,
id_change_set INT,
CONSTRAINT FK_Shop_Product_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,22 +0,0 @@
-- Products
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Audit';
CREATE TABLE IF NOT EXISTS Shop_Product_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_product INT NOT NULL,
CONSTRAINT FK_Shop_Product_Audit_id_product
FOREIGN KEY (id_product)
REFERENCES Shop_Product(id_product)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Product_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,21 +0,0 @@
-- Products Temp
-- DROP TABLE IF EXISTS Shop_Product_Temp;
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Temp';
CREATE TABLE IF NOT EXISTS Shop_Product_Temp (
id_temp INT NOT NULL PRIMARY KEY AUTO_INCREMENT
, id_product INT NOT NULL
, name VARCHAR(255) NOT NULL
, id_category INT NOT NULL
, has_variations BIT NOT NULL
, id_access_level_required INT NOT NULL
, display_order INT NOT NULL
, active BIT NOT NULL DEFAULT 1
, can_view BIT NULL DEFAULT NULL
, can_edit BIT NULL DEFAULT NULL
, can_admin BIT NULL DEFAULT NULL
, guid BINARY(36) NOT NULL
);

View File

@@ -1,61 +0,0 @@
-- Product Permutation
-- DROP TABLE partsltd_prod.Shop_Product_Permutation;
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Permutation';
CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
id_permutation INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_permutation_temp INT NOT NULL,
id_product INT NOT NULL,
CONSTRAINT FK_Shop_Product_Permutation_id_product
FOREIGN KEY (id_product)
REFERENCES Shop_Product(id_product)
ON UPDATE RESTRICT,
-- name VARCHAR(255) NOT NULL,
description VARCHAR(4000) NOT NULL,
cost_local_VAT_excl FLOAT NULL,
cost_local_VAT_incl FLOAT NULL,
id_currency_cost INT NOT NULL,
profit_local_min FLOAT NULL,
-- id_currency_profit_min INT NOT NULL,
latency_manufacture INT NOT NULL,
id_unit_measurement_quantity INT NOT NULL,
CONSTRAINT FK_Shop_Product_Permutation_id_unit_quantity
FOREIGN KEY (id_unit_measurement_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
count_unit_measurement_per_quantity_step FLOAT NOT NULL,
quantity_min FLOAT NULL,
quantity_max FLOAT NULL,
quantity_stock FLOAT NOT NULL,
is_subscription BIT NOT NULL,
id_unit_measurement_interval_recurrence INT,
CONSTRAINT FK_Shop_Product_Permutation_id_unit_interval_recurrence
FOREIGN KEY (id_unit_measurement_interval_recurrence)
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
/*
CONSTRAINT CHECK_FK_Shop_Product_Permutation_id_unit_measurement_interval_recurrence
CHECK (id_unit_measurement_interval_recurrence IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)),
*/
count_interval_recurrence INT,
id_stripe_product VARCHAR(100) NULL,
does_expire_faster_once_unsealed BIT NOT NULL DEFAULT 0,
id_unit_measurement_interval_expiration_unsealed INT,
CONSTRAINT FK_Shop_Product_Permutation_id_unit_interval_expiration_unsealed
FOREIGN KEY (id_unit_measurement_interval_expiration_unsealed)
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
/*
CONSTRAINT CHECK_FK_Shop_Product_Permutation_id_interval_expiration_unsealed
CHECK (id_interval_expiration_unsealed IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)),
*/
count_interval_expiration_unsealed INT,
active BIT NOT NULL DEFAULT 1,
-- display_order INT NOT NULL,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Product_Permutation_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

View File

@@ -1,23 +0,0 @@
-- Product Permutation Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Permutation_Audit';
CREATE TABLE IF NOT EXISTS Shop_Product_Permutation_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_permutation INT NOT NULL,
CONSTRAINT FK_Shop_Product_Permutation_Audit_id_permutation
FOREIGN KEY (id_permutation)
REFERENCES Shop_Product_Permutation(id_permutation)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Product_Permutation_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
ON UPDATE RESTRICT
);

View File

@@ -1,37 +0,0 @@
-- Product Permutation Temp
-- DROP TABLE IF EXISTS Shop_Product_Permutation_Temp;
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Permutation_Temp';
CREATE TABLE IF NOT EXISTS Shop_Product_Permutation_Temp (
id_temp INT NOT NULL PRIMARY KEY AUTO_INCREMENT
, id_permutation INT NOT NULL
, id_product INT NOT NULL
, csv_id_pairs_variation VARCHAR(4000) NULL
, description VARCHAR(4000) NOT NULL
, cost_local_VAT_excl FLOAT NULL
, cost_local_VAT_incl FLOAT NULL
, id_currency_cost INT NOT NULL
, profit_local_min FLOAT NULL
, latency_manufacture INT NOT NULL
, id_unit_measurement_quantity INT NOT NULL
, count_unit_measurement_per_quantity_step FLOAT NOT NULL
, quantity_min FLOAT NULL
, quantity_max FLOAT NULL
, quantity_stock FLOAT NULL
, is_subscription BIT NOT NULL
, id_unit_measurement_interval_recurrence INT
, count_interval_recurrence INT
, id_stripe_product VARCHAR(100) NULL
, does_expire_faster_once_unsealed BIT NOT NULL DEFAULT 0
, id_unit_measurement_interval_expiration_unsealed INT
, count_interval_expiration_unsealed INT
, active BIT NOT NULL DEFAULT 1
-- display_order INT NOT NULL
, guid BINARY(36)
, can_view BIT NULL DEFAULT NULL
, can_edit BIT NULL DEFAULT NULL
, can_admin BIT NULL DEFAULT NULL
);

View File

@@ -1,22 +0,0 @@
-- Variation Types
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Variation_Type';
CREATE TABLE IF NOT EXISTS Shop_Variation_Type (
id_type INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_type_temp INT NULL
, code VARCHAR(50)
, name VARCHAR(255)
, name_plural VARCHAR(256)
, active BIT NOT NULL DEFAULT 1
, display_order INT NOT NULL
, created_on DATETIME
, created_by INT
, id_change_set INT
, CONSTRAINT FK_Shop_Variation_Type_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
);

Some files were not shown because too many files have changed in this diff Show More