Allow user to rename task order and do no push othertext to DB
This commit is contained in:
parent
3765bbea12
commit
804ddc4db5
@ -62,21 +62,6 @@ class ShowTaskOrderWorkflow:
|
||||
|
||||
return self._task_order
|
||||
|
||||
@property
|
||||
def task_order_formdata(self):
|
||||
task_order_dict = self.task_order.to_dictionary()
|
||||
for field in task_order_dict:
|
||||
if task_order_dict[field] is None:
|
||||
task_order_dict[field] = ""
|
||||
|
||||
# don't save other text in DB unless "other" is checked
|
||||
if "other" not in task_order_dict["complexity"]:
|
||||
task_order_dict["complexity_other"] = ""
|
||||
if "other" not in task_order_dict["dev_team"]:
|
||||
task_order_dict["dev_team_other"] = ""
|
||||
|
||||
return task_order_dict
|
||||
|
||||
@property
|
||||
def form(self):
|
||||
form_type = (
|
||||
@ -137,12 +122,14 @@ class UpdateTaskOrderWorkflow(ShowTaskOrderWorkflow):
|
||||
def task_order_form_data(self):
|
||||
to_data = self.form.data.copy()
|
||||
if "portfolio_name" in to_data:
|
||||
new_name = self.form.data["portfolio_name"]
|
||||
old_name = self.task_order.to_dictionary()["portfolio_name"]
|
||||
if not new_name is old_name:
|
||||
Portfolios.update(self.task_order.portfolio, {"name": new_name})
|
||||
to_data.pop("portfolio_name")
|
||||
|
||||
# don't save other text in DB unless "other" is checked
|
||||
if "complexity" in to_data and "other" not in to_data["complexity"]:
|
||||
to_data["complexity_other"] = ""
|
||||
if "dev_team" in to_data and "other" not in to_data["dev_team"]:
|
||||
to_data["dev_team_other"] = ""
|
||||
|
||||
return to_data
|
||||
|
||||
def validate(self):
|
||||
@ -150,6 +137,11 @@ class UpdateTaskOrderWorkflow(ShowTaskOrderWorkflow):
|
||||
|
||||
def _update_task_order(self):
|
||||
if self.task_order:
|
||||
if "portfolio_name" in self.form.data:
|
||||
new_name = self.form.data["portfolio_name"]
|
||||
old_name = self.task_order.to_dictionary()["portfolio_name"]
|
||||
if not new_name is old_name:
|
||||
Portfolios.update(self.task_order.portfolio, {"name": new_name})
|
||||
TaskOrders.update(self.user, self.task_order, **self.task_order_form_data)
|
||||
else:
|
||||
pf = Portfolios.create(self.user, self.form.portfolio_name.data)
|
||||
|
@ -162,6 +162,18 @@ def test_update_task_order_with_existing_task_order(task_order):
|
||||
assert workflow.task_order.start_date.strftime("%m/%d/%Y") == to_data["start_date"]
|
||||
|
||||
|
||||
def test_other_text_not_saved_if_other_not_checked(task_order):
|
||||
to_data = {
|
||||
**TaskOrderFactory.dictionary(),
|
||||
"complexity": ["conus", "other"],
|
||||
"complexity_other": "quite complex",
|
||||
}
|
||||
workflow = UpdateTaskOrderWorkflow(
|
||||
task_order.creator, to_data, task_order_id=task_order.id
|
||||
)
|
||||
workflow.update()
|
||||
|
||||
|
||||
def test_invite_officers_to_task_order(task_order, queue):
|
||||
to_data = {
|
||||
**TaskOrderFactory.dictionary(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user