Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvanrun committed Jan 24, 2025
1 parent e33ac9a commit 70f6631
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/grandchallenge/challenges/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class OnboardingTaskAdmin(ModelAdmin):
"on_time",
"complete",
"deadline",
"responsible",
"responsible_party",
)
list_filter = (
OnTimeFilter,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.17 on 2025-01-22 12:28
# Generated by Django 4.2.17 on 2025-01-24 14:43

import uuid

Expand Down Expand Up @@ -60,7 +60,7 @@ class Migration(migrations.Migration):
),
),
(
"responsible",
"responsible_party",
models.CharField(
choices=[
("SUP", "Support"),
Expand Down
20 changes: 13 additions & 7 deletions app/grandchallenge/challenges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1405,13 +1405,13 @@ class ChallengeRequestGroupObjectPermission(GroupObjectPermissionBase):
)


class TaskResponsibleChoices(models.TextChoices):
class TaskResponsiblePartyChoices(models.TextChoices):
SUPPORT = "SUP", "Support"
CHALLENGE_ORGANIZERS = "ORG", "Challenge Organizers"


class OnboardingTask(FieldChangeMixin, UUIDModel):
ResponsibleChoices = TaskResponsibleChoices
ResponsiblePartyChoices = TaskResponsiblePartyChoices

class Meta:
permissions = [
Expand Down Expand Up @@ -1441,11 +1441,11 @@ class Meta:
blank=True,
help_text="Time this task was last marked completed.",
)
responsible = models.CharField(
responsible_party = models.CharField(
blank=False,
max_length=3,
choices=ResponsibleChoices.choices,
default=ResponsibleChoices.CHALLENGE_ORGANIZERS,
choices=ResponsiblePartyChoices.choices,
default=ResponsiblePartyChoices.CHALLENGE_ORGANIZERS,
help_text="Who is responsible for completion of this task.",
)
deadline = models.DateTimeField(
Expand All @@ -1464,11 +1464,17 @@ def save(self, *args, **kwargs):

super().save(*args, **kwargs)

if self.responsible == self.ResponsibleChoices.CHALLENGE_ORGANIZERS:
self.assign_permissions()

def assign_permissions(self):
if (
self.responsible_party
== self.ResponsiblePartyChoices.CHALLENGE_ORGANIZERS
):
assign_perm(
"complete_onboaringtask", self.challenge.admins_group, self
)
elif not adding:
else:
remove_perm(
"complete_onboaringtask", self.challenge.admins_group, self
)
Expand Down
6 changes: 3 additions & 3 deletions app/tests/challenges_tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def test_challenge_request_list_view_permissions(client, challenge_reviewer):
"responsible,permitted",
(
(None, True), # Default
(OnboardingTask.ResponsibleChoices.SUPPORT, False),
(OnboardingTask.ResponsibleChoices.CHALLENGE_ORGANIZERS, True),
(OnboardingTask.ResponsiblePartyChoices.SUPPORT, False),
(OnboardingTask.ResponsiblePartyChoices.CHALLENGE_ORGANIZERS, True),
),
)
def test_onboarding_task_completion_permissions(responsible, permitted):
Expand All @@ -137,7 +137,7 @@ def test_onboarding_task_completion_permissions(responsible, permitted):

kwargs = {}
if responsible:
kwargs["responsible"] = responsible
kwargs["responsible_party"] = responsible

task = OnboardingTaskFactory(challenge=ch, **kwargs)

Expand Down

0 comments on commit 70f6631

Please sign in to comment.