diff --git a/codalab/apps/teams/migrations/0004_auto_20220409_2242.py b/codalab/apps/teams/migrations/0004_auto_20220409_2242.py new file mode 100644 index 000000000..74fea6916 --- /dev/null +++ b/codalab/apps/teams/migrations/0004_auto_20220409_2242.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2022-04-09 22:42 +from __future__ import unicode_literals + +import codalab.azure_storage +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('teams', '0003_auto_20220328_1713'), + ] + + operations = [ + migrations.AlterField( + model_name='team', + name='image', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='public'), upload_to='team_logo', verbose_name='Logo'), + ), + ] diff --git a/codalab/apps/web/admin.py b/codalab/apps/web/admin.py index e5bdbc1e5..f6dbfa094 100644 --- a/codalab/apps/web/admin.py +++ b/codalab/apps/web/admin.py @@ -81,3 +81,5 @@ class PageAdmin(admin.ModelAdmin): admin.site.register(models.CompetitionSubmission) admin.site.register(models.CompetitionSubmissionMetadata) admin.site.register(models.CompetitionDefBundle) + +admin.site.register(models.NewsPost) \ No newline at end of file diff --git a/codalab/apps/web/migrations/0006_auto_20220409_2242.py b/codalab/apps/web/migrations/0006_auto_20220409_2242.py new file mode 100644 index 000000000..96e09b68f --- /dev/null +++ b/codalab/apps/web/migrations/0006_auto_20220409_2242.py @@ -0,0 +1,162 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2022-04-09 22:42 +from __future__ import unicode_literals + +import apps.web.models +import codalab.azure_storage +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('web', '0005_auto_20220328_1713'), + ] + + operations = [ + 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()), + ('date', models.DateTimeField(blank=True, null=True, verbose_name='Post Date (UTC)')), + ('post', models.TextField(blank=True, null=True)), + ], + ), + migrations.AlterField( + model_name='competition', + name='image', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='public'), upload_to=apps.web.models._uuidify('logos'), verbose_name='Logo'), + ), + migrations.AlterField( + model_name='competitiondefbundle', + name='config_bundle', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('competition-bundles')), + ), + migrations.AlterField( + model_name='competitiondump', + name='data_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('competition_dump'), verbose_name='Data file'), + ), + migrations.AlterField( + model_name='competitionphase', + name='ingestion_program', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('ingestion_program')), + ), + migrations.AlterField( + model_name='competitionphase', + name='input_data', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('phase_input_data_file'), verbose_name='Input Data'), + ), + migrations.AlterField( + model_name='competitionphase', + name='public_data', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('public_data'), verbose_name='Public Data'), + ), + migrations.AlterField( + model_name='competitionphase', + name='reference_data', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('phase_reference_data_file'), verbose_name='Reference Data'), + ), + migrations.AlterField( + model_name='competitionphase', + name='scoring_program', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('phase_scoring_program_file'), verbose_name='Scoring Program'), + ), + migrations.AlterField( + model_name='competitionphase', + name='starting_kit', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('starting_kit'), verbose_name='Starting Kit'), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='coopetition_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_coopetition')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='detailed_results_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_detailed_results')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_file_name')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='history_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_history')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='ingestion_program_stderr_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('predict_submission_stderr')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='ingestion_program_stdout_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('predict_submission_stdout')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='inputfile', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_inputfile')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='output_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_output')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='prediction_output_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_prediction_output')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='prediction_runfile', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_prediction_runfile')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='prediction_stderr_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('predict_submission_stderr')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='prediction_stdout_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('predict_submission_stdout')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='private_output_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_private_output')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='runfile', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_runfile')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='scores_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_scores')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='stderr_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_stderr')), + ), + migrations.AlterField( + model_name='competitionsubmission', + name='stdout_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('submission_stdout')), + ), + migrations.AlterField( + model_name='organizerdataset', + name='data_file', + field=models.FileField(blank=True, null=True, storage=codalab.azure_storage.AzureStorage(account_key='qY4fuziQqP0N63JurVsEvp7rioAsqnwPdRRgpLKDoCTNrVj1Xwt0l/EJVP3Yxn2IySXqjgMFYnvWd+B1mgPUAA==', account_name='codalabpython3test', azure_container='bundles'), upload_to=apps.web.models._uuidify('dataset_data_file'), verbose_name='Data file'), + ), + ] diff --git a/codalab/apps/web/models.py b/codalab/apps/web/models.py index f7ff1db53..8835c0e71 100644 --- a/codalab/apps/web/models.py +++ b/codalab/apps/web/models.py @@ -2722,3 +2722,21 @@ def filename(self): def competitiondump_post_delete_handler(sender, **kwargs): comp_dump = kwargs['instance'] delete_key_from_storage(comp_dump, 'data_file') + +class NewsPost(models.Model): + """ + News section on /highlights page + + Attributes or columns include: + * Title + """ + title = models.CharField(max_length=40, unique=True) + link = models.URLField(max_length=200) + date = models.DateTimeField(null=True, blank=True, verbose_name="Post Date (UTC)") + post = models.TextField(null=True, blank=True) + + def __unicode__(self): + return self.title + + def __str__(self): + return self.title \ No newline at end of file diff --git a/codalab/apps/web/templates/web/highlights.html b/codalab/apps/web/templates/web/highlights.html index ad97426a1..9f54c47ee 100644 --- a/codalab/apps/web/templates/web/highlights.html +++ b/codalab/apps/web/templates/web/highlights.html @@ -390,6 +390,15 @@

