Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4347: Flag for submissions UI and CLI #4349

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
18 changes: 18 additions & 0 deletions apps/jobs/migrations/0027_submission_from_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.20 on 2024-04-21 02:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('jobs', '0026_auto_20230804_1946'),
]

operations = [
migrations.AddField(
model_name='submission',
name='from_cli',
field=models.BooleanField(default=False),
),
]
3 changes: 3 additions & 0 deletions apps/jobs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class Submission(TimeStampedModel):
submission_metadata = JSONField(blank=True, null=True)
is_verified_by_host = models.BooleanField(default=False)

# flag for submission type: UI(False) and CLI(True)
from_cli = models.BooleanField(default=False)

def __str__(self):
return "{}".format(self.id)

Expand Down
1 change: 1 addition & 0 deletions apps/jobs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Meta:
"job_name",
"submission_metadata",
"is_verified_by_host",
"from_cli",
)

def to_representation(self, instance):
Expand Down
1 change: 1 addition & 0 deletions tests/unit/challenges/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4503,6 +4503,7 @@ def test_get_all_submissions_when_user_is_participant_of_challenge(self):
"job_name": self.submission1.job_name,
"submission_metadata": None,
"is_verified_by_host": False,
"from_cli": False,
}
]
self.challenge5.participant_teams.add(self.participant_team6)
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/jobs/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ def test_get_challenge_submissions(self):
"job_name": self.submission.job_name,
"submission_metadata": None,
"is_verified_by_host": False,
"from_cli": False,
}
]
self.challenge.participant_teams.add(self.participant_team)
Expand Down Expand Up @@ -1403,6 +1404,7 @@ def test_change_submission_data_and_visibility_when_submission_exist(self):
"job_name": self.submission.job_name,
"submission_metadata": None,
"is_verified_by_host": False,
"from_cli": False,
}
self.challenge.participant_teams.add(self.participant_team)
response = self.client.patch(self.url, self.data)
Expand Down Expand Up @@ -1457,6 +1459,7 @@ def test_change_submission_data_and_visibility_when_challenge_phase_is_private_a
"job_name": self.submission.job_name,
"submission_metadata": None,
"is_verified_by_host": False,
"from_cli": False,
}

self.client.force_authenticate(user=self.user)
Expand Down Expand Up @@ -1528,6 +1531,7 @@ def test_change_submission_data_and_visibility_when_is_public_is_false(
"job_name": self.submission.job_name,
"submission_metadata": None,
"is_verified_by_host": False,
"from_cli": False,
}
self.challenge.participant_teams.add(self.participant_team)
response = self.client.patch(self.url, self.data)
Expand Down Expand Up @@ -1618,6 +1622,7 @@ def test_toggle_baseline_when_user_is_host(self):
"job_name": self.host_participant_team_submission.job_name,
"submission_metadata": None,
"is_verified_by_host": False,
"from_cli": False,
}
response = self.client.patch(self.url, self.data)
self.assertEqual(response.data, expected)
Expand Down Expand Up @@ -1700,6 +1705,7 @@ def test_get_submission_by_pk_when_user_created_the_submission(self):
"job_name": self.submission.job_name,
"submission_metadata": None,
"is_verified_by_host": False,
"from_cli": False,
}

self.client.force_authenticate(user=self.submission.created_by)
Expand Down Expand Up @@ -1749,6 +1755,7 @@ def test_get_submission_by_pk_when_user_is_challenge_host(self):
"job_name": self.submission.job_name,
"submission_metadata": None,
"is_verified_by_host": False,
"from_cli": False,
}

self.client.force_authenticate(user=self.user)
Expand Down