Skip to content

Commit e6ac55d

Browse files
Removes the possibility of adding yourself twice as a creator
1 parent 8228765 commit e6ac55d

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
@@ -566,16 +566,16 @@ def _create_sample(
566566
elif isinstance(creator, str):
567567
additional_creator_ids.append(ObjectId(creator))
568568

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

580580
if "share_with_groups" in sample_dict and sample_dict["share_with_groups"]:
581581
group_ids = []

0 commit comments

Comments
 (0)