Skip to content

Commit

Permalink
SUGGESTED visibility + Project Notification Template (#1992)
Browse files Browse the repository at this point in the history
* actual date max value for extension event

* project notification latest template
  • Loading branch information
dinesh-aot authored Mar 15, 2024
1 parent f0ca71f commit 42cb9f3
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""adding column in action template and configuration
Revision ID: 0ccfa4829660
Revises: cb80bd4fe249
Create Date: 2024-03-14 11:55:04.817258
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '0ccfa4829660'
down_revision = 'cb80bd4fe249'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('action_configurations', schema=None) as batch_op:
batch_op.add_column(sa.Column('description', sa.String(), nullable=True))

with op.batch_alter_table('action_configurations_history', schema=None) as batch_op:
batch_op.add_column(sa.Column('description', sa.String(), autoincrement=False, nullable=True))

with op.batch_alter_table('action_templates', schema=None) as batch_op:
batch_op.add_column(sa.Column('description', sa.String(), nullable=True))

with op.batch_alter_table('action_templates_history', schema=None) as batch_op:
batch_op.add_column(sa.Column('description', sa.String(), autoincrement=False, nullable=True))

with op.batch_alter_table('special_fields', schema=None) as batch_op:
batch_op.drop_index('entity_field_index')
batch_op.create_index('entity_field_index', ['entity', 'entity_id', 'field_name', 'time_range'], unique=False)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('special_fields', schema=None) as batch_op:
batch_op.drop_index('entity_field_index')

with op.batch_alter_table('action_templates_history', schema=None) as batch_op:
batch_op.drop_column('description')

with op.batch_alter_table('action_templates', schema=None) as batch_op:
batch_op.drop_column('description')

with op.batch_alter_table('action_configurations_history', schema=None) as batch_op:
batch_op.drop_column('description')

with op.batch_alter_table('action_configurations', schema=None) as batch_op:
batch_op.drop_column('description')

# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""adding SUGGESTED in visibility enum
Revision ID: cb80bd4fe249
Revises: 498c9e7f50b6
Create Date: 2024-03-11 19:52:22.422861
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'cb80bd4fe249'
down_revision = '498c9e7f50b6'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("alter type eventtemplatevisibilityenum add value 'SUGGESTED' after 'HIDDEN'")
with op.batch_alter_table('action_configurations', schema=None) as batch_op:
batch_op.create_foreign_key(None, 'outcome_configurations', ['outcome_configuration_id'], ['id'])

with op.batch_alter_table('special_fields_history', schema=None) as batch_op:
batch_op.drop_index('entity_field_history_index')
batch_op.drop_index('entity_field_index')
batch_op.create_index('entity_field_index', ['entity', 'entity_id', 'field_name', 'time_range'], unique=False)

with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('simple_title',
existing_type=sa.TEXT(),
type_=sa.String(),
existing_nullable=True)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('simple_title',
existing_type=sa.String(),
type_=sa.TEXT(),
existing_nullable=True)

with op.batch_alter_table('special_fields_history', schema=None) as batch_op:
batch_op.drop_index('entity_field_index')
batch_op.create_index('entity_field_history_index', ['entity', 'entity_id', 'field_name', 'time_range'], unique=False)

with op.batch_alter_table('action_configurations', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='foreignkey')

# ### end Alembic commands ###
1 change: 1 addition & 0 deletions epictrack-api/src/api/models/event_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class EventTemplateVisibilityEnum(enum.Enum):
MANDATORY = "MANDATORY"
OPTIONAL = "OPTIONAL"
HIDDEN = "HIDDEN"
SUGGESTED = "SUGGESTED"


class EventTemplate(BaseModelVersioned):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class ActionConfigurationBodyParameterSchema(RequestBodyParameterSchema):
metadata={"description": "Additional parameters for the action"}
)

description = fields.Str(
metadata={"description": "Description of the action"}
)

sort_order = fields.Int(
metadata={"description": "Sort order of the event template item"}
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class ActionTemplateBodyParameterSchema(RequestBodyParameterSchema):
metadata={"description": "Additional parameters for the action"}
)

description = fields.Str(
metadata={"description": "Description of the action"}
)

sort_order = fields.Int(
metadata={"description": "Sort order of the event template item"}
)
13 changes: 9 additions & 4 deletions epictrack-api/src/api/services/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def update_event(
raise ResourceNotFoundError("Event not found")
if not event.is_active:
raise UnprocessableEntityError("Event is inactive and cannot be updated")
if current_work_phase.is_completed:
raise UnprocessableEntityError("Events cannot be added to completed phase")
# if current_work_phase.is_completed:
# raise UnprocessableEntityError("Events cannot be added to completed phase")
event = event.update(data, commit=False)
# Do not process the date logic if the event is already locked(has actual date entered)
if not event_old.actual_date:
Expand Down Expand Up @@ -341,6 +341,11 @@ def _process_events(
number_of_days_to_be_pushed,
event_old,
)
else:
all_work_event_configurations = (
EventConfigurationService.find_all_configurations_by_work(event.work_id)
)
cls._handle_child_events(all_work_event_configurations, event)

@classmethod
def _push_subsequent_events(
Expand Down Expand Up @@ -965,7 +970,7 @@ def _handle_child_events(
)
if existing_event:
existing_event.anticipated_date = c_event_start_date
existing_event.update(existing_event.as_dict(), commit=False)
existing_event.update(existing_event.as_dict(recursive=False), commit=False)
else:
Event.flush(
Event(
Expand All @@ -974,7 +979,7 @@ def _handle_child_events(
str(c_event_start_date),
c_event_conf.number_of_days,
c_event_conf.id,
c_event_conf.work_id,
event.work_id,
event.id,
)
)
Expand Down
1 change: 1 addition & 0 deletions epictrack-api/src/api/services/event_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ def _read_excel(cls, configuration_file: IO) -> Dict[str, pd.DataFrame]:
"OutcomeNo": "outcome_no",
"OutcomeName": "outcome_id",
"ActionName": "action_id",
"ActionDescription": "description",
"AdditionalParams": "additional_params",
"SortOrder": "sort_order",
},
Expand Down
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions epictrack-web/src/models/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ export enum EventTemplateVisibility {
MANDATORY = "MANDATORY",
OPTIONAL = "OPTIONAL",
HIDDEN = "HIDDEN",
SUGGESTED = "SUGGESTED",
}

0 comments on commit 42cb9f3

Please sign in to comment.