From ff04155462470e69a8bfa3035e6a050e2fedca94 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 16 Jun 2023 00:37:25 +0500 Subject: [PATCH 1/7] Dynamic announcement and news added --- src/apps/announcements/__init__.py | 0 src/apps/announcements/admin.py | 6 + src/apps/announcements/apps.py | 5 + .../announcements/migrations/0001_initial.py | 32 ++++ src/apps/announcements/migrations/__init__.py | 0 src/apps/announcements/models.py | 13 ++ src/apps/announcements/tests.py | 3 + src/apps/announcements/views.py | 3 + src/apps/pages/views.py | 8 + src/settings/base.py | 1 + src/static/stylus/home.styl | 16 +- src/templates/pages/home.html | 147 ++---------------- 12 files changed, 101 insertions(+), 133 deletions(-) create mode 100644 src/apps/announcements/__init__.py create mode 100644 src/apps/announcements/admin.py create mode 100644 src/apps/announcements/apps.py create mode 100644 src/apps/announcements/migrations/0001_initial.py create mode 100644 src/apps/announcements/migrations/__init__.py create mode 100644 src/apps/announcements/models.py create mode 100644 src/apps/announcements/tests.py create mode 100644 src/apps/announcements/views.py diff --git a/src/apps/announcements/__init__.py b/src/apps/announcements/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/apps/announcements/admin.py b/src/apps/announcements/admin.py new file mode 100644 index 000000000..e675dd528 --- /dev/null +++ b/src/apps/announcements/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin + +from . import models + +admin.site.register(models.Announcement) +admin.site.register(models.NewsPost) diff --git a/src/apps/announcements/apps.py b/src/apps/announcements/apps.py new file mode 100644 index 000000000..1a07a47b4 --- /dev/null +++ b/src/apps/announcements/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class AnnouncementsConfig(AppConfig): + name = 'announcements' diff --git a/src/apps/announcements/migrations/0001_initial.py b/src/apps/announcements/migrations/0001_initial.py new file mode 100644 index 000000000..a04637dc3 --- /dev/null +++ b/src/apps/announcements/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 2.2.17 on 2023-06-15 18:12 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Announcement', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.TextField(blank=True, null=True)), + ], + ), + migrations.CreateModel( + name='NewsPost', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=40, unique=True)), + ('link', models.URLField()), + ('created_when', models.DateTimeField(default=django.utils.timezone.now)), + ('text', models.TextField(blank=True, null=True)), + ], + ), + ] diff --git a/src/apps/announcements/migrations/__init__.py b/src/apps/announcements/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/apps/announcements/models.py b/src/apps/announcements/models.py new file mode 100644 index 000000000..cd2cd2389 --- /dev/null +++ b/src/apps/announcements/models.py @@ -0,0 +1,13 @@ +from django.db import models +from django.utils.timezone import now + + +class Announcement(models.Model): + text = models.TextField(null=True, blank=True) + + +class NewsPost(models.Model): + title = models.CharField(max_length=40, unique=True) + link = models.URLField(max_length=200) + created_when = models.DateTimeField(default=now) + text = models.TextField(null=True, blank=True) diff --git a/src/apps/announcements/tests.py b/src/apps/announcements/tests.py new file mode 100644 index 000000000..7ce503c2d --- /dev/null +++ b/src/apps/announcements/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/src/apps/announcements/views.py b/src/apps/announcements/views.py new file mode 100644 index 000000000..91ea44a21 --- /dev/null +++ b/src/apps/announcements/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/src/apps/pages/views.py b/src/apps/pages/views.py index 441cfe40e..e2eb0cd6b 100644 --- a/src/apps/pages/views.py +++ b/src/apps/pages/views.py @@ -7,6 +7,7 @@ from competitions.models import Competition, Submission, CompetitionParticipant from profiles.models import User +from announcements.models import Announcement, NewsPost from django.shortcuts import render @@ -36,6 +37,13 @@ def get_context_data(self, *args, **kwargs): {'label': "Competition Participants", 'count': competition_participants}, {'label': "Submissions", 'count': submissions}, ] + + announcement = Announcement.objects.all().first() + context['announcement'] = announcement.text if announcement else None + + news_posts = NewsPost.objects.all() + context['news_posts'] = news_posts + return context diff --git a/src/settings/base.py b/src/settings/base.py index 64ab54589..1366a0cc8 100644 --- a/src/settings/base.py +++ b/src/settings/base.py @@ -58,6 +58,7 @@ 'queues', 'health', 'forums', + 'announcements', ) INSTALLED_APPS = THIRD_PARTY_APPS + OUR_APPS diff --git a/src/static/stylus/home.styl b/src/static/stylus/home.styl index 3a3e06601..ede1b7bca 100644 --- a/src/static/stylus/home.styl +++ b/src/static/stylus/home.styl @@ -226,11 +226,25 @@ body .color-header color #4a4a4a +.news + margin-bottom 5em + clear both +.news-heading + float left + +.news-date + float right + color darkslategray + +.news-body + float left + clear left + text-align left + #cite-container padding 2em align-items left - #cite-container .row margin 2em padding 1em !important diff --git a/src/templates/pages/home.html b/src/templates/pages/home.html index 09e48f02b..93ab7810d 100644 --- a/src/templates/pages/home.html +++ b/src/templates/pages/home.html @@ -15,19 +15,20 @@ {% endblock %} {% block content %} + + + {% if announcement %}

