add officers to task order and redirect to TO when they accept a workspace invite

This commit is contained in:
dandds
2019-01-04 11:14:50 -05:00
parent 33de14caaf
commit d0bfa16f17
7 changed files with 137 additions and 5 deletions

View File

@@ -154,7 +154,7 @@ class UpdateTaskOrderWorkflow(ShowTaskOrderWorkflow):
},
]
def _update_invitations(self):
def _update_officer_invitations(self):
for officer_type in self.OFFICER_INVITATIONS:
field = officer_type["field"]
if (
@@ -169,16 +169,19 @@ class UpdateTaskOrderWorkflow(ShowTaskOrderWorkflow):
}
invite_service = InvitationService(
self.user,
self.task_order.workspace,
self.workspace,
{**officer_data, "workspace_role": officer_type["role"]},
subject=officer_type["subject"],
email_template=officer_type["template"],
)
invite_service.invite()
invite = invite_service.invite()
TaskOrders.add_officer(
self.task_order, invite.user, officer_type["role"]
)
def update(self):
self._update_task_order()
self._update_invitations()
self._update_officer_invitations()
return self.task_order

View File

@@ -20,6 +20,25 @@ def send_invite_email(owner_name, token, new_member_email):
def accept_invitation(token):
invite = Invitations.accept(g.current_user, token)
# TODO: this will eventually redirect to different places depending on
# whether the user is an officer for the TO and what kind of officer they
# are. It will also have to manage cases like:
# - the logged-in user has multiple roles on the TO (e.g., KO and COR)
# - the logged-in user has officer roles on multiple unsigned TOs
for task_order in invite.workspace.task_orders:
if g.current_user == task_order.contracting_officer:
return redirect(
url_for("task_orders.new", screen=4, task_order_id=task_order.id)
)
elif g.current_user == task_order.contracting_officer_representative:
return redirect(
url_for("task_orders.new", screen=4, task_order_id=task_order.id)
)
elif g.current_user == task_order.security_officer:
return redirect(
url_for("task_orders.new", screen=4, task_order_id=task_order.id)
)
return redirect(
url_for("workspaces.show_workspace", workspace_id=invite.workspace.id)
)