39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import api.projects
|
|
from typing import Dict, Any
|
|
from color import Color
|
|
|
|
COLOR_TITLE = Color(Color.YELLOW)
|
|
COLOR_HEADER = Color(Color.CYAN)
|
|
COLOR_WHITE = Color(Color.BRIGHT_WHITE)
|
|
|
|
COLOR_PLANNED = Color(Color.BRIGHT_BLACK)
|
|
COLOR_STARTED = Color(226)
|
|
COLOR_FINISHED = Color(Color.BRIGHT_BLUE)
|
|
COLOR_DELIVERED = Color(208)
|
|
COLOR_ACCEPTED = Color(Color.BRIGHT_GREEN)
|
|
COLOR_REJECTED = Color(Color.BRIGHT_RED)
|
|
|
|
|
|
def _format_state(state: str) -> str:
|
|
STATES = {
|
|
'accepted': COLOR_ACCEPTED.format('accepted'),
|
|
'rejected': COLOR_REJECTED.format('rejected'),
|
|
'delivered': COLOR_DELIVERED.format('delivered'),
|
|
'finished': COLOR_FINISHED.format('finished'),
|
|
'started': COLOR_STARTED.format('started'),
|
|
'planned': COLOR_PLANNED.format('planned'),
|
|
'unstarted': COLOR_PLANNED.format('unstarted'),
|
|
}
|
|
|
|
return STATES[state]
|
|
|
|
|
|
def _get_persons(token: str, project_id: int) -> Dict[int, Dict[str, Any]]:
|
|
memberships = api.projects.get_memberships(token, project_id)
|
|
|
|
persons: Dict[int, Dict[str, Any]] = {}
|
|
for membership in memberships:
|
|
person = membership['person']
|
|
persons[person['id']] = person
|
|
|
|
return persons
|