Skip to content

Commit 98336e0

Browse files
Fix #4591: Adds Github icon on for challenge hosts repository (#4625)
* Added github icon on hosted challenge page * Modified the test files to pass the Travis CI checks * reformatted code of test_views.py file --------- Co-authored-by: Rishabh Jain <rishabhjain2018@gmail.com>
1 parent fd6708a commit 98336e0

File tree

6 files changed

+58
-23
lines changed

6 files changed

+58
-23
lines changed

apps/challenges/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class Meta:
9494
"worker_image_url",
9595
"worker_instance_type",
9696
"sqs_retention_period",
97+
"github_repository",
9798
)
9899

99100

frontend/src/css/modules/challenge.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,12 @@ md-select .md-select-value span:first-child:after {
381381
li {
382382
margin-bottom: -0.5%;
383383
}
384-
384+
385385
.nav-item {
386386
flex: 1;
387387
text-align: center;
388388
color: #4d4d4d;
389-
389+
390390
.nav-link {
391391
display: block;
392392
padding: 10px 0;
@@ -397,7 +397,7 @@ md-select .md-select-value span:first-child:after {
397397
font-weight: 500;
398398
transition: border-bottom 0.3s ease;
399399
cursor: pointer;
400-
400+
401401
&.active {
402402
border-bottom: 2px solid #000;
403403
color: #4d4d4d;
@@ -413,7 +413,7 @@ md-select .md-select-value span:first-child:after {
413413
a {
414414
color: #4d4d4d;
415415
font-weight: 400;
416-
416+
417417
&.active {
418418
color: #3f51b5;
419419
font-weight: 600;
@@ -425,7 +425,7 @@ md-select .md-select-value span:first-child:after {
425425
.challenges-container {
426426
margin-top: 20px;
427427
min-height: 200px;
428-
428+
429429
.card-content {
430430
padding: 20px;
431431
text-align: center;
@@ -436,4 +436,6 @@ md-select .md-select-value span:first-child:after {
436436
margin-right: 10px;
437437
display: inline-block;
438438
vertical-align: middle;
439+
color: #000; // Ensure the icon is visible
440+
font-size: 15px; // Adjust size if needed
439441
}

frontend/src/js/controllers/challengeCtrl.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@
396396
vm.has_sponsors = details.has_sponsors;
397397
vm.queueName = details.queue;
398398
vm.evaluation_module_error = details.evaluation_module_error;
399+
vm.githubRepository = details.github_repository;
399400
vm.getTeamName(vm.challengeId);
400401
if (vm.page.image === null) {
401402
vm.page.image = "dist/images/logo.png";

frontend/src/views/web/challenge/challenge-page.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ <h4 class="challenge-step-title w-300">{{challenge.page.title}}
9393
</div>
9494
</div>
9595
<div class="col m2 l2 fs-16 w-300 center">
96-
<a ng-if="(challenge.isChallengeHost ) && challenge.page.github_repository"
97-
ng-href="{{ 'https://github.com/' + challenge.page.github_repository }}"
96+
<a ng-if="(challenge.isChallengeHost) && challenge.githubRepository"
97+
ng-href="{{ 'https://github.com/' + challenge.githubRepository }}"
9898
target="_blank"
9999
class="github-icon-link">
100100
<i class="fa fa-github fa-2x black-text" aria-hidden="true"></i>
101-
</a>
101+
</a>
102102
<button class="waves-effect waves-dark btn ev-btn-dark w-300 fs-14" type="submit"
103103
ng-click="challenge.starChallenge()" ng-init="challenge.isStarred()"><i class="fa fa-star star"></i>
104104
{{challenge.data}}&nbsp;&nbsp;{{challenge.count}}</button>

tests/unit/challenges/test_views.py

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def setUp(self):
8686
start_date=timezone.now() - timedelta(days=2),
8787
end_date=timezone.now() + timedelta(days=1),
8888
approved_by_admin=False,
89+
github_repository="challenge/github_repo",
8990
)
9091
self.challenge.slug = "{}-{}".format(
9192
self.challenge.title.replace(" ", "-").lower(), self.challenge.pk
@@ -203,6 +204,7 @@ def test_get_challenge(self):
203204
"worker_image_url": self.challenge.worker_image_url,
204205
"worker_instance_type": self.challenge.worker_instance_type,
205206
"sqs_retention_period": self.challenge.sqs_retention_period,
207+
"github_repository": self.challenge.github_repository,
206208
}
207209
]
208210

@@ -574,6 +576,7 @@ def test_get_particular_challenge(self):
574576
"worker_image_url": self.challenge.worker_image_url,
575577
"worker_instance_type": self.challenge.worker_instance_type,
576578
"sqs_retention_period": self.challenge.sqs_retention_period,
579+
"github_repository": self.challenge.github_repository,
577580
}
578581
response = self.client.get(self.url, {})
579582
self.assertEqual(response.data, expected)
@@ -676,6 +679,7 @@ def test_update_challenge_when_user_is_its_creator(self):
676679
"worker_image_url": self.challenge.worker_image_url,
677680
"worker_instance_type": self.challenge.worker_instance_type,
678681
"sqs_retention_period": self.challenge.sqs_retention_period,
682+
"github_repository": self.challenge.github_repository,
679683
}
680684
response = self.client.put(
681685
self.url, {"title": new_title, "description": new_description}
@@ -804,6 +808,7 @@ def test_particular_challenge_partial_update(self):
804808
"worker_image_url": self.challenge.worker_image_url,
805809
"worker_instance_type": self.challenge.worker_instance_type,
806810
"sqs_retention_period": self.challenge.sqs_retention_period,
811+
"github_repository": self.challenge.github_repository,
807812
}
808813
response = self.client.patch(self.url, self.partial_update_data)
809814
self.assertEqual(response.data, expected)
@@ -881,6 +886,7 @@ def test_particular_challenge_update(self):
881886
"worker_image_url": self.challenge.worker_image_url,
882887
"worker_instance_type": self.challenge.worker_instance_type,
883888
"sqs_retention_period": self.challenge.sqs_retention_period,
889+
"github_repository": self.challenge.github_repository,
884890
}
885891
response = self.client.put(self.url, self.data)
886892
self.assertEqual(response.data, expected)
@@ -1344,6 +1350,7 @@ def setUp(self):
13441350
manual_participant_approval=False,
13451351
start_date=timezone.now() - timedelta(days=2),
13461352
end_date=timezone.now() + timedelta(days=1),
1353+
github_repository="challenge2/github_repo",
13471354
)
13481355

13491356
# Past Challenge challenge
@@ -1365,6 +1372,7 @@ def setUp(self):
13651372
manual_participant_approval=False,
13661373
start_date=timezone.now() - timedelta(days=2),
13671374
end_date=timezone.now() - timedelta(days=1),
1375+
github_repository="challenge3/github_repo",
13681376
)
13691377

13701378
# Future challenge
@@ -1385,6 +1393,7 @@ def setUp(self):
13851393
manual_participant_approval=False,
13861394
start_date=timezone.now() + timedelta(days=2),
13871395
end_date=timezone.now() + timedelta(days=1),
1396+
github_repository="challenge4/github_repo",
13881397
)
13891398

13901399
# Disabled challenge
@@ -1474,6 +1483,7 @@ def test_get_past_challenges(self):
14741483
"worker_image_url": self.challenge3.worker_image_url,
14751484
"worker_instance_type": self.challenge3.worker_instance_type,
14761485
"sqs_retention_period": self.challenge3.sqs_retention_period,
1486+
"github_repository": self.challenge3.github_repository,
14771487
}
14781488
]
14791489
response = self.client.get(self.url, {}, format="json")
@@ -1552,11 +1562,12 @@ def test_get_present_challenges(self):
15521562
"job_memory": self.challenge2.job_memory,
15531563
"uses_ec2_worker": self.challenge2.uses_ec2_worker,
15541564
"evaluation_module_error": self.challenge2.evaluation_module_error,
1555-
"ec2_storage": self.challenge.ec2_storage,
1556-
"ephemeral_storage": self.challenge.ephemeral_storage,
1557-
"worker_image_url": self.challenge.worker_image_url,
1558-
"worker_instance_type": self.challenge.worker_instance_type,
1559-
"sqs_retention_period": self.challenge.sqs_retention_period,
1565+
"ec2_storage": self.challenge2.ec2_storage,
1566+
"ephemeral_storage": self.challenge2.ephemeral_storage,
1567+
"worker_image_url": self.challenge2.worker_image_url,
1568+
"worker_instance_type": self.challenge2.worker_instance_type,
1569+
"sqs_retention_period": self.challenge2.sqs_retention_period,
1570+
"github_repository": self.challenge2.github_repository,
15601571
}
15611572
]
15621573
response = self.client.get(self.url, {}, format="json")
@@ -1640,6 +1651,7 @@ def test_get_future_challenges(self):
16401651
"worker_image_url": self.challenge4.worker_image_url,
16411652
"worker_instance_type": self.challenge4.worker_instance_type,
16421653
"sqs_retention_period": self.challenge4.sqs_retention_period,
1654+
"github_repository": self.challenge4.github_repository,
16431655
}
16441656
]
16451657
response = self.client.get(self.url, {}, format="json")
@@ -1713,16 +1725,17 @@ def test_get_all_challenges(self):
17131725
"queue": self.challenge4.queue,
17141726
"worker_cpu_cores": 512,
17151727
"worker_memory": 1024,
1716-
"cpu_only_jobs": self.challenge3.cpu_only_jobs,
1717-
"job_cpu_cores": self.challenge3.job_cpu_cores,
1718-
"job_memory": self.challenge3.job_memory,
1719-
"uses_ec2_worker": self.challenge3.uses_ec2_worker,
1720-
"evaluation_module_error": self.challenge3.evaluation_module_error,
1721-
"ec2_storage": self.challenge3.ec2_storage,
1722-
"ephemeral_storage": self.challenge3.ephemeral_storage,
1723-
"worker_image_url": self.challenge3.worker_image_url,
1724-
"worker_instance_type": self.challenge3.worker_instance_type,
1725-
"sqs_retention_period": self.challenge3.sqs_retention_period,
1728+
"cpu_only_jobs": self.challenge4.cpu_only_jobs,
1729+
"job_cpu_cores": self.challenge4.job_cpu_cores,
1730+
"job_memory": self.challenge4.job_memory,
1731+
"uses_ec2_worker": self.challenge4.uses_ec2_worker,
1732+
"evaluation_module_error": self.challenge4.evaluation_module_error,
1733+
"ec2_storage": self.challenge4.ec2_storage,
1734+
"ephemeral_storage": self.challenge4.ephemeral_storage,
1735+
"worker_image_url": self.challenge4.worker_image_url,
1736+
"worker_instance_type": self.challenge4.worker_instance_type,
1737+
"sqs_retention_period": self.challenge4.sqs_retention_period,
1738+
"github_repository": self.challenge4.github_repository,
17261739
},
17271740
{
17281741
"id": self.challenge3.pk,
@@ -1790,6 +1803,7 @@ def test_get_all_challenges(self):
17901803
"worker_image_url": self.challenge3.worker_image_url,
17911804
"worker_instance_type": self.challenge3.worker_instance_type,
17921805
"sqs_retention_period": self.challenge3.sqs_retention_period,
1806+
"github_repository": self.challenge3.github_repository,
17931807
},
17941808
{
17951809
"id": self.challenge2.pk,
@@ -1857,6 +1871,7 @@ def test_get_all_challenges(self):
18571871
"worker_image_url": self.challenge2.worker_image_url,
18581872
"worker_instance_type": self.challenge2.worker_instance_type,
18591873
"sqs_retention_period": self.challenge2.sqs_retention_period,
1874+
"github_repository": self.challenge2.github_repository,
18601875
},
18611876
]
18621877
response = self.client.get(self.url, {}, format="json")
@@ -1925,6 +1940,7 @@ def setUp(self):
19251940
start_date=timezone.now() - timedelta(days=2),
19261941
end_date=timezone.now() - timedelta(days=1),
19271942
featured=True,
1943+
github_repository="challenge3/github_repo",
19281944
)
19291945

