From 3d2c825d1822a582940d0bd0391e6fbd80eecb14 Mon Sep 17 00:00:00 2001 From: Suryansh Pathak <34577232+Suryansh5545@users.noreply.github.com> Date: Wed, 19 Jul 2023 07:04:33 +0530 Subject: [PATCH] [Frontend] Add tags and domains to challenge (#3981) * Added Tags and Domain * Fixed Test Case * Fixed Line issue * Update frontend/src/views/web/challenge/edit-challenge/edit-challenge-tag.html Co-authored-by: Gautam Jajoo * Addressing the comments * Fix Domain and Tags validation * Indentation Fix * Fixed Migration * Fixed Migration * Fixed Migrations * Fixes and Optimization * Fix indentation * Fixed test case * Shifted the methods to utils * Renamed Functions * . * Fix import issue --------- Co-authored-by: Gunjan Chhablani Co-authored-by: Gautam Jajoo --- apps/challenges/challenge_config_utils.py | 22 +++++- .../migrations/0098_challenge_tags_domains.py | 24 ++++++ apps/challenges/models.py | 7 ++ apps/challenges/serializers.py | 7 ++ apps/challenges/urls.py | 10 +++ apps/challenges/utils.py | 34 ++++++++ apps/challenges/views.py | 67 ++++++++++++++++ frontend/src/js/controllers/challengeCtrl.js | 75 ++++++++++++++++++ frontend/src/views/web/challenge-list.html | 6 ++ .../views/web/challenge/challenge-page.html | 10 +++ .../edit-challenge/edit-challenge-tag.html | 39 ++++++++++ frontend/src/views/web/hosted-challenges.html | 2 + .../controllers-test/challengeCtrl.test.js | 74 ++++++++++++++++++ tests/unit/challenges/test_views.py | 77 +++++++++++++++++++ tests/unit/participants/test_views.py | 8 ++ 15 files changed, 461 insertions(+), 1 deletion(-) create mode 100644 apps/challenges/migrations/0098_challenge_tags_domains.py create mode 100644 frontend/src/views/web/challenge/edit-challenge/edit-challenge-tag.html diff --git a/apps/challenges/challenge_config_utils.py b/apps/challenges/challenge_config_utils.py index 6112fb7652..c08dd02641 100644 --- a/apps/challenges/challenge_config_utils.py +++ b/apps/challenges/challenge_config_utils.py @@ -6,7 +6,7 @@ from django.core.files.base import ContentFile from os.path import basename, isfile, join -from challenges.models import ChallengePhase, ChallengePhaseSplit, DatasetSplit, Leaderboard +from challenges.models import ChallengePhase, ChallengePhaseSplit, DatasetSplit, Leaderboard, Challenge from rest_framework import status from yaml.scanner import ScannerError @@ -277,6 +277,8 @@ def get_value_from_field(data, base_location, field_name): "start_date_greater_than_end_date": "ERROR: Start date cannot be greater than end date.", "missing_dates_challenge_phase": "ERROR: Please add the start_date and end_date in challenge phase {}.", "start_date_greater_than_end_date_challenge_phase": "ERROR: Start date cannot be greater than end date in challenge phase {}.", + "extra_tags": "ERROR: Tags are limited to 4. Please remove extra tags then try again!", + "wrong_domain": "ERROR: Domain name is incorrect. Please enter correct domain name then try again!", } @@ -935,6 +937,24 @@ def validate_dataset_splits(self, current_dataset_config_ids): ].format(current_dataset_split_config_id) self.error_messages.append(message) + # Check for Tags and Domain + def check_tags(self): + if "tags" in self.yaml_file_data: + tags_data = self.yaml_file_data["tags"] + # Verify Tags are limited to 4 + if len(tags_data) > 4: + message = self.error_messages_dict["extra_tags"] + self.error_messages.append(message) + + def check_domain(self): + # Verify Domain name is correct + if "domain" in self.yaml_file_data: + domain_value = self.yaml_file_data["domain"] + domain_choice = [option[0] for option in Challenge.DOMAIN_OPTIONS] + if domain_value not in domain_choice: + message = self.error_messages_dict["wrong_domain"] + self.error_messages.append(message) + def validate_challenge_config_util( request, diff --git a/apps/challenges/migrations/0098_challenge_tags_domains.py b/apps/challenges/migrations/0098_challenge_tags_domains.py new file mode 100644 index 0000000000..2882037902 --- /dev/null +++ b/apps/challenges/migrations/0098_challenge_tags_domains.py @@ -0,0 +1,24 @@ +# Generated by Django 2.2.20 on 2023-07-16 15:41 + +import django.contrib.postgres.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('challenges', '0097_challengephase_disable_logs'), + ] + + operations = [ + migrations.AddField( + model_name='challenge', + name='domain', + field=models.CharField(blank=True, choices=[('CV', 'Computer Vision'), ('NLP', 'Natural Language Processing'), ('RL', 'Reinforcement Learning')], max_length=50, null=True), + ), + migrations.AddField( + model_name='challenge', + name='list_tags', + field=django.contrib.postgres.fields.ArrayField(base_field=models.TextField(blank=True, null=True), blank=True, default=list, size=None), + ), + ] diff --git a/apps/challenges/models.py b/apps/challenges/models.py index 6ab8c4399d..117a414f33 100644 --- a/apps/challenges/models.py +++ b/apps/challenges/models.py @@ -59,6 +59,13 @@ def __init__(self, *args, **kwargs): related_name="challenge_creator", on_delete=models.CASCADE, ) + DOMAIN_OPTIONS = ( + ("CV", "Computer Vision"), + ("NLP", "Natural Language Processing"), + ("RL", "Reinforcement Learning"), + ) + domain = models.CharField(max_length=50, choices=DOMAIN_OPTIONS, null=True, blank=True) + list_tags = ArrayField(models.TextField(null=True, blank=True), default=list, blank=True) published = models.BooleanField( default=False, verbose_name="Publicly Available", db_index=True ) diff --git a/apps/challenges/serializers.py b/apps/challenges/serializers.py index 7d49d0bfc4..52365a7265 100644 --- a/apps/challenges/serializers.py +++ b/apps/challenges/serializers.py @@ -21,6 +21,10 @@ class ChallengeSerializer(serializers.ModelSerializer): is_active = serializers.ReadOnlyField() + domain_name = serializers.SerializerMethodField() + + def get_domain_name(self, obj): + return obj.get_domain_display() def __init__(self, *args, **kwargs): super(ChallengeSerializer, self).__init__(*args, **kwargs) @@ -45,6 +49,9 @@ class Meta: "start_date", "end_date", "creator", + "domain", + "domain_name", + "list_tags", "published", "submission_time_limit", "is_registration_open", diff --git a/apps/challenges/urls.py b/apps/challenges/urls.py index bbfbc8b6e1..98e5bc593e 100644 --- a/apps/challenges/urls.py +++ b/apps/challenges/urls.py @@ -249,6 +249,16 @@ views.deregister_participant_team_from_challenge, name="deregister_participant_team_from_challenge", ), + url( + r"^challenge/(?P[0-9]+)/update_challenge_tags_and_domain/$", + views.update_challenge_tags_and_domain, + name="update_challenge_tags_and_domain", + ), + url( + r"^challenge/get_domain_choices/$", + views.get_domain_choices, + name="get_domain_choices", + ), ] app_name = "challenges" diff --git a/apps/challenges/utils.py b/apps/challenges/utils.py index 12fea45a3a..0fbd6690e6 100644 --- a/apps/challenges/utils.py +++ b/apps/challenges/utils.py @@ -9,6 +9,8 @@ from django.conf import settings from django.core.files.base import ContentFile from moto import mock_ecr, mock_sts +from rest_framework.response import Response +from rest_framework import status from base.utils import ( get_model_object, @@ -477,3 +479,35 @@ def parse_submission_meta_attributes(submission): meta_attribute["name"] ] = meta_attribute.get("value") return submission_meta_attributes + + +def add_tags_to_challenge(yaml_file_data, challenge): + if "tags" in yaml_file_data: + tags_data = yaml_file_data["tags"] + new_tags = set(tags_data) + # Remove tags not present in the YAML file + challenge.list_tags = [tag for tag in challenge.list_tags if tag in new_tags] + + # Add new tags to the challenge + for tag_name in new_tags: + if tag_name not in challenge.list_tags: + challenge.list_tags.append(tag_name) + else: + # Remove all existing tags if no tags are defined in the YAML file + challenge.list_tags = [] + + +def add_domain_to_challenge(yaml_file_data, challenge): + if "domain" in yaml_file_data: + domain_value = yaml_file_data["domain"] + valid_domains = [choice[0] for choice in challenge.DOMAIN_OPTIONS] + if domain_value in valid_domains: + challenge.domain = domain_value + challenge.save() + else: + message = f"Invalid domain value: {domain_value}, valid values are: {valid_domains}" + response_data = {"error": message} + return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE) + else: + challenge.domain = None + challenge.save() diff --git a/apps/challenges/views.py b/apps/challenges/views.py index 6aa1e2f6c8..f16a3ec13f 100644 --- a/apps/challenges/views.py +++ b/apps/challenges/views.py @@ -67,6 +67,8 @@ is_user_in_allowed_email_domains, is_user_in_blocked_email_domains, parse_submission_meta_attributes, + add_domain_to_challenge, + add_tags_to_challenge, ) from challenges.challenge_config_utils import ( download_and_write_file, @@ -1560,6 +1562,12 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk): # transaction.set_rollback(True) # return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE) + # Add Tags + add_tags_to_challenge(yaml_file_data, challenge) + + # Add Domain + add_domain_to_challenge(yaml_file_data, challenge) + # Create Leaderboard yaml_file_data_of_leaderboard = yaml_file_data["leaderboard"] leaderboard_ids = {} @@ -2568,6 +2576,53 @@ def get_or_update_challenge_phase_split(request, challenge_phase_split_pk): return Response(response_data, status=status.HTTP_200_OK) +@api_view(["PATCH"]) +@throttle_classes([UserRateThrottle]) +@permission_classes((permissions.IsAuthenticatedOrReadOnly, HasVerifiedEmail)) +@authentication_classes((JWTAuthentication, ExpiringTokenAuthentication)) +def update_challenge_tags_and_domain(request, challenge_pk): + """ + Returns or Updates challenge tags and domain + """ + challenge = get_challenge_model(challenge_pk) + + if request.method == "PATCH": + new_tags = request.data.get("list_tags", []) + domain_value = request.data.get("domain") + # Remove tags not present in the YAML file + challenge.list_tags = [tag for tag in challenge.list_tags if tag in new_tags] + # Add new tags to the challenge + for tag_name in new_tags: + if tag_name not in challenge.list_tags: + challenge.list_tags.append(tag_name) + # Verifying Domain name + valid_domains = [choice[0] for choice in challenge.DOMAIN_OPTIONS] + if domain_value in valid_domains: + challenge.domain = domain_value + challenge.save() + return Response(status=status.HTTP_200_OK) + else: + message = f"Invalid domain value:{domain_value}" + response_data = {"error": message} + return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE) + + +@api_view(["GET"]) +@throttle_classes([UserRateThrottle]) +@permission_classes((permissions.IsAuthenticatedOrReadOnly, HasVerifiedEmail)) +@authentication_classes((JWTAuthentication, ExpiringTokenAuthentication)) +def get_domain_choices(request): + """ + Returns domain choices + """ + if request.method == "GET": + domain_choices = Challenge.DOMAIN_OPTIONS + return Response(domain_choices, status.HTTP_200_OK) + else: + response_data = {"error": "Method not allowed"} + return Response(response_data, status.HTTP_405_METHOD_NOT_ALLOWED) + + @api_view(["GET", "POST"]) @throttle_classes([UserRateThrottle]) @permission_classes((permissions.IsAuthenticatedOrReadOnly, HasVerifiedEmail)) @@ -3549,6 +3604,12 @@ def create_or_update_github_challenge(request, challenge_host_team_pk): challenge.queue = queue_name challenge.save() + # Add Tags + add_tags_to_challenge(yaml_file_data, challenge) + + # Add Domain + add_domain_to_challenge(yaml_file_data, challenge) + # Create Leaderboard yaml_file_data_of_leaderboard = yaml_file_data[ "leaderboard" @@ -3792,6 +3853,12 @@ def create_or_update_github_challenge(request, challenge_host_team_pk): raise RuntimeError() challenge = serializer.instance + # Add Tags + add_tags_to_challenge(yaml_file_data, challenge) + + # Add Domain + add_domain_to_challenge(yaml_file_data, challenge) + # Updating Leaderboard object leaderboard_ids = {} yaml_file_data_of_leaderboard = yaml_file_data["leaderboard"] diff --git a/frontend/src/js/controllers/challengeCtrl.js b/frontend/src/js/controllers/challengeCtrl.js index 4247e62e0b..e6aaeaad72 100644 --- a/frontend/src/js/controllers/challengeCtrl.js +++ b/frontend/src/js/controllers/challengeCtrl.js @@ -2878,6 +2878,81 @@ } }; + vm.editchallengeTagDialog = function(ev) { + vm.tags = vm.page.list_tags; + vm.domain_choices(); + $mdDialog.show({ + scope: $scope, + preserveScope: true, + targetEvent: ev, + templateUrl: 'dist/views/web/challenge/edit-challenge/edit-challenge-tag.html', + escapeToClose: false + }); + }; + + vm.editChallengeTag = function(editChallengeTagDomainForm) { + var new_tags; + if (!editChallengeTagDomainForm) { + $mdDialog.hide(); + return; + } + new_tags = typeof vm.tags === 'string' + ? vm.tags.split(",").map(item => item.trim()) + : vm.page.list_tags.map(tag => tag); + + if (typeof vm.tags === 'string' && (new_tags.length > 4 || new_tags.some(tag => tag.length > 15))) { + $rootScope.notify("error", "Invalid tags! Maximum 4 tags are allowed, and each tag must be 15 characters or less."); + return; + } + parameters.url = "challenges/challenge/" + vm.challengeId + "/update_challenge_tags_and_domain/"; + parameters.method = 'PATCH'; + parameters.data = { + "list_tags": new_tags, + "domain": vm.domain + }; + parameters.callback = { + onSuccess: function(response) { + var status = response.status; + utilities.hideLoader(); + if (status === 200) { + $rootScope.notify("success", "The challenge tags and domain is successfully updated!"); + $state.reload(); + $mdDialog.hide(); + } + }, + onError: function(response) { + utilities.hideLoader(); + $mdDialog.hide(); + var error = response.data; + $rootScope.notify("error", error); + } + }; + utilities.showLoader(); + utilities.sendRequest(parameters); + }; + + vm.domain_choices = function() { + parameters.url = "challenges/challenge/get_domain_choices/"; + parameters.method = 'GET'; + parameters.data = {}; + parameters.callback = { + onSuccess: function(response) { + var domain_choices = response.data; + for (var i = 0; i < domain_choices.length; i++) { + if (domain_choices[i][0] == vm.page.domain) { + vm.domain = domain_choices[i][0]; + } + } + vm.domainoptions = domain_choices; + }, + onError: function(response) { + var error = response.data; + $rootScope.notify("error", error); + } + }; + utilities.sendRequest(parameters); + }; + $scope.$on('$destroy', function() { vm.stopFetchingSubmissions(); vm.stopLeaderboard(); diff --git a/frontend/src/views/web/challenge-list.html b/frontend/src/views/web/challenge-list.html index aafd3e01da..b0e1247c4c 100644 --- a/frontend/src/views/web/challenge-list.html +++ b/frontend/src/views/web/challenge-list.html @@ -10,6 +10,8 @@ {{challenge.title}}
+
  • {{tags}}
  • +
  • {{challenge.domain}}
  • Organized by
    {{challenge.creator.team_name}}

    Starts on @@ -51,6 +53,8 @@ {{challenge.title}}

    +
  • {{tags}}
  • +
  • {{challenge.domain}}
  • Organized by
    {{challenge.creator.team_name}}

    Starts on @@ -75,6 +79,8 @@ {{challenge.title}}

    +
  • {{tags}}
  • +
  • {{challenge.domain}}
  • Organized by
    {{challenge.creator.team_name}}

    Starts on diff --git a/frontend/src/views/web/challenge/challenge-page.html b/frontend/src/views/web/challenge/challenge-page.html index 3475639c78..f064d314e3 100644 --- a/frontend/src/views/web/challenge/challenge-page.html +++ b/frontend/src/views/web/challenge/challenge-page.html @@ -80,6 +80,16 @@

    {{challenge.page.title}} +

    diff --git a/frontend/src/views/web/challenge/edit-challenge/edit-challenge-tag.html b/frontend/src/views/web/challenge/edit-challenge/edit-challenge-tag.html new file mode 100644 index 0000000000..569fc0dca6 --- /dev/null +++ b/frontend/src/views/web/challenge/edit-challenge/edit-challenge-tag.html @@ -0,0 +1,39 @@ +
    +
    +
    +
    +
    Edit Challenge Tags and Domain
    +
    + Tags + + +
    +
    + + Domain + + {{ option[1] }} + +
    +
    This field is required.
    +
    +
    +
    +
    +
      +
    • + Cancel +
    • +
    • + +
    • +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/frontend/src/views/web/hosted-challenges.html b/frontend/src/views/web/hosted-challenges.html index 7ca6cf4035..8ae4e1efc1 100644 --- a/frontend/src/views/web/hosted-challenges.html +++ b/frontend/src/views/web/hosted-challenges.html @@ -13,6 +13,8 @@ {{challenge.title}}
    +
  • {{tags}}
  • +
  • {{challenge.domain}}
  • Organized by {{challenge.creator.team_name}}

    Starts on diff --git a/frontend/tests/controllers-test/challengeCtrl.test.js b/frontend/tests/controllers-test/challengeCtrl.test.js index 2fb14832e5..c76e779253 100644 --- a/frontend/tests/controllers-test/challengeCtrl.test.js +++ b/frontend/tests/controllers-test/challengeCtrl.test.js @@ -2031,6 +2031,80 @@ describe('Unit tests for challenge controller', function () { }); }); + describe('Unit tests for editchallengeTagDialog function', function () { + it('open dialog for edit challenge tag', function () { + var $mdDialog = $injector.get('$mdDialog'); + var $mdDialogOpened = false; + vm.page.list_tags = ['tag1', 'tag2']; + $mdDialog.show = jasmine.createSpy().and.callFake(function () { + $mdDialogOpened = true; + }); + + vm.editchallengeTagDialog(); + expect($mdDialog.show).toHaveBeenCalled(); + expect($mdDialogOpened).toEqual(true); + }); + }); + + describe('Unit test for editChallengeTag function', function () { + var success; + var errorResponse = 'error'; + beforeEach(function () { + spyOn($mdDialog, 'hide'); + spyOn($rootScope, 'notify'); + + utilities.sendRequest = function (parameters) { + if (success) { + parameters.callback.onSuccess({ + status: 200 + }); + } else { + parameters.callback.onError({ + data: errorResponse + }); + } + }; + }); + + it('valid edit challenge tag', function () { + var editChallengeTagDomainForm = true; + success = true; + vm.tags = "tag1, tag2"; + vm.domain = 'CV'; + spyOn($state, 'reload'); + vm.editChallengeTag(editChallengeTagDomainForm); + expect($rootScope.notify).toHaveBeenCalledWith("success", "The challenge tags and domain is successfully updated!"); + expect($state.reload).toHaveBeenCalled(); + }); + + it('invalid edit challenge tag', function () { + var editChallengeTagDomainForm = false; + success = true; + vm.tags = "tag1, tag2"; + vm.domain = 'CV'; + vm.editChallengeTag(editChallengeTagDomainForm); + expect($mdDialog.hide).toHaveBeenCalled(); + }); + + it('invalid edit challenge domain and backend error', function () { + var editChallengeTagDomainForm = true; + success = false; + vm.tags = "tag1, tag2"; + vm.domain = 'domain'; + vm.editChallengeTag(editChallengeTagDomainForm); + expect($rootScope.notify).toHaveBeenCalledWith("error", "error"); + }); + + it('valid edit challenge more than 4 error', function () { + var editChallengeTagDomainForm = true; + success = true; + vm.tags = "tag1, tag2, tag3, tag4, tag5WithMorethan15Charactersd"; + vm.domain = 'CV'; + vm.editChallengeTag(editChallengeTagDomainForm); + expect($rootScope.notify).toHaveBeenCalledWith("error", "Invalid tags! Maximum 4 tags are allowed, and each tag must be 15 characters or less."); + }); + }); + describe('Unit tests for deleteChallengeDialog function', function () { it('open dialog for delete challenge', function () { var $mdDialog = $injector.get('$mdDialog'); diff --git a/tests/unit/challenges/test_views.py b/tests/unit/challenges/test_views.py index ccbc918a08..15b3a27251 100644 --- a/tests/unit/challenges/test_views.py +++ b/tests/unit/challenges/test_views.py @@ -67,6 +67,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge", submission_guidelines="Submission guidelines for test challenge", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=False, is_registration_open=True, enable_forum=True, @@ -147,6 +149,9 @@ def test_get_challenge(self): "created_by": self.challenge.creator.created_by.username, "team_url": self.challenge.creator.team_url, }, + "domain": self.challenge.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge.list_tags, "published": self.challenge.published, "submission_time_limit": self.challenge.submission_time_limit, "is_registration_open": self.challenge.is_registration_open, @@ -490,6 +495,9 @@ def test_get_particular_challenge(self): "created_by": self.challenge.creator.created_by.username, "team_url": self.challenge.creator.team_url, }, + "domain": self.challenge.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge.list_tags, "published": self.challenge.published, "submission_time_limit": self.challenge.submission_time_limit, "is_registration_open": self.challenge.is_registration_open, @@ -578,6 +586,9 @@ def test_update_challenge_when_user_is_its_creator(self): "created_by": self.challenge.creator.created_by.username, "team_url": self.challenge.creator.team_url, }, + "domain": self.challenge.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge.list_tags, "published": self.challenge.published, "submission_time_limit": self.challenge.submission_time_limit, "is_registration_open": self.challenge.is_registration_open, @@ -687,6 +698,9 @@ def test_particular_challenge_partial_update(self): "created_by": self.challenge.creator.created_by.username, "team_url": self.challenge.creator.team_url, }, + "domain": self.challenge.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge.list_tags, "published": self.challenge.published, "submission_time_limit": self.challenge.submission_time_limit, "is_registration_open": self.challenge.is_registration_open, @@ -752,6 +766,9 @@ def test_particular_challenge_update(self): "created_by": self.challenge.creator.created_by.username, "team_url": self.challenge.creator.team_url, }, + "domain": self.challenge.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge.list_tags, "published": self.challenge.published, "submission_time_limit": self.challenge.submission_time_limit, "is_registration_open": self.challenge.is_registration_open, @@ -1247,6 +1264,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge 2", submission_guidelines="Submission guidelines for test challenge 2", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=True, is_registration_open=True, enable_forum=True, @@ -1265,6 +1284,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge 3", submission_guidelines="Submission guidelines for test challenge 3", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=True, is_registration_open=True, enable_forum=True, @@ -1284,6 +1305,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge 4", submission_guidelines="Submission guidelines for test challenge 4", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=True, is_registration_open=True, enable_forum=True, @@ -1336,6 +1359,9 @@ def test_get_past_challenges(self): "created_by": self.challenge3.creator.created_by.username, "team_url": self.challenge3.creator.team_url, }, + "domain": self.challenge3.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge3.list_tags, "published": self.challenge3.published, "submission_time_limit": self.challenge3.submission_time_limit, "is_registration_open": self.challenge3.is_registration_open, @@ -1407,6 +1433,9 @@ def test_get_present_challenges(self): "created_by": self.challenge2.creator.created_by.username, "team_url": self.challenge2.creator.team_url, }, + "domain": self.challenge2.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge2.list_tags, "published": self.challenge2.published, "submission_time_limit": self.challenge2.submission_time_limit, "is_registration_open": self.challenge2.is_registration_open, @@ -1478,6 +1507,9 @@ def test_get_future_challenges(self): "created_by": self.challenge4.creator.created_by.username, "team_url": self.challenge4.creator.team_url, }, + "domain": self.challenge4.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge4.list_tags, "published": self.challenge4.published, "submission_time_limit": self.challenge4.submission_time_limit, "is_registration_open": self.challenge4.is_registration_open, @@ -1549,6 +1581,9 @@ def test_get_all_challenges(self): "created_by": self.challenge4.creator.created_by.username, "team_url": self.challenge4.creator.team_url, }, + "domain": self.challenge4.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge4.list_tags, "published": self.challenge4.published, "submission_time_limit": self.challenge4.submission_time_limit, "is_registration_open": self.challenge4.is_registration_open, @@ -1604,6 +1639,9 @@ def test_get_all_challenges(self): "created_by": self.challenge3.creator.created_by.username, "team_url": self.challenge3.creator.team_url, }, + "domain": self.challenge3.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge3.list_tags, "published": self.challenge3.published, "submission_time_limit": self.challenge3.submission_time_limit, "is_registration_open": self.challenge3.is_registration_open, @@ -1659,6 +1697,9 @@ def test_get_all_challenges(self): "created_by": self.challenge2.creator.created_by.username, "team_url": self.challenge2.creator.team_url, }, + "domain": self.challenge2.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge2.list_tags, "published": self.challenge2.published, "submission_time_limit": self.challenge2.submission_time_limit, "is_registration_open": self.challenge2.is_registration_open, @@ -1728,6 +1769,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge 2", submission_guidelines="Submission guidelines for test challenge 2", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=True, is_registration_open=True, enable_forum=True, @@ -1746,6 +1789,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge 3", submission_guidelines="Submission guidelines for test challenge 3", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=True, is_registration_open=True, enable_forum=True, @@ -1781,6 +1826,9 @@ def test_get_featured_challenges(self): "created_by": self.challenge3.creator.created_by.username, "team_url": self.challenge3.creator.team_url, }, + "domain": self.challenge3.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge3.list_tags, "published": self.challenge3.published, "submission_time_limit": self.challenge3.submission_time_limit, "is_registration_open": self.challenge3.is_registration_open, @@ -1845,6 +1893,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge 3", submission_guidelines="Submission guidelines for test challenge 3", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=False, is_registration_open=True, enable_forum=True, @@ -1862,6 +1912,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge 4", submission_guidelines="Submission guidelines for test challenge 4", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=True, is_registration_open=True, enable_forum=True, @@ -1927,6 +1979,9 @@ def test_get_challenge_by_pk_when_user_is_challenge_host(self): "created_by": self.challenge3.creator.created_by.username, "team_url": self.challenge3.creator.team_url, }, + "domain": self.challenge3.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge3.list_tags, "published": self.challenge3.published, "submission_time_limit": self.challenge3.submission_time_limit, "is_registration_open": self.challenge3.is_registration_open, @@ -2006,6 +2061,9 @@ def test_get_challenge_by_pk_when_user_is_participant(self): "created_by": self.challenge4.creator.created_by.username, "team_url": self.challenge4.creator.team_url, }, + "domain": self.challenge4.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge4.list_tags, "published": self.challenge4.published, "submission_time_limit": self.challenge4.submission_time_limit, "is_registration_open": self.challenge4.is_registration_open, @@ -2078,6 +2136,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge", submission_guidelines="Submission guidelines for test challenge", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=True, is_registration_open=True, enable_forum=True, @@ -2095,6 +2155,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for some test challenge", submission_guidelines="Submission guidelines for some test challenge", creator=self.challenge_host_team2, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=True, is_registration_open=True, enable_forum=True, @@ -2141,6 +2203,9 @@ def test_get_challenge_when_host_team_is_given(self): "created_by": self.challenge2.creator.created_by.username, "team_url": self.challenge2.creator.team_url, }, + "domain": self.challenge2.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge2.list_tags, "published": self.challenge2.published, "submission_time_limit": self.challenge2.submission_time_limit, "is_registration_open": self.challenge2.is_registration_open, @@ -2208,6 +2273,9 @@ def test_get_challenge_when_participant_team_is_given(self): "created_by": self.challenge2.creator.created_by.username, "team_url": self.challenge2.creator.team_url, }, + "domain": self.challenge2.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge2.list_tags, "published": self.challenge2.published, "submission_time_limit": self.challenge2.submission_time_limit, "is_registration_open": self.challenge2.is_registration_open, @@ -2275,6 +2343,9 @@ def test_get_challenge_when_mode_is_participant(self): "created_by": self.challenge2.creator.created_by.username, "team_url": self.challenge2.creator.team_url, }, + "domain": self.challenge2.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge2.list_tags, "published": self.challenge2.published, "submission_time_limit": self.challenge2.submission_time_limit, "is_registration_open": self.challenge2.is_registration_open, @@ -2340,6 +2411,9 @@ def test_get_challenge_when_mode_is_host(self): "created_by": self.challenge.creator.created_by.username, "team_url": self.challenge.creator.team_url, }, + "domain": self.challenge.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge.list_tags, "published": self.challenge.published, "submission_time_limit": self.challenge.submission_time_limit, "is_registration_open": self.challenge.is_registration_open, @@ -2395,6 +2469,9 @@ def test_get_challenge_when_mode_is_host(self): "created_by": self.challenge2.creator.created_by.username, "team_url": self.challenge2.creator.team_url, }, + "domain": self.challenge2.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge2.list_tags, "published": self.challenge2.published, "submission_time_limit": self.challenge2.submission_time_limit, "is_registration_open": self.challenge2.is_registration_open, diff --git a/tests/unit/participants/test_views.py b/tests/unit/participants/test_views.py index 445af3046a..846a616502 100644 --- a/tests/unit/participants/test_views.py +++ b/tests/unit/participants/test_views.py @@ -772,6 +772,8 @@ def setUp(self): terms_and_conditions="Terms and conditions for test challenge 1", submission_guidelines="Submission guidelines for test challenge 1", creator=self.challenge_host_team, + domain="CV", + list_tags=["Paper", "Dataset", "Environment", "Workshop"], published=False, is_registration_open=True, enable_forum=True, @@ -837,6 +839,9 @@ def test_get_teams_and_corresponding_challenges_for_a_participant(self): "created_by": self.challenge_host_team.created_by.username, "team_url": self.challenge_host_team.team_url, }, + "domain": self.challenge1.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge1.list_tags, "published": self.challenge1.published, "submission_time_limit": self.challenge1.submission_time_limit, "is_registration_open": self.challenge1.is_registration_open, @@ -919,6 +924,9 @@ def test_get_participant_team_challenge_list(self): "created_by": self.challenge_host_team.created_by.username, "team_url": self.challenge_host_team.team_url, }, + "domain": self.challenge1.domain, + "domain_name": 'Computer Vision', + "list_tags": self.challenge1.list_tags, "published": self.challenge1.published, "submission_time_limit": self.challenge1.submission_time_limit, "is_registration_open": self.challenge1.is_registration_open,