Skip to content

Commit

Permalink
Merge pull request #1567 from dealako/bug/1533-python-get-project-issue
Browse files Browse the repository at this point in the history
[#1533] Resolved CORS API Issue - Signed at Foundation Flag
  • Loading branch information
dealako authored Aug 13, 2020
2 parents 188449b + 94341a6 commit aea6aca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
19 changes: 10 additions & 9 deletions cla-backend/cla/models/dynamo_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2819,16 +2819,17 @@ def delete(self):
self.model.delete()

@property
def signed_at_foundation(self):
cla_group = {}
def signed_at_foundation(self) -> bool:
# use a 'set' so that we don't have any duplicates
unique_cla_groups = set()
if self.model.foundation_sfid:
project_cla_groups = self.get_by_foundation_sfid(self.model.foundation_sfid)
for pcg in project_cla_groups:
if cla_group.get(self.model.cla_group_id):
cla_group[self.model.cla_group_id] = cla_group[self.model.cla_group_id].append(self.model.project_sfid)
else:
cla_group[self.model.cla_group_id] = [self.model.project_sfid]
return len(cla_group) == 1
# Get all records that might have the same foundation ID (including this current record)
for mapping in self.get_by_foundation_sfid(self.model.foundation_sfid):
# Add the CLA Group ID - no duplicates
unique_cla_groups.add(mapping.get_cla_group_id())

# if only CLA Group - we consider this at the Foundation Level
return len(unique_cla_groups) == 1

def get_project_sfid(self):
return self.model.project_sfid
Expand Down
8 changes: 7 additions & 1 deletion cla-backend/cla/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,13 @@ def get_project(project_id: hug.types.uuid):
for project_cla_group in project_cla_group_list:
sf_projects.append(project_cla_group.to_dict())
project["projects"] = sf_projects
project["signed_at_foundation_level"] = project_cla_group_list[0].signed_at_foundation

# if we have at least one SF Project associated with this CLA Group
if len(project_cla_group_list) > 0:
project["signed_at_foundation_level"] = project_cla_group_list[0].signed_at_foundation
else:
# Default is false, common for v1 not to have any mappings
project["signed_at_foundation_level"] = False

return project

Expand Down

0 comments on commit aea6aca

Please sign in to comment.