Repository: Cloud-CV/EvalAI

Issue:
Add leaderboard description field
## Current Behaviour
Currently, we don't display leaderboard description under the leaderboard tab.

## Expected Behaviour
A text field which will display the description about the leaderboard.

## Deliverables
- [ ] Add a blank and nullable text field in the Challenge model with the name `leaderboard_description`.
- [ ] Name the migrations as `Add_leaderboard_description_field_in_challenge`
- [ ] Add a card on the frontend above the card for selecting phases to display the leaderboard with the heading `Description`
- [ ] Paste the screenshot of the leaderboard with some sample data in the `Description` card.

Add leaderboard description field
## Current Behaviour
Currently, we don't display leaderboard description under the leaderboard tab.

## Expected Behaviour
A text field which will display the description about the leaderboard.

## Deliverables
- [ ] Add a blank and nullable text field in the Challenge model with the name `leaderboard_description`.
- [ ] Name the migrations as `Add_leaderboard_description_field_in_challenge`
- [ ] Add a card on the frontend above the card for selecting phases to display the leaderboard with the heading `Description`
- [ ] Paste the screenshot of the leaderboard with some sample data in the `Description` card.



Discussion:
Can I work on this issue?
Sure! you can work on this issue.
Can I work on this issue?
Sure! you can work on this issue.

Resolving patch:
diff --git a/apps/challenges/migrations/0045_Add_leaderboard_description_field_in_challenge.py b/apps/challenges/migrations/0045_Add_leaderboard_description_field_in_challenge.py
new file mode 100644
--- /dev/null
+++ b/apps/challenges/migrations/0045_Add_leaderboard_description_field_in_challenge.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.15 on 2019-01-30 16:05
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('challenges', '0044_add_field_to_allow_email_ids_in_challenge_phase'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='challenge',
+            name='leaderboard_description',
+            field=models.TextField(blank=True, null=True),
+        ),
+    ]
diff --git a/apps/challenges/models.py b/apps/challenges/models.py
--- a/apps/challenges/models.py
+++ b/apps/challenges/models.py
@@ -37,6 +37,7 @@ def __init__(self, *args, **kwargs):
         default=False, verbose_name="Publicly Available", db_index=True)
     enable_forum = models.BooleanField(default=True)
     forum_url = models.URLField(max_length=100, blank=True, null=True)
+    leaderboard_description = models.TextField(null=True, blank=True)
     anonymous_leaderboard = models.BooleanField(default=False)
     participant_teams = models.ManyToManyField(ParticipantTeam, blank=True)
     is_disabled = models.BooleanField(default=False, db_index=True)
diff --git a/apps/challenges/serializers.py b/apps/challenges/serializers.py
--- a/apps/challenges/serializers.py
+++ b/apps/challenges/serializers.py
@@ -29,7 +29,7 @@ class Meta:
         fields = ('id', 'title', 'short_description', 'description', 'terms_and_conditions',
                   'submission_guidelines', 'evaluation_details',
                   'image', 'start_date', 'end_date', 'creator',
-                  'published', 'enable_forum', 'anonymous_leaderboard', 'is_active',
+                  'published', 'enable_forum', 'anonymous_leaderboard', 'is_active', 'leaderboard_description',
                   'allowed_email_domains', 'blocked_email_domains',
                   'approved_by_admin', 'forum_url', 'is_docker_based', 'slug', 'max_docker_image_size',)
 
@@ -122,9 +122,9 @@ class Meta:
         model = Challenge
         fields = ('id', 'title', 'short_description', 'description', 'terms_and_conditions',
                   'submission_guidelines', 'start_date', 'end_date', 'creator', 'evaluation_details',
-                  'published', 'enable_forum', 'anonymous_leaderboard', 'image', 'is_active', 'evaluation_script',
-                  'allowed_email_domains', 'blocked_email_domains', 'forum_url', 'remote_evaluation',
-                  'is_docker_based', 'slug', 'max_docker_image_size',)
+                  'published', 'enable_forum', 'anonymous_leaderboard', 'leaderboard_description', 'image',
+                  'is_active', 'evaluation_script', 'allowed_email_domains', 'blocked_email_domains',
+                  'forum_url', 'remote_evaluation', 'is_docker_based', 'slug', 'max_docker_image_size',)
 
 
 class ZipChallengePhaseSplitSerializer(serializers.ModelSerializer):