Announcement

-

- -

Welcome to Codabench!

-

+ {{ announcement | safe }}
+ {% endif %}
@@ -198,136 +199,18 @@

Codalab in Research

- -
-

TrackML

-

- September 2018: - The LAL and CERN are organizing a challenge to reconstruct - particle trajectories in high energy physics detectors. After the success of the - first phase with result submission only, a second phase with code submission will be - run on Codalab. TrackML is an officially selected - challenge of the NIPS 2018 conference. -

-
- -
-

AutoML3

-

- August 2018: - Codalab is proud to host the third challenge on Automatic Machine Learning: - Lifelong Machine Learning - with drift. - AutoML3 is an officially selected challenge of the NIPS 2018 conference. -

-
- -
-

See.4C

-

February 2018: 2 million Euro Big Data EU prize powered by Codalab.

-
- -
-

DataIA

-

February 2018: Isabelle Guyon presents Codalab at the newly formed Institute of - Convergence DataIA

-
- -
-

Student - Projects

-

January 2018: Paris-Saclay master students create challenges for L2 students.

-
- -
- -

Homework

-

January 2018: Paris-Saclay instructors create reinforcement learning homework.

-
- -
-

10,000 Users

-

December 2017: Codalab exceeds 10000 users with 480 competitions (145 public)

-
- -
-

CiML workshop

-

- December 2017: Codalab presented at the Challenges in Machine Learning workshop [slides]. -

-
- -
-

Version 1.5 is out!

-
-

- November 2017: Explore the new features: scale up your code submission - competition with - your own compute workers (full privacy, dockers); organize RL challenges and hook up - simulators - providing data on demand (with your own "ingestion program"); use the ChaLab wizard to - create - competitions in minutes. Thanks! -

+ {% for post in news_posts %} +
+ {{post.created_when|date:"M d, Y"}} + +
+ {{ post.text | safe }} +
+ {% endfor %}
From 11fb4f02cae43d7301e8856b44920499f142e8c4 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 16 Jun 2023 00:46:08 +0500 Subject: [PATCH 2/7] unused test file removed --- src/apps/announcements/tests.py | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/apps/announcements/tests.py diff --git a/src/apps/announcements/tests.py b/src/apps/announcements/tests.py deleted file mode 100644 index 7ce503c2d..000000000 --- a/src/apps/announcements/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. From c3d7003f04cfae6c3022a9d5d8d0a70437cb6b90 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 16 Jun 2023 00:48:39 +0500 Subject: [PATCH 3/7] News section comment added --- src/templates/pages/home.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/templates/pages/home.html b/src/templates/pages/home.html index 93ab7810d..f112eed51 100644 --- a/src/templates/pages/home.html +++ b/src/templates/pages/home.html @@ -196,6 +196,7 @@

Codalab in Research

+

News

