forked from kompetenzinventar/ki-backend
implement searchtopics
This commit is contained in:
16
ki/models.py
16
ki/models.py
@ -41,6 +41,7 @@ class Profile(db.Model):
|
||||
contacts = relationship("Contact")
|
||||
address = relationship("Address", uselist=False, back_populates="profile")
|
||||
skills = relationship("ProfileSkill", back_populates="profile")
|
||||
searchtopics = relationship("ProfileSearchtopic", back_populates="profile")
|
||||
languages = relationship("ProfileLanguage", back_populates="profile")
|
||||
|
||||
def to_dict(self):
|
||||
@ -55,6 +56,7 @@ class Profile(db.Model):
|
||||
"address": self.address.to_dict(),
|
||||
"contacts": list(map(lambda contact: contact.to_dict(), self.contacts)),
|
||||
"skills": list(map(lambda skill: skill.to_dict(), self.skills)),
|
||||
"searchtopics": list(map(lambda searchtopic: searchtopic.to_dict(), self.searchtopics)),
|
||||
"languages": list(map(lambda language: language.to_dict(), self.languages))
|
||||
}
|
||||
|
||||
@ -137,6 +139,7 @@ class Skill(db.Model):
|
||||
name = Column(String(25), unique=True, nullable=False)
|
||||
|
||||
profiles = relationship("ProfileSkill", back_populates="skill")
|
||||
searchtopics = relationship("ProfileSearchtopic", back_populates="skill")
|
||||
|
||||
def to_dict(self):
|
||||
return {"id": self.id, "name": self.name, "icon_url": "/skills/{}/icon".format(self.id)}
|
||||
@ -156,6 +159,19 @@ class ProfileSkill(db.Model):
|
||||
return {"profile_id": self.profile_id, "skill": self.skill.to_dict(), "level": self.level}
|
||||
|
||||
|
||||
class ProfileSearchtopic(db.Model):
|
||||
__tablename__ = "profile_searchtopic"
|
||||
|
||||
profile_id = Column(Integer, ForeignKey("profile.id"), primary_key=True)
|
||||
skill_id = Column(Integer, ForeignKey("skill.id"), primary_key=True)
|
||||
|
||||
profile = relationship("Profile", back_populates="searchtopics")
|
||||
skill = relationship("Skill", back_populates="searchtopics")
|
||||
|
||||
def to_dict(self):
|
||||
return {"profile_id": self.profile_id, "skill": self.skill.to_dict()}
|
||||
|
||||
|
||||
class Language(db.Model):
|
||||
__tablename__ = "language"
|
||||
|
||||
|
Reference in New Issue
Block a user