Skip to content

Commit

Permalink
1470 (#2121)
Browse files Browse the repository at this point in the history
* project name issue fix for works

* Existence check for work title changes

* handle termination/withdrawn

* work start date per start event and phaes change
  • Loading branch information
dinesh-aot authored Apr 16, 2024
1 parent eec121a commit cad0c10
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
15 changes: 13 additions & 2 deletions epictrack-api/src/api/actions/set_work_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@

from api.actions.base import ActionFactory
from api.models import db
from api.models.work import Work
from api.models.work import Work, WorkStateEnum
from .change_phase_end_event import ChangePhaseEndEvent


class SetWorkState(ActionFactory):
"""Set work state status action"""

def run(self, source_event, params) -> None:
"""Sets the work as per action configuration"""
work_state = params.get("work_state")
if work_state in [WorkStateEnum.TERMINATED.value, WorkStateEnum.WITHDRAWN.value]:
change_phase_end_event = ChangePhaseEndEvent()
change_phase_end_event_param = {
"phase_name": source_event.event_configuration.work_phase.name,
"work_type_id": source_event.work.work_type_id,
"ea_act_id": source_event.work.ea_act_id,
"event_name": source_event.event_configuration.name
}
change_phase_end_event.run(source_event, change_phase_end_event_param)
db.session.query(Work).filter(Work.id == source_event.work_id).update(
{Work.work_state: params.get("work_state")}
{Work.work_state: work_state}
)
17 changes: 17 additions & 0 deletions epictrack-api/src/api/services/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ def _process_events(
cls._previous_event_acutal_date_rule(
all_work_events, all_work_phases, current_work_phase_index, event, event_old
)
cls._handle_work_start_date_for_start_event_start_phase(
event, current_work_phase_index
)
number_of_days_to_be_pushed = cls._get_number_of_days_to_be_pushed(
event, event_old, current_work_phase
)
Expand Down Expand Up @@ -531,6 +534,20 @@ def _handle_work_phase_for_start_event(
current_work_phase.as_dict(recursive=False), commit=False
)

@classmethod
def _handle_work_start_date_for_start_event_start_phase(
cls, event: Event, current_phase_index: int
):
"""Update the work start date to the event's actual if the event is start event and the phase is start phase"""
if (
event.actual_date
and event.event_position == EventPositionEnum.START.value
and current_phase_index == 0
):
work = event.work
work.start_date = event.actual_date
work.update(work.as_dict(recursive=False), commit=False)

@classmethod
def _handle_end_event_date_when_start_event_changed(
cls,
Expand Down
Binary file not shown.
23 changes: 17 additions & 6 deletions epictrack-web/src/components/workPlan/phase/PhaseAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ const PhaseAccordion = ({ phase, ...rest }: PhaseAccordionProps) => {
</Grid>
<Grid item xs={2}>
<SummaryItem
title="Days left / Total"
title={
phase.work_phase.is_completed
? "Total"
: "Days left / Total"
}
children={
<Box
sx={{
Expand All @@ -167,11 +171,18 @@ const PhaseAccordion = ({ phase, ...rest }: PhaseAccordionProps) => {
: Palette.neutral.dark,
}}
>
{phase.days_left < 0 ? 0 : phase.days_left} /{" "}
{phase.total_number_of_days.toString()}
{phase.days_left < 0
? ` (${Math.abs(phase.days_left)} over)`
: ""}
{phase.work_phase.is_completed && (
<>{phase.days_left < 0 ? 0 : phase.days_left}</>
)}
{!phase.work_phase.is_completed && (
<>
{phase.days_left < 0 ? 0 : phase.days_left} /{" "}
{phase.total_number_of_days.toString()}
{phase.days_left < 0
? ` (${Math.abs(phase.days_left)} over)`
: ""}
</>
)}
</ETParagraph>
<When condition={phase.days_left < 0}>
<Box
Expand Down

0 comments on commit cad0c10

Please sign in to comment.