From c99e28894938f660106086c5bd3faaf476097af2 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 16 Jun 2023 00:51:03 +0500 Subject: [PATCH 4/7] unused view file removed --- src/apps/announcements/views.py | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/apps/announcements/views.py diff --git a/src/apps/announcements/views.py b/src/apps/announcements/views.py deleted file mode 100644 index 91ea44a21..000000000 --- a/src/apps/announcements/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here. From 5ecdfc76f25dff9fc844d492d6d4b34bac6d1358 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 16 Jun 2023 01:12:57 +0500 Subject: [PATCH 5/7] news title unique removed --- .../migrations/0002_auto_20230615_2012.py | 18 ++++++++++++++++++ src/apps/announcements/models.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/apps/announcements/migrations/0002_auto_20230615_2012.py diff --git a/src/apps/announcements/migrations/0002_auto_20230615_2012.py b/src/apps/announcements/migrations/0002_auto_20230615_2012.py new file mode 100644 index 000000000..1e446cb6c --- /dev/null +++ b/src/apps/announcements/migrations/0002_auto_20230615_2012.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.17 on 2023-06-15 20:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('announcements', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='newspost', + name='title', + field=models.CharField(max_length=40), + ), + ] diff --git a/src/apps/announcements/models.py b/src/apps/announcements/models.py index cd2cd2389..e1bc2a455 100644 --- a/src/apps/announcements/models.py +++ b/src/apps/announcements/models.py @@ -7,7 +7,7 @@ class Announcement(models.Model): class NewsPost(models.Model): - title = models.CharField(max_length=40, unique=True) + title = models.CharField(max_length=40) link = models.URLField(max_length=200) created_when = models.DateTimeField(default=now) text = models.TextField(null=True, blank=True) From 620d93188f2dc3a2781b95afb5c1992950dd85c7 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 16 Jun 2023 18:00:18 +0500 Subject: [PATCH 6/7] news ordered by id DESC --- src/apps/pages/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/pages/views.py b/src/apps/pages/views.py index e2eb0cd6b..7395d416a 100644 --- a/src/apps/pages/views.py +++ b/src/apps/pages/views.py @@ -41,7 +41,7 @@ def get_context_data(self, *args, **kwargs): announcement = Announcement.objects.all().first() context['announcement'] = announcement.text if announcement else None - news_posts = NewsPost.objects.all() + news_posts = NewsPost.objects.all().order_by('-id') context['news_posts'] = news_posts return context From 95da7b0b1eb7ff44378bc04a771f3fd3e5b43fdb Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 16 Jun 2023 18:32:38 +0500 Subject: [PATCH 7/7] news link made optional --- .../migrations/0003_auto_20230616_1326.py | 18 ++++++++++++++++++ src/apps/announcements/models.py | 2 +- src/static/stylus/home.styl | 5 +++++ src/templates/pages/home.html | 6 +++++- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/apps/announcements/migrations/0003_auto_20230616_1326.py diff --git a/src/apps/announcements/migrations/0003_auto_20230616_1326.py b/src/apps/announcements/migrations/0003_auto_20230616_1326.py new file mode 100644 index 000000000..c17efe978 --- /dev/null +++ b/src/apps/announcements/migrations/0003_auto_20230616_1326.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.17 on 2023-06-16 13:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('announcements', '0002_auto_20230615_2012'), + ] + + operations = [ + migrations.AlterField( + model_name='newspost', + name='link', + field=models.URLField(blank=True), + ), + ] diff --git a/src/apps/announcements/models.py b/src/apps/announcements/models.py index e1bc2a455..fbb0a4d1f 100644 --- a/src/apps/announcements/models.py +++ b/src/apps/announcements/models.py @@ -8,6 +8,6 @@ class Announcement(models.Model): class NewsPost(models.Model): title = models.CharField(max_length=40) - link = models.URLField(max_length=200) + link = models.URLField(max_length=200, blank=True) created_when = models.DateTimeField(default=now) text = models.TextField(null=True, blank=True) diff --git a/src/static/stylus/home.styl b/src/static/stylus/home.styl index ede1b7bca..d7e86a491 100644 --- a/src/static/stylus/home.styl +++ b/src/static/stylus/home.styl @@ -229,9 +229,14 @@ body .news margin-bottom 5em clear both + .news-heading float left +.news-heading-title + color darkslategray + + .news-date float right color darkslategray diff --git a/src/templates/pages/home.html b/src/templates/pages/home.html index f112eed51..fb586f5a4 100644 --- a/src/templates/pages/home.html +++ b/src/templates/pages/home.html @@ -205,7 +205,11 @@

News

{{post.created_when|date:"M d, Y"}}
-

{{post.title}}

+ {% if post.link %} +

{{post.title}}

+ {% else %} +

{{post.title}}

+ {% endif %}
{{ post.text | safe }}