Test patch:
diff --git a/tests/unit/challenges/test_views.py b/tests/unit/challenges/test_views.py
--- a/tests/unit/challenges/test_views.py
+++ b/tests/unit/challenges/test_views.py
@@ -93,6 +93,7 @@ def setUp(self):
             published=False,
             enable_forum=True,
             is_disabled=True,
+            leaderboard_description=None,
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() + timedelta(days=1),
@@ -123,6 +124,7 @@ def test_get_challenge(self):
                 },
                 "published": self.challenge.published,
                 "enable_forum": self.challenge.enable_forum,
+                "leaderboard_description": self.challenge.leaderboard_description,
                 "anonymous_leaderboard": self.challenge.anonymous_leaderboard,
                 "is_active": True,
                 "allowed_email_domains": [],
@@ -169,6 +171,7 @@ def setUp(self):
             },
             'published': False,
             'enable_forum': True,
+            "leaderboard_description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
             'anonymous_leaderboard': False,
             'start_date': timezone.now() - timedelta(days=2),
             'end_date': timezone.now() + timedelta(days=1),
@@ -218,6 +221,7 @@ def test_get_particular_challenge(self):
             },
             "published": self.challenge.published,
             "enable_forum": self.challenge.enable_forum,
+            "leaderboard_description": self.challenge.leaderboard_description,
             "anonymous_leaderboard": self.challenge.anonymous_leaderboard,
             "is_active": True,
             "allowed_email_domains": [],
@@ -274,6 +278,7 @@ def test_update_challenge_when_user_is_its_creator(self):
             },
             "published": self.challenge.published,
             "enable_forum": self.challenge.enable_forum,
+            "leaderboard_description": self.challenge.leaderboard_description,
             "anonymous_leaderboard": self.challenge.anonymous_leaderboard,
             "is_active": True,
             "allowed_email_domains": [],
@@ -350,6 +355,7 @@ def test_particular_challenge_partial_update(self):
             },
             "published": self.challenge.published,
             "enable_forum": self.challenge.enable_forum,
+            "leaderboard_description": self.challenge.leaderboard_description,
             "anonymous_leaderboard": self.challenge.anonymous_leaderboard,
             "is_active": True,
             "start_date": "{0}{1}".format(self.challenge.start_date.isoformat(), 'Z').replace("+00:00", ""),
@@ -386,6 +392,7 @@ def test_particular_challenge_update(self):
             },
             "published": self.challenge.published,
             "enable_forum": self.challenge.enable_forum,
+            "leaderboard_description": self.challenge.leaderboard_description,
             "anonymous_leaderboard": self.challenge.anonymous_leaderboard,
             "is_active": True,
             "start_date": "{0}{1}".format(self.challenge.start_date.isoformat(), 'Z').replace("+00:00", ""),
@@ -473,6 +480,7 @@ def setUp(self):
             creator=self.challenge_host_team2,
             published=False,
             enable_forum=True,
+            leaderboard_description='Pellentesque at dictum odio, sit amet fringilla sem',
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() + timedelta(days=1),
@@ -735,6 +743,7 @@ def setUp(self):
             published=True,
             enable_forum=True,
             approved_by_admin=True,
+            leaderboard_description='Donec sollicitudin, nisi vel tempor semper, nulla odio dapibus felis',
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() - timedelta(days=1),
@@ -767,6 +776,7 @@ def setUp(self):
             published=True,
             enable_forum=True,
             approved_by_admin=True,
+            leaderboard_description=None,
             anonymous_leaderboard=False,
             start_date=timezone.now() + timedelta(days=2),
             end_date=timezone.now() + timedelta(days=1),
@@ -794,6 +804,7 @@ def test_get_past_challenges(self):
                 },
                 "published": self.challenge3.published,
                 "enable_forum": self.challenge3.enable_forum,
