def setup_challenge_groups( instance: Challenge = None, created: bool = False, *_, **__ ): if created: # Create the evaluation config Config.objects.create(challenge=instance) # Create the groups only on first save admins_group = Group.objects.create(name=instance.admin_group_name()) participants_group = Group.objects.create( name=instance.participants_group_name() ) instance.admins_group = admins_group instance.participants_group = participants_group instance.save() assign_perm("change_challenge", admins_group, instance) # Create the datasets ImageSet.objects.create(phase=ImageSet.TESTING, challenge=instance) ImageSet.objects.create(phase=ImageSet.TRAINING, challenge=instance) # add current user to admins for this site try: instance.creator.groups.add(admins_group) except AttributeError: # No creator set pass send_challenge_created_email(instance)
def setup_challenge_groups( instance: Challenge = None, created: bool = False, *_, **__ ): if created: # Create the evaluation config Config.objects.create(challenge=instance) # Create the groups only on first save admins_group = Group.objects.create(name=instance.admin_group_name()) participants_group = Group.objects.create( name=instance.participants_group_name() ) instance.admins_group = admins_group instance.participants_group = participants_group instance.save() assign_perm("change_challenge", admins_group, instance) # Create the datasets ImageSet.objects.create(phase=ImageSet.TESTING, challenge=instance) ImageSet.objects.create(phase=ImageSet.TRAINING, challenge=instance) # add current user to admins for this challenge try: instance.creator.groups.add(admins_group) except AttributeError: # No creator set pass send_challenge_created_email(instance)
def _create_new_challenge(self, *, src_challenge, dest_name): new_challenge = Challenge( short_name=dest_name, **{f: getattr(src_challenge, f) for f in self.challenge_fields}, ) new_challenge.full_clean() new_challenge.save() return new_challenge