from minibase import db, create_minibase
import minibase.database.utils as dbUtils 
from minibase.database.models import Person, Person_role, Person_competence, Person_note
from minibase.database.models import Person, Person_role, Person_competence, Person_note
from minibase.database.models import Company, Company_relation, Company_legal_entity, Company_note, Company_status
from minibase.database.models import Status, Industry, Note_status
from minibase.database.models import Project, Project_status, Project_element, Project_note
from minibase.database.models import Product, Product_status, Product_physical, Product_packaging, Product_domain, Product_eligibility, Product_category, Product_sub_category, Product_classification

app = create_minibase()
app.app_context().push()

status = db.drop_all()
status = db.create_all()

###################################################################################################

dbUtils.db_add_name_and_description("minibase/database/industry.csv", Industry)

###################################################################################################

dbUtils.db_add_name_and_description("minibase/database/company_relation.csv", Company_relation)

dbUtils.db_add_name_and_description("minibase/database/company_legal_entity.csv", Company_legal_entity)

dbUtils.db_add_name_and_description("minibase/database/company_status.csv", Company_status)

dbUtils.db_add_company("minibase/database/company.csv")

dbUtils.db_add_name_and_description("minibase/database/note_status.csv", Note_status)

note1 = Company_note(
    title='Need to find a valid MCU For Stefan',
    content='ST is not able to deliver F0 mcu so NXP may do the trick',
    priority='1',
    company_id='1',
    status_id='1')
db.session.add(note1)

note2 = Company_note(
    title='Need to find a valid LDO',
    content='Please find an LDO for 100mAh',
    priority='2',
    company_id='1',
    status_id='3')
db.session.add(note2)

note2 = Company_note(
    title='Please contact your custommers',
    content='I won\'t earn any money if i don\'t get in touch with them',
    priority='0',
    company_id='2',
    status_id='1')
db.session.add(note2)


###################################################################################################
dbUtils.db_add_name_and_description("minibase/database/person_role.csv", Person_role)

dbUtils.db_add_name_and_description("minibase/database/person_competence.csv", Person_competence)

dbUtils.db_add_person("minibase/database/person.csv")


note3 = Person_note(
    title='Birthday of Stefan',
    content='Congratulate Stefan for his birthday',
    priority='5',
    person_id='2',
    status_id='1')
db.session.add(note3)

note4 = Person_note(
    title='Wake Up kerem',
    content='He is still slepping',
    priority='10',
    person_id='1',
    status_id='3')
db.session.add(note4)

note5 = Person_note(
    title='Research for Stefan',
    content='He is looking for a new job',
    priority='8',
    person_id='2',
    status_id='2')
db.session.add(note5)

###################################################################################################

dbUtils.db_add_name_and_description("minibase/database/project_status.csv", Project_status)

dbUtils.db_add_project("minibase/database/project.csv")

dbUtils.db_add_project_element("minibase/database/project_element.csv")

note6 = Project_note(
    title='STWAHAving issues to get the RFID chip',
    content='STM doesn t want to deliver the chip throug distribution channel',
    priority='10',
    project_id='1',
    status_id='1')
db.session.add(note6)

note7 = Project_note(
    title='STM whants to go to steinerl directly',
    content='Italian part of STM is willin gto to directly to Steinel and they are not interested on letting us get the lead',
    priority='10',
    project_id='1',
    status_id='1')
db.session.add(note7)

note8 = Project_note(
    title='Ilker Is speeling',
    content='Ilker is tocupied too much wiht the shisha bar an letting our project fall',
    priority='5',
    project_id='2',
    status_id='2')
db.session.add(note8)
###################################################################################################
dbUtils.db_add_name_and_description("minibase/database/product_category.csv", Product_category)
dbUtils.db_add_name_and_description("minibase/database/product_classification.csv", Product_classification)
dbUtils.db_add_name_and_description("minibase/database/product_domain.csv", Product_domain)
dbUtils.db_add_name_and_description("minibase/database/product_eligibility.csv", Product_eligibility)
dbUtils.db_add_name_and_description("minibase/database/product_packaging.csv", Product_packaging)
dbUtils.db_add_name_and_description("minibase/database/product_physical.csv", Product_physical)
dbUtils.db_add_name_and_description("minibase/database/product_status.csv", Product_status)
dbUtils.db_add_name_and_description("minibase/database/product_sub_category.csv", Product_sub_category)
dbUtils.db_add_product("minibase/database/product.csv")