+                "leaderboard_description": self.challenge3.leaderboard_description,
                 "anonymous_leaderboard": self.challenge3.anonymous_leaderboard,
                 "is_active": False,
                 "allowed_email_domains": [],
@@ -833,6 +844,7 @@ def test_get_present_challenges(self):
                 },
                 "published": self.challenge2.published,
                 "enable_forum": self.challenge2.enable_forum,
+                "leaderboard_description": self.challenge2.leaderboard_description,
                 "anonymous_leaderboard": self.challenge2.anonymous_leaderboard,
                 "is_active": True,
                 "allowed_email_domains": [],
@@ -872,6 +884,7 @@ def test_get_future_challenges(self):
                 },
                 "published": self.challenge4.published,
                 "enable_forum": self.challenge4.enable_forum,
+                "leaderboard_description": self.challenge4.leaderboard_description,
                 "anonymous_leaderboard": self.challenge4.anonymous_leaderboard,
                 "is_active": False,
                 "allowed_email_domains": [],
@@ -911,6 +924,7 @@ def test_get_all_challenges(self):
                 },
                 "published": self.challenge4.published,
                 "enable_forum": self.challenge4.enable_forum,
+                "leaderboard_description": self.challenge4.leaderboard_description,
                 "anonymous_leaderboard": self.challenge4.anonymous_leaderboard,
                 "is_active": False,
                 "allowed_email_domains": [],
@@ -940,6 +954,7 @@ def test_get_all_challenges(self):
                 },
                 "published": self.challenge3.published,
                 "enable_forum": self.challenge3.enable_forum,
+                "leaderboard_description": self.challenge3.leaderboard_description,
                 "anonymous_leaderboard": self.challenge3.anonymous_leaderboard,
                 "is_active": False,
                 "allowed_email_domains": [],
@@ -969,6 +984,7 @@ def test_get_all_challenges(self):
                 },
                 "published": self.challenge2.published,
                 "enable_forum": self.challenge2.enable_forum,
+                "leaderboard_description": self.challenge2.leaderboard_description,
                 "anonymous_leaderboard": self.challenge2.anonymous_leaderboard,
                 "is_active": True,
                 "allowed_email_domains": [],
@@ -1027,6 +1043,7 @@ def setUp(self):
             published=True,
             enable_forum=True,
             approved_by_admin=True,
+            leaderboard_description=None,
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() - timedelta(days=1),
@@ -1054,6 +1071,7 @@ def test_get_featured_challenges(self):
                 },
                 "published": self.challenge3.published,
                 "enable_forum": self.challenge3.enable_forum,
+                "leaderboard_description": self.challenge3.leaderboard_description,
                 "anonymous_leaderboard": self.challenge3.anonymous_leaderboard,
                 "is_active": False,
                 "allowed_email_domains": self.challenge3.allowed_email_domains,
@@ -1110,6 +1128,7 @@ def setUp(self):
             creator=self.challenge_host_team,
             published=True,
             enable_forum=True,
+            leaderboard_description='Curabitur nec placerat libero.',
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() + timedelta(days=1),
@@ -1126,6 +1145,7 @@ def setUp(self):
             creator=self.challenge_host_team,
             published=False,
             enable_forum=True,
+            leaderboard_description=None,
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() + timedelta(days=1),
@@ -1164,6 +1184,7 @@ def test_get_challenge_by_pk_when_user_is_challenge_host(self):
             },
             "published": self.challenge3.published,
             "enable_forum": self.challenge3.enable_forum,
+            "leaderboard_description": self.challenge3.leaderboard_description,
             "anonymous_leaderboard": self.challenge3.anonymous_leaderboard,
             "is_active": True,
             "allowed_email_domains": [],
@@ -1215,6 +1236,7 @@ def test_get_challenge_by_pk_when_user_is_participant(self):
             },
             "published": self.challenge4.published,
             "enable_forum": self.challenge4.enable_forum,
+            "leaderboard_description": self.challenge4.leaderboard_description,
             "anonymous_leaderboard": self.challenge4.anonymous_leaderboard,
             "is_active": True,
             "allowed_email_domains": [],