19301946
def test_get_featured_challenges(self):
@@ -1995,6 +2011,7 @@ def test_get_featured_challenges(self):
19952011
"worker_image_url": self.challenge3.worker_image_url,
19962012
"worker_instance_type": self.challenge3.worker_instance_type,
19972013
"sqs_retention_period": self.challenge3.sqs_retention_period,
2014+
"github_repository": self.challenge3.github_repository,
19982015
}
19992016
]
20002017
response = self.client.get(self.url, {}, format="json")
@@ -2036,6 +2053,7 @@ def setUp(self):
20362053
start_date=timezone.now() - timedelta(days=2),
20372054
end_date=timezone.now() + timedelta(days=1),
20382055
approved_by_admin=False,
2056+
github_repository="challenge3/github_repo",
20392057
)
20402058

20412059
self.challenge4 = Challenge.objects.create(
@@ -2057,6 +2075,7 @@ def setUp(self):
20572075
end_date=timezone.now() + timedelta(days=1),
20582076
is_disabled=False,
20592077
approved_by_admin=True,
2078+
github_repository="challenge4/github_repo",
20602079
)
20612080

20622081
self.challenge5 = Challenge.objects.create(
@@ -2157,6 +2176,7 @@ def test_get_challenge_by_pk_when_user_is_challenge_host(self):
21572176
"worker_image_url": self.challenge3.worker_image_url,
21582177
"worker_instance_type": self.challenge3.worker_instance_type,
21592178
"sqs_retention_period": self.challenge3.sqs_retention_period,
2179+
"github_repository": self.challenge3.github_repository,
21602180
}
21612181

