Move OT notifier to stages API (#3389)

* move OT notifier to stages API

* remove from features API
This commit is contained in:
Daniel Smith 2023-10-02 18:09:34 -07:00 коммит произвёл GitHub
Родитель 49b70583f4
Коммит a58936924a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 8 добавлений и 9 удалений

Просмотреть файл

@ -173,7 +173,6 @@ class FeaturesAPI(basehandlers.EntitiesAPIHandler):
) -> bool:
"""Update stage fields with changes provided in the PATCH request."""
stages: list[Stage] = []
ot_action_requested_stage: Stage | None = None
for change_info in stage_changes_list:
stage_was_updated = False
# Check if valid ID is provided and fetch stage if it exists.
@ -190,10 +189,6 @@ class FeaturesAPI(basehandlers.EntitiesAPIHandler):
continue
form_field_name = change_info[field]['form_field_name']
# If a creation request has been submitted, save for notification.
if form_field_name == 'ot_action_requested':
ot_action_requested_stage = stage
old_value = getattr(stage, field)
new_value = change_info[field]['value']
self.update_field_value(stage, field, field_type, new_value)
@ -224,10 +219,6 @@ class FeaturesAPI(basehandlers.EntitiesAPIHandler):
if stages:
ndb.put_multi(stages)
# Notify of OT request if one was sent.
if ot_action_requested_stage:
notifier_helpers.send_ot_creation_notification(ot_action_requested_stage)
# Return a boolean representing if any changes were made to any stages.
return len(stages) > 0

Просмотреть файл

@ -55,6 +55,7 @@ class StagesAPI(basehandlers.EntitiesAPIHandler):
) -> bool:
"""Update stage fields with changes provided."""
stage_was_updated = False
ot_action_requested = False
# Check if valid ID is provided and fetch stage if it exists.
# Update stage fields.
@ -62,6 +63,8 @@ class StagesAPI(basehandlers.EntitiesAPIHandler):
if field not in change_info:
continue
form_field_name = change_info[field]['form_field_name']
if form_field_name == 'ot_action_requested':
ot_action_requested = True
old_value = getattr(stage, field)
new_value = change_info[field]['value']
self.update_field_value(stage, field, field_type, new_value)
@ -85,6 +88,11 @@ class StagesAPI(basehandlers.EntitiesAPIHandler):
if stage_was_updated:
stage.put()
# Notify of OT request if one was sent.
if ot_action_requested:
notifier_helpers.send_ot_creation_notification(stage)
return stage_was_updated
def do_get(self, **kwargs):