add contacttypes seed and endpoint
This commit is contained in:
@ -5,7 +5,25 @@ from app import app, db
|
||||
from ki.models import Address, Contact, ContactType, Language, Skill, Profile, ProfileLanguage, ProfileSkill, User
|
||||
|
||||
|
||||
def seed_contacttypes():
|
||||
contacttypes_seed_file_path = app.config["KI_DATA_DIR"] + "/seed_data/contacttypes.csv"
|
||||
|
||||
logging.info("importing contacttypes")
|
||||
|
||||
with open(contacttypes_seed_file_path) as file:
|
||||
csv_reader = csv.DictReader(file)
|
||||
|
||||
for contacttype in csv_reader:
|
||||
id = int(contacttype["id"])
|
||||
db_contacttype = ContactType.query.get(id)
|
||||
|
||||
if db_contacttype is None:
|
||||
db.session.add(ContactType(id=int(contacttype["id"]), name=contacttype["name"]))
|
||||
|
||||
|
||||
def seed(dev: bool):
|
||||
seed_contacttypes()
|
||||
|
||||
skill_seed_file_path = app.config["KI_DATA_DIR"] + "/seed_data/skills.csv"
|
||||
|
||||
logging.info("importing skills")
|
||||
@ -47,16 +65,10 @@ def seed(dev: bool):
|
||||
user=peter)
|
||||
db.session.add(peters_profile)
|
||||
|
||||
matrix_type = ContactType(name="Matrix")
|
||||
db.session.add(matrix_type)
|
||||
|
||||
matrix_contact = Contact(profile=peters_profile, contacttype=matrix_type, content="@peter:wtf-eg.de")
|
||||
matrix_contact = Contact(profile=peters_profile, contacttype_id=4, content="@peter:wtf-eg.de")
|
||||
db.session.add(matrix_contact)
|
||||
|
||||
email_type = ContactType(name="E-Mail")
|
||||
db.session.add(email_type)
|
||||
|
||||
email_contact = Contact(profile=peters_profile, contacttype=email_type, content="peter@wtf-eg.de")
|
||||
email_contact = Contact(profile=peters_profile, contacttype_id=1, content="peter@wtf-eg.de")
|
||||
db.session.add(email_contact)
|
||||
|
||||
peters_address = Address(name="Peter Nichtlustig",
|
||||
|
Reference in New Issue
Block a user