-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* suspension/resumption * actions * suspension/resumption * implement actions - initial * #1102 - Create action logic --------- Co-authored-by: Dinesh <dinesh.pb@aot-technologies.com>
- Loading branch information
1 parent
40bb9e1
commit 5493537
Showing
18 changed files
with
182 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,37 @@ | ||
"""Disable work start date action handler""" | ||
|
||
from api.actions.base import ActionFactory | ||
from api.models.event import Event | ||
|
||
|
||
class CreateWork(ActionFactory): # pylint: disable=too-few-public-methods | ||
"""Create a new work based on the current project and other parameters""" | ||
|
||
def run(self, source_event: Event, params: dict) -> None: | ||
"""Performs the required operations""" | ||
return | ||
|
||
def get_additional_params(self, params): | ||
"""Returns additional parameter""" | ||
return params | ||
"""Create work action handler""" | ||
# from datetime import timedelta | ||
|
||
from api.actions.base import ActionFactory | ||
|
||
|
||
# from api.models import db | ||
# from api.models.work_type import WorkType | ||
|
||
|
||
class CreateWork(ActionFactory): | ||
"""Create work action""" | ||
|
||
def run(self, source_event, params) -> None: | ||
"""Create a new WORK: "Minister's Designation" and link to this work's Project""" | ||
# TODO: Uncomment after work type data is imported | ||
# # Importing here to avoid circular imports | ||
# from api.services.work import WorkService # pylint: disable=import-outside-toplevel | ||
# work_type = ( | ||
# db.session.query(WorkType) | ||
# .filter( | ||
# WorkType.name == "Minister's Designation", WorkType.is_active.is_(True) | ||
# ) | ||
# .first() | ||
# ) | ||
# new_work = { | ||
# "ea_act_id": source_event.work.ea_act_id, | ||
# "work_type_id": work_type.id, | ||
# "start_date": source_event.actual_date + timedelta(days=1), | ||
# "project_id": source_event.work.project_id, | ||
# "ministry_id": source_event.work.ministry_id, | ||
# "federal_involvement_id": source_event.work.federal_involvement_id, | ||
# "title": f"{source_event.work.project.name} - {work_type.report_title}", | ||
# "is_active": True, | ||
# "responsible_epd_id": source_event.work.responsible_epd_id | ||
# } | ||
# WorkService.create_work(new_work) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
"""Disable work start date action handler""" | ||
|
||
from api.actions.base import ActionFactory | ||
from api.models.event import Event | ||
|
||
|
||
class SetEventDate(ActionFactory): # pylint: disable=too-few-public-methods | ||
"""Sets the event date""" | ||
|
||
def run(self, source_event: Event, params: dict) -> None: | ||
def run(self, source_event, params: dict) -> None: | ||
"""Performs the required operations""" | ||
return | ||
|
||
def get_additional_params(self, params): | ||
"""Returns additional parameter""" | ||
return params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
"""Disable work start date action handler""" | ||
|
||
from api.actions.base import ActionFactory | ||
from api.models.event import Event | ||
|
||
|
||
class SetEventsStatus(ActionFactory): # pylint: disable=too-few-public-methods | ||
"""Sets all the future events status""" | ||
|
||
def run(self, source_event: Event, params: dict) -> None: | ||
"""Performs the required operations""" | ||
return | ||
|
||
def get_additional_params(self, params): | ||
"""Returns additional parameter""" | ||
return params | ||
"""Set events status action handler""" | ||
from api.actions.base import ActionFactory | ||
from api.models import db | ||
from api.models.event import Event | ||
|
||
|
||
class SetEventsStatus(ActionFactory): | ||
"""Set events status action""" | ||
|
||
def run(self, source_event, params): | ||
"""Sets all future events to INACTIVE""" | ||
db.session.query(Event).filter( | ||
Event.work_id == source_event.work_id, | ||
Event.anticipated_date >= source_event.actual_date | ||
).update(params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
"""Disable work start date action handler""" | ||
|
||
from api.actions.base import ActionFactory | ||
from api.models.event import Event | ||
|
||
|
||
class SetPhasesStatus(ActionFactory): # pylint: disable=too-few-public-methods | ||
"""Sets all the future phases status""" | ||
|
||
def run(self, source_event: Event, params: dict) -> None: | ||
"""Performs the required operations""" | ||
return | ||
|
||
def get_additional_params(self, params): | ||
"""Returns additional parameter""" | ||
return params | ||
"""Set phases status action handler""" | ||
from api.actions.base import ActionFactory | ||
from api.models import db | ||
from api.models.work_phase import WorkPhase | ||
|
||
|
||
class SetPhasesStatus(ActionFactory): | ||
"""Set phases status action""" | ||
|
||
def run(self, source_event, params): | ||
"""Sets all future PHASEs to INACTIVE""" | ||
db.session.query(WorkPhase).filter( | ||
WorkPhase.work_id == source_event.work_id, | ||
WorkPhase.start_date >= source_event.actual_date | ||
).update(params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
"""Disable work start date action handler""" | ||
|
||
from api.actions.base import ActionFactory | ||
from api.models import db | ||
from api.models.event import Event | ||
from api.models.project import Project | ||
|
||
|
||
class SetProjectStatus(ActionFactory): # pylint: disable=too-few-public-methods | ||
"""Sets the project status active/inactive""" | ||
|
||
def run(self, source_event: Event, params: dict) -> None: | ||
"""Performs the required operations""" | ||
db.session.query(Project).filter( | ||
Project.id == source_event.work.project.id | ||
).update(params) | ||
db.session.commit() | ||
|
||
def get_additional_params(self, params): | ||
"""Returns additional parameter""" | ||
return params | ||
"""Set project status action handler""" | ||
|
||
from api.actions.base import ActionFactory | ||
from api.models import db | ||
from api.models.project import Project | ||
|
||
|
||
class SetProjectStatus(ActionFactory): # pylint: disable=too-few-public-methods | ||
"""Set project status action""" | ||
|
||
def run(self, source_event, params) -> None: | ||
"""Sets the project's is_active status to False""" | ||
db.session.query(Project).filter( | ||
Project.id == source_event.work.project_id | ||
).update(params) | ||
db.session.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
"""Disable work start date action handler""" | ||
|
||
from api.actions.base import ActionFactory | ||
from api.models.event import Event | ||
|
||
|
||
class SetWorkDecisionMaker(ActionFactory): # pylint: disable=too-few-public-methods | ||
"""Sets the work decision maker""" | ||
|
||
def run(self, source_event: Event, params: dict) -> None: | ||
def run(self, source_event, params: dict) -> None: | ||
"""Performs the required operations""" | ||
return | ||
|
||
def get_additional_params(self, params): | ||
"""Returns additional parameter""" | ||
return params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
"""Disable work start date action handler""" | ||
|
||
from api.actions.base import ActionFactory | ||
from api.models.event import Event | ||
|
||
|
||
class SetWorkState(ActionFactory): # pylint: disable=too-few-public-methods | ||
"""Sets the work state""" | ||
|
||
def run(self, source_event: Event, params: dict) -> None: | ||
"""Performs the required operations""" | ||
return | ||
|
||
def get_additional_params(self, params): | ||
"""Returns additional parameter""" | ||
return params | ||
"""Set work state action handler""" | ||
|
||
from api.actions.base import ActionFactory | ||
from api.models import db | ||
from api.models.work import Work | ||
|
||
|
||
class SetWorkState(ActionFactory): | ||
"""Set work state status action""" | ||
|
||
def run(self, source_event, params) -> None: | ||
"""Sets the work as per action configuration""" | ||
work_state = self.get_additional_params(params) | ||
db.session.query(Work).filter(Work.id == source_event.work_id).update(work_state) | ||
db.session.commit() | ||
|
||
def get_additional_params(self, params) -> dict: | ||
"""Returns the derived additional parameters required to perform action from templates""" | ||
return {"work_state": params["work_state"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.