diff --git a/oioioi/acm/tests.py b/oioioi/acm/tests.py
index 864bd68c2..12b5b2715 100644
--- a/oioioi/acm/tests.py
+++ b/oioioi/acm/tests.py
@@ -1,8 +1,7 @@
import re
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_timezone_now
from oioioi.contests.models import Contest
@@ -53,20 +52,20 @@ def test_ranking_view(self):
# trial round begins at 11:00, ends at 16:00, results are available
# at 19:00
- with fake_timezone_now(datetime(2013, 12, 13, 10, 59, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 13, 10, 59, tzinfo=timezone.utc)):
response = self.client.get(url)
content = response.content.decode('utf-8')
for task in ['trial', 'A', 'sum', 'test']:
self.assertActiveTaskNotIn(task, content)
- with fake_timezone_now(datetime(2013, 12, 13, 11, 30, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 13, 11, 30, tzinfo=timezone.utc)):
response = self.client.get(url)
content = response.content.decode('utf-8')
self.assertActiveTaskIn('trial', content)
for task in ['A', 'sum', 'test']:
self.assertActiveTaskNotIn(task, content)
- with fake_timezone_now(datetime(2013, 12, 13, 17, 0, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 13, 17, 0, tzinfo=timezone.utc)):
response = self.client.get(url)
content = response.content.decode('utf-8')
self.assertInactiveTaskIn('trial', content)
@@ -75,14 +74,14 @@ def test_ranking_view(self):
# round 1 starts at 20:40, ends at 01:40, results are available at
# 09:00
- with fake_timezone_now(datetime(2013, 12, 14, 20, 39, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 14, 20, 39, tzinfo=timezone.utc)):
response = self.client.get(url)
content = response.content.decode('utf-8')
self.assertInactiveTaskIn('trial', content)
for task in ['A', 'sum', 'test']:
self.assertInactiveTaskNotIn(task, content)
- with fake_timezone_now(datetime(2013, 12, 14, 20, 40, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 14, 20, 40, tzinfo=timezone.utc)):
response = self.client.get(url)
content = response.content.decode('utf-8')
self.assertActiveTaskNotIn('trial', content)
@@ -90,7 +89,7 @@ def test_ranking_view(self):
self.assertActiveTaskIn(task, content)
self.assertNotContains(response, 'The ranking is frozen.')
- with fake_timezone_now(datetime(2013, 12, 15, 1, 0, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 15, 1, 0, tzinfo=timezone.utc)):
response = self.client.get(url)
content = response.content.decode('utf-8')
self.assertActiveTaskNotIn('trial', content)
@@ -98,7 +97,7 @@ def test_ranking_view(self):
self.assertActiveTaskIn(task, content)
self.assertContains(response, 'The ranking is frozen.')
- with fake_timezone_now(datetime(2013, 12, 15, 7, 0, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 15, 7, 0, tzinfo=timezone.utc)):
response = self.client.get(url)
content = response.content.decode('utf-8')
self.assertInactiveTaskNotIn('trial', content)
@@ -106,7 +105,7 @@ def test_ranking_view(self):
self.assertInactiveTaskIn(task, content)
self.assertContains(response, 'The ranking is frozen.')
- with fake_timezone_now(datetime(2013, 12, 15, 9, 0, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 15, 9, 0, tzinfo=timezone.utc)):
response = self.client.get(url)
content = response.content.decode('utf-8')
self.assertInactiveTaskNotIn('trial', content)
@@ -114,13 +113,13 @@ def test_ranking_view(self):
self.assertInactiveTaskIn(task, content)
self.assertNotContains(response, 'The ranking is frozen.')
- with fake_timezone_now(datetime(2013, 12, 15, 0, 40, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 15, 0, 40, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, 'data-username="test_user"', count=2)
self.assertTrue(self.client.login(username='test_admin'))
- with fake_timezone_now(datetime(2013, 12, 15, 0, 40, tzinfo=utc)):
+ with fake_timezone_now(datetime(2013, 12, 15, 0, 40, tzinfo=timezone.utc)):
response = self.client.get(csv_url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, '\n', count=4)
diff --git a/oioioi/balloons/admin.py b/oioioi/balloons/admin.py
index ff13304f6..069ef1c1f 100644
--- a/oioioi/balloons/admin.py
+++ b/oioioi/balloons/admin.py
@@ -166,7 +166,7 @@ class BalloonsDeliveryAccessDataAdminMixin(object):
def __init__(self, *args, **kwargs):
super(BalloonsDeliveryAccessDataAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [BalloonsDeliveryAccessDataInline]
+ self.inlines = self.inlines + (BalloonsDeliveryAccessDataInline,)
ContestAdmin.mix_in(BalloonsDeliveryAccessDataAdminMixin)
diff --git a/oioioi/balloons/tests.py b/oioioi/balloons/tests.py
index bdc9ae558..299c09bb1 100644
--- a/oioioi/balloons/tests.py
+++ b/oioioi/balloons/tests.py
@@ -1,9 +1,8 @@
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.admin.utils import quote
from django.contrib.auth.models import User
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.balloons.models import BalloonDelivery, BalloonsDeliveryAccessData
from oioioi.base.tests import TestCase, fake_time
@@ -190,11 +189,11 @@ def test_setting_delivered_status(self):
def test_cookie_expiry_date(self):
url = reverse('balloons_delivery_panel', kwargs=self.c_kwargs)
- with fake_time(datetime(2012, 8, 5, 0, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, 0, 5, tzinfo=timezone.utc)):
self._generate_link_and_set_cookie()
- with fake_time(datetime(2012, 8, 12, 0, 4, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 12, 0, 4, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
- with fake_time(datetime(2012, 8, 12, 0, 6, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 12, 0, 6, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(response.status_code, 403)
diff --git a/oioioi/base/admin.py b/oioioi/base/admin.py
index 3edb300e0..c94318eee 100644
--- a/oioioi/base/admin.py
+++ b/oioioi/base/admin.py
@@ -456,7 +456,7 @@ def has_delete_permission(self, request, obj=None):
class UserWithConsentsAdminMixin(object):
def __init__(self, *args, **kwargs):
super(UserWithConsentsAdminMixin, self).__init__(*args, **kwargs)
- self.inlines += [ConsentsInline]
+ self.inlines += (ConsentsInline,)
OioioiUserAdmin.mix_in(UserWithConsentsAdminMixin)
diff --git a/oioioi/base/fields.py b/oioioi/base/fields.py
index 48158afc5..6cd1a2e5f 100644
--- a/oioioi/base/fields.py
+++ b/oioioi/base/fields.py
@@ -2,7 +2,7 @@
from django.db import models
from django.db.models.fields import BLANK_CHOICE_DASH, exceptions
from django.forms import ValidationError
-from django.utils.encoding import smart_text
+from django.utils.encoding import smart_str
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy as _
@@ -64,13 +64,13 @@ def get_choices(
lst = [
(
getattr(x, self.remote_field.get_related_field().attname),
- smart_text(x),
+ smart_str(x),
)
for x in rel_model._default_manager.complex_filter(limit_choices_to)
]
else:
lst = [
- (x._get_pk_val(), smart_text(x))
+ (x._get_pk_val(), smart_str(x))
for x in rel_model._default_manager.complex_filter(limit_choices_to)
]
return first_choice + lst
diff --git a/oioioi/base/models.py b/oioioi/base/models.py
index cc56182ec..e3c89c6b7 100644
--- a/oioioi/base/models.py
+++ b/oioioi/base/models.py
@@ -35,7 +35,7 @@
auditLogger = logging.getLogger(__name__ + ".audit")
# Sender will be equal to the form that was completed
-PreferencesSaved = django.dispatch.Signal(providing_args=['user'])
+PreferencesSaved = django.dispatch.Signal()
class Consents(models.Model):
diff --git a/oioioi/base/templates/two_factor/core/login.html b/oioioi/base/templates/two_factor/core/login.html
index 97a165244..aac1d62f9 100644
--- a/oioioi/base/templates/two_factor/core/login.html
+++ b/oioioi/base/templates/two_factor/core/login.html
@@ -1,5 +1,5 @@
{% extends "two_factor/_base_focus.html" %}
-{% load i18n two_factor %}
+{% load i18n %}
{% block content %}
{% comment %}
@@ -19,17 +19,17 @@
{% if wizard.steps.current == 'token' %}
{% if device.method == 'call' %}
-
{% blocktrans %}We are calling your phone right now, please enter the
+
{% blocktrans trimmed %}We are calling your phone right now, please enter the
digits you hear.{% endblocktrans %}
{% elif device.method == 'sms' %}
-
{% blocktrans %}We sent you a text message, please enter the tokens we
+
{% blocktrans trimmed %}We sent you a text message, please enter the tokens we
sent.{% endblocktrans %}
{% else %}
-
{% blocktrans %}Please enter the tokens generated by your token
+
{% blocktrans trimmed %}Please enter the tokens generated by your token
generator.{% endblocktrans %}
{% endif %}
{% elif wizard.steps.current == 'backup' %}
-
{% blocktrans %}Use this form for entering backup tokens for logging in.
+
{% blocktrans trimmed %}Use this form for entering backup tokens for logging in.
These tokens have been generated for you to print and keep safe. Please
enter one of these backup tokens to login to your account.{% endblocktrans %}
{% endif %}
@@ -46,7 +46,7 @@
{% block title %}{% trans "Log in" %}{% endblock %}
{% for other in other_devices %}
- {{ other|device_action }}
+ {{ other.generate_challenge_button_title }}
{% endfor %}
{% endif %}
diff --git a/oioioi/celery/celery.py b/oioioi/celery/celery.py
index c57751938..c12461d97 100644
--- a/oioioi/celery/celery.py
+++ b/oioioi/celery/celery.py
@@ -7,11 +7,14 @@
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'oioioi.default_settings')
-from django.conf import settings # noqa
-
app = Celery('oioioi')
+from django.conf import settings
+
+CELERY_CONFIG = settings.CELERY or {}
+
# Using a string here means the worker will not have to
# pickle the object when using Windows.
-app.config_from_object('django.conf:settings')
+app.config_from_object('oioioi.celery.celery:CELERY_CONFIG')
+
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
diff --git a/oioioi/clock/tests.py b/oioioi/clock/tests.py
index 4f23b53c0..2ca95c927 100644
--- a/oioioi/clock/tests.py
+++ b/oioioi/clock/tests.py
@@ -1,12 +1,11 @@
import calendar
import time
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from dateutil.parser import parse as parse_date
from django.contrib.auth.models import User
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase
from oioioi.contests.current_contest import ContestMode
@@ -67,7 +66,7 @@ def test_countdown_with_extended_rounds(self):
def test_admin_time(self):
self.assertTrue(self.client.login(username='test_admin'))
session = self.client.session
- session['admin_time'] = datetime(2012, 12, 12, tzinfo=utc).isoformat()
+ session['admin_time'] = datetime(2012, 12, 12, tzinfo=timezone.utc).isoformat()
session.save()
response = self.client.get(reverse('get_status')).json()
self.assertTrue(response['is_admin_time_set'])
diff --git a/oioioi/complaints/admin.py b/oioioi/complaints/admin.py
index a7ba1f948..bfaf084c4 100644
--- a/oioioi/complaints/admin.py
+++ b/oioioi/complaints/admin.py
@@ -27,7 +27,7 @@ class ComplaintsAdminMixin(object):
def __init__(self, *args, **kwargs):
super(ComplaintsAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [ComplaintsConfigInline]
+ self.inlines = self.inlines + (ComplaintsConfigInline,)
ContestAdmin.mix_in(ComplaintsAdminMixin)
diff --git a/oioioi/complaints/tests.py b/oioioi/complaints/tests.py
index 8ad41771f..ca7aeccb8 100644
--- a/oioioi/complaints/tests.py
+++ b/oioioi/complaints/tests.py
@@ -1,10 +1,9 @@
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.core import mail
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.complaints.models import ComplaintsConfig
@@ -24,7 +23,7 @@ def test_making_complaint(self):
p = Participant(contest=contest, user=user, status='ACTIVE')
p.save()
- with fake_time(datetime(2012, 8, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 11, tzinfo=timezone.utc)):
self.assertTrue(self.client.login(username='test_user'))
response = self.client.post(
reverse('add_complaint', kwargs={'contest_id': contest.id}),
@@ -36,24 +35,24 @@ def test_making_complaint(self):
cconfig = ComplaintsConfig(
contest=contest,
enabled=True,
- start_date=datetime(2012, 8, 10, tzinfo=utc),
- end_date=datetime(2012, 8, 12, tzinfo=utc),
+ start_date=datetime(2012, 8, 10, tzinfo=timezone.utc),
+ end_date=datetime(2012, 8, 12, tzinfo=timezone.utc),
)
cconfig.save()
- with fake_time(datetime(2012, 8, 9, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 9, tzinfo=timezone.utc)):
response = self.client.get(
reverse('add_complaint', kwargs={'contest_id': contest.id})
)
self.assertEqual(response.status_code, 403)
- with fake_time(datetime(2012, 8, 13, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 13, tzinfo=timezone.utc)):
response = self.client.get(
reverse('add_complaint', kwargs={'contest_id': contest.id})
)
self.assertEqual(response.status_code, 403)
- with fake_time(datetime(2012, 8, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 11, tzinfo=timezone.utc)):
response = self.client.post(
reverse('add_complaint', kwargs={'contest_id': contest.id}),
{'complaint': "I am innocent! It is your fault!"},
diff --git a/oioioi/contestexcl/admin.py b/oioioi/contestexcl/admin.py
index 16c20cbb7..4bb80a0d7 100644
--- a/oioioi/contestexcl/admin.py
+++ b/oioioi/contestexcl/admin.py
@@ -50,7 +50,7 @@ class ContestAdminWithExclusivenessInlineMixin(object):
def __init__(self, *args, **kwargs):
super(ContestAdminWithExclusivenessInlineMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [ExclusivenessConfigInline]
+ self.inlines = self.inlines + (ExclusivenessConfigInline,)
def _warn_on_contestexcl_overlap(self, request, ex_confs):
for obj in ex_confs:
diff --git a/oioioi/contestexcl/tests.py b/oioioi/contestexcl/tests.py
index 7ae04e5bd..1fdc7716e 100644
--- a/oioioi/contestexcl/tests.py
+++ b/oioioi/contestexcl/tests.py
@@ -1,10 +1,9 @@
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.core import mail
from django.test import Client
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.contestexcl.models import ExclusivenessConfig
@@ -80,8 +79,8 @@ def test_no_exclusiveness(self):
def test_exclusiveness_on(self):
add_ex_conf(
self.c,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 14, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
)
self._check_user_access()
@@ -91,8 +90,8 @@ def test_exclusiveness_on(self):
def test_exclusiveness_off(self):
add_ex_conf(
self.c,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 14, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
False,
)
@@ -103,14 +102,14 @@ def test_exclusiveness_off(self):
def test_exclusiveness_multiple_on(self):
add_ex_conf(
self.c,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 14, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
)
add_ex_conf(
self.c,
- datetime(2012, 1, 1, 12, tzinfo=utc),
- datetime(2012, 1, 1, 16, tzinfo=utc),
+ datetime(2012, 1, 1, 12, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 16, tzinfo=timezone.utc),
)
self._check_user_access()
self._check_contestadmin_access(visible=True)
@@ -119,15 +118,15 @@ def test_exclusiveness_multiple_on(self):
def test_exclusiveness_multiple_off(self):
add_ex_conf(
self.c,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 14, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
False,
)
add_ex_conf(
self.c,
- datetime(2012, 1, 1, 12, tzinfo=utc),
- datetime(2012, 1, 1, 16, tzinfo=utc),
+ datetime(2012, 1, 1, 12, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 16, tzinfo=timezone.utc),
False,
)
self._check_user_access()
@@ -137,14 +136,14 @@ def test_exclusiveness_multiple_off(self):
def test_exclusiveness_multiple_mixed_on_off(self):
ex_conf_1 = add_ex_conf(
self.c,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 14, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
)
ex_conf_2 = add_ex_conf(
self.c,
- datetime(2012, 1, 1, 12, tzinfo=utc),
- datetime(2012, 1, 1, 16, tzinfo=utc),
+ datetime(2012, 1, 1, 12, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 16, tzinfo=timezone.utc),
False,
)
self._check_user_access()
@@ -386,76 +385,76 @@ def test_exclusive_contest(self):
add_ex_conf(
self.c2,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 14, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
)
- with fake_time(datetime(2012, 1, 1, 9, 59, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 9, 59, tzinfo=timezone.utc)):
self._assertContestVisible('c1')
self._assertContestVisible('c2')
- with fake_time(datetime(2012, 1, 1, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 11, tzinfo=timezone.utc)):
self._assertContestRedirects('c1', '/c/c2/')
self._assertContestVisible('c2')
- with fake_time(datetime(2012, 1, 1, 14, 1, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 14, 1, tzinfo=timezone.utc)):
self._assertContestVisible('c1')
self._assertContestVisible('c2')
def test_exclusive_contest_multiple_configs(self):
add_ex_conf(
self.c2,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 12, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 12, tzinfo=timezone.utc),
)
add_ex_conf(
self.c2,
- datetime(2012, 1, 1, 14, tzinfo=utc),
- datetime(2012, 1, 1, 16, tzinfo=utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 16, tzinfo=timezone.utc),
)
- with fake_time(datetime(2012, 1, 1, 9, 59, 59, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 9, 59, 59, tzinfo=timezone.utc)):
self._assertContestVisible('c1')
self._assertContestVisible('c2')
- with fake_time(datetime(2012, 1, 1, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 10, tzinfo=timezone.utc)):
self._assertContestRedirects('c1', '/c/c2/')
self._assertContestVisible('c2')
- with fake_time(datetime(2012, 1, 1, 11, 59, 59, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 11, 59, 59, tzinfo=timezone.utc)):
self._assertContestRedirects('c1', '/c/c2/')
self._assertContestVisible('c2')
- with fake_time(datetime(2012, 1, 1, 12, 0, 1, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 12, 0, 1, tzinfo=timezone.utc)):
self._assertContestVisible('c1')
self._assertContestVisible('c2')
- with fake_time(datetime(2012, 1, 1, 13, 59, 59, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 13, 59, 59, tzinfo=timezone.utc)):
self._assertContestVisible('c1')
self._assertContestVisible('c2')
- with fake_time(datetime(2012, 1, 1, 14, 0, 1, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 14, 0, 1, tzinfo=timezone.utc)):
self._assertContestRedirects('c1', '/c/c2/')
self._assertContestVisible('c2')
- with fake_time(datetime(2012, 1, 1, 15, 59, 59, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 15, 59, 59, tzinfo=timezone.utc)):
self._assertContestRedirects('c1', '/c/c2/')
self._assertContestVisible('c2')
- with fake_time(datetime(2012, 1, 1, 16, 0, 1, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 16, 0, 1, tzinfo=timezone.utc)):
self._assertContestVisible('c1')
self._assertContestVisible('c2')
def test_enabled_field(self):
ex_conf = add_ex_conf(
self.c2,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 14, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
False,
)
- with fake_time(datetime(2012, 1, 1, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 11, tzinfo=timezone.utc)):
self._assertContestVisible('c1')
self._assertContestVisible('c2')
@@ -471,17 +470,17 @@ def test_exclusive_contests_error(self):
add_ex_conf(
self.c1,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 14, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
)
add_ex_conf(
self.c2,
- datetime(2012, 1, 1, 12, tzinfo=utc),
- datetime(2012, 1, 1, 16, tzinfo=utc),
+ datetime(2012, 1, 1, 12, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 16, tzinfo=timezone.utc),
)
- with fake_time(datetime(2012, 1, 1, 13, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 13, tzinfo=timezone.utc)):
response = self.client.get('/c/c1/id/')
self.assertContains(
response, 'participate in more than one contest that exc'
@@ -498,10 +497,10 @@ def test_default_selector(self):
add_ex_conf(
self.c1,
- datetime(2012, 1, 1, 10, tzinfo=utc),
- datetime(2012, 1, 1, 14, tzinfo=utc),
+ datetime(2012, 1, 1, 10, tzinfo=timezone.utc),
+ datetime(2012, 1, 1, 14, tzinfo=timezone.utc),
)
- with fake_time(datetime(2012, 1, 1, 12, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 12, tzinfo=timezone.utc)):
self._assertContestVisible('c1')
self._assertContestVisible('c2')
diff --git a/oioioi/contestlogo/admin.py b/oioioi/contestlogo/admin.py
index 4ee2652df..cfe1ec856 100644
--- a/oioioi/contestlogo/admin.py
+++ b/oioioi/contestlogo/admin.py
@@ -29,7 +29,7 @@ class ContestLogoAdminMixin(object):
def __init__(self, *args, **kwargs):
super(ContestLogoAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [ContestLogoInline]
+ self.inlines = self.inlines + (ContestLogoInline,)
ContestAdmin.mix_in(ContestLogoAdminMixin)
@@ -62,7 +62,7 @@ class ContestIconAdminMixin(object):
def __init__(self, *args, **kwargs):
super(ContestIconAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [ContestIconInline]
+ self.inlines = self.inlines + (ContestIconInline,)
ContestAdmin.mix_in(ContestIconAdminMixin)
diff --git a/oioioi/contestlogo/tests.py b/oioioi/contestlogo/tests.py
index 0f686944f..5d9ee6296 100644
--- a/oioioi/contestlogo/tests.py
+++ b/oioioi/contestlogo/tests.py
@@ -1,10 +1,10 @@
import calendar
+from datetime import timedelta
from django.contrib.auth.models import User
from django.core.files.base import ContentFile
from django.urls import reverse
from django.utils.http import http_date
-from django.utils.timezone import timedelta
from oioioi.base.tests import TestCase
from oioioi.contestlogo.models import ContestIcon, ContestLogo
diff --git a/oioioi/contests/admin.py b/oioioi/contests/admin.py
index 1e2d078f2..a0dff4b0e 100644
--- a/oioioi/contests/admin.py
+++ b/oioioi/contests/admin.py
@@ -193,7 +193,7 @@ class ContestLinkInline(admin.TabularInline):
class ContestAdmin(admin.ModelAdmin):
- inlines = [RoundInline, AttachmentInline, ContestLinkInline]
+ inlines = (RoundInline, AttachmentInline, ContestLinkInline)
readonly_fields = ['creation_date']
prepopulated_fields = {'id': ('name',)}
list_display = ['name', 'id', 'creation_date']
diff --git a/oioioi/contests/notifications.py b/oioioi/contests/notifications.py
index 0cfab4ff1..43cfe5ed9 100644
--- a/oioioi/contests/notifications.py
+++ b/oioioi/contests/notifications.py
@@ -1,8 +1,7 @@
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.test import RequestFactory
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.notification import NotificationHandler
@@ -13,7 +12,7 @@ def notification_function_submission_judged(arguments):
request = RequestFactory().get('/', data={'name': u'test'})
request.user = arguments.user
request.contest = pi.contest
- request.timestamp = datetime.now().replace(tzinfo=utc)
+ request.timestamp = datetime.now().replace(tzinfo=timezone.utc)
# Check if the final report is visible to the user
if not pi.contest.controller.can_see_submission_score(
diff --git a/oioioi/contests/tests/tests.py b/oioioi/contests/tests/tests.py
index a02bd903e..abd09b3e7 100644
--- a/oioioi/contests/tests/tests.py
+++ b/oioioi/contests/tests/tests.py
@@ -2,7 +2,7 @@
from __future__ import print_function
import re
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from functools import partial
import pytest
@@ -19,7 +19,6 @@
from django.test import RequestFactory
from django.test.utils import override_settings
from django.urls import NoReverseMatch, reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, TestsUtilsMixin, check_not_accessible, fake_time
from oioioi.contests.current_contest import ContestMode
from oioioi.contests.date_registration import date_registry
@@ -442,16 +441,16 @@ def test_order_rounds_by_focus(self):
r2 = Round.objects.get(pk=2)
r3 = Round.objects.get(pk=3)
- r1.start_date = datetime(2012, 1, 1, 8, 0, tzinfo=utc)
- r1.end_date = datetime(2012, 1, 1, 10, 0, tzinfo=utc)
+ r1.start_date = datetime(2012, 1, 1, 8, 0, tzinfo=timezone.utc)
+ r1.end_date = datetime(2012, 1, 1, 10, 0, tzinfo=timezone.utc)
r1.save()
- r2.start_date = datetime(2012, 1, 1, 9, 59, tzinfo=utc)
- r2.end_date = datetime(2012, 1, 1, 11, 00, tzinfo=utc)
+ r2.start_date = datetime(2012, 1, 1, 9, 59, tzinfo=timezone.utc)
+ r2.end_date = datetime(2012, 1, 1, 11, 00, tzinfo=timezone.utc)
r2.save()
- r3.start_date = datetime(2012, 1, 2, 8, 0, tzinfo=utc)
- r3.end_date = datetime(2012, 1, 2, 10, 0, tzinfo=utc)
+ r3.start_date = datetime(2012, 1, 2, 8, 0, tzinfo=timezone.utc)
+ r3.end_date = datetime(2012, 1, 2, 10, 0, tzinfo=timezone.utc)
r3.save()
rounds = [r1, r2, r3]
@@ -463,20 +462,20 @@ def __init__(self, timestamp, contest):
self.contest = contest
for date, expected_order in (
- (datetime(2011, 1, 1, tzinfo=utc), [r1, r2, r3]),
- (datetime(2012, 1, 1, 7, 0, tzinfo=utc), [r1, r2, r3]),
- (datetime(2012, 1, 1, 7, 55, tzinfo=utc), [r1, r2, r3]),
- (datetime(2012, 1, 1, 9, 40, tzinfo=utc), [r1, r2, r3]),
- (datetime(2012, 1, 1, 9, 55, tzinfo=utc), [r2, r1, r3]),
- (datetime(2012, 1, 1, 9, 59, 29, tzinfo=utc), [r2, r1, r3]),
- (datetime(2012, 1, 1, 9, 59, 31, tzinfo=utc), [r1, r2, r3]),
- (datetime(2012, 1, 1, 10, 0, 1, tzinfo=utc), [r2, r1, r3]),
- (datetime(2012, 1, 1, 11, 0, 1, tzinfo=utc), [r2, r1, r3]),
- (datetime(2012, 1, 1, 12, 0, 1, tzinfo=utc), [r2, r1, r3]),
- (datetime(2012, 1, 2, 2, 0, 1, tzinfo=utc), [r3, r2, r1]),
- (datetime(2012, 1, 2, 2, 7, 55, tzinfo=utc), [r3, r2, r1]),
- (datetime(2012, 1, 2, 2, 9, 0, tzinfo=utc), [r3, r2, r1]),
- (datetime(2012, 1, 2, 2, 11, 0, tzinfo=utc), [r3, r2, r1]),
+ (datetime(2011, 1, 1, tzinfo=timezone.utc), [r1, r2, r3]),
+ (datetime(2012, 1, 1, 7, 0, tzinfo=timezone.utc), [r1, r2, r3]),
+ (datetime(2012, 1, 1, 7, 55, tzinfo=timezone.utc), [r1, r2, r3]),
+ (datetime(2012, 1, 1, 9, 40, tzinfo=timezone.utc), [r1, r2, r3]),
+ (datetime(2012, 1, 1, 9, 55, tzinfo=timezone.utc), [r2, r1, r3]),
+ (datetime(2012, 1, 1, 9, 59, 29, tzinfo=timezone.utc), [r2, r1, r3]),
+ (datetime(2012, 1, 1, 9, 59, 31, tzinfo=timezone.utc), [r1, r2, r3]),
+ (datetime(2012, 1, 1, 10, 0, 1, tzinfo=timezone.utc), [r2, r1, r3]),
+ (datetime(2012, 1, 1, 11, 0, 1, tzinfo=timezone.utc), [r2, r1, r3]),
+ (datetime(2012, 1, 1, 12, 0, 1, tzinfo=timezone.utc), [r2, r1, r3]),
+ (datetime(2012, 1, 2, 2, 0, 1, tzinfo=timezone.utc), [r3, r2, r1]),
+ (datetime(2012, 1, 2, 2, 7, 55, tzinfo=timezone.utc), [r3, r2, r1]),
+ (datetime(2012, 1, 2, 2, 9, 0, tzinfo=timezone.utc), [r3, r2, r1]),
+ (datetime(2012, 1, 2, 2, 11, 0, tzinfo=timezone.utc), [r3, r2, r1]),
):
self.assertEqual(
contest.controller.order_rounds_by_focus(
@@ -555,7 +554,7 @@ def test_contest_visibility(self):
controller_name='oioioi.contests.tests.PrivateContestController',
)
contest2.save()
- contest2.creation_date = datetime(2002, 1, 1, tzinfo=utc)
+ contest2.creation_date = datetime(2002, 1, 1, tzinfo=timezone.utc)
contest2.save()
contest3 = Contest(
id='c3',
@@ -563,7 +562,7 @@ def test_contest_visibility(self):
controller_name='oioioi.contests.tests.PrivateContestController',
)
contest3.save()
- contest3.creation_date = datetime(2004, 1, 1, tzinfo=utc)
+ contest3.creation_date = datetime(2004, 1, 1, tzinfo=timezone.utc)
contest3.save()
contest4 = Contest(
id='c4',
@@ -571,7 +570,7 @@ def test_contest_visibility(self):
controller_name='oioioi.contests.tests.PrivateContestController',
)
contest4.save()
- contest4.creation_date = datetime(2003, 1, 1, tzinfo=utc)
+ contest4.creation_date = datetime(2003, 1, 1, tzinfo=timezone.utc)
contest4.save()
response = self.client.get(reverse('select_contest'))
self.assertEqual(len(response.context['contests']), 5)
@@ -586,7 +585,7 @@ def test_contest_visibility(self):
self.assertLess(content.index('Contest3'), content.index('Contest4'))
self.assertLess(content.index('Contest4'), content.index('Contest2'))
- contest2.creation_date = datetime(2003, 6, 1, tzinfo=utc)
+ contest2.creation_date = datetime(2003, 6, 1, tzinfo=timezone.utc)
contest2.save()
response = self.client.get(reverse('select_contest'))
content = response.content.decode('utf-8')
@@ -715,7 +714,7 @@ def remove_ws(response):
def test_problems_visibility(self):
contest = Contest.objects.get()
url = reverse('problems_list', kwargs={'contest_id': contest.id})
- with fake_time(datetime(2012, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, tzinfo=timezone.utc)):
for user in ['test_admin', 'test_contest_admin']:
self.assertTrue(self.client.login(username=user))
response = self.client.get(url)
@@ -739,7 +738,7 @@ def test_submissions_visibility(self):
contest = Contest.objects.get()
url = reverse('my_submissions', kwargs={'contest_id': contest.id})
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2012, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
for task in ['zad1', 'zad3', 'zad4']:
self.assertContains(response, task)
@@ -751,20 +750,20 @@ def test_submissions_visibility(self):
self.assertEqual(self.remove_ws(response).count('>34<'), 2)
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(self.remove_ws(response).count('>34<'), 4)
- with fake_time(datetime(2012, 7, 31, 20, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, 20, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertNotIn('>34<', self.remove_ws(response))
self.assertNotContains(response, 'Score')
- with fake_time(datetime(2012, 7, 31, 21, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, 21, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(self.remove_ws(response).count('>34<'), 1)
- with fake_time(datetime(2012, 7, 31, 22, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, 22, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(self.remove_ws(response).count('>34<'), 2)
@@ -773,29 +772,29 @@ def test_submissions_visibility(self):
ext = RoundTimeExtension(user=user, round=round4, extra_time=60)
ext.save()
- with fake_time(datetime(2012, 7, 31, 22, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, 22, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(self.remove_ws(response).count('>34<'), 1)
- round4.end_date = datetime(2012, 8, 10, 0, 0, tzinfo=utc)
- round4.results_date = datetime(2012, 8, 10, 0, 10, tzinfo=utc)
+ round4.end_date = datetime(2012, 8, 10, 0, 0, tzinfo=timezone.utc)
+ round4.results_date = datetime(2012, 8, 10, 0, 10, tzinfo=timezone.utc)
round4.save()
ext.extra_time = 0
ext.save()
- with fake_time(datetime(2012, 8, 10, 0, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 10, 0, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(self.remove_ws(response).count('>34<'), 1)
ext.extra_time = 20
ext.save()
- with fake_time(datetime(2012, 8, 10, 0, 15, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 10, 0, 15, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(self.remove_ws(response).count('>34<'), 1)
- with fake_time(datetime(2012, 8, 10, 0, 21, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 10, 0, 21, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(self.remove_ws(response).count('>34<'), 2)
@@ -809,11 +808,11 @@ def test_mixin_past_rounds_hidden_during_prep_time(self):
user = User.objects.get(username='test_user')
r1 = Round.objects.get(pk=1)
- r1.end_date = datetime(2012, 7, 30, 21, 40, tzinfo=utc)
+ r1.end_date = datetime(2012, 7, 30, 21, 40, tzinfo=timezone.utc)
r1.save()
url = reverse('problems_list', kwargs={'contest_id': contest.id})
- with fake_time(datetime(2012, 7, 31, 21, 1, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, 21, 1, tzinfo=timezone.utc)):
# r3, r4 are active
self.assertTrue(self.client.login(username=user))
response = self.client.get(url)
@@ -821,13 +820,13 @@ def test_mixin_past_rounds_hidden_during_prep_time(self):
self.assertContains(response, task)
self.assertEqual(len(response.context['problem_instances']), 2)
- with fake_time(datetime(2015, 7, 31, 20, 1, tzinfo=utc)):
+ with fake_time(datetime(2015, 7, 31, 20, 1, tzinfo=timezone.utc)):
# r1,r3,r4 are past, preparation time for r2
self.assertTrue(self.client.login(username=user))
response = self.client.get(url)
self.assertEqual(len(response.context['problem_instances']), 0)
- with fake_time(datetime(2015, 7, 31, 20, 28, tzinfo=utc)):
+ with fake_time(datetime(2015, 7, 31, 20, 28, tzinfo=timezone.utc)):
# r2 is active
self.assertTrue(self.client.login(username=user))
response = self.client.get(url)
@@ -835,10 +834,10 @@ def test_mixin_past_rounds_hidden_during_prep_time(self):
self.assertEqual(len(response.context['problem_instances']), 1)
r2 = Round.objects.get(pk=2)
- r2.start_date = datetime(2012, 7, 31, 21, 40, tzinfo=utc)
+ r2.start_date = datetime(2012, 7, 31, 21, 40, tzinfo=timezone.utc)
r2.save()
- with fake_time(datetime(2012, 7, 31, 21, 29, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, 21, 29, tzinfo=timezone.utc)):
# r1,r3,r4 are past, break = (21.27, 21.40) -- first half
self.assertTrue(self.client.login(username=user))
response = self.client.get(url)
@@ -846,13 +845,13 @@ def test_mixin_past_rounds_hidden_during_prep_time(self):
self.assertContains(response, task)
self.assertEqual(len(response.context['problem_instances']), 3)
- with fake_time(datetime(2012, 7, 31, 21, 35, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, 21, 35, tzinfo=timezone.utc)):
# r1,r3,r3 are past, break = (21.27, 21.40) -- second half
self.assertTrue(self.client.login(username=user))
response = self.client.get(url)
self.assertEqual(len(response.context['problem_instances']), 0)
- with fake_time(datetime(2012, 7, 31, 21, 41, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, 21, 41, tzinfo=timezone.utc)):
# r2 is active
self.assertTrue(self.client.login(username=user))
response = self.client.get(url)
@@ -983,13 +982,13 @@ def test_with_no_submissions_left(self):
def test_with_ended_round(self):
round = Round.objects.get()
- round.end_date = datetime(2020, 1, 1, tzinfo=utc)
+ round.end_date = datetime(2020, 1, 1, tzinfo=timezone.utc)
round.save()
contest = Contest.objects.get()
pi = ProblemInstance.objects.get()
- with fake_time(datetime(2020, 1, 2, tzinfo=utc)):
+ with fake_time(datetime(2020, 1, 2, tzinfo=timezone.utc)):
self.assertTrue(self.client.login(username='test_user'))
response = self.client.get(
reverse('problems_list', kwargs={'contest_id': contest.id})
@@ -1424,7 +1423,7 @@ def test_attachments(self):
)
self.assertStreamingEqual(response, b'content-of-roundatt')
- with fake_time(datetime(2011, 7, 10, tzinfo=utc)):
+ with fake_time(datetime(2011, 7, 10, tzinfo=timezone.utc)):
response = self.client.get(
reverse('contest_files', kwargs={'contest_id': contest.id})
)
@@ -1469,14 +1468,14 @@ def test_pub_date(self):
contest=contest,
description='contest-attachment',
content=ContentFile(b'content-visible', name='conatt-visible.txt'),
- pub_date=datetime(2011, 7, 10, 0, 0, 0, tzinfo=utc),
+ pub_date=datetime(2011, 7, 10, 0, 0, 0, tzinfo=timezone.utc),
)
cb.save()
cc = ContestAttachment(
contest=contest,
description='contest-attachment',
content=ContentFile(b'content-hidden', name='conatt-hidden.txt'),
- pub_date=datetime(2011, 7, 10, 1, 0, 0, tzinfo=utc),
+ pub_date=datetime(2011, 7, 10, 1, 0, 0, tzinfo=timezone.utc),
)
cc.save()
@@ -1510,7 +1509,7 @@ def check_accessibility(should_be_accesible, should_not_be_accesible):
kwargs={'contest_id': contest.id, 'attachment_id': id},
)
- with fake_time(datetime(2011, 7, 10, 0, 30, 0, tzinfo=utc)):
+ with fake_time(datetime(2011, 7, 10, 0, 30, 0, tzinfo=timezone.utc)):
self.assertTrue(self.client.login(username='test_user'))
check_visibility('conatt-null-date.txt', 'conatt-visible.txt')
check_accessibility(
@@ -1547,18 +1546,18 @@ def test_round_extension(self):
problem_instance2 = ProblemInstance.objects.get(pk=2)
self.assertTrue(problem_instance1.round == round1)
self.assertTrue(problem_instance2.round == round2)
- round1.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round1.end_date = datetime(2012, 8, 5, tzinfo=utc)
+ round1.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round1.end_date = datetime(2012, 8, 5, tzinfo=timezone.utc)
round1.save()
- round2.start_date = datetime(2012, 8, 10, tzinfo=utc)
- round2.end_date = datetime(2012, 8, 12, tzinfo=utc)
+ round2.start_date = datetime(2012, 8, 10, tzinfo=timezone.utc)
+ round2.end_date = datetime(2012, 8, 12, tzinfo=timezone.utc)
round2.save()
user = User.objects.get(username='test_user')
ext = RoundTimeExtension(user=user, round=round1, extra_time=10)
ext.save()
- with fake_time(datetime(2012, 8, 5, 0, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, 0, 5, tzinfo=timezone.utc)):
self.assertTrue(self.client.login(username='test_user2'))
response = self.submit_file(contest, problem_instance1)
self.assertEqual(200, response.status_code)
@@ -1567,12 +1566,12 @@ def test_round_extension(self):
response = self.submit_file(contest, problem_instance1)
self._assertSubmitted(contest, response)
- with fake_time(datetime(2012, 8, 5, 0, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, 0, 11, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance1)
self.assertEqual(200, response.status_code)
self.assertContains(response, 'Sorry, there are no problems')
- with fake_time(datetime(2012, 8, 12, 0, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 12, 0, 5, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance2)
self.assertEqual(200, response.status_code)
self.assertContains(response, 'Sorry, there are no problems')
@@ -1634,11 +1633,11 @@ def setUp(self):
self.contest.save()
self.ccontr = self.contest.controller
self.round = Round.objects.get()
- self.round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- self.round.end_date = datetime(2012, 8, 5, tzinfo=utc)
+ self.round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ self.round.end_date = datetime(2012, 8, 5, tzinfo=timezone.utc)
self.round.save()
- self.during = datetime(2012, 8, 1, tzinfo=utc)
+ self.during = datetime(2012, 8, 1, tzinfo=timezone.utc)
self.observer = User.objects.get(username='test_observer')
self.cadmin = User.objects.get(username='test_contest_admin')
@@ -2389,9 +2388,9 @@ def test_round_inline(self):
self.assertContains(response, 'Public results date')
def _check_public_results(self, expected):
- before_results = datetime(2012, 6, 20, 8, 0, tzinfo=utc)
- after_results_before_public = datetime(2012, 8, 20, 8, 0, tzinfo=utc)
- after_public = datetime(2012, 10, 20, 8, 0, tzinfo=utc)
+ before_results = datetime(2012, 6, 20, 8, 0, tzinfo=timezone.utc)
+ after_results_before_public = datetime(2012, 8, 20, 8, 0, tzinfo=timezone.utc)
+ after_public = datetime(2012, 10, 20, 8, 0, tzinfo=timezone.utc)
dates = [before_results, after_results_before_public, after_public]
request = RequestFactory().request()
@@ -2412,7 +2411,7 @@ def test_public_results_visible(self):
self._check_public_results([False, False, False])
round = Round.objects.get()
- round.public_results_date = datetime(2012, 9, 20, 8, 0, tzinfo=utc)
+ round.public_results_date = datetime(2012, 9, 20, 8, 0, tzinfo=timezone.utc)
round.save()
self._check_public_results([False, False, True])
@@ -2432,22 +2431,22 @@ def fake_request(timestamp):
self.assertFalse(
all_public_results_visible(
- fake_request(datetime(2012, 7, 31, 21, 0, 0, tzinfo=utc))
+ fake_request(datetime(2012, 7, 31, 21, 0, 0, tzinfo=timezone.utc))
)
)
round1 = Round.objects.get()
- round1.public_results_date = datetime(2012, 8, 1, 12, 0, 0, tzinfo=utc)
+ round1.public_results_date = datetime(2012, 8, 1, 12, 0, 0, tzinfo=timezone.utc)
round1.save()
self.assertFalse(
all_public_results_visible(
- fake_request(datetime(2012, 7, 31, 21, 0, 0, tzinfo=utc))
+ fake_request(datetime(2012, 7, 31, 21, 0, 0, tzinfo=timezone.utc))
)
)
self.assertTrue(
all_public_results_visible(
- fake_request(datetime(2012, 8, 1, 12, 30, 0, tzinfo=utc))
+ fake_request(datetime(2012, 8, 1, 12, 30, 0, tzinfo=timezone.utc))
)
)
@@ -2463,21 +2462,21 @@ def fake_request(timestamp):
self.assertFalse(
all_public_results_visible(
- fake_request(datetime(2012, 8, 2, 12, 30, 0, tzinfo=utc))
+ fake_request(datetime(2012, 8, 2, 12, 30, 0, tzinfo=timezone.utc))
)
)
self.assertTrue(
all_non_trial_public_results_visible(
- fake_request(datetime(2012, 8, 2, 12, 30, 0, tzinfo=utc))
+ fake_request(datetime(2012, 8, 2, 12, 30, 0, tzinfo=timezone.utc))
)
)
- round2.public_results_date = datetime(2012, 8, 2, 12, 0, 0, tzinfo=utc)
+ round2.public_results_date = datetime(2012, 8, 2, 12, 0, 0, tzinfo=timezone.utc)
round2.save()
self.assertTrue(
all_public_results_visible(
- fake_request(datetime(2012, 8, 2, 12, 30, 0, tzinfo=utc))
+ fake_request(datetime(2012, 8, 2, 12, 30, 0, tzinfo=timezone.utc))
)
)
@@ -2540,12 +2539,12 @@ def test_user_info_page(self):
)
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2012, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url, follow=True)
self.assertContains(response, '403', status_code=403)
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2012, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url, follow=True)
self.assertContains(response, 'title>Test User - User info')
self.assertContains(response, "User's submissions")
@@ -3111,27 +3110,27 @@ def test_simple_submission(self):
contest = Contest.objects.get()
problem_instance = ProblemInstance.objects.get(pk=1)
round = Round.objects.get()
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 10, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 10, tzinfo=timezone.utc)
round.save()
- with fake_time(datetime(2012, 7, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 10, tzinfo=timezone.utc)):
response = self.contest_submit(contest, problem_instance)
self.assertContains(response, 'Permission denied', status_code=400)
- with fake_time(datetime(2012, 7, 31, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, tzinfo=timezone.utc)):
response = self.contest_submit(contest, problem_instance)
self._assertSubmitted(response, 2)
- with fake_time(datetime(2012, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, tzinfo=timezone.utc)):
response = self.contest_submit(contest, problem_instance)
self._assertSubmitted(response, 3)
- with fake_time(datetime(2012, 8, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 10, tzinfo=timezone.utc)):
response = self.contest_submit(contest, problem_instance)
self._assertSubmitted(response, 4)
- with fake_time(datetime(2012, 8, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 11, tzinfo=timezone.utc)):
response = self.contest_submit(contest, problem_instance)
self.assertContains(response, 'Permission denied', status_code=400)
diff --git a/oioioi/ctimes/tests.py b/oioioi/ctimes/tests.py
index 9bc9a6a47..7c6d379dd 100644
--- a/oioioi/ctimes/tests.py
+++ b/oioioi/ctimes/tests.py
@@ -1,10 +1,9 @@
from __future__ import print_function
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.contests.models import Contest, Round, RoundTimeExtension
@@ -20,19 +19,19 @@ def setUp(self):
Round(
name='round1',
contest=contest1,
- start_date=datetime(2013, 10, 11, 8, 0, tzinfo=utc),
- end_date=datetime(2013, 12, 5, 9, 0, tzinfo=utc),
+ start_date=datetime(2013, 10, 11, 8, 0, tzinfo=timezone.utc),
+ end_date=datetime(2013, 12, 5, 9, 0, tzinfo=timezone.utc),
),
Round(
name='round2',
contest=contest1,
- start_date=datetime(2013, 10, 22, 10, 0, tzinfo=utc),
- end_date=datetime(2013, 11, 5, 11, 0, tzinfo=utc),
+ start_date=datetime(2013, 10, 22, 10, 0, tzinfo=timezone.utc),
+ end_date=datetime(2013, 11, 5, 11, 0, tzinfo=timezone.utc),
),
Round(
name='round1p',
contest=contest2,
- start_date=datetime(2014, 1, 2, 3, 10, tzinfo=utc),
+ start_date=datetime(2014, 1, 2, 3, 10, tzinfo=timezone.utc),
end_date=None,
),
]
@@ -66,29 +65,29 @@ def setUp(self):
def test_ctimes_order(self):
url = reverse('ctimes', kwargs={'contest_id': 'c1'})
self.client.get(url)
- with fake_time(datetime(2013, 10, 1, 21, tzinfo=utc)):
+ with fake_time(datetime(2013, 10, 1, 21, tzinfo=timezone.utc)):
response = self.client.get(url).json()
self.assertEqual(response, self.round2_result)
- with fake_time(datetime(2013, 10, 11, 7, 56, tzinfo=utc)):
+ with fake_time(datetime(2013, 10, 11, 7, 56, tzinfo=timezone.utc)):
response = self.client.get(url).json()
self.assertEqual(response, self.round1_result)
- with fake_time(datetime(2013, 10, 22, 9, 56, tzinfo=utc)):
+ with fake_time(datetime(2013, 10, 22, 9, 56, tzinfo=timezone.utc)):
response = self.client.get(url).json()
self.assertEqual(response, self.round1_result)
- with fake_time(datetime(2013, 12, 11, 5, 0, tzinfo=utc)):
+ with fake_time(datetime(2013, 12, 11, 5, 0, tzinfo=timezone.utc)):
response = self.client.get(url).json()
self.assertEqual(response['status'], 'NO_ROUND')
Contest.objects.all().delete()
self.client.get('/') # removes current contest
url = reverse('ctimes')
- with fake_time(datetime(2013, 12, 11, 5, 0, tzinfo=utc)):
+ with fake_time(datetime(2013, 12, 11, 5, 0, tzinfo=timezone.utc)):
response = self.client.get(url).json()
self.assertEqual(response['status'], 'NO_CONTEST')
def test_ctimes_format(self):
url = reverse('ctimes', kwargs={'contest_id': 'c1'})
date_regexp = r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'
- with fake_time(datetime(2013, 10, 1, 21, tzinfo=utc)):
+ with fake_time(datetime(2013, 10, 1, 21, tzinfo=timezone.utc)):
response = self.client.get(url).json()
print(response)
self.assertRegex(response['start'], date_regexp)
@@ -99,7 +98,7 @@ def test_ctimes_with_roundextension(self):
rnd = Round.objects.get(name='round1')
user = User.objects.get(username='test_user')
RoundTimeExtension.objects.create(round=rnd, user=user, extra_time=5)
- with fake_time(datetime(2013, 10, 11, 7, 56, tzinfo=utc)):
+ with fake_time(datetime(2013, 10, 11, 7, 56, tzinfo=timezone.utc)):
response = self.client.get(url).json()
self.assertEqual(
response,
@@ -116,19 +115,19 @@ def test_ctimes_with_roundextension(self):
def test_ctimes_anonymous(self):
url = reverse('ctimes', kwargs={'contest_id': 'c2'})
self.client.logout()
- with fake_time(datetime(2014, 1, 2, 4, 56, tzinfo=utc)):
+ with fake_time(datetime(2014, 1, 2, 4, 56, tzinfo=timezone.utc)):
response = self.client.get(url).json()
self.assertEqual(response, self.round1p_result)
def test_ctimes_no_contest_id(self):
url = reverse('ctimes')
- with fake_time(datetime(2013, 10, 11, 7, 56, tzinfo=utc)):
+ with fake_time(datetime(2013, 10, 11, 7, 56, tzinfo=timezone.utc)):
response = self.client.get(url, follow=True).json()
self.assertEqual(response, self.round1p_result)
def test_ctimes_no_end(self):
url = reverse('ctimes', kwargs={'contest_id': 'c2'})
- with fake_time(datetime(2013, 10, 11, 7, 56, tzinfo=utc)):
+ with fake_time(datetime(2013, 10, 11, 7, 56, tzinfo=timezone.utc)):
response = self.client.get(url).json()
self.assertEqual(response, self.round1p_result)
diff --git a/oioioi/default_settings.py b/oioioi/default_settings.py
index ef9311961..0d2abb611 100755
--- a/oioioi/default_settings.py
+++ b/oioioi/default_settings.py
@@ -508,23 +508,21 @@
}
# Celery configuration
-
-CELERY_QUEUES = {}
-CELERY_RESULT_BACKEND = 'amqp'
-CELERY_ACKS_LATE = True
-CELERY_SEND_EVENTS = True
-
-BROKER_URL = 'sqla+sqlite:///' + os.path.join(tempfile.gettempdir(),
- 'celerydb.sqlite')
-
-CELERY_IMPORTS = [
- 'oioioi.evalmgr.tasks',
- 'oioioi.problems.unpackmgr',
-]
-
-CELERY_ROUTES = {
- 'oioioi.evalmgr.tasks.evalmgr_job': dict(queue='evalmgr'),
- 'oioioi.problems.unpackmgr.unpackmgr_job': dict(queue='unpackmgr'),
+CELERY = {
+ 'broker_url': 'sqla+sqlite:///' + os.path.join(tempfile.gettempdir(),
+ 'celerydb.sqlite'),
+ 'imports': [
+ 'oioioi.evalmgr.tasks',
+ 'oioioi.problems.unpackmgr',
+ ],
+ 'result_backend': 'rpc',
+ 'tasks_acks_late': True,
+ 'task_queues': {},
+ 'task_routes': {
+ 'oioioi.evalmgr.tasks.evalmgr_job': dict(queue='evalmgr'),
+ 'oioioi.problems.unpackmgr.unpackmgr_job': dict(queue='unpackmgr'),
+ },
+ 'worker_send_task_events': True,
}
# Number of concurrently evaluated submissions
diff --git a/oioioi/disqualification/admin.py b/oioioi/disqualification/admin.py
index f91faa443..a744cf876 100644
--- a/oioioi/disqualification/admin.py
+++ b/oioioi/disqualification/admin.py
@@ -134,7 +134,7 @@ class DisqualificationsAdminMixin(object):
def __init__(self, *args, **kwargs):
super(DisqualificationsAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [DisqualificationsConfigInline]
+ self.inlines = self.inlines + (DisqualificationsConfigInline,)
ContestAdmin.mix_in(DisqualificationsAdminMixin)
diff --git a/oioioi/disqualification/tests.py b/oioioi/disqualification/tests.py
index 6c708a0fa..cc1a5061a 100644
--- a/oioioi/disqualification/tests.py
+++ b/oioioi/disqualification/tests.py
@@ -1,10 +1,9 @@
import re
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.test import RequestFactory
from django.urls import reverse
-from pytz import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.contests.models import Contest, Submission
@@ -37,7 +36,7 @@ def wrapped():
fake_request = RequestFactory().request()
fake_request.user = user
fake_request.contest = contest
- fake_request.timestamp = datetime(2013, 1, 1, tzinfo=utc)
+ fake_request.timestamp = datetime(2013, 1, 1, tzinfo=timezone.utc)
return fake_request
return wrapped
@@ -145,7 +144,7 @@ def _assert_submission(self, submission_id, disqualified):
self.assertTrue(self.client.login(username="test_user"))
submission = Submission.objects.get(id=submission_id)
- with fake_time(datetime(2015, 1, 1, tzinfo=utc)):
+ with fake_time(datetime(2015, 1, 1, tzinfo=timezone.utc)):
response = self.client.get(
reverse(
"submission",
@@ -207,7 +206,7 @@ def setUp(self):
self.contest_kwargs = {"contest_id": Contest.objects.get().id}
def _assert_disqualification_box(self, response_callback):
- with fake_time(datetime(2015, 1, 1, tzinfo=utc)):
+ with fake_time(datetime(2015, 1, 1, tzinfo=timezone.utc)):
response = response_callback()
self.assertContains(response, "Ni in code")
self.assertContains(response, "ninininini")
@@ -216,7 +215,7 @@ def _assert_disqualification_box(self, response_callback):
self.assertIn(">42<", self.remove_whitespaces(response))
_disqualify_contestwide()
- with fake_time(datetime(2015, 1, 1, tzinfo=utc)):
+ with fake_time(datetime(2015, 1, 1, tzinfo=timezone.utc)):
response = response_callback()
self.assertContains(response, "Ni in code")
self.assertContains(response, "I cannot tell")
@@ -226,7 +225,7 @@ def _assert_disqualification_box(self, response_callback):
self.assertIn(">42<", self.remove_whitespaces(response))
Disqualification.objects.filter(submission__isnull=False).delete()
- with fake_time(datetime(2015, 1, 1, tzinfo=utc)):
+ with fake_time(datetime(2015, 1, 1, tzinfo=timezone.utc)):
response = response_callback()
self.assertNotContains(response, "Ni in code")
self.assertContains(response, "I cannot tell")
@@ -238,13 +237,13 @@ def test_ranking(self):
url = reverse("default_ranking", kwargs={"contest_id": contest.id})
self.assertTrue(self.client.login(username="test_admin"))
- with fake_time(datetime(2015, 1, 1, tzinfo=utc)):
+ with fake_time(datetime(2015, 1, 1, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, "Test User")
self.assertContains(response, "disqualified")
self.assertTrue(self.client.login(username="test_user"))
- with fake_time(datetime(2015, 1, 1, tzinfo=utc)):
+ with fake_time(datetime(2015, 1, 1, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertNotContains(response, "Test User")
@@ -253,7 +252,7 @@ def test_ranking_csv(self):
url = reverse("ranking_csv", kwargs={"contest_id": contest.id, "key": "c"})
self.assertTrue(self.client.login(username="test_admin"))
- with fake_time(datetime(2015, 1, 1, tzinfo=utc)):
+ with fake_time(datetime(2015, 1, 1, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, "Test")
self.assertContains(response, "Disqualified")
@@ -279,7 +278,7 @@ def setUp(self):
self.contest_kwargs = {"contest_id": Contest.objects.get().id}
def _assert_disqualification_box(self, response_callback):
- with fake_time(datetime(2015, 1, 1, tzinfo=utc)):
+ with fake_time(datetime(2015, 1, 1, tzinfo=timezone.utc)):
response = response_callback()
self.assertContains(response, "Ni in code")
self.assertContains(response, "ninininini")
diff --git a/oioioi/evalmgr/tasks.py b/oioioi/evalmgr/tasks.py
index acf5cb5e0..00d801e5a 100644
--- a/oioioi/evalmgr/tasks.py
+++ b/oioioi/evalmgr/tasks.py
@@ -4,8 +4,8 @@
from uuid import uuid4
import six
+from celery import shared_task
from celery.exceptions import Ignore
-from celery.task import task
from django.db import transaction
from django.utils.module_loading import import_string
@@ -270,7 +270,7 @@ def delay_environ(environ, **evalmgr_extra_args):
return async_result
-@task
+@shared_task
def evalmgr_job(env):
r"""Takes environment and evaluates it according to its recipe.
diff --git a/oioioi/forum/tests.py b/oioioi/forum/tests.py
index a7a8e5895..ab7784a36 100644
--- a/oioioi/forum/tests.py
+++ b/oioioi/forum/tests.py
@@ -1,5 +1,5 @@
import re
-from datetime import timedelta # pylint: disable=E0611
+from datetime import timedelta
from django.conf import settings
from django.contrib.auth.models import User
diff --git a/oioioi/globalmessage/tests.py b/oioioi/globalmessage/tests.py
index b7d56424d..70e773d05 100644
--- a/oioioi/globalmessage/tests.py
+++ b/oioioi/globalmessage/tests.py
@@ -1,3 +1,5 @@
+from datetime import timedelta
+
from django.test.utils import override_settings
from django.urls import reverse
from django.utils import timezone
@@ -11,7 +13,7 @@ def setUp(self):
self.now = timezone.now()
def test_visibility_dates(self):
- day = timezone.timedelta(days=1)
+ day = timedelta(days=1)
tomorrow = self.now + day
yesterday = self.now - day
diff --git a/oioioi/ipauthsync/admin.py b/oioioi/ipauthsync/admin.py
index 5e40044b2..9322d5849 100644
--- a/oioioi/ipauthsync/admin.py
+++ b/oioioi/ipauthsync/admin.py
@@ -25,4 +25,4 @@ class ContestAdminWithIpAuthSyncInlineMixin(object):
def __init__(self, *args, **kwargs):
super(ContestAdminWithIpAuthSyncInlineMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [IpAuthSyncConfigInline]
+ self.inlines = self.inlines + (IpAuthSyncConfigInline,)
diff --git a/oioioi/ipdnsauth/tests.py b/oioioi/ipdnsauth/tests.py
index 87816f554..3cffce455 100644
--- a/oioioi/ipdnsauth/tests.py
+++ b/oioioi/ipdnsauth/tests.py
@@ -1,10 +1,9 @@
import os
import socket
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.test.utils import override_settings
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.contestexcl.models import ExclusivenessConfig
@@ -34,12 +33,12 @@ def setUp(self):
ex_conf = ExclusivenessConfig()
ex_conf.contest = Contest.objects.get(id='c1')
- ex_conf.start_date = datetime(2012, 1, 1, 10, tzinfo=utc)
- ex_conf.end_date = datetime(2012, 1, 1, 14, tzinfo=utc)
+ ex_conf.start_date = datetime(2012, 1, 1, 10, tzinfo=timezone.utc)
+ ex_conf.end_date = datetime(2012, 1, 1, 14, tzinfo=timezone.utc)
ex_conf.save()
def _assertBackend(self, user):
- with fake_time(datetime(2012, 1, 1, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 11, tzinfo=timezone.utc)):
self.client.get('/c/c1/id')
session = self.client.session
self.assertEqual(session['_auth_user_id'], str(user.id))
diff --git a/oioioi/livedata/views.py b/oioioi/livedata/views.py
index 1fc67ff2c..409e86559 100644
--- a/oioioi/livedata/views.py
+++ b/oioioi/livedata/views.py
@@ -7,7 +7,6 @@
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.utils import dateformat
-from django.utils.timezone import utc
from django.utils.translation import get_language
from oioioi.base.permissions import enforce_condition
from oioioi.base.utils import allow_cross_origin, jsonify
@@ -115,7 +114,7 @@ def livedata_events_view(request, round_id):
# Only admin/observer is allowed to specify 'from' parameter.
start_time = datetime.datetime.utcfromtimestamp(
int(request.GET['from'])
- ).replace(tzinfo=utc)
+ ).replace(tzinfo=datetime.timezone.utc)
reports = reports.filter(creation_date__gte=start_time)
round = get_object_or_404(request.contest.round_set.all(), pk=round_id)
diff --git a/oioioi/mailsubmit/admin.py b/oioioi/mailsubmit/admin.py
index 59fce43ff..961c61f40 100644
--- a/oioioi/mailsubmit/admin.py
+++ b/oioioi/mailsubmit/admin.py
@@ -38,7 +38,7 @@ class MailSubmissionConfigAdminMixin(object):
def __init__(self, *args, **kwargs):
super(MailSubmissionConfigAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [MailSubmissionConfigInline]
+ self.inlines = self.inlines + (MailSubmissionConfigInline,)
ContestAdmin.mix_in(MailSubmissionConfigAdminMixin)
diff --git a/oioioi/mailsubmit/tests.py b/oioioi/mailsubmit/tests.py
index c3a859d23..8048ff2eb 100644
--- a/oioioi/mailsubmit/tests.py
+++ b/oioioi/mailsubmit/tests.py
@@ -1,9 +1,8 @@
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.core.files.base import ContentFile
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.contests.models import Contest, ProblemInstance, Round, Submission
@@ -56,30 +55,30 @@ def test_simple_mailsubmission(self):
problem_instance.submissions_limit = 0
problem_instance.save()
round = Round.objects.get()
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 10, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 10, tzinfo=timezone.utc)
round.save()
msc = MailSubmissionConfig(
contest=contest,
enabled=True,
- start_date=datetime(2012, 8, 12, tzinfo=utc),
- end_date=datetime(2012, 8, 14, tzinfo=utc),
+ start_date=datetime(2012, 8, 12, tzinfo=timezone.utc),
+ end_date=datetime(2012, 8, 14, tzinfo=timezone.utc),
)
msc.save()
- with fake_time(datetime(2012, 8, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 11, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance)
self.assertEqual(403, response.status_code)
self.assertEqual(MailSubmission.objects.count(), 0)
- with fake_time(datetime(2012, 8, 13, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 13, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance)
self.assertEqual(200, response.status_code)
self.assertEqual(MailSubmission.objects.count(), 1)
- with fake_time(datetime(2012, 8, 15, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 15, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance)
self.assertEqual(403, response.status_code)
@@ -91,18 +90,18 @@ def test_accepting_mailsubmissions(self):
problem_instance.submissions_limit = 0
problem_instance.save()
round = Round.objects.get()
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 10, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 10, tzinfo=timezone.utc)
round.save()
msc = MailSubmissionConfig(
contest=contest,
enabled=True,
- start_date=datetime(2012, 8, 12, tzinfo=utc),
- end_date=datetime(2012, 8, 14, tzinfo=utc),
+ start_date=datetime(2012, 8, 12, tzinfo=timezone.utc),
+ end_date=datetime(2012, 8, 14, tzinfo=timezone.utc),
)
msc.save()
- with fake_time(datetime(2012, 8, 13, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 13, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance)
self.assertEqual(200, response.status_code)
@@ -151,14 +150,14 @@ def test_mailsubmit_permissions(self):
problem_instance.submissions_limit = 0
problem_instance.save()
round = Round.objects.get()
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 10, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 10, tzinfo=timezone.utc)
round.save()
msc = MailSubmissionConfig(
contest=contest,
enabled=True,
- start_date=datetime(2012, 8, 12, tzinfo=utc),
- end_date=datetime(2012, 8, 14, tzinfo=utc),
+ start_date=datetime(2012, 8, 12, tzinfo=timezone.utc),
+ end_date=datetime(2012, 8, 14, tzinfo=timezone.utc),
)
msc.save()
@@ -166,7 +165,7 @@ def test_mailsubmit_permissions(self):
p = Participant(contest=contest, user=user, status='BANNED')
p.save()
- with fake_time(datetime(2012, 8, 13, 0, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 13, 0, 5, tzinfo=timezone.utc)):
self.assertTrue(self.client.login(username='test_user2'))
response = self.submit_file(contest, problem_instance)
self.assertEqual(403, response.status_code)
diff --git a/oioioi/oi/admin.py b/oioioi/oi/admin.py
index 72137e4a7..2deb41ce3 100644
--- a/oioioi/oi/admin.py
+++ b/oioioi/oi/admin.py
@@ -146,9 +146,9 @@ class OIRegistrationParticipantAdmin(ParticipantAdmin):
'school_city',
'school_province',
]
- inlines = ParticipantAdmin.inlines + [
+ inlines = ParticipantAdmin.inlines + (
OIRegistrationInline,
- ]
+ )
readonly_fields = ['user']
search_fields = ParticipantAdmin.search_fields + [
'oi_oiregistration__school__name',
diff --git a/oioioi/oi/tests.py b/oioioi/oi/tests.py
index e93c69b5d..1d4ff525a 100644
--- a/oioioi/oi/tests.py
+++ b/oioioi/oi/tests.py
@@ -1,13 +1,12 @@
# ~*~ coding: utf-8 ~*~
import os
import re
-from datetime import datetime, timedelta # pylint: disable=E0611
+from datetime import datetime, timedelta, timezone
from django.contrib.admin.utils import quote
from django.contrib.auth.models import User
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time, fake_timezone_now
from oioioi.contests.current_contest import ContestMode
@@ -439,15 +438,15 @@ def test_submit_permissions(self):
round = Round.objects.get(pk=1)
problem_instance = ProblemInstance.objects.get(pk=1)
self.assertTrue(problem_instance.round == round)
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 5, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 5, tzinfo=timezone.utc)
round.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user, status='BANNED')
p.save()
- with fake_time(datetime(2012, 8, 4, 0, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 4, 0, 5, tzinfo=timezone.utc)):
self.client.logout()
response = self.submit_file(contest, problem_instance)
self.assertEqual(200, response.status_code)
@@ -490,15 +489,15 @@ def test_submit_permissions(self):
round = Round.objects.get(pk=1)
problem_instance = ProblemInstance.objects.get(pk=1)
self.assertTrue(problem_instance.round == round)
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 5, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 5, tzinfo=timezone.utc)
round.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user, status='BANNED')
p.save()
- with fake_time(datetime(2012, 8, 4, 0, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 4, 0, 5, tzinfo=timezone.utc)):
self.client.logout()
response = self.submit_file(contest, problem_instance)
self._assertNotSubmitted(contest, response)
diff --git a/oioioi/oireports/tests.py b/oioioi/oireports/tests.py
index ffbf209df..c482abb63 100644
--- a/oioioi/oireports/tests.py
+++ b/oioioi/oireports/tests.py
@@ -1,10 +1,9 @@
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from io import BytesIO
from django.contrib.auth.models import User
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.base.utils.pdf import extract_text_from_pdf
from oioioi.contests.models import Contest
@@ -45,12 +44,12 @@ def test_pdf_report_view(self):
# Let's check if report is not available for regular user.
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.post(url, post_vars)
self.assertEqual(response.status_code, 403)
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.post(url, post_vars)
pages = extract_text_from_pdf(BytesIO(self.streamingContent(response)))
@@ -75,12 +74,12 @@ def test_xml_view(self):
# Let's check if report is not available for regular user.
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.post(url, post_vars)
self.assertEqual(response.status_code, 403)
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.post(url, post_vars)
content = self.streamingContent(response).decode('utf-8')
self.assertIn("
Test User (test_user)", content)
@@ -103,7 +102,7 @@ def test_single_report(self):
}
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.post(url, post_vars)
content = self.streamingContent(response).decode('utf-8')
self.assertNotIn('test_user2', content)
@@ -114,6 +113,6 @@ def test_default_selected_round(self):
url = reverse('oireports', kwargs={'contest_id': contest.id})
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2016, 11, 6, tzinfo=utc)):
+ with fake_time(datetime(2016, 11, 6, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, 'selected>Past round')
diff --git a/oioioi/oisubmit/tests.py b/oioioi/oisubmit/tests.py
index ae9eb0c04..661e0ddd3 100644
--- a/oioioi/oisubmit/tests.py
+++ b/oioioi/oisubmit/tests.py
@@ -1,8 +1,8 @@
-from datetime import datetime, timedelta # pylint: disable=E0611
+from datetime import datetime, timedelta, timezone
from django.core.files.base import ContentFile
from django.urls import reverse
-from django.utils.timezone import get_current_timezone, utc
+from django.utils.timezone import get_current_timezone
from oioioi.base.tests import TestCase, fake_time
from oioioi.contests.models import Contest, ProblemInstance, Round, Submission
@@ -25,7 +25,7 @@ def submit_file(
file = ContentFile('a' * file_size, name=file_name)
if localtime is None:
- localtime = datetime.now(utc)
+ localtime = datetime.now(timezone.utc)
if isinstance(localtime, datetime):
localtime_str = localtime.astimezone(get_current_timezone()).strftime(
@@ -99,11 +99,11 @@ def test_simple_submission(self):
contest = Contest.objects.get()
pi = ProblemInstance.objects.get()
round = Round.objects.get()
- round.start_date = datetime(2012, 7, 30, tzinfo=utc)
- round.end_date = datetime(2012, 8, 10, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 30, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 10, tzinfo=timezone.utc)
round.save()
- dt = datetime(2012, 7, 10, tzinfo=utc)
+ dt = datetime(2012, 7, 10, tzinfo=timezone.utc)
with fake_time(dt):
submission_number = Submission.objects.all().count()
suspected_number = Submission.objects.filter(kind='SUSPECTED').count()
@@ -115,28 +115,28 @@ def test_simple_submission(self):
str(SUSPICION_REASONS['BEFORE_START']),
)
- dt = datetime(2012, 7, 31, tzinfo=utc)
+ dt = datetime(2012, 7, 31, tzinfo=timezone.utc)
with fake_time(dt):
submission_number = Submission.objects.all().count()
suspected_number = Submission.objects.filter(kind='SUSPECTED').count()
response = self.submit_file(contest, pi.short_name, dt)
self._assertNotSuspected(response, submission_number, suspected_number)
- dt = datetime(2012, 8, 5, tzinfo=utc)
+ dt = datetime(2012, 8, 5, tzinfo=timezone.utc)
with fake_time(dt):
submission_number = Submission.objects.all().count()
suspected_number = Submission.objects.filter(kind='SUSPECTED').count()
response = self.submit_file(contest, pi.short_name, dt)
self._assertNotSuspected(response, submission_number, suspected_number)
- dt = datetime(2012, 8, 10, tzinfo=utc)
+ dt = datetime(2012, 8, 10, tzinfo=timezone.utc)
with fake_time(dt):
submission_number = Submission.objects.all().count()
suspected_number = Submission.objects.filter(kind='SUSPECTED').count()
response = self.submit_file(contest, pi.short_name, dt)
self._assertNotSuspected(response, submission_number, suspected_number)
- dt = datetime(2012, 8, 11, tzinfo=utc)
+ dt = datetime(2012, 8, 11, tzinfo=timezone.utc)
with fake_time(dt):
submission_number = Submission.objects.all().count()
suspected_number = Submission.objects.filter(kind='SUSPECTED').count()
@@ -148,7 +148,7 @@ def test_simple_submission(self):
str(SUSPICION_REASONS['AFTER_END']),
)
- dt = datetime(2012, 8, 9, tzinfo=utc)
+ dt = datetime(2012, 8, 9, tzinfo=timezone.utc)
with fake_time(dt):
submission_number = Submission.objects.all().count()
suspected_number = Submission.objects.filter(kind='SUSPECTED').count()
@@ -157,7 +157,7 @@ def test_simple_submission(self):
)
self._assertNotSuspected(response, submission_number, suspected_number)
- dt = datetime(2012, 8, 9, tzinfo=utc)
+ dt = datetime(2012, 8, 9, tzinfo=timezone.utc)
with fake_time(dt):
submission_number = Submission.objects.all().count()
suspected_number = Submission.objects.filter(kind='SUSPECTED').count()
@@ -171,7 +171,7 @@ def test_simple_submission(self):
str(SUSPICION_REASONS['TIMES_DIFFER']),
)
- dt = datetime(2012, 8, 9, tzinfo=utc)
+ dt = datetime(2012, 8, 9, tzinfo=timezone.utc)
with fake_time(dt):
submission_number = Submission.objects.all().count()
suspected_number = Submission.objects.filter(kind='SUSPECTED').count()
@@ -200,7 +200,7 @@ def test_size_limit_accuracy(self):
self._assertSubmitted(response, submission_number)
def test_submissions_limitation(self):
- dt = datetime(2012, 8, 9, tzinfo=utc)
+ dt = datetime(2012, 8, 9, tzinfo=timezone.utc)
with fake_time(dt):
contest = Contest.objects.get()
pi = ProblemInstance.objects.get()
diff --git a/oioioi/pa/admin.py b/oioioi/pa/admin.py
index 6c6aff29d..2c3dd1b3d 100644
--- a/oioioi/pa/admin.py
+++ b/oioioi/pa/admin.py
@@ -20,7 +20,7 @@ class PARegistrationInline(admin.StackedInline):
class PARegistrationParticipantAdmin(ParticipantAdmin):
list_display = ParticipantAdmin.list_display
- inlines = ParticipantAdmin.inlines + [PARegistrationInline]
+ inlines = ParticipantAdmin.inlines + (PARegistrationInline,)
readonly_fields = ['user']
def has_add_permission(self, request):
@@ -56,7 +56,7 @@ class PAProblemInstanceAdminMixin(object):
def __init__(self, *args, **kwargs):
super(PAProblemInstanceAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [PAProblemInstanceInline]
+ self.inlines = self.inlines + (PAProblemInstanceInline,)
ProblemInstanceAdmin.mix_in(PAProblemInstanceAdminMixin)
diff --git a/oioioi/pa/tests.py b/oioioi/pa/tests.py
index 8e17ff21a..302ce89c1 100644
--- a/oioioi/pa/tests.py
+++ b/oioioi/pa/tests.py
@@ -1,5 +1,5 @@
import re
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
import urllib.parse
@@ -9,7 +9,6 @@
from django.test import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time, fake_timezone_now
from oioioi.contests.models import (
Contest,
diff --git a/oioioi/participants/admin.py b/oioioi/participants/admin.py
index 06d5ed167..9820e281f 100644
--- a/oioioi/participants/admin.py
+++ b/oioioi/participants/admin.py
@@ -328,7 +328,7 @@ def __init__(self, field, request, *args, **kwargs):
class OnsiteRegistrationParticipantAdmin(ParticipantAdmin):
list_display = ParticipantAdmin.list_display + ['number', 'region', 'local_number']
- inlines = ParticipantAdmin.inlines + [OnsiteRegistrationInline]
+ inlines = ParticipantAdmin.inlines + (OnsiteRegistrationInline,)
list_filter = ParticipantAdmin.list_filter + [
('participants_onsiteregistration__region', RegionFilter)
]
@@ -404,7 +404,7 @@ class UserWithParticipantsAdminMixin(object):
def __init__(self, *args, **kwargs):
super(UserWithParticipantsAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [ParticipantInline]
+ self.inlines = self.inlines + (ParticipantInline,)
admin.OioioiUserAdmin.mix_in(UserWithParticipantsAdminMixin)
@@ -475,4 +475,4 @@ class TermsAcceptedPhraseAdminMixin(object):
def __init__(self, *args, **kwargs):
super(TermsAcceptedPhraseAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [TermsAcceptedPhraseInline]
+ self.inlines = self.inlines + (TermsAcceptedPhraseInline,)
diff --git a/oioioi/participants/tests.py b/oioioi/participants/tests.py
index 8441e3197..7234a71f7 100644
--- a/oioioi/participants/tests.py
+++ b/oioioi/participants/tests.py
@@ -1,6 +1,6 @@
import os
import re
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.core.cache import cache
@@ -8,7 +8,6 @@
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.encoding import force_str
-from django.utils.timezone import utc
from oioioi.base.tests import (
TestCase,
@@ -148,15 +147,15 @@ def test_submit_permissions(self):
round = Round.objects.get(pk=1)
problem_instance = ProblemInstance.objects.get(pk=1)
self.assertTrue(problem_instance.round == round)
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 5, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 5, tzinfo=timezone.utc)
round.save()
user = User.objects.get(username='test_user')
p = Participant(contest=contest, user=user, status='BANNED')
p.save()
- with fake_time(datetime(2012, 8, 4, 0, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 4, 0, 5, tzinfo=timezone.utc)):
self.assertTrue(self.client.login(username='test_user2'))
response = self.submit_file(contest, problem_instance)
self.assertEqual(403, response.status_code)
@@ -446,11 +445,11 @@ def test_participants_selector(self):
ex_conf = ExclusivenessConfig()
ex_conf.contest = self.c1
- ex_conf.start_date = datetime(2012, 1, 1, 8, tzinfo=utc)
- ex_conf.end_date = datetime(2012, 1, 1, 12, tzinfo=utc)
+ ex_conf.start_date = datetime(2012, 1, 1, 8, tzinfo=timezone.utc)
+ ex_conf.end_date = datetime(2012, 1, 1, 12, tzinfo=timezone.utc)
ex_conf.save()
- with fake_time(datetime(2012, 1, 1, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 10, tzinfo=timezone.utc)):
self._assertContestVisible('c1')
self._assertContestRedirects('c2', '/c/c1/')
self.assertTrue(self.client.login(username='test_user2'))
@@ -469,18 +468,18 @@ def test_contest_admin_with_participant(self):
ex_conf1 = ExclusivenessConfig()
ex_conf1.contest = self.c1
- ex_conf1.start_date = datetime(2012, 1, 1, 8, tzinfo=utc)
- ex_conf1.end_date = datetime(2012, 1, 1, 12, tzinfo=utc)
+ ex_conf1.start_date = datetime(2012, 1, 1, 8, tzinfo=timezone.utc)
+ ex_conf1.end_date = datetime(2012, 1, 1, 12, tzinfo=timezone.utc)
ex_conf1.save()
ex_conf2 = ExclusivenessConfig()
ex_conf2.contest = self.c2
- ex_conf2.start_date = datetime(2012, 1, 1, 8, tzinfo=utc)
- ex_conf2.end_date = datetime(2012, 1, 1, 12, tzinfo=utc)
+ ex_conf2.start_date = datetime(2012, 1, 1, 8, tzinfo=timezone.utc)
+ ex_conf2.end_date = datetime(2012, 1, 1, 12, tzinfo=timezone.utc)
ex_conf2.save()
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2012, 1, 1, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 1, 1, 10, tzinfo=timezone.utc)):
self._assertContestVisible('c2')
self._assertContestRedirects('c1', '/c/c2')
@@ -583,7 +582,7 @@ def test_no_anonymous_participants(self):
url = reverse('default_ranking', kwargs={'contest_id': contest.id})
self.assertTrue(self.client.login(username='test_admin'))
- with fake_timezone_now(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_timezone_now(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
user_pattern = r'>\s*%s\s*'
@@ -614,7 +613,7 @@ def test_anonymous_participants(self):
url = reverse('default_ranking', kwargs={'contest_id': contest.id})
self.assertTrue(self.client.login(username='test_contest_admin'))
- with fake_timezone_now(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_timezone_now(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
user_pattern = r'>\s*%s\s*'
diff --git a/oioioi/portals/widgets.py b/oioioi/portals/widgets.py
index 111aeda3b..07e389d70 100644
--- a/oioioi/portals/widgets.py
+++ b/oioioi/portals/widgets.py
@@ -7,119 +7,117 @@
from django.urls import resolve, reverse
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
-from mistune import BlockLexer, InlineGrammar, InlineLexer, Markdown, Renderer
+from mistune import BlockParser, InlineParser, HTMLRenderer, Markdown
+from mistune.plugins import PLUGINS
from oioioi.contests.models import UserResultForProblem
from oioioi.portals.conditions import is_portal_admin
from oioioi.problems.models import Problem
-REGISTERED_WIDGETS = []
+REGISTERED_WIDGETS = set()
_block_spoiler_leading_pattern = re.compile(r'^ *>! ?', flags=re.M)
-class PortalInlineGrammar(InlineGrammar):
- pass
+def plugin_portal(md: Markdown, request):
+ BLOCK_SPOILER_MAX_DEPTH = 6
+ def parse_block_center(block, m, state):
+ return {
+ 'type': 'block_center',
+ 'text': m.group(1),
+ }
-class PortalRenderer(Renderer):
- def block_center(self, text):
+ def parse_block_spoiler(block: BlockParser, m, state):
+ block._blockspoiler_depth += 1
+
+ if block._blockspoiler_depth > BLOCK_SPOILER_MAX_DEPTH:
+ return block.parse_text(m, state)
+ else:
+ content = _block_spoiler_leading_pattern.sub('', m.group(2))
+ content_parsed = block.parse(content, state)
+ content_parsed.insert(0, {'type': 'block_spoiler', 'summary': m.group(1)})
+ content_parsed.append({'type': 'block_spoiler_end'})
+ block._blockspoiler_depth -= 1
+ return {
+ 'type': 'block_spoiler',
+ 'children': content_parsed,
+ 'params': (m.group(1),)
+ }
+
+ def render_block_center(text):
return render_to_string(
'portals/widgets/block-center.html', {'content': mark_safe(text)}
)
- def block_spoiler(self, summary, body):
+ def render_block_spoiler(text, summary):
return render_to_string(
'portals/widgets/block-spoiler.html',
- {'summary': summary, 'body': mark_safe(body)},
+ {'summary': summary, 'body': mark_safe(text)},
)
- def table(self, header, body):
+ # Ugly hack incoming: next 3 methods
+ # Although ugly, it is correct
+ def render_table(self, content):
"""Rendering table element. Wrap header and body in it.
:param header: header part of the table.
:param body: body part of the table.
"""
+ header, body = content
return render_to_string(
'portals/widgets/table.html',
{'header': mark_safe(header), 'body': mark_safe(body)},
)
+ def render_table_body(text):
+ return (text,)
-class PortalInlineLexer(InlineLexer):
- default_rules = InlineLexer.default_rules[:]
-
- def __init__(self, request, renderer, rules=None, **kwargs):
- self.request = request
- if rules is None:
- rules = PortalInlineGrammar()
- super(PortalInlineLexer, self).__init__(renderer, rules, **kwargs)
+ def render_table_head(text):
+ return (text,)
+ md.block.register_rule(
+ 'block_center',
+ r'^ *->(.*?)<-',
+ parse_block_center
+ )
+ md.block.rules.insert(
+ md.block.rules.index('block_code'),
+ 'block_center'
+ )
+ md.block.register_rule(
+ 'block_spoiler'
+ r'^ *>!\[([^\n]*)\] *((?:\n *>![^\n]*)+)',
+ parse_block_spoiler
+ )
+ md.block.rules.insert(0, 'block_spoiler')
-class PortalBlockLexer(BlockLexer):
- default_rules = BlockLexer.default_rules[:]
-
- def __init__(self, *args, **kwargs):
- super(PortalBlockLexer, self).__init__(*args, **kwargs)
- self._blockspoiler_depth = 0
-
- self.rules.block_spoiler = re.compile(
- r'^ *>!\[([^\n]*)\] *((?:\n *>![^\n]*)+)',
- flags=re.DOTALL | re.M,
- )
- self.rules.block_center = re.compile(r'^ *->(.*?)<-', re.DOTALL)
- # Insert before 'block_code'
- if 'block_center' not in self.default_rules:
- self.default_rules.insert(
- self.default_rules.index('block_code'), 'block_center'
- )
- if 'block_spoiler' not in self.default_rules:
- self.default_rules.insert(0, 'block_spoiler')
-
- def parse_block_center(self, m):
- self.tokens.append(
- {
- 'type': 'block_center',
- 'text': m.group(1),
- }
- )
-
- def parse_block_spoiler(self, m):
- self._blockspoiler_depth += 1
+ renderer: HTMLRenderer = md.renderer
+ renderer.register('block_center', render_block_center)
+ renderer.register('block_spoiler', render_block_spoiler)
+ # Override table rendering
+ renderer.register('table', render_table)
+ renderer.register('table_body', render_table_body)
+ renderer.register('table_head', render_table_head)
- if self._blockspoiler_depth > self._max_recursive_depth:
- self.parse_text(m)
- else:
- self.tokens.append({'type': 'block_spoiler', 'summary': m.group(1)})
- # Clean leading >!
- content = _block_spoiler_leading_pattern.sub("", m.group(2))
- self.parse(content)
- self.tokens.append({'type': 'block_spoiler_end'})
-
- self._blockspoiler_depth -= 1
-
-
-class PortalMarkdown(Markdown):
- def __init__(self, request):
- renderer = PortalRenderer(escape=True)
- inline_lexer = PortalInlineLexer(request, renderer)
- block_lexer = PortalBlockLexer()
- super(PortalMarkdown, self).__init__(
- renderer, inline=inline_lexer, block=block_lexer
- )
+ for widget in REGISTERED_WIDGETS:
+ def parse_func(inline: InlineParser, m, state):
+ return 'block_text', widget.render(request, m)
- def output_block_center(self):
- return self.renderer.block_center(self.inline(self.token['text']))
+ md.inline.register_rule(widget.name, widget.compiled_tag_regex.pattern,
+ parse_func)
- def output_block_spoiler(self):
- spoiler_summary = self.token['summary']
- body = self.renderer.placeholder()
- while self.pop()['type'] != 'block_spoiler_end':
- body += self.tok()
- return self.renderer.block_spoiler(spoiler_summary, body)
def render_panel(request, panel):
- return PortalMarkdown(request).render(panel)
+ return Markdown(HTMLRenderer(), plugins=[
+ # Standard plugins
+ PLUGINS['strikethrough'],
+ PLUGINS['footnotes'],
+ PLUGINS['table'],
+
+ # Custom plugins
+ lambda md: plugin_portal(md, request),
+ ]).render(panel)
def register_widget(widget):
@@ -135,20 +133,13 @@ def register_widget(widget):
corresponding :class:`re.MatchObject` instance as the only
parameter (named 'm'). Should return a string (rendered widget).
"""
- if hasattr(PortalInlineGrammar, widget.name):
+ if widget in REGISTERED_WIDGETS:
raise ValueError(
'Inline tag for widget named %s has already been '
'registered.' % widget.name
)
- PortalInlineLexer.default_rules.insert(0, widget.name)
- setattr(PortalInlineGrammar, widget.name, widget.compiled_tag_regex)
-
- def func(self, m):
- return widget.render(self.request, m)
-
- setattr(PortalInlineLexer, 'output_' + widget.name, func)
- REGISTERED_WIDGETS.append(widget)
+ REGISTERED_WIDGETS.add(widget)
class YouTubeWidget(object):
diff --git a/oioioi/problems/admin.py b/oioioi/problems/admin.py
index 837ea5e38..82d28979a 100644
--- a/oioioi/problems/admin.py
+++ b/oioioi/problems/admin.py
@@ -83,7 +83,7 @@ class StatementConfigAdminMixin(object):
def __init__(self, *args, **kwargs):
super(StatementConfigAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [StatementConfigInline]
+ self.inlines = self.inlines + (StatementConfigInline,)
ContestAdmin.mix_in(StatementConfigAdminMixin)
@@ -112,7 +112,7 @@ class RankingVisibilityConfigAdminMixin(object):
def __init__(self, *args, **kwargs):
super(RankingVisibilityConfigAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [RankingVisibilityConfigInline]
+ self.inlines = self.inlines + (RankingVisibilityConfigInline,)
ContestAdmin.mix_in(RankingVisibilityConfigAdminMixin)
@@ -373,7 +373,7 @@ def formfield_for_manytomany(self, db_field, request, **kwargs):
class ProblemAdmin(admin.ModelAdmin):
- inlines = [
+ inlines = (
DifficultyTagInline,
AlgorithmTagInline,
OriginTagInline,
@@ -383,7 +383,7 @@ class ProblemAdmin(admin.ModelAdmin):
AttachmentInline,
ProblemInstanceInline,
ProblemSiteInline,
- ]
+ )
readonly_fields = [
'author',
'legacy_name',
diff --git a/oioioi/problems/tests/test_problemset.py b/oioioi/problems/tests/test_problemset.py
index 65d6104a4..7f1a0b619 100644
--- a/oioioi/problems/tests/test_problemset.py
+++ b/oioioi/problems/tests/test_problemset.py
@@ -1,9 +1,8 @@
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase
from oioioi.contests.models import Contest
@@ -140,7 +139,7 @@ def test_add_from_selectcontest(self):
controller_name='oioioi.contests.tests.PrivateContestController',
)
contest2.save()
- contest2.creation_date = datetime(2002, 1, 1, tzinfo=utc)
+ contest2.creation_date = datetime(2002, 1, 1, tzinfo=timezone.utc)
contest2.save()
contest3 = Contest(
id='c3',
@@ -148,7 +147,7 @@ def test_add_from_selectcontest(self):
controller_name='oioioi.contests.tests.PrivateContestController',
)
contest3.save()
- contest3.creation_date = datetime(2004, 1, 1, tzinfo=utc)
+ contest3.creation_date = datetime(2004, 1, 1, tzinfo=timezone.utc)
contest3.save()
contest4 = Contest(
id='c4',
@@ -156,7 +155,7 @@ def test_add_from_selectcontest(self):
controller_name='oioioi.contests.tests.PrivateContestController',
)
contest4.save()
- contest4.creation_date = datetime(2003, 1, 1, tzinfo=utc)
+ contest4.creation_date = datetime(2003, 1, 1, tzinfo=timezone.utc)
contest4.save()
self.assertTrue(self.client.login(username='test_admin'))
diff --git a/oioioi/problems/unpackmgr.py b/oioioi/problems/unpackmgr.py
index 9a825f1b3..4f3033ebe 100644
--- a/oioioi/problems/unpackmgr.py
+++ b/oioioi/problems/unpackmgr.py
@@ -1,13 +1,13 @@
import logging
-from celery.task import task
+from celery import shared_task
from django.utils.module_loading import import_string
from oioioi.problems.models import Problem, ProblemPackage
logger = logging.getLogger(__name__)
-@task
+@shared_task
def unpackmgr_job(env):
"""Creates (or modifies) a :class:`~oioioi.problems.models.Problem`
instance using a package file represented by a
diff --git a/oioioi/programs/admin.py b/oioioi/programs/admin.py
index 9f81a662c..d759d0393 100644
--- a/oioioi/programs/admin.py
+++ b/oioioi/programs/admin.py
@@ -39,18 +39,6 @@ class ProgramsConfigInline(admin.TabularInline):
can_delete = False
category = _("Advanced")
- def has_add_permission(self, request, obj=None):
- return False
-
- def has_change_permission(self, request, obj=None):
- return request.user.is_superuser
-
- def has_delete_permission(self, request, obj=None):
- return False
-
- def has_view_permission(self, request, obj=None):
- return self.has_change_permission(request, obj)
-
class ValidationFormset(BaseInlineFormSet):
def get_time_limit_sum(self):
@@ -269,7 +257,7 @@ class ProgramsContestAdminMixin(object):
def __init__(self, *args, **kwargs):
super(ProgramsContestAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [ProgramsConfigInline, ContestCompilerInline]
+ self.inlines = self.inlines + (ProgramsConfigInline, ContestCompilerInline)
ContestAdmin.mix_in(ProgramsContestAdminMixin)
@@ -282,7 +270,7 @@ class LibraryProblemDataAdminMixin(object):
def __init__(self, *args, **kwargs):
super(LibraryProblemDataAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [LibraryProblemDataInline]
+ self.inlines = self.inlines + (LibraryProblemDataInline,)
class ProgrammingProblemAdminMixin(object):
@@ -295,13 +283,13 @@ class ProgrammingProblemAdminMixin(object):
def __init__(self, *args, **kwargs):
super(ProgrammingProblemAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [
+ self.inlines = self.inlines + (
ReportActionsConfigInline,
OutputCheckerInline,
LibraryProblemDataInline,
ProblemCompilerInline,
ProblemAllowedLanguageInline,
- ]
+ )
class ProgrammingProblemInstanceAdminMixin(object):
@@ -309,7 +297,7 @@ class ProgrammingProblemInstanceAdminMixin(object):
def __init__(self, *args, **kwargs):
super(ProgrammingProblemInstanceAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [TestInline]
+ self.inlines = self.inlines + (TestInline,)
ProblemInstanceAdmin.mix_in(ProgrammingProblemInstanceAdminMixin)
@@ -320,7 +308,7 @@ class ProgrammingMainProblemInstanceAdminMixin(object):
def __init__(self, *args, **kwargs):
super(ProgrammingMainProblemInstanceAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [TestInline]
+ self.inlines = self.inlines + (TestInline,)
MainProblemInstanceAdmin.mix_in(ProgrammingMainProblemInstanceAdminMixin)
diff --git a/oioioi/programs/notifications.py b/oioioi/programs/notifications.py
index 8ae54618c..d14062642 100644
--- a/oioioi/programs/notifications.py
+++ b/oioioi/programs/notifications.py
@@ -1,8 +1,7 @@
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.test import RequestFactory
from django.urls import reverse
-from django.utils.timezone import utc
from django.utils.translation import gettext_noop
from oioioi.base.notification import NotificationHandler
@@ -14,7 +13,7 @@ def notification_function_initial_results(arguments):
request = RequestFactory().get('/', data={'name': u'test'})
request.user = arguments.user
request.contest = pi.contest
- request.timestamp = datetime.now().replace(tzinfo=utc)
+ request.timestamp = datetime.now().replace(tzinfo=timezone.utc)
# Check if any initial result is visible for user
if not pi.controller.can_see_submission_status(request, arguments.submission):
diff --git a/oioioi/programs/tests.py b/oioioi/programs/tests.py
index e7df7b4de..2047358c6 100644
--- a/oioioi/programs/tests.py
+++ b/oioioi/programs/tests.py
@@ -1,7 +1,7 @@
import os
import re
from collections import defaultdict
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
import pytest
import six
@@ -17,7 +17,6 @@
from django.urls import reverse
from django.utils.html import escape, strip_tags
from django.utils.http import urlencode
-from django.utils.timezone import utc
from oioioi.base.notification import NotificationHandler
from oioioi.base.tests import (
TestCase,
@@ -586,28 +585,28 @@ def test_simple_submission(self):
contest = Contest.objects.get()
problem_instance = ProblemInstance.objects.get(pk=1)
round = Round.objects.get()
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 10, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 10, tzinfo=timezone.utc)
round.save()
- with fake_time(datetime(2012, 7, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 10, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance)
self.assertEqual(200, response.status_code)
self.assertContains(response, 'Sorry, there are no problems')
- with fake_time(datetime(2012, 7, 31, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 31, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance)
self._assertSubmitted(contest, response)
- with fake_time(datetime(2012, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance)
self._assertSubmitted(contest, response)
- with fake_time(datetime(2012, 8, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 10, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance)
self._assertSubmitted(contest, response)
- with fake_time(datetime(2012, 8, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 11, tzinfo=timezone.utc)):
response = self.submit_file(contest, problem_instance)
self.assertEqual(200, response.status_code)
self.assertContains(response, 'Sorry, there are no problems')
@@ -1251,7 +1250,7 @@ def test_generate_and_download_user_permission(self):
self.assertEqual(response.status_code, 404)
# test if results have not been published yet (2012-07-31)
- with fake_time(datetime(2012, 7, 29, 11, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 7, 29, 11, 11, tzinfo=timezone.utc)):
response = self.client.post(gen_url, follow=True)
self.assertEqual(response.status_code, 403)
diff --git a/oioioi/publicsolutions/tests.py b/oioioi/publicsolutions/tests.py
index 0be98e213..79e2c652f 100644
--- a/oioioi/publicsolutions/tests.py
+++ b/oioioi/publicsolutions/tests.py
@@ -1,10 +1,9 @@
# ~*~ encoding: utf-8 ~*~
import re
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.core.cache import cache
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time, fake_timezone_now
from oioioi.contests.models import Contest, Submission
@@ -61,13 +60,13 @@ def _href(self, url):
return 'href="' + url + '"'
def _no_public_rounds(self):
- return datetime(2010, 6, 25, tzinfo=utc)
+ return datetime(2010, 6, 25, tzinfo=timezone.utc)
def _rounds_14(self):
- return datetime(2013, 4, 4, tzinfo=utc)
+ return datetime(2013, 4, 4, tzinfo=timezone.utc)
def _all_rounds(self):
- return datetime(2016, 1, 1, tzinfo=utc)
+ return datetime(2016, 1, 1, tzinfo=timezone.utc)
def assertUserSubmissionHTMLDataCount(self, html, username, count):
actual = len(
diff --git a/oioioi/questions/admin.py b/oioioi/questions/admin.py
index 4ff027a1d..321e45c76 100644
--- a/oioioi/questions/admin.py
+++ b/oioioi/questions/admin.py
@@ -147,7 +147,7 @@ class MessageNotifierContestAdminMixin(object):
def __init__(self, *args, **kwargs):
super(MessageNotifierContestAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [MessageNotifierConfigInline]
+ self.inlines = self.inlines + (MessageNotifierConfigInline,)
ContestAdmin.mix_in(MessageNotifierContestAdminMixin)
diff --git a/oioioi/questions/mails.py b/oioioi/questions/mails.py
index e2a63db4d..a2c2fed18 100644
--- a/oioioi/questions/mails.py
+++ b/oioioi/questions/mails.py
@@ -5,7 +5,7 @@
from oioioi.questions.models import MessageNotifierConfig
-new_question_signal = Signal(providing_args=['request', 'instance'])
+new_question_signal = Signal()
@receiver(new_question_signal)
diff --git a/oioioi/questions/tests.py b/oioioi/questions/tests.py
index bed6de3b2..2db001ffb 100644
--- a/oioioi/questions/tests.py
+++ b/oioioi/questions/tests.py
@@ -1,5 +1,5 @@
from copy import deepcopy
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
try:
import mock
@@ -9,7 +9,6 @@
from django.core import mail
from django.test import RequestFactory
from django.urls import reverse
-from django.utils import timezone
from oioioi.base.notification import NotificationHandler
from oioioi.base.tests import TestCase, check_not_accessible, fake_time
diff --git a/oioioi/quizzes/admin.py b/oioioi/quizzes/admin.py
index c770f6b7f..f27bb0807 100644
--- a/oioioi/quizzes/admin.py
+++ b/oioioi/quizzes/admin.py
@@ -62,7 +62,7 @@ class QuizAnswerInline(nested.NestedTabularInline):
formset = QuizAnswerFormset
sortable_field_name = 'order'
extra = 0
- inlines = [QuizAnswerPictureInline]
+ inlines = (QuizAnswerPictureInline,)
def has_add_permission(self, request, obj=None):
return True
@@ -78,7 +78,7 @@ class QuizQuestionInline(nested.NestedStackedInline):
model = QuizQuestion
sortable_field_name = 'order'
extra = 0
- inlines = [QuizAnswerInline, QuizQuestionPictureInline]
+ inlines = (QuizAnswerInline, QuizQuestionPictureInline)
def has_add_permission(self, request, obj=None):
return True
@@ -95,7 +95,7 @@ def has_view_permission(self, request, obj=None):
class QuizModelAdmin(nested.NestedModelAdmin):
model = Quiz
- inlines = [QuizQuestionInline]
+ inlines = (QuizQuestionInline,)
class Media(object):
css = {'all': ('quizzes/quizadmin.css',)}
@@ -155,4 +155,4 @@ class QuizAdminMixin(object):
def __init__(self, *args, **kwargs):
super(QuizAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [QuizInline]
+ self.inlines = self.inlines + (QuizInline,)
diff --git a/oioioi/quizzes/tests.py b/oioioi/quizzes/tests.py
index b5d6038dd..05fb84ceb 100644
--- a/oioioi/quizzes/tests.py
+++ b/oioioi/quizzes/tests.py
@@ -1,9 +1,8 @@
import os.path
-from datetime import datetime
+from datetime import datetime, timezone
from django.test import RequestFactory
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.contests.models import (
diff --git a/oioioi/quizzes/utils.py b/oioioi/quizzes/utils.py
index fba3f6af8..d495b32f7 100644
--- a/oioioi/quizzes/utils.py
+++ b/oioioi/quizzes/utils.py
@@ -1,7 +1,7 @@
import bleach
from django.utils.safestring import mark_safe
-ALLOWED_TAGS = bleach.ALLOWED_TAGS + ['br', 'pre', 'tt', 'hr']
+ALLOWED_TAGS = bleach.ALLOWED_TAGS.union(['br', 'pre', 'tt', 'hr'])
ALLOWED_ATTRIBUTES = bleach.ALLOWED_ATTRIBUTES
diff --git a/oioioi/rankings/tests.py b/oioioi/rankings/tests.py
index fb4923c4b..b86c2b796 100644
--- a/oioioi/rankings/tests.py
+++ b/oioioi/rankings/tests.py
@@ -1,12 +1,11 @@
import re
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.conf import settings
from django.contrib.auth.models import User
from django.http import QueryDict
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.templatetags.simple_filters import result_color_class
from oioioi.base.tests import (
@@ -154,14 +153,14 @@ def test_ranking_view(self):
url = reverse('default_ranking', kwargs={'contest_id': contest.id})
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, 'Export to CSV')
self.assertContains(response, 'Regenerate ranking')
# Check that Admin is filtered out.
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertFalse(
@@ -179,7 +178,7 @@ def test_ranking_view(self):
admin.save()
self.assertTrue(self.client.login(username='test_user'))
- with fake_timezone_now(datetime(2012, 8, 5, tzinfo=utc)):
+ with fake_timezone_now(datetime(2012, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertIn(
'rankings/ranking_view.html', [t.name for t in response.templates]
@@ -202,7 +201,7 @@ def test_ranking_view(self):
)
)
- with fake_timezone_now(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_timezone_now(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
expected_order = ['Test User', 'Test User 2', 'Test Admin']
prev_pos = 0
@@ -236,7 +235,7 @@ def test_ranking_view(self):
)
contest.save()
- with fake_timezone_now(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_timezone_now(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
for task in VISIBLE_TASKS:
@@ -256,11 +255,11 @@ def test_ranking_csv_view(self):
url = reverse('ranking_csv', kwargs={'contest_id': contest.id, 'key': 'c'})
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
check_not_accessible(self, url)
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2012, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, 'User,')
# Check that Admin is filtered out.
@@ -295,11 +294,11 @@ def test_invalidate_view(self):
)
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2019, 1, 27, tzinfo=utc)):
+ with fake_time(datetime(2019, 1, 27, tzinfo=timezone.utc)):
check_not_accessible(self, url)
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2019, 1, 27, tzinfo=utc)):
+ with fake_time(datetime(2019, 1, 27, tzinfo=timezone.utc)):
ranking, _ = Ranking.objects.get_or_create(
contest=contest, key='admin#key', needs_recalculation=False
)
diff --git a/oioioi/scoresreveal/admin.py b/oioioi/scoresreveal/admin.py
index 9deaa78d1..73ce9ac2d 100644
--- a/oioioi/scoresreveal/admin.py
+++ b/oioioi/scoresreveal/admin.py
@@ -37,7 +37,7 @@ class ScoresRevealProblemInstanceAdminMixin(object):
def __init__(self, *args, **kwargs):
super(ScoresRevealProblemInstanceAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [ScoresRevealConfigInline]
+ self.inlines = self.inlines + (ScoresRevealConfigInline,)
ProblemInstanceAdmin.mix_in(ScoresRevealProblemInstanceAdminMixin)
diff --git a/oioioi/scoresreveal/tests.py b/oioioi/scoresreveal/tests.py
index aef2881f2..1492dc5fe 100644
--- a/oioioi/scoresreveal/tests.py
+++ b/oioioi/scoresreveal/tests.py
@@ -1,9 +1,8 @@
import re
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.contests.models import (
@@ -54,9 +53,9 @@ def setUp(self):
self.assertTrue(self.client.login(username='test_user'))
self.user = User.objects.get(username='test_user')
round = Round.objects.get()
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 10, tzinfo=utc)
- round.results_date = datetime(2012, 8, 12, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 10, tzinfo=timezone.utc)
+ round.results_date = datetime(2012, 8, 12, tzinfo=timezone.utc)
round.save()
problem_instance = ProblemInstance.objects.get()
config = ScoreRevealConfig()
@@ -66,7 +65,7 @@ def setUp(self):
config.save()
def test_simple_reveal(self):
- with fake_time(datetime(2012, 8, 8, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 8, tzinfo=timezone.utc)):
response = self.reveal_submit(1)
self.assertContains(response, '34')
@@ -74,7 +73,7 @@ def test_simple_reveal(self):
def test_disable_time(self):
contest = Contest.objects.get()
- date = datetime(2012, 8, 9, 23, 15, tzinfo=utc)
+ date = datetime(2012, 8, 9, 23, 15, tzinfo=timezone.utc)
with fake_time(date):
submission = Submission.objects.get(pk=1)
submission.date = date
@@ -93,11 +92,11 @@ def test_round_time_extension(self):
r1 = Round.objects.get()
RoundTimeExtension(user=user, round=r1, extra_time=10).save()
- with fake_time(datetime(2012, 8, 9, 23, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 9, 23, 10, tzinfo=timezone.utc)):
self.reveal_submit(1)
def test_reveal_limit(self):
- with fake_time(datetime(2012, 8, 8, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 8, tzinfo=timezone.utc)):
self.reveal_submit(4)
self.reveal_submit(5)
response = self.reveal_submit(1, success=False)
@@ -105,13 +104,13 @@ def test_reveal_limit(self):
self.assertContains(response, 'used 2 out of 2 reveals')
def test_compilation_error(self):
- with fake_time(datetime(2012, 8, 8, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 8, tzinfo=timezone.utc)):
self.reveal_submit(2, success=False)
def test_not_scored(self):
contest = Contest.objects.get()
- with fake_time(datetime(2012, 8, 8, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 8, tzinfo=timezone.utc)):
kwargs = {'contest_id': contest.id, 'submission_id': 3}
response = self.client.get(reverse('submission', kwargs=kwargs))
self.assertEqual(response.status_code, 200)
@@ -122,10 +121,10 @@ def test_not_scored(self):
def test_after_round(self):
contest = Contest.objects.get()
- with fake_time(datetime(2012, 8, 8, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 8, tzinfo=timezone.utc)):
self.reveal_submit(4)
- with fake_time(datetime(2012, 8, 11, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 11, tzinfo=timezone.utc)):
kwargs = {'contest_id': contest.id, 'submission_id': 4}
response = self.client.get(reverse('submission', kwargs=kwargs))
self.assertEqual(response.status_code, 200)
@@ -153,9 +152,9 @@ def setUp(self):
self.assertTrue(self.client.login(username='test_user'))
self.user = User.objects.get(username='test_user')
round = Round.objects.get()
- round.start_date = datetime(2012, 7, 31, tzinfo=utc)
- round.end_date = datetime(2012, 8, 10, tzinfo=utc)
- round.results_date = datetime(2012, 8, 12, tzinfo=utc)
+ round.start_date = datetime(2012, 7, 31, tzinfo=timezone.utc)
+ round.end_date = datetime(2012, 8, 10, tzinfo=timezone.utc)
+ round.results_date = datetime(2012, 8, 12, tzinfo=timezone.utc)
round.save()
problem_instance = ProblemInstance.objects.get()
config = ScoreRevealConfig()
@@ -179,7 +178,7 @@ def no_whitespaces(self, response):
return re.sub(r'\s*', '', response.content.decode('utf-8'))
def test_simple_reveal(self):
- with fake_time(datetime(2012, 8, 8, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 8, tzinfo=timezone.utc)):
self.assertIn(
'34 ', self.no_whitespaces(self.get_submission_page(1))
)
@@ -191,7 +190,7 @@ def test_simple_reveal(self):
)
def test_disable_time(self):
- date = datetime(2012, 8, 9, 23, 15, tzinfo=utc)
+ date = datetime(2012, 8, 9, 23, 15, tzinfo=timezone.utc)
submission = Submission.objects.get(pk=1)
submission.date = date
submission.save()
@@ -209,7 +208,7 @@ def test_round_time_extension(self):
r1 = Round.objects.get()
RoundTimeExtension(user=user, round=r1, extra_time=10).save()
- date = datetime(2012, 8, 9, 23, 10, tzinfo=utc)
+ date = datetime(2012, 8, 9, 23, 10, tzinfo=timezone.utc)
with fake_time(date):
submission = Submission.objects.get(pk=1)
submission.date = date
@@ -217,18 +216,18 @@ def test_round_time_extension(self):
self.assertContains(self.get_submission_page(1), '34')
def test_compilation_error(self):
- with fake_time(datetime(2012, 8, 8, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 8, tzinfo=timezone.utc)):
self.assertContains(
self.get_submission_page(2),
'You cannot reveal the score of the submission with status',
)
def test_not_scored(self):
- with fake_time(datetime(2012, 8, 8, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 8, tzinfo=timezone.utc)):
self.assertContains(self.get_submission_page(3), 'has not been scored yet')
def test_after_round(self):
- with fake_time(datetime(2012, 8, 10, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 10, 10, tzinfo=timezone.utc)):
response = self.get_submission_page(4)
no_whitespaces_response = re.sub(
r'\s*', '', response.content.decode('utf-8')
diff --git a/oioioi/similarsubmits/admin.py b/oioioi/similarsubmits/admin.py
index e74ff8529..85202f01b 100644
--- a/oioioi/similarsubmits/admin.py
+++ b/oioioi/similarsubmits/admin.py
@@ -155,7 +155,7 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):
class SubmissionsSimilarityGroupAdmin(admin.ModelAdmin):
list_display = ['id']
- inlines = [SubmisionsSimilarityEntryInline]
+ inlines = (SubmisionsSimilarityEntryInline,)
exclude = ['contest']
def has_add_permission(self, request):
diff --git a/oioioi/sinolpack/admin.py b/oioioi/sinolpack/admin.py
index e1dd02b6f..ca4a80271 100644
--- a/oioioi/sinolpack/admin.py
+++ b/oioioi/sinolpack/admin.py
@@ -67,4 +67,4 @@ class SinolpackProblemAdminMixin(object):
def __init__(self, *args, **kwargs):
super(SinolpackProblemAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [SinolpackConfigInline, SinolpackExtraFilesInline]
+ self.inlines = self.inlines + (SinolpackConfigInline, SinolpackExtraFilesInline)
diff --git a/oioioi/sioworkers/management/commands/download_sandboxes.py b/oioioi/sioworkers/management/commands/download_sandboxes.py
index d061d1f8b..41e51ae5f 100644
--- a/oioioi/sioworkers/management/commands/download_sandboxes.py
+++ b/oioioi/sioworkers/management/commands/download_sandboxes.py
@@ -15,7 +15,7 @@
DEFAULT_SANDBOXES_MANIFEST = getattr(
settings,
'SANDBOXES_MANIFEST',
- 'https://downloads.sio2project.mimuw.edu.pl/sandboxes/Manifest',
+ 'http://localhost:8001/Manifest',
)
@@ -122,7 +122,7 @@ def handle(self, *args, **options):
urls = []
cached_args = []
for arg in args:
- basename = arg + '.tar.gz'
+ basename = arg + '.tar.zst'
if options['cache_dir']:
path = os.path.join(options['cache_dir'], basename)
if os.path.isfile(path):
@@ -161,7 +161,7 @@ def handle(self, *args, **options):
print("--- Saving sandboxes to the Filetracker ...", file=self.stdout)
for arg in args:
- basename = arg + '.tar.gz'
+ basename = arg + '.tar.zst'
if arg in cached_args:
local_file = os.path.join(options['cache_dir'], basename)
else:
diff --git a/oioioi/statistics/admin.py b/oioioi/statistics/admin.py
index a8924facd..27c59d05c 100644
--- a/oioioi/statistics/admin.py
+++ b/oioioi/statistics/admin.py
@@ -30,7 +30,7 @@ class StatisticsAdminMixin(object):
def __init__(self, *args, **kwargs):
super(StatisticsAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [StatisticsConfigInline]
+ self.inlines = self.inlines + (StatisticsConfigInline,)
ContestAdmin.mix_in(StatisticsAdminMixin)
diff --git a/oioioi/statistics/tests.py b/oioioi/statistics/tests.py
index 22114ebd3..5e16247fd 100644
--- a/oioioi/statistics/tests.py
+++ b/oioioi/statistics/tests.py
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.test import RequestFactory
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.contests.models import Contest, ProblemInstance
@@ -33,7 +32,7 @@ def setUp(self):
self.request = RequestFactory().request()
self.request.user = User.objects.get(username='test_user')
self.request.contest = Contest.objects.get()
- self.request.timestamp = datetime.now().replace(tzinfo=utc)
+ self.request.timestamp = datetime.now().replace(tzinfo=timezone.utc)
def assertSizes(self, data, dims):
"""Assert that ``data`` is a ``len(dims)``-dimensional rectangular
@@ -113,7 +112,7 @@ def setUp(self):
self.request = RequestFactory().request()
self.request.user = User.objects.get(username='test_user')
self.request.contest = Contest.objects.get()
- self.request.timestamp = datetime.now().replace(tzinfo=utc)
+ self.request.timestamp = datetime.now().replace(tzinfo=timezone.utc)
def test_scatter(self):
plot_function, plot_type = statistics_plot_kinds[
@@ -174,29 +173,29 @@ def test_statistics_view(self):
# Without StatisticsConfig model
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, 'Results histogram')
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(403, response.status_code)
cfg = StatisticsConfig(
contest=contest,
visible_to_users=True,
- visibility_date=datetime(2014, 2, 3, tzinfo=utc),
+ visibility_date=datetime(2014, 2, 3, tzinfo=timezone.utc),
)
cfg.save()
self.assertTrue(self.client.login(username='test_admin'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, 'Results histogram')
self.assertTrue(self.client.login(username='test_user'))
- with fake_time(datetime(2015, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, 'Results histogram')
self.assertContains(response, 'zad4')
diff --git a/oioioi/teams/admin.py b/oioioi/teams/admin.py
index 4a68df245..f5612ad65 100644
--- a/oioioi/teams/admin.py
+++ b/oioioi/teams/admin.py
@@ -22,9 +22,7 @@ class TeamsAdmin(admin.ModelAdmin):
list_display = ['name', 'join_key']
fields = ['name', 'login']
search_fields = ['name']
- inlines = [
- MembersInline,
- ]
+ inlines = (MembersInline,)
form = TeamForm
def has_add_permission(self, request):
@@ -76,7 +74,7 @@ class TeamsAdminMixin(object):
def __init__(self, *args, **kwargs):
super(TeamsAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [TeamsConfigInline]
+ self.inlines = self.inlines + (TeamsConfigInline,)
ContestAdmin.mix_in(TeamsAdminMixin)
diff --git a/oioioi/teams/tests.py b/oioioi/teams/tests.py
index 4935e8db3..597bf840b 100644
--- a/oioioi/teams/tests.py
+++ b/oioioi/teams/tests.py
@@ -1,11 +1,10 @@
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.core.files.base import ContentFile
from django.test import RequestFactory
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.contests.models import Contest, ProblemInstance, Submission
@@ -32,8 +31,8 @@ def test_permissions(self):
contest = Contest.objects.get()
tconf = TeamsConfig(
contest=contest,
- modify_begin_date=datetime(2012, 1, 1, 8, tzinfo=utc),
- modify_end_date=datetime(2012, 1, 1, 12, tzinfo=utc),
+ modify_begin_date=datetime(2012, 1, 1, 8, tzinfo=timezone.utc),
+ modify_end_date=datetime(2012, 1, 1, 12, tzinfo=timezone.utc),
enabled=True,
)
tconf.save()
@@ -45,7 +44,7 @@ def test_permissions(self):
request.contest = contest
request.user = user
- timestamp = datetime(2012, 1, 1, 10, tzinfo=utc)
+ timestamp = datetime(2012, 1, 1, 10, tzinfo=timezone.utc)
with fake_time(timestamp):
request.timestamp = timestamp
self.assertEqual(contest.controller.can_modify_team(request), True)
@@ -77,13 +76,13 @@ def test_views(self):
contest = Contest.objects.get()
tconf = TeamsConfig(
contest=contest,
- modify_begin_date=datetime(2012, 1, 1, 8, tzinfo=utc),
- modify_end_date=datetime(2012, 1, 1, 12, tzinfo=utc),
+ modify_begin_date=datetime(2012, 1, 1, 8, tzinfo=timezone.utc),
+ modify_end_date=datetime(2012, 1, 1, 12, tzinfo=timezone.utc),
enabled=True,
)
tconf.save()
- timestamp = datetime(2012, 1, 1, 10, tzinfo=utc)
+ timestamp = datetime(2012, 1, 1, 10, tzinfo=timezone.utc)
with fake_time(timestamp):
self.assertTrue(self.client.login(username='test_user'))
response = self.client.get(
diff --git a/oioioi/test_settings.py b/oioioi/test_settings.py
index 95a8861e6..57bea194c 100644
--- a/oioioi/test_settings.py
+++ b/oioioi/test_settings.py
@@ -1,5 +1,6 @@
# pylint: disable=wildcard-import
from oioioi.default_settings import *
+from settings import CELERY
TIME_ZONE = 'UTC'
diff --git a/oioioi/testrun/admin.py b/oioioi/testrun/admin.py
index 76334cb26..0f9efac09 100644
--- a/oioioi/testrun/admin.py
+++ b/oioioi/testrun/admin.py
@@ -16,7 +16,7 @@ class TestRunAdminMixin(object):
def __init__(self, *args, **kwargs):
super(TestRunAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [TestRunConfigInline]
+ self.inlines = self.inlines + (TestRunConfigInline,)
ProblemInstanceAdmin.mix_in(TestRunAdminMixin)
diff --git a/oioioi/testrun/controllers.py b/oioioi/testrun/controllers.py
index 8a53299a9..23181b58a 100644
--- a/oioioi/testrun/controllers.py
+++ b/oioioi/testrun/controllers.py
@@ -279,7 +279,7 @@ def render_submission(self, request, submission):
context={
'submission': submission_template_context(request, sbm_testrun),
'supported_extra_args': self.get_supported_extra_args(submission),
- 'input_is_zip': is_zipfile(sbm_testrun.input_file),
+ 'input_is_zip': is_zipfile(sbm_testrun.input_file.read_using_cache()),
},
)
@@ -295,7 +295,7 @@ def _render_testrun_report(
input_is_zip = False
if testrun_report:
input_is_zip = is_zipfile(
- testrun_report.submission_report.submission.programsubmission.testrunprogramsubmission.input_file
+ testrun_report.submission_report.submission.programsubmission.testrunprogramsubmission.input_file.read_using_cache()
)
return render_to_string(
diff --git a/oioioi/testrun/tests.py b/oioioi/testrun/tests.py
index c57a59b48..fd80bdcc7 100644
--- a/oioioi/testrun/tests.py
+++ b/oioioi/testrun/tests.py
@@ -1,12 +1,11 @@
# coding: utf-8
import os
import re
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
from django.contrib.auth.models import User
from django.core.files.base import ContentFile
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import (
TestCase,
@@ -42,7 +41,7 @@ def test_status_visible(self):
'submission_id': submission.id,
}
- with fake_time(datetime(2011, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2011, 8, 5, tzinfo=timezone.utc)):
submission_view = self.client.get(reverse('submission', kwargs=kwargs))
self.assertContains(submission_view, 'Input')
self.assertContains(submission_view, 'Output')
@@ -66,7 +65,7 @@ def test_input_views(self):
'submission_id': submission.id,
}
- with fake_time(datetime(2011, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2011, 8, 5, tzinfo=timezone.utc)):
show_output = self.client.get(
reverse('get_testrun_input', kwargs=kwargs),
HTTP_X_REQUESTED_WITH='XMLHttpRequest',
@@ -94,7 +93,7 @@ def test_output_views(self):
'submission_id': submission.id,
}
- with fake_time(datetime(2011, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2011, 8, 5, tzinfo=timezone.utc)):
show_output = self.client.get(
reverse('get_testrun_output', kwargs=kwargs),
HTTP_X_REQUESTED_WITH='XMLHttpRequest',
@@ -114,7 +113,7 @@ def test_output_views(self):
'filename="output.out"', download_response['Content-Disposition']
)
- with fake_time(datetime(2014, 8, 5, tzinfo=utc)):
+ with fake_time(datetime(2014, 8, 5, tzinfo=timezone.utc)):
show_output = self.client.get(
reverse('get_testrun_output', kwargs=kwargs),
HTTP_X_REQUESTED_WITH='XMLHttpRequest',
diff --git a/oioioi/testspackages/admin.py b/oioioi/testspackages/admin.py
index 5d690f941..f4dd1dc37 100644
--- a/oioioi/testspackages/admin.py
+++ b/oioioi/testspackages/admin.py
@@ -71,7 +71,7 @@ class TestsPackageAdminMixin(object):
def __init__(self, *args, **kwargs):
super(TestsPackageAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [TestsPackageInline]
+ self.inlines = self.inlines + (TestsPackageInline,)
ProblemAdmin.mix_in(TestsPackageAdminMixin)
diff --git a/oioioi/testspackages/tests.py b/oioioi/testspackages/tests.py
index c8a5c6583..942a251ca 100644
--- a/oioioi/testspackages/tests.py
+++ b/oioioi/testspackages/tests.py
@@ -1,10 +1,10 @@
import os
import zipfile
-from datetime import datetime # pylint: disable=E0611
+from datetime import datetime, timezone
+
from django.core.exceptions import ValidationError
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, fake_time
from oioioi.base.utils import strip_num_or_hash
@@ -47,7 +47,7 @@ def test_validating_packages(self):
problem=problem,
name='some name',
description='some desc',
- publish_date=datetime(2012, 8, 5, 0, 11, tzinfo=utc),
+ publish_date=datetime(2012, 8, 5, 0, 11, tzinfo=timezone.utc),
)
with self.assertRaises(ValidationError):
@@ -57,7 +57,7 @@ def test_validating_packages(self):
problem=problem,
name='some_name',
description='some desc',
- publish_date=datetime(2012, 8, 5, 0, 11, tzinfo=utc),
+ publish_date=datetime(2012, 8, 5, 0, 11, tzinfo=timezone.utc),
)
tp.full_clean()
tp.save()
@@ -73,7 +73,7 @@ def test_packing_packages(self):
problem=problem,
name='some_name',
description='some desc',
- publish_date=datetime(2012, 8, 5, 0, 11, tzinfo=utc),
+ publish_date=datetime(2012, 8, 5, 0, 11, tzinfo=timezone.utc),
)
tp.save()
tp.tests.add(test1, test3)
@@ -93,7 +93,7 @@ def test_packages_visibility(self):
problem=problem,
name='some_name',
description='some desc',
- publish_date=datetime(2012, 8, 5, 0, 11, tzinfo=utc),
+ publish_date=datetime(2012, 8, 5, 0, 11, tzinfo=timezone.utc),
)
tp.full_clean()
tp.save()
@@ -103,7 +103,7 @@ def test_packages_visibility(self):
problem=problem,
name='some_name2',
description='some desc2',
- publish_date=datetime(2012, 8, 5, 1, 11, tzinfo=utc),
+ publish_date=datetime(2012, 8, 5, 1, 11, tzinfo=timezone.utc),
)
tp2.full_clean()
tp2.save()
@@ -112,18 +112,18 @@ def test_packages_visibility(self):
self.assertTrue(self.client.login(username='test_user'))
url = reverse('contest_files', kwargs={'contest_id': contest.id})
- with fake_time(datetime(2012, 8, 5, 0, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, 0, 10, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertNotContains(response, 'some_name.zip')
self.assertNotContains(response, 'some_name2.zip')
- with fake_time(datetime(2012, 8, 5, 0, 12, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, 0, 12, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, 'some_name.zip')
self.assertNotContains(response, 'some_name2.zip')
self.assertEqual(200, response.status_code)
- with fake_time(datetime(2012, 8, 5, 1, 12, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, 1, 12, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertContains(response, 'some_name.zip')
self.assertContains(response, 'some_name2.zip')
@@ -131,10 +131,10 @@ def test_packages_visibility(self):
url = reverse('test', kwargs={'contest_id': contest.id, 'package_id': 1})
- with fake_time(datetime(2012, 8, 5, 0, 10, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, 0, 10, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(403, response.status_code)
- with fake_time(datetime(2012, 8, 5, 0, 12, tzinfo=utc)):
+ with fake_time(datetime(2012, 8, 5, 0, 12, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertEqual(200, response.status_code)
diff --git a/oioioi/timeline/tests.py b/oioioi/timeline/tests.py
index a75ed1144..7a563722a 100644
--- a/oioioi/timeline/tests.py
+++ b/oioioi/timeline/tests.py
@@ -1,7 +1,6 @@
import datetime
from django.urls import reverse
-from django.utils.timezone import utc
from oioioi.base.tests import TestCase, check_not_accessible
from oioioi.contests.date_registration import date_registry
@@ -149,7 +148,7 @@ def test_valid_unset_date_change(self):
obj = Round.objects.get(pk=2)
self.assertEqual(
- obj.end_date, datetime.datetime(2021, 10, 10, 10, 10, tzinfo=utc)
+ obj.end_date, datetime.datetime(2021, 10, 10, 10, 10, tzinfo=datetime.timezone.utc)
)
def test_invalid_date_change(self):
diff --git a/oioioi/urls.py b/oioioi/urls.py
index a8f5920a8..1616ab9ea 100644
--- a/oioioi/urls.py
+++ b/oioioi/urls.py
@@ -44,7 +44,7 @@
urls_module = import_module(app + '.urls')
if hasattr(urls_module, 'urlpatterns'):
urlpatterns += getattr(urls_module, 'urlpatterns')
- except ImportError:
+ except ModuleNotFoundError:
pass
urlpatterns.extend(
diff --git a/oioioi/usercontests/admin.py b/oioioi/usercontests/admin.py
index e3ffee267..d9f969b56 100755
--- a/oioioi/usercontests/admin.py
+++ b/oioioi/usercontests/admin.py
@@ -133,7 +133,7 @@ def get_inline_instances(self, request, obj=None):
else:
modified_inlines.append(inline)
- return modified_inlines
+ return tuple(modified_inlines)
ContestAdmin.mix_in(UserContestAdminMixin)
diff --git a/oioioi/usergroups/admin.py b/oioioi/usergroups/admin.py
index 1c6bc371f..0fc8da499 100644
--- a/oioioi/usergroups/admin.py
+++ b/oioioi/usergroups/admin.py
@@ -76,7 +76,7 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):
class UserGroupRankingsContestAdminMixin(object):
def __init__(self, *args, **kwargs):
super(UserGroupRankingsContestAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = self.inlines + [UserGroupRankingInline]
+ self.inlines = self.inlines + (UserGroupRankingInline,)
ContestAdmin.mix_in(UserGroupRankingsContestAdminMixin)
diff --git a/oioioi/zeus/admin.py b/oioioi/zeus/admin.py
index 14453ca4d..e8e6a5522 100644
--- a/oioioi/zeus/admin.py
+++ b/oioioi/zeus/admin.py
@@ -42,4 +42,4 @@ class ZeusProblemAdminMixin(object):
def __init__(self, *args, **kwargs):
super(ZeusProblemAdminMixin, self).__init__(*args, **kwargs)
- self.inlines = [ZeusProblemDataInline] + self.inlines
+ self.inlines = (ZeusProblemDataInline,) + self.inlines
diff --git a/requirements.txt b/requirements.txt
index c6beb29ba..ff01a2e03 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,8 +1,5 @@
# These dependencies need to be installed from external sources,
# therefore they must be listed here. Moreover, they cannot be listed in
# setup.py, as pip is not able to install them.
-http://github.com/Supervisor/supervisor/zipball/master#egg=supervisor==4.0.0.dev0
-http://github.com/badochov/djsupervisor/zipball/master#egg=djsupervisor==0.4.0
-http://github.com/sio2project/sioworkers/archive/refs/tags/v1.4.1.tar.gz
-e .
diff --git a/requirements_static.txt b/requirements_static.txt
index 5d1a510d9..7559a405a 100644
--- a/requirements_static.txt
+++ b/requirements_static.txt
@@ -1,2 +1,2 @@
-black==22.3
-isort==5.6.4
+black
+isort
diff --git a/setup.py b/setup.py
index 8b9959b4e..19a74caa5 100644
--- a/setup.py
+++ b/setup.py
@@ -20,58 +20,53 @@
sys.exit(2)
requirements = [
- "Django>=3.2,<3.3", # when upgrading, upgrade also django-two-factor-auth!
- "pytz>=2013b,<=2021.1",
- "sqlalchemy<1.5",
- "beautifulsoup4<4.10",
- "PyYAML<5.5",
- "python-dateutil<2.9",
- "django-two-factor-auth==1.13.2",
- "django-formtools>=2.2,<=2.3",
- "django-registration-redux>=2.6,<=2.9",
- "Celery==4.4.7",
- "coreapi>=2.3.0,<2.4",
- "dj-pagination==2.5",
- "django-compressor==2.4.1", # latest version
- "pygments<2.6",
- "django-libsass>=0.7,<=0.8",
- "django-debug-toolbar>=3.0,<=3.3",
- "django-extensions>=3.0,<=3.2", # Django 2.2
- "djangorestframework>=3.10,<3.13",
- "werkzeug<1.1",
- 'pytest==4.6.11',
- 'pytest-metadata==1.11.0',
- 'pytest-django==3.10.0',
- 'pytest-html==1.22.1',
- 'pytest-xdist==1.34.0',
- 'pytest-cov>=2.11,<2.12',
- 'requests<3',
- "fpdf<1.8",
- "unicodecsv<0.15",
- "shortuuid<1",
- "dnslib<0.10",
- "bleach>=3.1.0,<3.2",
- "chardet<4.1",
- "django-gravatar2<1.5",
- "django-mptt>=0.10,<=0.12",
- "mistune<0.9",
- "pika<1.3",
- "raven<6.11",
- "unidecode<1.3",
+ "Django",
+ "pytz",
+ "sqlalchemy",
+ "beautifulsoup4",
+ "PyYAML",
+ "python-dateutil",
+ "django-two-factor-auth",
+ "django-formtools",
+ "django-registration-redux",
+ "Celery",
+ "coreapi",
+ "dj-pagination",
+ "django-compressor",
+ "pygments",
+ "django-libsass",
+ "django-debug-toolbar",
+ "django-extensions",
+ "djangorestframework",
+ "werkzeug",
+ 'pytest',
+ 'pytest-metadata',
+ 'pytest-django',
+ 'pytest-html',
+ 'pytest-xdist',
+ 'pytest-cov',
+ 'requests',
+ "fpdf",
+ "unicodecsv",
+ "shortuuid",
+ "dnslib",
+ "bleach",
+ "chardet",
+ "django-gravatar2",
+ "django-mptt",
+ "mistune",
+ "pika",
+ "raven",
+ "unidecode",
"sentry-sdk",
- "fontawesomefree==6.1.1",
+ "fontawesomefree",
# A library allowing to nest inlines in django admin.
# Used in quizzes module for adding new quizzes.
- "django-nested-admin<3.4",
+ "django-nested-admin",
# SIO2 dependencies:
- "filetracker>=2.1.5,<3.0",
- "django-simple-captcha>=0.5.16,<=0.5.18",
- # HOTFIX
- "phonenumbers<8.13",
- # this is the last pdfminer.six version to support python2
- "pdfminer.six==20191110",
- # https://stackoverflow.com/questions/73929564/entrypoints-object-has-no-attribute-get-digital-ocean
- "importlib-metadata<5.0",
+ "filetracker",
+ "django-simple-captcha",
+ "pdfminer.six"
]
setup(