Research and Education

News

+ + {% for news_component in news %} +
+

{{ news_component.title }}
+

+

{{ news_component.date|date:'F Y' }}: {{ news_component.post|safe }} +

+
+ {% endfor %}

New server
diff --git a/codalab/apps/web/views.py b/codalab/apps/web/views.py index 34b203f46..9053dbbd7 100644 --- a/codalab/apps/web/views.py +++ b/codalab/apps/web/views.py @@ -27,7 +27,7 @@ from apps.web import tasks from apps.web.exceptions import ScoringException from apps.web.forms import CompetitionS3UploadForm -from apps.web.models import SubmissionScore, SubmissionScoreDef, get_current_phase, \ +from apps.web.models import NewsPost, SubmissionScore, SubmissionScoreDef, get_current_phase, \ get_first_previous_active_and_next_phases, Competition, CompetitionSubmission from datetime import datetime, timedelta from django.conf import settings @@ -143,15 +143,15 @@ class Highlights(TemplateView): def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) - data = Competition.objects.aggregate( + comp = Competition.objects.aggregate( count=Count('*'), published_comps=Count(Case(When(published=True, then=1))), unpublished_comps=Count(Case(When(published=False, then=1))) ) - - total_competitions = data['count'] - public_competitions = data['published_comps'] - private_competitions = data['unpublished_comps'] + + total_competitions = comp['count'] + public_competitions = comp['published_comps'] + private_competitions = comp['unpublished_comps'] users = User.objects.all().count() # from authenz_cluser competition_participants = models.CompetitionParticipant.objects.all().count() submissions = models.CompetitionSubmission.objects.all().count() @@ -165,6 +165,18 @@ def get_context_data(self, *args, **kwargs): {'label': "Submissions", 'count': submissions}, ] + news_list = [] + try: + news = NewsPost.objects.all() + for news_component in news: + nc = {'title':news_component.title,'link':news_component.link,'date':news_component.date,'post':news_component.post} + news_list.append(nc) + except: + logger.info("No new news") + + context['news'] = news_list + + return context diff --git a/codalab/codalab/azure_storage.py b/codalab/codalab/azure_storage.py index 59f4e385d..02b1f6143 100644 --- a/codalab/codalab/azure_storage.py +++ b/codalab/codalab/azure_storage.py @@ -12,6 +12,9 @@ from django.core.exceptions import ImproperlyConfigured from io import RawIOBase +# https://docs.djangoproject.com/en/1.11/topics/migrations/#migration-serializing +from django.utils.deconstruct import deconstructible + # keep consistent path separators pathjoin = lambda *args: os.path.join(*args).replace("\\", "/") @@ -38,7 +41,7 @@ def clean_name(name): return os.path.normpath(name).replace("\\", "/") - +@deconstructible class AzureStorage(Storage): chunk_size = 65536 @@ -49,6 +52,9 @@ def __init__(self, *args, **kwargs): super(AzureStorage, self).__init__(*args, **kwargs) self._connection = None + def __eq__(self, other): + return self.foo == other.foo + @property def connection(self): if self._connection is None: