diff --git a/epictrack-api/migrations/versions/0ccfa4829660_adding_column_in_action_template_and_.py b/epictrack-api/migrations/versions/0ccfa4829660_adding_column_in_action_template_and_.py new file mode 100644 index 000000000..59f49c883 --- /dev/null +++ b/epictrack-api/migrations/versions/0ccfa4829660_adding_column_in_action_template_and_.py @@ -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 ### diff --git a/epictrack-api/migrations/versions/cb80bd4fe249_adding_suggested_in_visibility_enum.py b/epictrack-api/migrations/versions/cb80bd4fe249_adding_suggested_in_visibility_enum.py new file mode 100644 index 000000000..2fb0ed258 --- /dev/null +++ b/epictrack-api/migrations/versions/cb80bd4fe249_adding_suggested_in_visibility_enum.py @@ -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 ### diff --git a/epictrack-api/src/api/models/event_template.py b/epictrack-api/src/api/models/event_template.py index c9e053f3a..5f2c5c330 100644 --- a/epictrack-api/src/api/models/event_template.py +++ b/epictrack-api/src/api/models/event_template.py @@ -34,6 +34,7 @@ class EventTemplateVisibilityEnum(enum.Enum): MANDATORY = "MANDATORY" OPTIONAL = "OPTIONAL" HIDDEN = "HIDDEN" + SUGGESTED = "SUGGESTED" class EventTemplate(BaseModelVersioned): diff --git a/epictrack-api/src/api/schemas/request/action_configuration_request.py b/epictrack-api/src/api/schemas/request/action_configuration_request.py index 3f827052d..442ed3927 100644 --- a/epictrack-api/src/api/schemas/request/action_configuration_request.py +++ b/epictrack-api/src/api/schemas/request/action_configuration_request.py @@ -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"} ) diff --git a/epictrack-api/src/api/schemas/request/action_template_request.py b/epictrack-api/src/api/schemas/request/action_template_request.py index 49b9d7399..e9b2e38c8 100644 --- a/epictrack-api/src/api/schemas/request/action_template_request.py +++ b/epictrack-api/src/api/schemas/request/action_template_request.py @@ -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"} ) diff --git a/epictrack-api/src/api/services/event.py b/epictrack-api/src/api/services/event.py index bb0e6ecba..35ff203da 100644 --- a/epictrack-api/src/api/services/event.py +++ b/epictrack-api/src/api/services/event.py @@ -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: @@ -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( @@ -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( @@ -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, ) ) diff --git a/epictrack-api/src/api/services/event_template.py b/epictrack-api/src/api/services/event_template.py index 4136a32c4..a31a5403f 100644 --- a/epictrack-api/src/api/services/event_template.py +++ b/epictrack-api/src/api/services/event_template.py @@ -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", }, diff --git a/epictrack-api/src/api/templates/event_templates/assessment/002_EAC_Assessment.xlsx b/epictrack-api/src/api/templates/event_templates/assessment/002_EAC_Assessment.xlsx new file mode 100644 index 000000000..5461b541a Binary files /dev/null and b/epictrack-api/src/api/templates/event_templates/assessment/002_EAC_Assessment.xlsx differ diff --git a/epictrack-api/src/api/templates/event_templates/project_notification/001-Project_Notification.xlsx b/epictrack-api/src/api/templates/event_templates/project_notification/001_Project_Notification.xlsx similarity index 100% rename from epictrack-api/src/api/templates/event_templates/project_notification/001-Project_Notification.xlsx rename to epictrack-api/src/api/templates/event_templates/project_notification/001_Project_Notification.xlsx diff --git a/epictrack-api/src/api/templates/event_templates/project_notification/002_Project_Notification.xlsx b/epictrack-api/src/api/templates/event_templates/project_notification/002_Project_Notification.xlsx new file mode 100644 index 000000000..a0ee4092b Binary files /dev/null and b/epictrack-api/src/api/templates/event_templates/project_notification/002_Project_Notification.xlsx differ diff --git a/epictrack-web/src/models/event.ts b/epictrack-web/src/models/event.ts index de97c7650..42afe6710 100644 --- a/epictrack-web/src/models/event.ts +++ b/epictrack-web/src/models/event.ts @@ -86,4 +86,5 @@ export enum EventTemplateVisibility { MANDATORY = "MANDATORY", OPTIONAL = "OPTIONAL", HIDDEN = "HIDDEN", + SUGGESTED = "SUGGESTED", }