Feat(Project Hub): Apply for Founding Partner Program page created with database structure and methods.
This commit is contained in:
198
business_objects/project_hub/apply_founding_partner_form.py
Normal file
198
business_objects/project_hub/apply_founding_partner_form.py
Normal file
@@ -0,0 +1,198 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Business Objects
|
||||
Feature: Apply_Founding_Partner_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 Apply_Founding_Partner_Form(SQLAlchemy_ABC, Base):
|
||||
FLAG_APPLY_FOUNDING_PARTNER_FORM: ClassVar[str] = 'apply-founding-partner-form'
|
||||
FLAG_COMMITMENT_FREQUENCY: ClassVar[str] = 'id_commitment_frequency'
|
||||
FLAG_DOG_COUNT: ClassVar[str] = 'dog-count'
|
||||
FLAG_EXISTING_CHALLENGES: ClassVar[str] = 'existing_challenges'
|
||||
FLAG_EXISTING_SYSTEM: ClassVar[str] = 'id_existing_system'
|
||||
FLAG_EXISTING_TIME_SINK_WEEKLY: ClassVar[str] = 'id_existing_time_sink_weekly'
|
||||
# FLAG_MOST_VALUABLE_FEATURE: ClassVar[str] = 'most_valuable_feature'
|
||||
FLAG_SPECIALITY: ClassVar[str] = 'id_speciality'
|
||||
FLAG_YEARS_OF_EXPERIENCE: ClassVar[str] = 'id_years_of_experience'
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = FLAG_APPLY_FOUNDING_PARTNER_FORM
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_EMAIL
|
||||
|
||||
__tablename__ = 'PH_Apply_Founding_Partner_Form'
|
||||
__table_args__ = { 'extend_existing': True }
|
||||
|
||||
id_apply_founding_partner_form = db.Column(db.Integer, primary_key=True)
|
||||
name_contact = db.Column(db.String(255))
|
||||
email = db.Column(db.String(255))
|
||||
phone_number = db.Column(db.String(255))
|
||||
name_company = db.Column(db.String(255))
|
||||
website = db.Column(db.String(1000))
|
||||
dog_count = db.Column(db.Integer)
|
||||
id_years_of_experience = db.Column(db.Integer)
|
||||
ids_speciality = db.Column(db.String(255))
|
||||
ids_existing_system = db.Column(db.String(255))
|
||||
id_existing_challenges = db.Column(db.Integer)
|
||||
id_existing_time_sink_weekly = db.Column(db.Integer)
|
||||
id_commitment_frequency = db.Column(db.Integer)
|
||||
# most_valuable_feature = db.Column(db.Integer)
|
||||
notes = db.Column(db.Text)
|
||||
active = db.Column(db.Boolean)
|
||||
created_on = db.Column(db.DateTime)
|
||||
|
||||
def __init__(self):
|
||||
self.id_apply_founding_partner_form = 0
|
||||
self.is_new = False
|
||||
super().__init__()
|
||||
|
||||
@classmethod
|
||||
def from_db_apply_founding_partner_form(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_apply_founding_partner_form'
|
||||
form = cls()
|
||||
form.id_apply_founding_partner_form = query_row[0]
|
||||
form.name_contact = query_row[2]
|
||||
form.email = query_row[1]
|
||||
form.phone_number = query_row[3]
|
||||
form.name_company = query_row[4]
|
||||
form.website = query_row[2]
|
||||
form.dog_count = query_row[3]
|
||||
form.id_years_of_experience = query_row[4]
|
||||
form.ids_speciality = query_row[2]
|
||||
form.ids_existing_system = query_row[3]
|
||||
form.id_existing_challenges = query_row[4]
|
||||
form.id_existing_time_sink_weekly = query_row[2]
|
||||
form.id_commitment_frequency = query_row[3]
|
||||
# form.most_valuable_feature = query_row[4]
|
||||
form.notes = query_row[2]
|
||||
form.active = av.input_bool(query_row[6], 'active', _m)
|
||||
form.created_on = query_row[7]
|
||||
return form
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
form = cls()
|
||||
if json is None: return form
|
||||
form.id_apply_founding_partner_form = -1
|
||||
form.name_company = json[cls.FLAG_NAME_COMPANY]
|
||||
form.email = json[cls.FLAG_EMAIL]
|
||||
form.phone_number = json[cls.FLAG_PHONE_NUMBER]
|
||||
form.name_contact = json[cls.FLAG_NAME_CONTACT]
|
||||
form.website = json[cls.FLAG_WEBSITE]
|
||||
form.dog_count = json[cls.FLAG_DOG_COUNT]
|
||||
form.years_of_experience = json[cls.FLAG_YEARS_OF_EXPERIENCE]
|
||||
form.speciality = json[cls.FLAG_SPECIALITY]
|
||||
form.existing_system = json[cls.FLAG_EXISTING_SYSTEM]
|
||||
form.existing_challenges = json[cls.FLAG_EXISTING_CHALLENGES]
|
||||
form.existing_time_sink_weekly = json[cls.FLAG_EXISTING_TIME_SINK_WEEKLY]
|
||||
form.commitment_frequency = json[cls.FLAG_COMMITMENT_FREQUENCY]
|
||||
# form.most_valuable_feature = json[cls.FLAG_MOST_VALUABLE_FEATURE]
|
||||
form.notes = json[cls.FLAG_NOTES]
|
||||
form.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
form.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
return form
|
||||
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
Contact_Form.FLAG_NAME_CONTACT: self.contact_name
|
||||
, Base.FLAG_EMAIL: self.email
|
||||
, Base.FLAG_PHONE_NUMBER: self.phone_number
|
||||
, Contact_Form.FLAG_NAME_COMPANY: self.company_name
|
||||
, Base.FLAG_WEBSITE: self.website
|
||||
, Apply_Founding_Partner_Form.FLAG_DOG_COUNT: self.dog_count
|
||||
, Apply_Founding_Partner_Form.FLAG_YEARS_OF_EXPERIENCE: self.years_of_experience
|
||||
, Apply_Founding_Partner_Form.FLAG_SPECIALITY: self.speciality
|
||||
, Apply_Founding_Partner_Form.FLAG_EXISTING_SYSTEM: self.existing_system
|
||||
, Apply_Founding_Partner_Form.FLAG_EXISTING_CHALLENGES: self.existing_challenges
|
||||
, Apply_Founding_Partner_Form.FLAG_EXISTING_TIME_SINK_WEEKLY: self.existing_time_sink_weekly
|
||||
, Apply_Founding_Partner_Form.FLAG_COMMITMENT_FREQUENCY: self.commitment_frequency
|
||||
# , Apply_Founding_Partner_Form.FLAG_IMPLEMENTATION_TIMELINE: self.implementation_timeline
|
||||
# , Apply_Founding_Partner_Form.FLAG_MOST_VALUABLE_FEATURE: self.most_valuable_feature
|
||||
, Apply_Founding_Partner_Form.FLAG_NOTES: self.notes
|
||||
, Contact_Form.FLAG_ALTCHA: self.altcha
|
||||
, Base.FLAG_ACTIVE: self.active
|
||||
, Base.FLAG_CREATED_ON: self.created_on
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
return f'''
|
||||
{self.__class__.__name__}(
|
||||
{self.FLAG_CONTACT_FORM}: {self.id_apply_founding_partner_form}
|
||||
{Contact_Form.FLAG_NAME_CONTACT}: {self.contact_name}
|
||||
{Base.FLAG_EMAIL}: {self.email}
|
||||
{Base.FLAG_PHONE_NUMBER}: {self.phone_number}
|
||||
{Contact_Form.FLAG_NAME_COMPANY}: {self.company_name}
|
||||
{Base.FLAG_WEBSITE}: {self.website}
|
||||
{Apply_Founding_Partner_Form.FLAG_DOG_COUNT}: {self.dog_count}
|
||||
{Apply_Founding_Partner_Form.FLAG_YEARS_OF_EXPERIENCE}: {self.years_of_experience}
|
||||
{Apply_Founding_Partner_Form.FLAG_SPECIALITY}: {self.speciality}
|
||||
{Apply_Founding_Partner_Form.FLAG_EXISTING_SYSTEM}: {self.existing_system}
|
||||
{Apply_Founding_Partner_Form.FLAG_EXISTING_CHALLENGES}: {self.existing_challenges}
|
||||
{Apply_Founding_Partner_Form.FLAG_EXISTING_TIME_SINK_WEEKLY}: {self.existing_time_sink_weekly}
|
||||
{Apply_Founding_Partner_Form.FLAG_COMMITMENT_FREQUENCY}: {self.commitment_frequency}
|
||||
{Apply_Founding_Partner_Form.FLAG_NOTES}: {self.notes}
|
||||
{Base.FLAG_ACTIVE}: {self.active}
|
||||
{Base.FLAG_CREATED_ON}: {self.created_on}
|
||||
)
|
||||
'''
|
||||
|
||||
class Apply_Founding_Partner_Form_Temp(db.Model, Base):
|
||||
__tablename__ = 'PH_Apply_Founding_Partner_Form_Temp'
|
||||
__table_args__ = { 'extend_existing': True }
|
||||
id_temp = db.Column(db.Integer, primary_key=True)
|
||||
id_apply_founding_partner_form = db.Column(db.Integer)
|
||||
name_contact = db.Column(db.String(255))
|
||||
email = db.Column(db.String(255))
|
||||
phone_number = db.Column(db.String(255))
|
||||
name_company = db.Column(db.String(255))
|
||||
website = db.Column(db.String(1000))
|
||||
dog_count = db.Column(db.Integer)
|
||||
id_years_of_experience = db.Column(db.Integer)
|
||||
ids_speciality = db.Column(db.String(255))
|
||||
ids_existing_system = db.Column(db.String(255))
|
||||
id_existing_challenges = db.Column(db.Integer)
|
||||
id_existing_time_sink_weekly = db.Column(db.Integer)
|
||||
id_commitment_frequency = db.Column(db.Integer)
|
||||
# most_valuable_feature = db.Column(db.Integer)
|
||||
notes = db.Column(db.Text)
|
||||
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 = f'{cls.__qualname__}.from_contact_form'
|
||||
temp = cls()
|
||||
temp.id_apply_founding_partner_form = contact_form.id_apply_founding_partner_form.data
|
||||
temp.name_contact = contact_form.name_contact.data
|
||||
temp.email = contact_form.email.data
|
||||
temp.phone_number = contact_form.phone_number.data
|
||||
temp.name_company = contact_form.name_company.data
|
||||
temp.website = contact_form.website.data
|
||||
temp.dog_count = contact_form.dog_count.data
|
||||
temp.id_years_of_experience = contact_form.id_years_of_experience.data
|
||||
temp.ids_speciality = contact_form.ids_speciality.data
|
||||
temp.ids_existing_system = contact_form.ids_existing_system.data
|
||||
temp.id_existing_challenges = contact_form.id_existing_challenges.data
|
||||
temp.id_existing_time_sink_weekly = contact_form.id_existing_time_sink_weekly.data
|
||||
temp.id_commitment_frequency = contact_form.id_commitment_frequency.data
|
||||
# temp.most_valuable_feature = contact_form.most_valuable_feature.data
|
||||
temp.notes = contact_form.notes.data
|
||||
temp.active = True
|
||||
return temp
|
||||
@@ -45,33 +45,34 @@ class Contact_Form(SQLAlchemy_ABC, Base):
|
||||
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_db_contact_form(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_contact_form'
|
||||
form = cls()
|
||||
form.id_contact_form = query_row[0]
|
||||
form.email = query_row[1]
|
||||
form.name_contact = query_row[2]
|
||||
form.name_company = query_row[3]
|
||||
form.message = query_row[4]
|
||||
form.receive_marketing_communications = av.input_bool(query_row[5], 'receive_marketing_communications', _m)
|
||||
form.active = av.input_bool(query_row[6], 'active', _m)
|
||||
form.created_on = query_row[7]
|
||||
return form
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = 'Contact_Form.from_json'
|
||||
contact_form = cls()
|
||||
if json is None: return Contact_Form
|
||||
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 = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
contact_form.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
return contact_form
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
form = cls()
|
||||
if json is None: return form
|
||||
form.id_contact_form = -1
|
||||
form.email = json[cls.FLAG_EMAIL]
|
||||
form.name_contact = json[cls.FLAG_NAME_CONTACT]
|
||||
form.name_company = json[cls.FLAG_NAME_COMPANY]
|
||||
form.message = json[cls.FLAG_MESSAGE]
|
||||
form.receive_marketing_communications = json[cls.FLAG_RECEIVE_MARKETING_COMMUNICATIONS]
|
||||
form.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
form.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
return form
|
||||
|
||||
|
||||
def to_json(self):
|
||||
@@ -120,7 +121,7 @@ class Contact_Form_Temp(db.Model, Base):
|
||||
|
||||
@classmethod
|
||||
def from_contact_form(cls, contact_form):
|
||||
_m = 'Contact_Form_Temp.from_Contact_Form'
|
||||
_m = f'{cls.__qualname__}.from_contact_form'
|
||||
temp = cls()
|
||||
temp.id_contact_form = contact_form.id_contact_form
|
||||
temp.email = contact_form.email
|
||||
|
||||
Reference in New Issue
Block a user