21622182
response = self.client.get(self.url, {})
@@ -2248,6 +2268,7 @@ def test_get_challenge_by_pk_when_user_is_participant(self):
22482268
"worker_image_url": self.challenge4.worker_image_url,
22492269
"worker_instance_type": self.challenge4.worker_instance_type,
22502270
"sqs_retention_period": self.challenge4.sqs_retention_period,
2271+
"github_repository": self.challenge4.github_repository,
22512272
}
22522273

22532274
self.client.force_authenticate(user=self.user1)
@@ -2297,6 +2318,7 @@ def setUp(self):
22972318
start_date=timezone.now() - timedelta(days=2),
22982319
end_date=timezone.now() + timedelta(days=1),
22992320
approved_by_admin=True,
2321+
github_repository="challenge/github_repo",
23002322
)
23012323

23022324
self.challenge2 = Challenge.objects.create(
@@ -2315,6 +2337,7 @@ def setUp(self):
23152337
start_date=timezone.now() - timedelta(days=2),
23162338
end_date=timezone.now() + timedelta(days=1),
23172339
approved_by_admin=True,
2340+
github_repository="challenge2/github_repo",
23182341
)
23192342

23202343
self.participant_team2 = ParticipantTeam.objects.create(
@@ -2399,6 +2422,7 @@ def test_get_challenge_when_host_team_is_given(self):
23992422
"worker_image_url": self.challenge2.worker_image_url,
24002423
"worker_instance_type": self.challenge2.worker_instance_type,
24012424
"sqs_retention_period": self.challenge2.sqs_retention_period,
2425+
"github_repository": self.challenge2.github_repository,
24022426
}
24032427
]
24042428

