Skip to content

Commit

Permalink
Extension date logic, push confirmation dialog not needed (#2311)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh-aot authored Jun 4, 2024
1 parent d8751ec commit 9af0f54
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
6 changes: 2 additions & 4 deletions epictrack-api/src/api/models/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ def fetch_all_works(
search_filters: WorkplanDashboardSearchOptions = None
) -> Tuple[List[Work], int]:
"""Fetch all active works."""
query = cls.filter_by_search_criteria(cls.query, search_filters)
query = cls.query.filter_by(is_deleted=False)
query = cls.filter_by_search_criteria(query, search_filters)
query = query.order_by(Work.start_date.desc())

no_pagination_options = not pagination_options or not pagination_options.page or not pagination_options.size
Expand Down Expand Up @@ -264,16 +265,13 @@ def _filter_by_work_states(cls, query, work_states):
ending_state_query = query.filter(
and_(
Work.work_state.in_(filtered_ending_states),
Work.is_active.is_(False),
Work.is_deleted.is_(False),
)
)
if filtered_non_ending_states:
query = query.filter(
and_(
Work.work_state.in_(filtered_non_ending_states),
Work.is_active.is_(True),
Work.is_deleted.is_(False),
)
)
if ending_state_query:
Expand Down
40 changes: 17 additions & 23 deletions epictrack-api/src/api/services/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,32 +891,26 @@ def _previous_event_acutal_date_rule( # pylint: disable=too-many-arguments
raise UnprocessableEntityError(
"Previous phase should be completed to proceed"
)
event_index = cls.find_event_index(
all_work_events,
event_old if event_old else event,
all_work_phases[current_work_phase_index],
)
phase_events = cls._find_work_phase_events(
all_work_events, event.event_configuration.work_phase_id
)
phase_events = sorted(
phase_events, key=functools.cmp_to_key(event_compare_func)
)
previous_event = phase_events[event_index - 1]
if (
event_index > 0
and not previous_event.actual_date
and not (
event.event_configuration.event_category_id
== EventCategoryEnum.EXTENSION.value
and previous_event.event_position == EventPositionEnum.END.value
)
# and not phase_events[event_index - 1].event_position
# == EventPositionEnum.END.value
event.event_configuration.event_category_id
!= EventCategoryEnum.EXTENSION.value
):
raise UnprocessableEntityError(
"Previous event should be completed to proceed"
event_index = cls.find_event_index(
all_work_events,
event_old if event_old else event,
all_work_phases[current_work_phase_index],
)
phase_events = cls._find_work_phase_events(
all_work_events, event.event_configuration.work_phase_id
)
phase_events = sorted(
phase_events, key=functools.cmp_to_key(event_compare_func)
)
previous_event = phase_events[event_index - 1]
if event_index > 0 and not previous_event.actual_date:
raise UnprocessableEntityError(
"Previous event should be completed to proceed"
)

@classmethod
def _handle_child_events(
Expand Down
10 changes: 9 additions & 1 deletion epictrack-web/src/components/workPlan/event/EventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ const EventForm = ({
),
[selectedConfiguration, selectedWorkPhase]
);
const pushRequired = useMemo(
() =>
dateCheckStatus?.subsequent_event_push_required &&
event?.event_configuration.event_category_id !== EventCategory.EXTENSION,
[dateCheckStatus, event]
);
const isHighPriorityActive = useMemo(() => {
if (event) {
return event.high_priority;
Expand Down Expand Up @@ -430,7 +436,6 @@ const EventForm = ({

const onSubmitHandler = async (submittedData: MilestoneEvent) => {
try {
const pushRequired = dateCheckStatus?.subsequent_event_push_required;
if (pushRequired) {
setShowEventPushConfirmation(pushRequired);
} else if (showLockConfirmDialog(submittedData)) {
Expand Down Expand Up @@ -509,6 +514,9 @@ const EventForm = ({
pushEventConfirmed = false,
confirmSaveInLocked = false
) => {
pushEventConfirmed =
pushEventConfirmed ||
event?.event_configuration.event_category_id === EventCategory.EXTENSION;
try {
const formData = data ?? getValues();
const dataToBeSubmitted = {
Expand Down

0 comments on commit 9af0f54

Please sign in to comment.