prevent redundant invitations for task order officers
This commit is contained in:
@@ -63,3 +63,21 @@ class Workspace(Base, mixins.TimestampsMixin, mixins.AuditableMixin):
|
||||
return "<Workspace(name='{}', request='{}', user_count='{}', id='{}')>".format(
|
||||
self.name, self.request_id, self.user_count, self.id
|
||||
)
|
||||
|
||||
def _find_by_role(self, role):
|
||||
try:
|
||||
return [member for member in self.members if member.role.name == role]
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
@property
|
||||
def contracting_officer(self):
|
||||
return self._find_by_role("contracting_officer")
|
||||
|
||||
@property
|
||||
def contracting_officer_representative(self):
|
||||
return self._find_by_role("contracting_officer_representative")
|
||||
|
||||
@property
|
||||
def security_officer(self):
|
||||
return self._find_by_role("security_officer")
|
||||
|
@@ -112,6 +112,11 @@ class UpdateTaskOrderWorkflow(ShowTaskOrderWorkflow):
|
||||
def form(self):
|
||||
return self._section["form"](self.form_data)
|
||||
|
||||
@property
|
||||
def workspace(self):
|
||||
if self.task_order:
|
||||
return self.task_order.workspace
|
||||
|
||||
def validate(self):
|
||||
return self.form.validate()
|
||||
|
||||
@@ -152,7 +157,11 @@ class UpdateTaskOrderWorkflow(ShowTaskOrderWorkflow):
|
||||
def _update_invitations(self):
|
||||
for officer_type in self.OFFICER_INVITATIONS:
|
||||
field = officer_type["field"]
|
||||
if hasattr(self.form, field) and self.form[field].data:
|
||||
if (
|
||||
hasattr(self.form, field)
|
||||
and self.form[field].data
|
||||
and not getattr(self.workspace, officer_type["role"])
|
||||
):
|
||||
prefix = officer_type["prefix"]
|
||||
officer_data = {
|
||||
field: getattr(self.task_order, prefix + "_" + field)
|
||||
|
Reference in New Issue
Block a user