Skip to content

Commit 87c61b6

Browse files
BenjaminCharmesml-evs
authored andcommitted
Removes the possibility of adding yourself twice as a creator
1 parent 426c7d1 commit 87c61b6

File tree

1 file changed

+10
-10
lines changed
  • pydatalab/src/pydatalab/routes/v0_1

1 file changed

+10
-10
lines changed

pydatalab/src/pydatalab/routes/v0_1/items.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -568,16 +568,16 @@ def _create_sample(
568568
elif isinstance(creator, str):
569569
additional_creator_ids.append(ObjectId(creator))
570570

571-
new_sample["creator_ids"].extend(additional_creator_ids)
572-
573-
for creator in sample_dict["additional_creators"]:
574-
if isinstance(creator, dict):
575-
new_sample["creators"].append(
576-
{
577-
"display_name": creator.get("display_name", ""),
578-
"contact_email": creator.get("contact_email", ""),
579-
}
580-
)
571+
new_sample["creator_ids"] = list(dict.fromkeys(new_sample["creator_ids"]))
572+
573+
seen_creators = set()
574+
unique_creators = []
575+
for creator in new_sample["creators"]:
576+
creator_key = (creator.get("display_name", ""), creator.get("contact_email", ""))
577+
if creator_key not in seen_creators:
578+
seen_creators.add(creator_key)
579+
unique_creators.append(creator)
580+
new_sample["creators"] = unique_creators
581581

582582
if "share_with_groups" in sample_dict and sample_dict["share_with_groups"]:
583583
group_ids = []

0 commit comments

Comments
 (0)