forked from kompetenzinventar/ki-backend
implement updating skills
This commit is contained in:
39
ki/models.py
39
ki/models.py
@ -29,10 +29,7 @@ class Profile(db.Model):
|
||||
volunteerwork = Column(String(4000), default="")
|
||||
freetext = Column(String(4000), default="")
|
||||
created = Column(DateTime, nullable=False, default=datetime.now)
|
||||
updated = Column(DateTime,
|
||||
onupdate=datetime.now,
|
||||
nullable=False,
|
||||
default=datetime.now)
|
||||
updated = Column(DateTime, onupdate=datetime.now, nullable=False, default=datetime.now)
|
||||
|
||||
user = relationship("User", back_populates="profile", uselist=False)
|
||||
contacts = relationship("Contact")
|
||||
@ -48,11 +45,9 @@ class Profile(db.Model):
|
||||
"volunteerwork": self.volunteerwork,
|
||||
"freetext": self.freetext,
|
||||
"address": self.address.to_dict(),
|
||||
"contacts": list(
|
||||
map(lambda contact: contact.to_dict(), self.contacts)),
|
||||
"contacts": list(map(lambda contact: contact.to_dict(), self.contacts)),
|
||||
"skills": list(map(lambda skill: skill.to_dict(), self.skills)),
|
||||
"languages": list(
|
||||
map(lambda language: language.to_dict(), self.languages))
|
||||
"languages": list(map(lambda language: language.to_dict(), self.languages))
|
||||
}
|
||||
|
||||
|
||||
@ -75,9 +70,7 @@ class Contact(db.Model):
|
||||
id = Column(Integer, primary_key=True)
|
||||
profile_id = Column(Integer, ForeignKey("profile.id"), nullable=False)
|
||||
profile = relationship("Profile", back_populates="contacts")
|
||||
contacttype_id = Column(Integer,
|
||||
ForeignKey("contacttype.id"),
|
||||
nullable=False)
|
||||
contacttype_id = Column(Integer, ForeignKey("contacttype.id"), nullable=False)
|
||||
contacttype = relationship("ContactType")
|
||||
content = Column(String(200), nullable=False)
|
||||
|
||||
@ -138,11 +131,7 @@ class Skill(db.Model):
|
||||
profiles = relationship("ProfileSkill", back_populates="skill")
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"icon_url": "/skills/{}/icon".format(self.id)
|
||||
}
|
||||
return {"id": self.id, "name": self.name, "icon_url": "/skills/{}/icon".format(self.id)}
|
||||
|
||||
|
||||
class ProfileSkill(db.Model):
|
||||
@ -156,11 +145,7 @@ class ProfileSkill(db.Model):
|
||||
skill = relationship("Skill", back_populates="profiles")
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"profile_id": self.profile_id,
|
||||
"skill": self.skill.to_dict(),
|
||||
"level": self.level
|
||||
}
|
||||
return {"profile_id": self.profile_id, "skill": self.skill.to_dict(), "level": self.level}
|
||||
|
||||
|
||||
class Language(db.Model):
|
||||
@ -172,11 +157,7 @@ class Language(db.Model):
|
||||
profiles = relationship("ProfileLanguage", back_populates="language")
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"icon_url": "/languages/{}/icon".format(self.id)
|
||||
}
|
||||
return {"id": self.id, "name": self.name, "icon_url": "/languages/{}/icon".format(self.id)}
|
||||
|
||||
|
||||
class ProfileLanguage(db.Model):
|
||||
@ -190,8 +171,4 @@ class ProfileLanguage(db.Model):
|
||||
language = relationship("Language", back_populates="profiles")
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"profile_id": self.profile_id,
|
||||
"language": self.language.to_dict(),
|
||||
"level": self.level
|
||||
}
|
||||
return {"profile_id": self.profile_id, "language": self.language.to_dict(), "level": self.level}
|
||||
|
Reference in New Issue
Block a user