Repository: Cloud-CV/EvalAI

Issue:
Add models to star a challenge
**Deliverable**:

- [x] Add a model in `apps/challenges/model.py` for starring a challenge.

**Attributes:** 
1. `user` - Foreign key to `User` model
2. `challenge` - Foreign key to `Challenge` model.

- [x] Add the migration file.

- [x] Register the model in django-admin.
                    


Discussion:

Resolving patch:
diff --git a/apps/challenges/admin.py b/apps/challenges/admin.py
--- a/apps/challenges/admin.py
+++ b/apps/challenges/admin.py
@@ -8,7 +8,8 @@
                      ChallengePhaseSplit,
                      DatasetSplit,
                      Leaderboard,
-                     LeaderboardData,)
+                     LeaderboardData,
+                     StarChallenge,)
 
 
 @admin.register(Challenge)
@@ -57,3 +58,9 @@ class ChallengeConfigurationAdmin(ImportExportTimeStampedAdmin):
     list_display = ('user', 'challenge', 'is_created', 'zip_configuration',)
     list_filter = ('user', 'is_created',)
     search_fields = ('user', 'challenge',)
+
+
+@admin.register(StarChallenge)
+class StarChallengeAdmin(ImportExportTimeStampedAdmin):
+    list_display = ('user', 'challenge',)
+    search_fields = ('user', 'challenge',)
diff --git a/apps/challenges/migrations/0029_add_challenge_star.py b/apps/challenges/migrations/0029_add_challenge_star.py
new file mode 100644
--- /dev/null
+++ b/apps/challenges/migrations/0029_add_challenge_star.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.2 on 2017-08-14 20:27
+from __future__ import unicode_literals
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('challenges', '0028_zip_configuration_models_for_challenge_creation'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='StarChallenge',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('created_at', models.DateTimeField(auto_now_add=True)),
+                ('modified_at', models.DateTimeField(auto_now=True)),
+                ('challenge', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='challenges.Challenge')),
+                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+            ],
+            options={
+                'db_table': 'starred_challenge',
+            },
+        ),
+    ]
diff --git a/apps/challenges/models.py b/apps/challenges/models.py
--- a/apps/challenges/models.py
+++ b/apps/challenges/models.py
@@ -220,3 +220,15 @@ class ChallengeConfiguration(TimeStampedModel):
     class Meta:
         app_label = 'challenges'
         db_table = 'challenge_zip_configuration'
+
+
+class StarChallenge(TimeStampedModel):
+    """
+    Model to star a challenge
+    """
+    user = models.ForeignKey(User)
+    challenge = models.ForeignKey(Challenge)
+
+    class Meta:
+        app_label = 'challenges'
+        db_table = 'starred_challenge'


Test patch: