New website focusing on ERP services.
This commit is contained in:
33
forms/contact.py
Normal file
33
forms/contact.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Contact Us Form
|
||||
|
||||
Description:
|
||||
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 models.model_view_store import Model_View_Store # circular
|
||||
from forms.base import Form_Base
|
||||
# external
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField
|
||||
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
class Form_Contact(FlaskForm):
|
||||
email = StringField('Email')
|
||||
contact_name = StringField('Name')
|
||||
company_name = StringField('Company')
|
||||
message = TextAreaField('Message')
|
||||
receive_marketing = BooleanField('I would like to receive marketing emails.')
|
||||
recaptcha = RecaptchaField()
|
||||
submit = SubmitField('Send Message')
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,40 +0,0 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Forms - Manufacturing Purchase Order Filters data input
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF forms for handling manufacturing purchase order filter input.
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from forms.base import Form_Base
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField, DateField
|
||||
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
class Filters_Manufacturing_Purchase_Order(Form_Base):
|
||||
active = BooleanField("Active only?", default = True)
|
||||
date_from = DateField('Date from')
|
||||
date_to = DateField('Date to')
|
||||
def __repr__(self):
|
||||
return f'Filters_Manufacturing_Purchase_Order(active={self.active.data}, date_from={self.date_from.data}, date_to={self.date_to.data})'
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = f'{cls.__name__}.from_json'
|
||||
form = cls()
|
||||
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], 'active', _m)
|
||||
if json[Store_Base.FLAG_DATE_FROM] != '':
|
||||
form.date_from.data = json[Store_Base.FLAG_DATE_FROM]
|
||||
if json[Store_Base.FLAG_DATE_TO] != '':
|
||||
form.date_to.data = json[Store_Base.FLAG_DATE_TO]
|
||||
return form
|
||||
@@ -1,43 +0,0 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Forms - Product Filter data input
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF forms for handling user input.
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
# internal
|
||||
# from business_objects.store.product_category import Filters_Product_Category
|
||||
# from models.model_view_store import Model_View_Store # circular
|
||||
# external
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField
|
||||
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
|
||||
|
||||
class Filters_Product(FlaskForm):
|
||||
id_category = SelectField('Category', validators=[Optional()], choices=[('', 'All')], default='')
|
||||
is_not_empty = BooleanField('Not empty only?')
|
||||
active = BooleanField("Active only?", default = True)
|
||||
@classmethod
|
||||
def from_filters_product(cls, filters_product):
|
||||
form = Filters_Product()
|
||||
form.id_category = filters_product.id_category
|
||||
form.is_not_empty.data = filters_product.is_not_empty
|
||||
form.active.data = filters_product.active
|
||||
return form
|
||||
def __repr__(self):
|
||||
return f'Filters_Product(id_category={self.id_category}, is_not_empty={self.is_not_empty.data}, active={self.active.data})'
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
filters = cls()
|
||||
filters.id_category.data = json['id_category']
|
||||
filters.is_not_empty.data = json['is_not_empty']
|
||||
filters.active.data = json['active']
|
||||
return filters
|
||||
@@ -1,47 +0,0 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Forms - Product Category Filters data input
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF forms for handling product category filter input.
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
# from business_objects.store.product_category import Filters_Product_Category
|
||||
# from models.model_view_store import Model_View_Store # circular
|
||||
# from helpers.DEPRECATED.helper_abc import Interface_ABC
|
||||
from forms.base import Form_Base
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField
|
||||
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
class Filters_Product_Category(Form_Base):
|
||||
is_not_empty = BooleanField('Not empty only?')
|
||||
active = BooleanField("Active only?", default = True)
|
||||
"""
|
||||
@classmethod
|
||||
def from_filters(cls, filters):
|
||||
form = Filters_Product_Category()
|
||||
form.is_not_empty.data = filters.is_not_empty
|
||||
form.active.data = filters.active
|
||||
return form
|
||||
"""
|
||||
def __repr__(self):
|
||||
return f'Filters_Product_Category(is_not_empty={self.is_not_empty.data}, active={self.active.data})'
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = f'{cls.__name__}.from_json'
|
||||
form = Filters_Product_Category() # is_not_empty=json['is_not_empty'], active=json['active'])
|
||||
form.is_not_empty.data = av.input_bool(json[Store_Base.FLAG_IS_NOT_EMPTY], 'is_not_empty', _m)
|
||||
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], 'active', _m)
|
||||
return form
|
||||
@@ -1,68 +0,0 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Forms - Product Category Filters data input
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF forms for handling product category filter input.
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
# from business_objects.store.product_category import Filters_Product_Category
|
||||
# from models.model_view_store import Model_View_Store # circular
|
||||
# from helpers.DEPRECATED.helper_abc import Interface_ABC
|
||||
from forms.base import Form_Base
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField
|
||||
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
class Filters_Product_Permutation(Form_Base):
|
||||
id_category = SelectField('Category', validators=[Optional()], choices=[('', 'All')], default='')
|
||||
id_product = SelectField('Product', validators=[Optional()], choices=[('', 'All')], default='')
|
||||
is_out_of_stock = BooleanField('Out of stock only?')
|
||||
active = BooleanField('Active only?', default=True)
|
||||
quantity_min = FloatField('Min stock')
|
||||
quantity_max = FloatField('Max stock')
|
||||
# submit = SubmitField('Submit')
|
||||
"""
|
||||
@classmethod
|
||||
def from_filters(cls, filters):
|
||||
form = Filters_Product_Permutation()
|
||||
form.id_category.choices = Store_Base.convert_list_objects_to_list_options(filters.categories)
|
||||
form.id_product.choices = Store_Base.convert_list_objects_to_list_options(filters.products)
|
||||
form.is_out_of_stock.data = filters.is_out_of_stock
|
||||
form.quantity_min.data = filters.quantity_min
|
||||
form.quantity_max.data = filters.quantity_max
|
||||
return form
|
||||
"""
|
||||
def __repr__(self):
|
||||
return f'''
|
||||
Filters_Product_Permutation(
|
||||
id_category={self.id_category.data},
|
||||
id_product={self.id_product.data},
|
||||
is_out_of_stock={self.is_out_of_stock.data},
|
||||
active={self.active.data},
|
||||
quantity_min={self.quantity_min.data},
|
||||
quantity_max={self.quantity_max.data})
|
||||
'''
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
form = cls()
|
||||
form.id_category.choices = [(json[Store_Base.ATTR_ID_PRODUCT_CATEGORY], json[Store_Base.ATTR_ID_PRODUCT_CATEGORY])]
|
||||
form.id_category.data = json[Store_Base.ATTR_ID_PRODUCT_CATEGORY]
|
||||
form.id_product.choices = [(json[Store_Base.ATTR_ID_PRODUCT], json[Store_Base.ATTR_ID_PRODUCT])]
|
||||
form.id_product.data = json[Store_Base.ATTR_ID_PRODUCT]
|
||||
form.is_out_of_stock.data = av.input_bool(json[Store_Base.FLAG_IS_OUT_OF_STOCK], Store_Base.FLAG_IS_OUT_OF_STOCK, f'{cls.__name__}.from_json')
|
||||
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], Store_Base.FLAG_ACTIVE, f'{cls.__name__}.from_json')
|
||||
form.quantity_min.data = json[Store_Base.FLAG_QUANTITY_MIN]
|
||||
form.quantity_max.data = json[Store_Base.FLAG_QUANTITY_MAX]
|
||||
return form
|
||||
@@ -1,38 +0,0 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Forms - Product Variation Filters data input
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF forms for handling product variation filter input.
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from forms.base import Form_Base
|
||||
from helpers.helper_app import Helper_App
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField, DateField
|
||||
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
class Filters_Product_Variation(Form_Base):
|
||||
is_not_empty = BooleanField('Not empty only?')
|
||||
active = BooleanField("Active only?", default = True)
|
||||
def __repr__(self):
|
||||
return f'Filters_Product_Variation(is_not_empty={self.is_not_empty.data}, active={self.active.data})'
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = f'{cls.__name__}.from_json'
|
||||
Helper_App.console_log(f'{_m}\njson={json}')
|
||||
form = cls()
|
||||
form.is_not_empty.data = av.input_bool(json[Store_Base.FLAG_IS_NOT_EMPTY], Store_Base.FLAG_IS_NOT_EMPTY, _m)
|
||||
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], Store_Base.FLAG_ACTIVE, _m)
|
||||
return form
|
||||
@@ -1,76 +0,0 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Forms - Product Category Filters data input
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF forms for handling product category filter input.
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
# from business_objects.store.product_category import Filters_Product_Category
|
||||
# from models.model_view_store import Model_View_Store # circular
|
||||
# from helpers.DEPRECATED.helper_abc import Interface_ABC
|
||||
from forms.base import Form_Base
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField
|
||||
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
class Filters_Stock_Item(Form_Base):
|
||||
id_category = SelectField('Category', choices=[Form_Base.get_choice_all()], default='')
|
||||
id_product = SelectField('Product', choices=[Form_Base.get_choice_all()], default='')
|
||||
is_out_of_stock = BooleanField('Out of stock only?')
|
||||
quantity_min = FloatField('Min stock')
|
||||
quantity_max = FloatField('Max stock')
|
||||
# submit = SubmitField('Submit')
|
||||
"""
|
||||
def __repr__(self):
|
||||
return f'''
|
||||
{self.__class__.__name__}(
|
||||
id_category={self.id_category.data},
|
||||
id_product={self.id_product.data},
|
||||
is_out_of_stock={self.is_out_of_stock.data},
|
||||
quantity_min={self.quantity_min.data},
|
||||
quantity_max={self.quantity_max.data})
|
||||
'''
|
||||
"""
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
form = cls()
|
||||
# form.id_category.choices = [(json[Store_Base.ATTR_ID_PRODUCT_CATEGORY], json[Store_Base.ATTR_ID_PRODUCT_CATEGORY])]
|
||||
form.id_category.data = json[Store_Base.ATTR_ID_PRODUCT_CATEGORY]
|
||||
# form.id_product.choices = [(json[Store_Base.ATTR_ID_PRODUCT], json[Store_Base.ATTR_ID_PRODUCT])]
|
||||
form.id_product.data = json[Store_Base.ATTR_ID_PRODUCT]
|
||||
form.is_out_of_stock.data = av.input_bool(json[Store_Base.FLAG_IS_OUT_OF_STOCK], Store_Base.FLAG_IS_OUT_OF_STOCK, f'{cls.__name__}.from_json')
|
||||
form.quantity_min.data = json[Store_Base.FLAG_QUANTITY_MIN]
|
||||
form.quantity_max.data = json[Store_Base.FLAG_QUANTITY_MAX]
|
||||
return form
|
||||
def to_json(self):
|
||||
return {
|
||||
Store_Base.ATTR_ID_PRODUCT_CATEGORY: self.id_category.data,
|
||||
Store_Base.ATTR_ID_PRODUCT: self.id_product.data,
|
||||
Store_Base.FLAG_IS_OUT_OF_STOCK: self.is_out_of_stock.data,
|
||||
Store_Base.FLAG_QUANTITY_MIN: self.quantity_min.data,
|
||||
Store_Base.FLAG_QUANTITY_MAX: self.quantity_max.data
|
||||
}
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
filters = cls()
|
||||
filters.id_category.choices = cls.get_choices_blank()
|
||||
filters.id_product.choices = cls.get_choices_blank()
|
||||
"""
|
||||
def import_values(self, form_filters):
|
||||
self.id_category.data = form_filters.id_category.data
|
||||
self.id_product.data = form_filters.id_product.data
|
||||
self.is_out_of_stock.data = form_filters.is_out_of_stock.data
|
||||
self.quantity_min.data = form_filters.quantity_min.data
|
||||
self.quantity_max.data = form_filters.quantity_max.data
|
||||
"""
|
||||
@@ -1,34 +0,0 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Forms - Supplier Filters data input
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF forms for handling supplier filter input.
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from forms.base import Form_Base
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField
|
||||
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
class Filters_Supplier(Form_Base):
|
||||
active = BooleanField("Active only?", default = True)
|
||||
def __repr__(self):
|
||||
return f'Filters_Supplier(active={self.active.data})'
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = f'{cls.__name__}.from_json'
|
||||
form = cls()
|
||||
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], 'active', _m)
|
||||
return form
|
||||
@@ -1,40 +0,0 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Forms - Supplier Purchase Order Filters data input
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF forms for handling supplier purchase order filter input.
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from forms.base import Form_Base
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField, DateField
|
||||
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
class Filters_Supplier_Purchase_Order(Form_Base):
|
||||
active = BooleanField("Active only?", default = True)
|
||||
date_from = DateField('Date from')
|
||||
date_to = DateField('Date to')
|
||||
def __repr__(self):
|
||||
return f'Filters_Supplier_Purchase_Order(active={self.active.data}, date_from={self.date_from.data}, date_to={self.date_to.data})'
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = f'{cls.__name__}.from_json'
|
||||
form = cls()
|
||||
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], 'active', _m)
|
||||
if json[Store_Base.FLAG_DATE_FROM] != '':
|
||||
form.date_from.data = json[Store_Base.FLAG_DATE_FROM]
|
||||
if json[Store_Base.FLAG_DATE_TO] != '':
|
||||
form.date_to.data = json[Store_Base.FLAG_DATE_TO]
|
||||
return form
|
||||
@@ -11,7 +11,7 @@ Defines Flask-WTF forms for handling unit of measurement filter input.
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from business_objects.base import Base
|
||||
from forms.base import Form_Base
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
@@ -34,9 +34,9 @@ class Filters_Unit_Measurement(Form_Base):
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
form = Filters_Unit_Measurement()
|
||||
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], 'active', 'Filters_Unit_Measurement')
|
||||
form.active.data = av.input_bool(json[Base.FLAG_ACTIVE], 'active', 'Filters_Unit_Measurement')
|
||||
return form
|
||||
def to_json(self):
|
||||
return {
|
||||
Store_Base.FLAG_ACTIVE: av.input_bool(self.active.data, Store_Base.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
|
||||
Base.FLAG_ACTIVE: av.input_bool(self.active.data, Base.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
|
||||
}
|
||||
Reference in New Issue
Block a user