72 lines
3.3 KiB
Python
72 lines
3.3 KiB
Python
def serialize_offer(row, candidate_name=None, created_by_name=None) -> dict:
|
|
return {
|
|
"id": str(row.id) if row.id else None,
|
|
"inbox_id": row.inbox_id,
|
|
"manual_upload_candidate_id": (
|
|
str(row.manual_upload_candidate_id) if row.manual_upload_candidate_id else None
|
|
),
|
|
"form_data_id": str(row.form_data_id) if row.form_data_id else None,
|
|
"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,
|
|
"candidate_name": candidate_name,
|
|
"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_by_name": created_by_name,
|
|
"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,
|
|
}
|
|
|
|
|
|
def serialize_offer_candidate(item) -> dict:
|
|
manual=item.get("manual_upload_candidate_id")
|
|
form_id=item.get("form_data_id")
|
|
user_id=item.get("user_id")
|
|
job_id=item.get("job_post_id")
|
|
return {
|
|
"inbox_id": item.get("inbox_id"),
|
|
"manual_upload_candidate_id": str(manual) if manual else None,
|
|
"form_data_id": str(form_id) if form_id else None,
|
|
"source": item.get("source"),
|
|
"user_id": str(user_id) if user_id else None,
|
|
"name": item.get("name"),
|
|
"email": item.get("email"),
|
|
"job_post_id": str(job_id) if job_id else None,
|
|
"job_title": item.get("job_title"),
|
|
"application_status": item.get("application_status"),
|
|
"stage": item.get("stage") or item.get("application_status"),
|
|
}
|