@@ -1266,6 +1288,7 @@ def setUp(self):
             creator=self.challenge_host_team,
             published=True,
             enable_forum=True,
+            leaderboard_description=None,
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() + timedelta(days=1),
@@ -1320,6 +1343,7 @@ def test_get_challenge_when_host_team_is_given(self):
             },
             "published": self.challenge2.published,
             "enable_forum": self.challenge2.enable_forum,
+            "leaderboard_description": self.challenge2.leaderboard_description,
             "anonymous_leaderboard": self.challenge2.anonymous_leaderboard,
             "is_active": True,
             "allowed_email_domains": [],
@@ -1357,6 +1381,7 @@ def test_get_challenge_when_participant_team_is_given(self):
             },
             "published": self.challenge2.published,
             "enable_forum": self.challenge2.enable_forum,
+            "leaderboard_description": self.challenge2.leaderboard_description,
             "anonymous_leaderboard": self.challenge2.anonymous_leaderboard,
             "is_active": True,
             "allowed_email_domains": [],
@@ -1394,6 +1419,7 @@ def test_get_challenge_when_mode_is_participant(self):
             },
             "published": self.challenge2.published,
             "enable_forum": self.challenge2.enable_forum,
+            "leaderboard_description": self.challenge2.leaderboard_description,
             "anonymous_leaderboard": self.challenge2.anonymous_leaderboard,
             "is_active": True,
             "allowed_email_domains": [],
@@ -1432,6 +1458,7 @@ def test_get_challenge_when_mode_is_host(self):
                 },
                 "published": self.challenge.published,
                 "enable_forum": self.challenge.enable_forum,
+                "leaderboard_description": self.challenge.leaderboard_description,
                 "anonymous_leaderboard": self.challenge.anonymous_leaderboard,
                 "is_active": True,
                 "allowed_email_domains": [],
@@ -1461,6 +1488,7 @@ def test_get_challenge_when_mode_is_host(self):
                 },
                 "published": self.challenge2.published,
                 "enable_forum": self.challenge2.enable_forum,
+                "leaderboard_description": self.challenge2.leaderboard_description,
                 "anonymous_leaderboard": self.challenge2.anonymous_leaderboard,
                 "is_active": True,
                 "allowed_email_domains": [],
diff --git a/tests/unit/participants/test_views.py b/tests/unit/participants/test_views.py
--- a/tests/unit/participants/test_views.py
+++ b/tests/unit/participants/test_views.py
@@ -381,6 +381,7 @@ def test_invite_participant_to_team_when_user_cannot_be_invited(self):
             creator=self.challenge_host_team,
             published=False,
             enable_forum=True,
+            leaderboard_description=None,
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() + timedelta(days=1),
@@ -553,6 +554,7 @@ def setUp(self):
             creator=self.challenge_host_team,
             published=False,
             enable_forum=True,
+            leaderboard_description='Lorem ipsum dolor sit amet, consectetur adipiscing elit',
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() + timedelta(days=1),
@@ -606,6 +608,7 @@ def test_get_teams_and_corresponding_challenges_for_a_participant(self):
                             },
                         "published": self.challenge1.published,
                         "enable_forum": self.challenge1.enable_forum,
+                        "leaderboard_description": self.challenge1.leaderboard_description,
                         "anonymous_leaderboard": self.challenge1.anonymous_leaderboard,
                         "is_active": True,
                         "allowed_email_domains": [],
@@ -659,6 +662,7 @@ def test_get_participant_team_challenge_list(self):
                     },
                 "published": self.challenge1.published,
                 "enable_forum": self.challenge1.enable_forum,
+                "leaderboard_description": self.challenge1.leaderboard_description,
                 "anonymous_leaderboard": self.challenge1.anonymous_leaderboard,
                 "is_active": True,
                 "allowed_email_domains": [],
@@ -750,6 +754,7 @@ def setUp(self):
             creator=self.challenge_host_team,
             published=False,
             enable_forum=True,
+            leaderboard_description='Fusce quis sapien eget sem accumsan euismod',
             anonymous_leaderboard=False,
             start_date=timezone.now() - timedelta(days=2),
             end_date=timezone.now() + timedelta(days=1),