@@ -2478,6 +2502,7 @@ def test_get_challenge_when_participant_team_is_given(self):
24782502
"worker_image_url": self.challenge2.worker_image_url,
24792503
"worker_instance_type": self.challenge2.worker_instance_type,
24802504
"sqs_retention_period": self.challenge2.sqs_retention_period,
2505+
"github_repository": self.challenge2.github_repository,
24812506
}
24822507
]
24832508

@@ -2557,6 +2582,7 @@ def test_get_challenge_when_mode_is_participant(self):
25572582
"worker_image_url": self.challenge2.worker_image_url,
25582583
"worker_instance_type": self.challenge2.worker_instance_type,
25592584
"sqs_retention_period": self.challenge2.sqs_retention_period,
2585+
"github_repository": self.challenge2.github_repository,
25602586
}
25612587
]
25622588

@@ -2634,6 +2660,7 @@ def test_get_challenge_when_mode_is_host(self):
26342660
"worker_image_url": self.challenge.worker_image_url,
26352661
"worker_instance_type": self.challenge.worker_instance_type,
26362662
"sqs_retention_period": self.challenge.sqs_retention_period,
2663+
"github_repository": self.challenge.github_repository,
26372664
},
26382665
{
26392666
"id": self.challenge2.pk,
@@ -2701,6 +2728,7 @@ def test_get_challenge_when_mode_is_host(self):
27012728
"worker_image_url": self.challenge2.worker_image_url,
27022729
"worker_instance_type": self.challenge2.worker_instance_type,
27032730
"sqs_retention_period": self.challenge2.sqs_retention_period,
2731+
"github_repository": self.challenge2.github_repository,
27042732
},
27052733
]
27062734

tests/unit/participants/test_views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ def setUp(self):
780780
manual_participant_approval=False,
781781
start_date=timezone.now() - timedelta(days=2),
782782
end_date=timezone.now() + timedelta(days=1),
783+
github_repository="challenge1/github_repo",
783784
)
784785
self.challenge1.slug = "{}-{}".format(
785786
self.challenge1.title.replace(" ", "-").lower(), self.challenge1.pk
@@ -882,6 +883,7 @@ def test_get_teams_and_corresponding_challenges_for_a_participant(self):
882883
"worker_image_url": self.challenge1.worker_image_url,
883884
"worker_instance_type": self.challenge1.worker_instance_type,
884885
"sqs_retention_period": self.challenge1.sqs_retention_period,
886+
"github_repository": self.challenge1.github_repository,
885887
},
886888
"participant_team": {
887889
"id": self.participant_team.id,
@@ -978,6 +980,7 @@ def test_get_participant_team_challenge_list(self):
978980
"worker_image_url": self.challenge1.worker_image_url,
979981
"worker_instance_type": self.challenge1.worker_instance_type,
980982
"sqs_retention_period": self.challenge1.sqs_retention_period,
983+
"github_repository": self.challenge1.github_repository,
981984
}
982985
]
983986

0 commit comments

Comments
 (0)