HR-ATS-Portal/backend/offer/serializers.py

46 lines
2.1 KiB
Python

def serialize_offer(row) -> dict:
return {
"id": str(row.id) if row.id else None,
"inbox_id": row.inbox_id,
"job_post_id": str(row.job_post_id) if row.job_post_id else None,
"candidate_user_id": str(row.candidate_user_id) if row.candidate_user_id else None,
"status": row.status,
"base_salary": row.base_salary,
"currency": row.currency,
"salary_period": row.salary_period,
"signing_bonus": row.signing_bonus,
"annual_bonus_pct": row.annual_bonus_pct,
"equity_units": row.equity_units,
"equity_instrument": row.equity_instrument,
"cadre": row.cadre,
"gross_salary_in_words": row.gross_salary_in_words,
"subsidized_services": row.subsidized_services,
"probation_period": row.probation_period,
"notice_period": row.notice_period,
"work_location": row.work_location,
"work_timings": row.work_timings,
"start_date": row.start_date.isoformat() if row.start_date else None,
"expiry_date": row.expiry_date.isoformat() if row.expiry_date else None,
"sent_at": row.sent_at.isoformat() if row.sent_at else None,
"responded_at": row.responded_at.isoformat() if row.responded_at else None,
"closed_at": row.closed_at.isoformat() if row.closed_at else None,
"issued_by": str(row.issued_by) if row.issued_by else None,
"created_by": str(row.created_by) if row.created_by else None,
"created_at": row.created_at.isoformat() if row.created_at else None,
"updated_at": row.updated_at.isoformat() if row.updated_at else None,
}
def serialize_offer_history(row) -> dict:
return {
"id": str(row.id) if row.id else None,
"offer_id": str(row.offer_id) if row.offer_id else None,
"from_status": row.from_status,
"to_status": row.to_status,
"valid_from": row.valid_from.isoformat() if row.valid_from else None,
"valid_to": row.valid_to.isoformat() if row.valid_to else None,
"changed_by": str(row.changed_by) if row.changed_by else None,
"actor_kind": row.actor_kind,
"change_reason": row.change_reason,
}