48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
from enum import Enum
|
|
|
|
|
|
class RequisitionStatus(str, Enum):
|
|
"""Hiring lifecycle on job_posts.requisition_status.
|
|
|
|
Distinct from job_posts.status, which is Buffer publish state
|
|
(draft/scheduled/published/failed). Values are the wire form the Jobs
|
|
screen already PATCHes; labels are what the dropdown renders.
|
|
"""
|
|
|
|
OPEN = "open"
|
|
ON_HOLD = "on_hold"
|
|
CLOSED = "closed"
|
|
COMPLETED = "completed"
|
|
|
|
@property
|
|
def label(self) -> str:
|
|
return _LABELS[self]
|
|
|
|
@classmethod
|
|
def parse(cls, value):
|
|
"""Accept the stored value or the UI label. None if neither matches."""
|
|
raw = (value or "").strip()
|
|
if not raw:
|
|
return None
|
|
lowered = raw.lower().replace(" ", "_")
|
|
for member in cls:
|
|
if raw == member.value or lowered == member.value or raw == member.label:
|
|
return member
|
|
return None
|
|
|
|
@classmethod
|
|
def values(cls) -> tuple[str, ...]:
|
|
return tuple(m.value for m in cls)
|
|
|
|
@classmethod
|
|
def as_list(cls) -> list[dict]:
|
|
return [{"value": m.value, "label": m.label} for m in cls]
|
|
|
|
|
|
_LABELS = {
|
|
RequisitionStatus.OPEN: "Open",
|
|
RequisitionStatus.ON_HOLD: "On Hold",
|
|
RequisitionStatus.CLOSED: "Closed",
|
|
RequisitionStatus.COMPLETED: "Completed",
|
|
}
|