Compare commits
1 Commits
main
...
feature/#6
Author | SHA1 | Date | |
---|---|---|---|
e60b708ea6 |
69
ki/models.py
69
ki/models.py
@ -19,6 +19,8 @@ class User(db.Model):
|
||||
|
||||
tokens = relationship("Token", back_populates="user")
|
||||
profile = relationship("Profile", back_populates="user")
|
||||
jobs = relationship("Job", back_populates="owner")
|
||||
job_responses = relationship("JobResponse",back_populates="user")
|
||||
|
||||
def to_dict(self):
|
||||
return {"id": self.id}
|
||||
@ -146,6 +148,7 @@ class Skill(db.Model):
|
||||
|
||||
profiles = relationship("ProfileSkill", back_populates="skill")
|
||||
searchtopics = relationship("ProfileSearchtopic", back_populates="skill")
|
||||
jobs = relationship("JobSkill", back_populates="skill")
|
||||
|
||||
def to_dict(self):
|
||||
return {"id": self.id, "name": self.name, "icon_url": "/skills/{}/icon".format(self.id)}
|
||||
@ -228,3 +231,69 @@ class ProfileLanguage(db.Model):
|
||||
|
||||
def to_dict(self):
|
||||
return {"profile_id": self.profile_id, "language": self.language.to_dict(), "level": self.level}
|
||||
|
||||
|
||||
class Job(db.Model):
|
||||
__tablename__ = "job"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
owner_id = Column(Integer, ForeignKey("user.id"), nullable=False)
|
||||
description = Column(String(5000))
|
||||
amount_of_people_needed = Column(Integer, nullable=False)
|
||||
amount_of_weekhours_needed = Column(Integer)
|
||||
amount_of_payment_hour = Column(Integer)
|
||||
timeframeImprecise = Column(String(120))
|
||||
remotePercent = Column(Integer)
|
||||
location = Column(String(50))
|
||||
beginDate = Column(DateTime)
|
||||
endDate = Column(DateTime)
|
||||
link = Column(String(500))
|
||||
aidsLevel = Column(Integer) ## Stupid Shit one has to deal with like Teams or weird Apps, Datathrower Webportals...
|
||||
created = Column(DateTime, nullable=False, default=datetime.now)
|
||||
updated = Column(DateTime, onupdate=datetime.now, nullable=False, default=datetime.now)
|
||||
withdrawn = Column(DateTime, nullable=True)
|
||||
|
||||
owner = relationship("User", back_populates="jobs")
|
||||
responses = relationship("JobResponse", back_populates="jobs")
|
||||
skills = relationship("JobSkill", back_populates="job")
|
||||
def to_dict(self):
|
||||
return {"job_id": self.id, "owner_id": self.owner_id, "description": self.description,
|
||||
"amount_of_people_needed": self.amount_of_people_needed, "amount_of_weekhours_needed": self.amount_of_weekhours_needed,
|
||||
"amount_of_payment_hour": self.amount_of_payment_hour, "timeframeImprecise": self.timeframeImprecise,
|
||||
"remotePercent": self.timeframeImprecise, "location": self.location, "beginDate": self.beginDate,
|
||||
"endDate": self.endDate, "link": self.link, "aidsLevel": self.aidsLevel, "created": self.created,
|
||||
"updated": self.updated, "withdrawn": self.withdrawn
|
||||
}
|
||||
|
||||
class JobSkill(db.Model):
|
||||
__tablename__ = "job_skill"
|
||||
|
||||
job_id = Column(Integer, ForeignKey("job.id"), primary_key=True)
|
||||
skill_id = Column(Integer, ForeignKey("skill.id"), primary_key=True)
|
||||
level = Column(SmallInteger, nullable=False)
|
||||
|
||||
job = relationship("Job", back_populates="skills")
|
||||
skill = relationship("Skill", back_populates="jobs")
|
||||
|
||||
def to_dict(self):
|
||||
return {"job_id": self.job_id, "skill": self.skill.to_dict(), "level": self.level}
|
||||
|
||||
|
||||
class JobResponse(db.Model):
|
||||
__tablename__ = "job_response"
|
||||
|
||||
job_id = Column(Integer, ForeignKey("job.id"), primary_key=True)
|
||||
user_id = Column(Integer, ForeignKey("user.id"), primary_key=True)
|
||||
created = Column(DateTime, nullable=False, default=datetime.now)
|
||||
withdrawn = Column(DateTime, nullable=True) # no longer interested/available
|
||||
|
||||
job = relationship("Job", back_populates="responses")
|
||||
user = relationship("User", back_populates="job_responses")
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"job": self.job.to_dict(),
|
||||
"user": self.user.to_dict(),
|
||||
"created": self.created,
|
||||
"withdrawn": self.withdrawn
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user