|
| 1 | +from datetime import date, datetime |
| 2 | +from typing import Any, Dict, List, Optional |
| 3 | + |
| 4 | +from pydantic import BaseModel, Field |
| 5 | + |
| 6 | +from models.common_models.calendar_event import ApplicantLogCalendarEvent |
| 7 | +from models.common_models.hf_base import AccountFile |
| 8 | +from models.common_models.survey_questionary import SurveyQuestionary |
| 9 | +from models.common_models.vacancy import Vacancy |
| 10 | +from models.consts import AgreementState, ApplicantLogType, SurveyType |
| 11 | + |
| 12 | + |
| 13 | +class ApplicantSocial(BaseModel): |
| 14 | + id: int = Field(..., description="Social ID", example=1) |
| 15 | + social_type: str = Field(..., description="Social type", example="TELEGRAM") |
| 16 | + value: str = Field(..., description="Social nick/email", example="test_tg") |
| 17 | + verified: bool = Field(..., description="Verification flag", example=True) |
| 18 | + verification_date: Optional[datetime] = Field( |
| 19 | + None, |
| 20 | + description="Verification datetime", |
| 21 | + example=datetime(1970, 1, 1, 1, 1, 1), |
| 22 | + ) |
| 23 | + |
| 24 | + |
| 25 | +class ApplicantPDAgreement(BaseModel): |
| 26 | + state: Optional[AgreementState] = Field( |
| 27 | + None, |
| 28 | + description="Agreement state", |
| 29 | + example=AgreementState.NOT_SENT, |
| 30 | + ) |
| 31 | + decision_date: Optional[datetime] = Field( |
| 32 | + None, |
| 33 | + description="Decision date", |
| 34 | + example=datetime(1970, 1, 1, 1, 1, 1), |
| 35 | + ) |
| 36 | + |
| 37 | + |
| 38 | +class VacancyApplicantStatus(BaseModel): |
| 39 | + id: int = Field(..., description="Status ID", example=1) |
| 40 | + name: str = Field(..., description="Status name", example="hired") |
| 41 | + |
| 42 | + |
| 43 | +class ApplicantPhoto(AccountFile): |
| 44 | + pass |
| 45 | + |
| 46 | + |
| 47 | +class Applicant(BaseModel): |
| 48 | + id: int = Field(..., description="Applicant ID", example=1) |
| 49 | + email: Optional[ str] = Field( None, description="Applicant's email", example="[email protected]") |
| 50 | + first_name: str = Field(..., description="Applicant's firstname", example="test_name") |
| 51 | + last_name: str = Field(..., description="Applicant's lastname", example="test") |
| 52 | + middle_name: Optional[str] = Field(None, description="Applicant's patronymic", example="test") |
| 53 | + position: Optional[str] = Field(None, description="Applicant's current job", example="test") |
| 54 | + birthday: Optional[date] = Field( |
| 55 | + None, |
| 56 | + description="Applicant's birthday", |
| 57 | + example=date(1970, 1, 1), |
| 58 | + ) |
| 59 | + company: Optional[str] = Field( |
| 60 | + None, |
| 61 | + description="Last company the applicant worked for", |
| 62 | + example="test", |
| 63 | + ) |
| 64 | + money: Optional[str] = Field(None, description="Desired salary of the applicant", example="10$") |
| 65 | + phone: Optional[str] = Field(None, description="Applicant's phone", example="+99999999") |
| 66 | + skype: Optional[str] = Field(None, description="Applicant's skype", example="test_skype") |
| 67 | + photo: Optional[ApplicantPhoto] = Field(None, description="Applicant's photo") |
| 68 | + social: List[ApplicantSocial] = Field([], description="Applicant social media list") |
| 69 | + questionary: Optional[datetime] = Field( |
| 70 | + None, |
| 71 | + description="Date of filling / changing additional information", |
| 72 | + example=datetime(1970, 1, 1, 1, 1, 1, 1), |
| 73 | + ) |
| 74 | + pd_agreement: Optional[ApplicantPDAgreement] = Field( |
| 75 | + None, |
| 76 | + description="Agreement on the processing of personal data", |
| 77 | + ) |
| 78 | + values: Optional[Dict[str, Any]] = Field( |
| 79 | + None, |
| 80 | + description="Additional applicant fields", |
| 81 | + example={"favorite_language": "python"}, |
| 82 | + ) |
| 83 | + |
| 84 | + |
| 85 | +class Respondent(BaseModel): |
| 86 | + account_id: int = Field(..., description="Account ID", example=1) |
| 87 | + custom_id: int = Field(..., description="Custom ID", example=1) |
| 88 | + name: Optional[str] = Field(None, description="Respondent name", example="John") |
| 89 | + email: str = Field(..., description="Respondent email", example="[email protected]") |
| 90 | + |
| 91 | + |
| 92 | +class Survey(BaseModel): |
| 93 | + id: int = Field(..., description="Survey ID", example=1) |
| 94 | + name: str = Field(..., description="Survey name", example="test") |
| 95 | + type: SurveyType = Field(..., description="Survey type", example=SurveyType.TYPE_A) |
| 96 | + created: datetime = Field( |
| 97 | + ..., |
| 98 | + description="Date the survey was created", |
| 99 | + example=datetime(1970, 1, 1, 1, 1, 1), |
| 100 | + ) |
| 101 | + updated: Optional[datetime] = Field( |
| 102 | + None, |
| 103 | + description="Date the survey was changed", |
| 104 | + example=datetime(1970, 1, 1, 1, 1, 1), |
| 105 | + ) |
| 106 | + active: bool = Field(..., description="Active flag", example=True) |
| 107 | + |
| 108 | + |
| 109 | +class SurveyAnswerOfTypeA(BaseModel): |
| 110 | + id: int = Field(..., description="Survey answer ID", example=1) |
| 111 | + respondent: Respondent |
| 112 | + survey: Survey |
| 113 | + created: datetime = Field( |
| 114 | + ..., |
| 115 | + description="Date of the questionnaire", |
| 116 | + example=datetime(1970, 1, 1, 1, 1, 1), |
| 117 | + ) |
| 118 | + updated: Optional[datetime] = Field( |
| 119 | + ..., |
| 120 | + description="Date the questionnaire was modified", |
| 121 | + example=datetime(1970, 1, 1, 1, 1, 1), |
| 122 | + ) |
| 123 | + values: Optional[Dict[str, Any]] = Field( |
| 124 | + None, |
| 125 | + description="Survey results", |
| 126 | + example={"question": "answer"}, |
| 127 | + ) |
| 128 | + |
| 129 | + |
| 130 | +class RejectionReason(BaseModel): |
| 131 | + id: int = Field(..., description="Rejection reason ID", example=1) |
| 132 | + name: str = Field(..., description="Rejection reason name", example="Too far") |
| 133 | + |
| 134 | + |
| 135 | +class ApplicantLog(BaseModel): |
| 136 | + id: int = Field(..., description="Applicant log ID", example=1) |
| 137 | + type: ApplicantLogType = Field( |
| 138 | + ..., |
| 139 | + description="Applicant log type", |
| 140 | + example=ApplicantLogType.STATUS, |
| 141 | + ) |
| 142 | + status: Optional[VacancyApplicantStatus] = None |
| 143 | + employment_date: Optional[date] = Field( |
| 144 | + None, |
| 145 | + description="Applicant employment date", |
| 146 | + example=date(1970, 1, 1), |
| 147 | + ) |
| 148 | + removed: Optional[datetime] = Field( |
| 149 | + None, |
| 150 | + description="Record delete date time", |
| 151 | + example=datetime(1970, 1, 1, 1, 1, 1), |
| 152 | + ) |
| 153 | + comment: Optional[str] = Field(None, description="Comment", example="comment") |
| 154 | + created: datetime = Field( |
| 155 | + ..., |
| 156 | + description="Log creation date time", |
| 157 | + example=datetime(1970, 1, 1, 1, 1, 1), |
| 158 | + ) |
| 159 | + source: Optional[str] |
| 160 | + files: List[AccountFile] = Field([], description="List of uploaded files") |
| 161 | + survey_answer_of_type_a: Optional[SurveyAnswerOfTypeA] = None |
| 162 | + rejection_reason: Optional[RejectionReason] = None |
| 163 | + survey_questionary: Optional[SurveyQuestionary] = None |
| 164 | + calendar_event: Optional[ApplicantLogCalendarEvent] = None |
| 165 | + vacancy: Optional[Vacancy] = None |
| 166 | + |
| 167 | + |
| 168 | +class ApplicantTag(BaseModel): |
| 169 | + id: int = Field(..., description="Tag ID", example=1) |
| 170 | + name: str = Field(..., description="Tag name", example="COOL") |
| 171 | + color: str = Field(..., description="Tag color", example="000000") |
0 commit comments