Upgrade to Django 3.2

This commit is contained in:
cuom1999 2022-10-31 20:43:06 -05:00
parent c1f710c9ac
commit 409d2e3115
23 changed files with 1469 additions and 151 deletions

View file

@ -6,13 +6,13 @@ from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('judge', '0135_auto_20221028_0300'), ("judge", "0135_auto_20221028_0300"),
('chat_box', '0009_auto_20220618_1452'), ("chat_box", "0009_auto_20220618_1452"),
] ]
operations = [ operations = [
migrations.AlterUniqueTogether( migrations.AlterUniqueTogether(
name='userroom', name="userroom",
unique_together={('user', 'room')}, unique_together={("user", "room")},
), ),
] ]

View file

@ -42,7 +42,6 @@ class Message(models.Model):
super(Message, self).save(*args, **kwargs) super(Message, self).save(*args, **kwargs)
class Meta: class Meta:
app_label = "chat_box"
verbose_name = "message" verbose_name = "message"
verbose_name_plural = "messages" verbose_name_plural = "messages"
ordering = ("-time",) ordering = ("-time",)

View file

@ -483,3 +483,5 @@ try:
exec(f.read(), globals()) exec(f.read(), globals())
except IOError: except IOError:
pass pass
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

View file

@ -1,4 +1,4 @@
import pymysql import pymysql
pymysql.install_as_MySQLdb() pymysql.install_as_MySQLdb()
pymysql.version_info = (1, 3, 13, "final", 0) pymysql.version_info = (1, 4, 0, "final", 0)

View file

@ -3,7 +3,7 @@ from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db.models import Count from django.db.models import Count, FilteredRelation, Q
from django.db.models.expressions import F, Value from django.db.models.expressions import F, Value
from django.db.models.functions import Coalesce from django.db.models.functions import Coalesce
from django.forms import ModelForm from django.forms import ModelForm
@ -22,8 +22,7 @@ from reversion import revisions
from reversion.models import Revision, Version from reversion.models import Revision, Version
from judge.dblock import LockModel from judge.dblock import LockModel
from judge.models import Comment, CommentLock, CommentVote, Notification from judge.models import Comment, CommentLock, Notification
from judge.utils.raw_sql import RawSQLColumn, unique_together_left_join
from judge.widgets import HeavyPreviewPageDownWidget from judge.widgets import HeavyPreviewPageDownWidget
from judge.jinja2.reference import get_user_from_text from judge.jinja2.reference import get_user_from_text
@ -178,13 +177,12 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View):
) )
if self.request.user.is_authenticated: if self.request.user.is_authenticated:
queryset = queryset.annotate(
vote_score=Coalesce(RawSQLColumn(CommentVote, "score"), Value(0))
)
profile = self.request.profile profile = self.request.profile
unique_together_left_join( queryset = queryset.annotate(
queryset, CommentVote, "comment", "voter", profile.id my_vote=FilteredRelation(
) "votes", condition=Q(votes__voter_id=profile.id)
),
).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0)))
context["is_new_user"] = ( context["is_new_user"] = (
not self.request.user.is_staff not self.request.user.is_staff
and not profile.submission_set.filter( and not profile.submission_set.filter(

View file

@ -1,7 +1,5 @@
from abc import ABCMeta, abstractmethod, abstractproperty from abc import ABCMeta, abstractmethod, abstractproperty
from django.utils import six
class abstractclassmethod(classmethod): class abstractclassmethod(classmethod):
__isabstractmethod__ = True __isabstractmethod__ = True
@ -11,7 +9,7 @@ class abstractclassmethod(classmethod):
super(abstractclassmethod, self).__init__(callable) super(abstractclassmethod, self).__init__(callable)
class BaseContestFormat(six.with_metaclass(ABCMeta)): class BaseContestFormat(metaclass=ABCMeta):
@abstractmethod @abstractmethod
def __init__(self, contest, config): def __init__(self, contest, config):
self.config = config self.config = config

View file

@ -1,5 +1,3 @@
from django.utils import six
formats = {} formats = {}
@ -13,4 +11,4 @@ def register_contest_format(name):
def choices(): def choices():
return [(key, value.name) for key, value in sorted(six.iteritems(formats))] return [(key, value.name) for key, value in sorted(formats.items())]

View file

@ -1,5 +1,3 @@
from django.utils import six
from judge.ratings import rating_class, rating_name, rating_progress from judge.ratings import rating_class, rating_name, rating_progress
from . import registry from . import registry
@ -8,7 +6,7 @@ def _get_rating_value(func, obj):
if obj is None: if obj is None:
return None return None
if isinstance(obj, six.integer_types): if isinstance(obj, int):
return func(obj) return func(obj)
else: else:
return func(obj.rating) return func(obj.rating)

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,677 @@
# Generated by Django 3.2.16 on 2022-11-01 01:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("judge", "0135_auto_20221028_0300"),
]
operations = [
migrations.AlterField(
model_name="profile",
name="timezone",
field=models.CharField(
choices=[
(
"Africa",
[
("Africa/Abidjan", "Abidjan"),
("Africa/Accra", "Accra"),
("Africa/Addis_Ababa", "Addis_Ababa"),
("Africa/Algiers", "Algiers"),
("Africa/Asmara", "Asmara"),
("Africa/Asmera", "Asmera"),
("Africa/Bamako", "Bamako"),
("Africa/Bangui", "Bangui"),
("Africa/Banjul", "Banjul"),
("Africa/Bissau", "Bissau"),
("Africa/Blantyre", "Blantyre"),
("Africa/Brazzaville", "Brazzaville"),
("Africa/Bujumbura", "Bujumbura"),
("Africa/Cairo", "Cairo"),
("Africa/Casablanca", "Casablanca"),
("Africa/Ceuta", "Ceuta"),
("Africa/Conakry", "Conakry"),
("Africa/Dakar", "Dakar"),
("Africa/Dar_es_Salaam", "Dar_es_Salaam"),
("Africa/Djibouti", "Djibouti"),
("Africa/Douala", "Douala"),
("Africa/El_Aaiun", "El_Aaiun"),
("Africa/Freetown", "Freetown"),
("Africa/Gaborone", "Gaborone"),
("Africa/Harare", "Harare"),
("Africa/Johannesburg", "Johannesburg"),
("Africa/Juba", "Juba"),
("Africa/Kampala", "Kampala"),
("Africa/Khartoum", "Khartoum"),
("Africa/Kigali", "Kigali"),
("Africa/Kinshasa", "Kinshasa"),
("Africa/Lagos", "Lagos"),
("Africa/Libreville", "Libreville"),
("Africa/Lome", "Lome"),
("Africa/Luanda", "Luanda"),
("Africa/Lubumbashi", "Lubumbashi"),
("Africa/Lusaka", "Lusaka"),
("Africa/Malabo", "Malabo"),
("Africa/Maputo", "Maputo"),
("Africa/Maseru", "Maseru"),
("Africa/Mbabane", "Mbabane"),
("Africa/Mogadishu", "Mogadishu"),
("Africa/Monrovia", "Monrovia"),
("Africa/Nairobi", "Nairobi"),
("Africa/Ndjamena", "Ndjamena"),
("Africa/Niamey", "Niamey"),
("Africa/Nouakchott", "Nouakchott"),
("Africa/Ouagadougou", "Ouagadougou"),
("Africa/Porto-Novo", "Porto-Novo"),
("Africa/Sao_Tome", "Sao_Tome"),
("Africa/Timbuktu", "Timbuktu"),
("Africa/Tripoli", "Tripoli"),
("Africa/Tunis", "Tunis"),
("Africa/Windhoek", "Windhoek"),
],
),
(
"America",
[
("America/Adak", "Adak"),
("America/Anchorage", "Anchorage"),
("America/Anguilla", "Anguilla"),
("America/Antigua", "Antigua"),
("America/Araguaina", "Araguaina"),
(
"America/Argentina/Buenos_Aires",
"Argentina/Buenos_Aires",
),
("America/Argentina/Catamarca", "Argentina/Catamarca"),
(
"America/Argentina/ComodRivadavia",
"Argentina/ComodRivadavia",
),
("America/Argentina/Cordoba", "Argentina/Cordoba"),
("America/Argentina/Jujuy", "Argentina/Jujuy"),
("America/Argentina/La_Rioja", "Argentina/La_Rioja"),
("America/Argentina/Mendoza", "Argentina/Mendoza"),
(
"America/Argentina/Rio_Gallegos",
"Argentina/Rio_Gallegos",
),
("America/Argentina/Salta", "Argentina/Salta"),
("America/Argentina/San_Juan", "Argentina/San_Juan"),
("America/Argentina/San_Luis", "Argentina/San_Luis"),
("America/Argentina/Tucuman", "Argentina/Tucuman"),
("America/Argentina/Ushuaia", "Argentina/Ushuaia"),
("America/Aruba", "Aruba"),
("America/Asuncion", "Asuncion"),
("America/Atikokan", "Atikokan"),
("America/Atka", "Atka"),
("America/Bahia", "Bahia"),
("America/Bahia_Banderas", "Bahia_Banderas"),
("America/Barbados", "Barbados"),
("America/Belem", "Belem"),
("America/Belize", "Belize"),
("America/Blanc-Sablon", "Blanc-Sablon"),
("America/Boa_Vista", "Boa_Vista"),
("America/Bogota", "Bogota"),
("America/Boise", "Boise"),
("America/Buenos_Aires", "Buenos_Aires"),
("America/Cambridge_Bay", "Cambridge_Bay"),
("America/Campo_Grande", "Campo_Grande"),
("America/Cancun", "Cancun"),
("America/Caracas", "Caracas"),
("America/Catamarca", "Catamarca"),
("America/Cayenne", "Cayenne"),
("America/Cayman", "Cayman"),
("America/Chicago", "Chicago"),
("America/Chihuahua", "Chihuahua"),
("America/Coral_Harbour", "Coral_Harbour"),
("America/Cordoba", "Cordoba"),
("America/Costa_Rica", "Costa_Rica"),
("America/Creston", "Creston"),
("America/Cuiaba", "Cuiaba"),
("America/Curacao", "Curacao"),
("America/Danmarkshavn", "Danmarkshavn"),
("America/Dawson", "Dawson"),
("America/Dawson_Creek", "Dawson_Creek"),
("America/Denver", "Denver"),
("America/Detroit", "Detroit"),
("America/Dominica", "Dominica"),
("America/Edmonton", "Edmonton"),
("America/Eirunepe", "Eirunepe"),
("America/El_Salvador", "El_Salvador"),
("America/Ensenada", "Ensenada"),
("America/Fort_Nelson", "Fort_Nelson"),
("America/Fort_Wayne", "Fort_Wayne"),
("America/Fortaleza", "Fortaleza"),
("America/Glace_Bay", "Glace_Bay"),
("America/Godthab", "Godthab"),
("America/Goose_Bay", "Goose_Bay"),
("America/Grand_Turk", "Grand_Turk"),
("America/Grenada", "Grenada"),
("America/Guadeloupe", "Guadeloupe"),
("America/Guatemala", "Guatemala"),
("America/Guayaquil", "Guayaquil"),
("America/Guyana", "Guyana"),
("America/Halifax", "Halifax"),
("America/Havana", "Havana"),
("America/Hermosillo", "Hermosillo"),
("America/Indiana/Indianapolis", "Indiana/Indianapolis"),
("America/Indiana/Knox", "Indiana/Knox"),
("America/Indiana/Marengo", "Indiana/Marengo"),
("America/Indiana/Petersburg", "Indiana/Petersburg"),
("America/Indiana/Tell_City", "Indiana/Tell_City"),
("America/Indiana/Vevay", "Indiana/Vevay"),
("America/Indiana/Vincennes", "Indiana/Vincennes"),
("America/Indiana/Winamac", "Indiana/Winamac"),
("America/Indianapolis", "Indianapolis"),
("America/Inuvik", "Inuvik"),
("America/Iqaluit", "Iqaluit"),
("America/Jamaica", "Jamaica"),
("America/Jujuy", "Jujuy"),
("America/Juneau", "Juneau"),
("America/Kentucky/Louisville", "Kentucky/Louisville"),
("America/Kentucky/Monticello", "Kentucky/Monticello"),
("America/Knox_IN", "Knox_IN"),
("America/Kralendijk", "Kralendijk"),
("America/La_Paz", "La_Paz"),
("America/Lima", "Lima"),
("America/Los_Angeles", "Los_Angeles"),
("America/Louisville", "Louisville"),
("America/Lower_Princes", "Lower_Princes"),
("America/Maceio", "Maceio"),
("America/Managua", "Managua"),
("America/Manaus", "Manaus"),
("America/Marigot", "Marigot"),
("America/Martinique", "Martinique"),
("America/Matamoros", "Matamoros"),
("America/Mazatlan", "Mazatlan"),
("America/Mendoza", "Mendoza"),
("America/Menominee", "Menominee"),
("America/Merida", "Merida"),
("America/Metlakatla", "Metlakatla"),
("America/Mexico_City", "Mexico_City"),
("America/Miquelon", "Miquelon"),
("America/Moncton", "Moncton"),
("America/Monterrey", "Monterrey"),
("America/Montevideo", "Montevideo"),
("America/Montreal", "Montreal"),
("America/Montserrat", "Montserrat"),
("America/Nassau", "Nassau"),
("America/New_York", "New_York"),
("America/Nipigon", "Nipigon"),
("America/Nome", "Nome"),
("America/Noronha", "Noronha"),
("America/North_Dakota/Beulah", "North_Dakota/Beulah"),
("America/North_Dakota/Center", "North_Dakota/Center"),
(
"America/North_Dakota/New_Salem",
"North_Dakota/New_Salem",
),
("America/Nuuk", "Nuuk"),
("America/Ojinaga", "Ojinaga"),
("America/Panama", "Panama"),
("America/Pangnirtung", "Pangnirtung"),
("America/Paramaribo", "Paramaribo"),
("America/Phoenix", "Phoenix"),
("America/Port-au-Prince", "Port-au-Prince"),
("America/Port_of_Spain", "Port_of_Spain"),
("America/Porto_Acre", "Porto_Acre"),
("America/Porto_Velho", "Porto_Velho"),
("America/Puerto_Rico", "Puerto_Rico"),
("America/Punta_Arenas", "Punta_Arenas"),
("America/Rainy_River", "Rainy_River"),
("America/Rankin_Inlet", "Rankin_Inlet"),
("America/Recife", "Recife"),
("America/Regina", "Regina"),
("America/Resolute", "Resolute"),
("America/Rio_Branco", "Rio_Branco"),
("America/Rosario", "Rosario"),
("America/Santa_Isabel", "Santa_Isabel"),
("America/Santarem", "Santarem"),
("America/Santiago", "Santiago"),
("America/Santo_Domingo", "Santo_Domingo"),
("America/Sao_Paulo", "Sao_Paulo"),
("America/Scoresbysund", "Scoresbysund"),
("America/Shiprock", "Shiprock"),
("America/Sitka", "Sitka"),
("America/St_Barthelemy", "St_Barthelemy"),
("America/St_Johns", "St_Johns"),
("America/St_Kitts", "St_Kitts"),
("America/St_Lucia", "St_Lucia"),
("America/St_Thomas", "St_Thomas"),
("America/St_Vincent", "St_Vincent"),
("America/Swift_Current", "Swift_Current"),
("America/Tegucigalpa", "Tegucigalpa"),
("America/Thule", "Thule"),
("America/Thunder_Bay", "Thunder_Bay"),
("America/Tijuana", "Tijuana"),
("America/Toronto", "Toronto"),
("America/Tortola", "Tortola"),
("America/Vancouver", "Vancouver"),
("America/Virgin", "Virgin"),
("America/Whitehorse", "Whitehorse"),
("America/Winnipeg", "Winnipeg"),
("America/Yakutat", "Yakutat"),
("America/Yellowknife", "Yellowknife"),
],
),
(
"Antarctica",
[
("Antarctica/Casey", "Casey"),
("Antarctica/Davis", "Davis"),
("Antarctica/DumontDUrville", "DumontDUrville"),
("Antarctica/Macquarie", "Macquarie"),
("Antarctica/Mawson", "Mawson"),
("Antarctica/McMurdo", "McMurdo"),
("Antarctica/Palmer", "Palmer"),
("Antarctica/Rothera", "Rothera"),
("Antarctica/South_Pole", "South_Pole"),
("Antarctica/Syowa", "Syowa"),
("Antarctica/Troll", "Troll"),
("Antarctica/Vostok", "Vostok"),
],
),
("Arctic", [("Arctic/Longyearbyen", "Longyearbyen")]),
(
"Asia",
[
("Asia/Aden", "Aden"),
("Asia/Almaty", "Almaty"),
("Asia/Amman", "Amman"),
("Asia/Anadyr", "Anadyr"),
("Asia/Aqtau", "Aqtau"),
("Asia/Aqtobe", "Aqtobe"),
("Asia/Ashgabat", "Ashgabat"),
("Asia/Ashkhabad", "Ashkhabad"),
("Asia/Atyrau", "Atyrau"),
("Asia/Baghdad", "Baghdad"),
("Asia/Bahrain", "Bahrain"),
("Asia/Baku", "Baku"),
("Asia/Bangkok", "Bangkok"),
("Asia/Barnaul", "Barnaul"),
("Asia/Beirut", "Beirut"),
("Asia/Bishkek", "Bishkek"),
("Asia/Brunei", "Brunei"),
("Asia/Calcutta", "Calcutta"),
("Asia/Chita", "Chita"),
("Asia/Choibalsan", "Choibalsan"),
("Asia/Chongqing", "Chongqing"),
("Asia/Chungking", "Chungking"),
("Asia/Colombo", "Colombo"),
("Asia/Dacca", "Dacca"),
("Asia/Damascus", "Damascus"),
("Asia/Dhaka", "Dhaka"),
("Asia/Dili", "Dili"),
("Asia/Dubai", "Dubai"),
("Asia/Dushanbe", "Dushanbe"),
("Asia/Famagusta", "Famagusta"),
("Asia/Gaza", "Gaza"),
("Asia/Harbin", "Harbin"),
("Asia/Hebron", "Hebron"),
("Asia/Ho_Chi_Minh", "Ho_Chi_Minh"),
("Asia/Hong_Kong", "Hong_Kong"),
("Asia/Hovd", "Hovd"),
("Asia/Irkutsk", "Irkutsk"),
("Asia/Istanbul", "Istanbul"),
("Asia/Jakarta", "Jakarta"),
("Asia/Jayapura", "Jayapura"),
("Asia/Jerusalem", "Jerusalem"),
("Asia/Kabul", "Kabul"),
("Asia/Kamchatka", "Kamchatka"),
("Asia/Karachi", "Karachi"),
("Asia/Kashgar", "Kashgar"),
("Asia/Kathmandu", "Kathmandu"),
("Asia/Katmandu", "Katmandu"),
("Asia/Khandyga", "Khandyga"),
("Asia/Kolkata", "Kolkata"),
("Asia/Krasnoyarsk", "Krasnoyarsk"),
("Asia/Kuala_Lumpur", "Kuala_Lumpur"),
("Asia/Kuching", "Kuching"),
("Asia/Kuwait", "Kuwait"),
("Asia/Macao", "Macao"),
("Asia/Macau", "Macau"),
("Asia/Magadan", "Magadan"),
("Asia/Makassar", "Makassar"),
("Asia/Manila", "Manila"),
("Asia/Muscat", "Muscat"),
("Asia/Nicosia", "Nicosia"),
("Asia/Novokuznetsk", "Novokuznetsk"),
("Asia/Novosibirsk", "Novosibirsk"),
("Asia/Omsk", "Omsk"),
("Asia/Oral", "Oral"),
("Asia/Phnom_Penh", "Phnom_Penh"),
("Asia/Pontianak", "Pontianak"),
("Asia/Pyongyang", "Pyongyang"),
("Asia/Qatar", "Qatar"),
("Asia/Qostanay", "Qostanay"),
("Asia/Qyzylorda", "Qyzylorda"),
("Asia/Rangoon", "Rangoon"),
("Asia/Riyadh", "Riyadh"),
("Asia/Saigon", "Saigon"),
("Asia/Sakhalin", "Sakhalin"),
("Asia/Samarkand", "Samarkand"),
("Asia/Seoul", "Seoul"),
("Asia/Shanghai", "Shanghai"),
("Asia/Singapore", "Singapore"),
("Asia/Srednekolymsk", "Srednekolymsk"),
("Asia/Taipei", "Taipei"),
("Asia/Tashkent", "Tashkent"),
("Asia/Tbilisi", "Tbilisi"),
("Asia/Tehran", "Tehran"),
("Asia/Tel_Aviv", "Tel_Aviv"),
("Asia/Thimbu", "Thimbu"),
("Asia/Thimphu", "Thimphu"),
("Asia/Tokyo", "Tokyo"),
("Asia/Tomsk", "Tomsk"),
("Asia/Ujung_Pandang", "Ujung_Pandang"),
("Asia/Ulaanbaatar", "Ulaanbaatar"),
("Asia/Ulan_Bator", "Ulan_Bator"),
("Asia/Urumqi", "Urumqi"),
("Asia/Ust-Nera", "Ust-Nera"),
("Asia/Vientiane", "Vientiane"),
("Asia/Vladivostok", "Vladivostok"),
("Asia/Yakutsk", "Yakutsk"),
("Asia/Yangon", "Yangon"),
("Asia/Yekaterinburg", "Yekaterinburg"),
("Asia/Yerevan", "Yerevan"),
],
),
(
"Atlantic",
[
("Atlantic/Azores", "Azores"),
("Atlantic/Bermuda", "Bermuda"),
("Atlantic/Canary", "Canary"),
("Atlantic/Cape_Verde", "Cape_Verde"),
("Atlantic/Faeroe", "Faeroe"),
("Atlantic/Faroe", "Faroe"),
("Atlantic/Jan_Mayen", "Jan_Mayen"),
("Atlantic/Madeira", "Madeira"),
("Atlantic/Reykjavik", "Reykjavik"),
("Atlantic/South_Georgia", "South_Georgia"),
("Atlantic/St_Helena", "St_Helena"),
("Atlantic/Stanley", "Stanley"),
],
),
(
"Australia",
[
("Australia/ACT", "ACT"),
("Australia/Adelaide", "Adelaide"),
("Australia/Brisbane", "Brisbane"),
("Australia/Broken_Hill", "Broken_Hill"),
("Australia/Canberra", "Canberra"),
("Australia/Currie", "Currie"),
("Australia/Darwin", "Darwin"),
("Australia/Eucla", "Eucla"),
("Australia/Hobart", "Hobart"),
("Australia/LHI", "LHI"),
("Australia/Lindeman", "Lindeman"),
("Australia/Lord_Howe", "Lord_Howe"),
("Australia/Melbourne", "Melbourne"),
("Australia/NSW", "NSW"),
("Australia/North", "North"),
("Australia/Perth", "Perth"),
("Australia/Queensland", "Queensland"),
("Australia/South", "South"),
("Australia/Sydney", "Sydney"),
("Australia/Tasmania", "Tasmania"),
("Australia/Victoria", "Victoria"),
("Australia/West", "West"),
("Australia/Yancowinna", "Yancowinna"),
],
),
(
"Brazil",
[
("Brazil/Acre", "Acre"),
("Brazil/DeNoronha", "DeNoronha"),
("Brazil/East", "East"),
("Brazil/West", "West"),
],
),
(
"Canada",
[
("Canada/Atlantic", "Atlantic"),
("Canada/Central", "Central"),
("Canada/Eastern", "Eastern"),
("Canada/Mountain", "Mountain"),
("Canada/Newfoundland", "Newfoundland"),
("Canada/Pacific", "Pacific"),
("Canada/Saskatchewan", "Saskatchewan"),
("Canada/Yukon", "Yukon"),
],
),
(
"Chile",
[
("Chile/Continental", "Continental"),
("Chile/EasterIsland", "EasterIsland"),
],
),
(
"Etc",
[
("Etc/Greenwich", "Greenwich"),
("Etc/UCT", "UCT"),
("Etc/UTC", "UTC"),
("Etc/Universal", "Universal"),
("Etc/Zulu", "Zulu"),
],
),
(
"Europe",
[
("Europe/Amsterdam", "Amsterdam"),
("Europe/Andorra", "Andorra"),
("Europe/Astrakhan", "Astrakhan"),
("Europe/Athens", "Athens"),
("Europe/Belfast", "Belfast"),
("Europe/Belgrade", "Belgrade"),
("Europe/Berlin", "Berlin"),
("Europe/Bratislava", "Bratislava"),
("Europe/Brussels", "Brussels"),
("Europe/Bucharest", "Bucharest"),
("Europe/Budapest", "Budapest"),
("Europe/Busingen", "Busingen"),
("Europe/Chisinau", "Chisinau"),
("Europe/Copenhagen", "Copenhagen"),
("Europe/Dublin", "Dublin"),
("Europe/Gibraltar", "Gibraltar"),
("Europe/Guernsey", "Guernsey"),
("Europe/Helsinki", "Helsinki"),
("Europe/Isle_of_Man", "Isle_of_Man"),
("Europe/Istanbul", "Istanbul"),
("Europe/Jersey", "Jersey"),
("Europe/Kaliningrad", "Kaliningrad"),
("Europe/Kiev", "Kiev"),
("Europe/Kirov", "Kirov"),
("Europe/Kyiv", "Kyiv"),
("Europe/Lisbon", "Lisbon"),
("Europe/Ljubljana", "Ljubljana"),
("Europe/London", "London"),
("Europe/Luxembourg", "Luxembourg"),
("Europe/Madrid", "Madrid"),
("Europe/Malta", "Malta"),
("Europe/Mariehamn", "Mariehamn"),
("Europe/Minsk", "Minsk"),
("Europe/Monaco", "Monaco"),
("Europe/Moscow", "Moscow"),
("Europe/Nicosia", "Nicosia"),
("Europe/Oslo", "Oslo"),
("Europe/Paris", "Paris"),
("Europe/Podgorica", "Podgorica"),
("Europe/Prague", "Prague"),
("Europe/Riga", "Riga"),
("Europe/Rome", "Rome"),
("Europe/Samara", "Samara"),
("Europe/San_Marino", "San_Marino"),
("Europe/Sarajevo", "Sarajevo"),
("Europe/Saratov", "Saratov"),
("Europe/Simferopol", "Simferopol"),
("Europe/Skopje", "Skopje"),
("Europe/Sofia", "Sofia"),
("Europe/Stockholm", "Stockholm"),
("Europe/Tallinn", "Tallinn"),
("Europe/Tirane", "Tirane"),
("Europe/Tiraspol", "Tiraspol"),
("Europe/Ulyanovsk", "Ulyanovsk"),
("Europe/Uzhgorod", "Uzhgorod"),
("Europe/Vaduz", "Vaduz"),
("Europe/Vatican", "Vatican"),
("Europe/Vienna", "Vienna"),
("Europe/Vilnius", "Vilnius"),
("Europe/Volgograd", "Volgograd"),
("Europe/Warsaw", "Warsaw"),
("Europe/Zagreb", "Zagreb"),
("Europe/Zaporozhye", "Zaporozhye"),
("Europe/Zurich", "Zurich"),
],
),
(
"Indian",
[
("Indian/Antananarivo", "Antananarivo"),
("Indian/Chagos", "Chagos"),
("Indian/Christmas", "Christmas"),
("Indian/Cocos", "Cocos"),
("Indian/Comoro", "Comoro"),
("Indian/Kerguelen", "Kerguelen"),
("Indian/Mahe", "Mahe"),
("Indian/Maldives", "Maldives"),
("Indian/Mauritius", "Mauritius"),
("Indian/Mayotte", "Mayotte"),
("Indian/Reunion", "Reunion"),
],
),
(
"Mexico",
[
("Mexico/BajaNorte", "BajaNorte"),
("Mexico/BajaSur", "BajaSur"),
("Mexico/General", "General"),
],
),
(
"Other",
[
("CET", "CET"),
("CST6CDT", "CST6CDT"),
("Cuba", "Cuba"),
("EET", "EET"),
("EST", "EST"),
("EST5EDT", "EST5EDT"),
("Egypt", "Egypt"),
("Eire", "Eire"),
("GB", "GB"),
("GB-Eire", "GB-Eire"),
("Greenwich", "Greenwich"),
("HST", "HST"),
("Hongkong", "Hongkong"),
("Iceland", "Iceland"),
("Iran", "Iran"),
("Israel", "Israel"),
("Jamaica", "Jamaica"),
("Japan", "Japan"),
("Kwajalein", "Kwajalein"),
("Libya", "Libya"),
("MET", "MET"),
("MST", "MST"),
("MST7MDT", "MST7MDT"),
("NZ", "NZ"),
("NZ-CHAT", "NZ-CHAT"),
("Navajo", "Navajo"),
("PRC", "PRC"),
("PST8PDT", "PST8PDT"),
("Poland", "Poland"),
("Portugal", "Portugal"),
("ROC", "ROC"),
("ROK", "ROK"),
("Singapore", "Singapore"),
("Turkey", "Turkey"),
("UCT", "UCT"),
("UTC", "UTC"),
("Universal", "Universal"),
("W-SU", "W-SU"),
("WET", "WET"),
("Zulu", "Zulu"),
],
),
(
"Pacific",
[
("Pacific/Apia", "Apia"),
("Pacific/Auckland", "Auckland"),
("Pacific/Bougainville", "Bougainville"),
("Pacific/Chatham", "Chatham"),
("Pacific/Chuuk", "Chuuk"),
("Pacific/Easter", "Easter"),
("Pacific/Efate", "Efate"),
("Pacific/Enderbury", "Enderbury"),
("Pacific/Fakaofo", "Fakaofo"),
("Pacific/Fiji", "Fiji"),
("Pacific/Funafuti", "Funafuti"),
("Pacific/Galapagos", "Galapagos"),
("Pacific/Gambier", "Gambier"),
("Pacific/Guadalcanal", "Guadalcanal"),
("Pacific/Guam", "Guam"),
("Pacific/Honolulu", "Honolulu"),
("Pacific/Johnston", "Johnston"),
("Pacific/Kanton", "Kanton"),
("Pacific/Kiritimati", "Kiritimati"),
("Pacific/Kosrae", "Kosrae"),
("Pacific/Kwajalein", "Kwajalein"),
("Pacific/Majuro", "Majuro"),
("Pacific/Marquesas", "Marquesas"),
("Pacific/Midway", "Midway"),
("Pacific/Nauru", "Nauru"),
("Pacific/Niue", "Niue"),
("Pacific/Norfolk", "Norfolk"),
("Pacific/Noumea", "Noumea"),
("Pacific/Pago_Pago", "Pago_Pago"),
("Pacific/Palau", "Palau"),
("Pacific/Pitcairn", "Pitcairn"),
("Pacific/Pohnpei", "Pohnpei"),
("Pacific/Ponape", "Ponape"),
("Pacific/Port_Moresby", "Port_Moresby"),
("Pacific/Rarotonga", "Rarotonga"),
("Pacific/Saipan", "Saipan"),
("Pacific/Samoa", "Samoa"),
("Pacific/Tahiti", "Tahiti"),
("Pacific/Tarawa", "Tarawa"),
("Pacific/Tongatapu", "Tongatapu"),
("Pacific/Truk", "Truk"),
("Pacific/Wake", "Wake"),
("Pacific/Wallis", "Wallis"),
("Pacific/Yap", "Yap"),
],
),
(
"US",
[
("US/Alaska", "Alaska"),
("US/Aleutian", "Aleutian"),
("US/Arizona", "Arizona"),
("US/Central", "Central"),
("US/East-Indiana", "East-Indiana"),
("US/Eastern", "Eastern"),
("US/Hawaii", "Hawaii"),
("US/Indiana-Starke", "Indiana-Starke"),
("US/Michigan", "Michigan"),
("US/Mountain", "Mountain"),
("US/Pacific", "Pacific"),
("US/Samoa", "Samoa"),
],
),
],
default="Asia/Ho_Chi_Minh",
max_length=50,
verbose_name="location",
),
),
]

View file

@ -28,7 +28,6 @@ from judge.models.problem import (
ProblemTranslation, ProblemTranslation,
ProblemType, ProblemType,
Solution, Solution,
TranslatedProblemForeignKeyQuerySet,
TranslatedProblemQuerySet, TranslatedProblemQuerySet,
ProblemPointsVote, ProblemPointsVote,
) )

View file

@ -6,8 +6,7 @@ from django.contrib.contenttypes.fields import GenericRelation
from django.core.cache import cache from django.core.cache import cache
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
from django.db import models from django.db import models
from django.db.models import CASCADE, F, Q, QuerySet, SET_NULL from django.db.models import CASCADE, F, FilteredRelation, Q, SET_NULL
from django.db.models.expressions import RawSQL
from django.db.models.functions import Coalesce from django.db.models.functions import Coalesce
from django.urls import reverse from django.urls import reverse
from django.utils.functional import cached_property from django.utils.functional import cached_property
@ -17,7 +16,6 @@ from judge.fulltext import SearchQuerySet
from judge.models.profile import Organization, Profile from judge.models.profile import Organization, Profile
from judge.models.runtime import Language from judge.models.runtime import Language
from judge.user_translations import gettext as user_gettext from judge.user_translations import gettext as user_gettext
from judge.utils.raw_sql import RawSQLColumn, unique_together_left_join
from judge.models.problem_data import ( from judge.models.problem_data import (
problem_data_storage, problem_data_storage,
problem_directory_file_helper, problem_directory_file_helper,
@ -31,7 +29,6 @@ __all__ = [
"License", "License",
"Solution", "Solution",
"TranslatedProblemQuerySet", "TranslatedProblemQuerySet",
"TranslatedProblemForeignKeyQuerySet",
] ]
@ -112,43 +109,18 @@ class TranslatedProblemQuerySet(SearchQuerySet):
) )
def add_i18n_name(self, language): def add_i18n_name(self, language):
queryset = self._clone() return self.annotate(
alias = unique_together_left_join( i18n_translation=FilteredRelation(
queryset, ProblemTranslation, "problem", "language", language "translations",
) condition=Q(translations__language=language),
return queryset.annotate( )
).annotate(
i18n_name=Coalesce( i18n_name=Coalesce(
RawSQL("%s.name" % alias, ()), F("i18n_translation__name"), F("name"), output_field=models.CharField()
F("name"),
output_field=models.CharField(),
) )
) )
class TranslatedProblemForeignKeyQuerySet(QuerySet):
def add_problem_i18n_name(self, key, language, name_field=None):
queryset = (
self._clone() if name_field is None else self.annotate(_name=F(name_field))
)
alias = unique_together_left_join(
queryset,
ProblemTranslation,
"problem",
"language",
language,
parent_model=Problem,
)
# You must specify name_field if Problem is not yet joined into the QuerySet.
kwargs = {
key: Coalesce(
RawSQL("%s.name" % alias, ()),
F(name_field) if name_field else RawSQLColumn(Problem, "name"),
output_field=models.CharField(),
)
}
return queryset.annotate(**kwargs)
class Problem(models.Model): class Problem(models.Model):
code = models.CharField( code = models.CharField(
max_length=20, max_length=20,

View file

@ -9,7 +9,7 @@ from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from judge.judgeapi import abort_submission, judge_submission from judge.judgeapi import abort_submission, judge_submission
from judge.models.problem import Problem, TranslatedProblemForeignKeyQuerySet from judge.models.problem import Problem
from judge.models.profile import Profile from judge.models.profile import Profile
from judge.models.runtime import Language from judge.models.runtime import Language
from judge.utils.unicode import utf8bytes from judge.utils.unicode import utf8bytes
@ -120,8 +120,6 @@ class Submission(models.Model):
related_name="+", related_name="+",
) )
objects = TranslatedProblemForeignKeyQuerySet.as_manager()
@classmethod @classmethod
def result_class_from_code(cls, result, case_points, case_total): def result_class_from_code(cls, result, case_points, case_total):
if result == "AC": if result == "AC":

View file

@ -1,5 +1,4 @@
from django.conf import settings from django.conf import settings
from django.utils import six
from django.utils.safestring import SafeData, mark_safe from django.utils.safestring import SafeData, mark_safe
if settings.USE_I18N: if settings.USE_I18N:
@ -27,7 +26,7 @@ if settings.USE_I18N:
else: else:
translation_object = translation(get_language()) translation_object = translation(get_language())
result = getattr(translation_object, translation_function)(eol_message) result = getattr(translation_object, translation_function)(eol_message)
if not isinstance(result, six.text_type): if not isinstance(result, str):
result = result.decode("utf-8") result = result.decode("utf-8")
if isinstance(message, SafeData): if isinstance(message, SafeData):

View file

@ -40,7 +40,6 @@ import requests
from django.conf import settings from django.conf import settings
from django.contrib.auth.password_validation import CommonPasswordValidator from django.contrib.auth.password_validation import CommonPasswordValidator
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.six import string_types
from django.utils.translation import gettext as _, ungettext from django.utils.translation import gettext as _, ungettext
from judge.utils.unicode import utf8bytes from judge.utils.unicode import utf8bytes
@ -83,7 +82,7 @@ def pwned_password(password):
""" """
Checks a password against the Pwned Passwords database. Checks a password against the Pwned Passwords database.
""" """
if not isinstance(password, string_types): if not isinstance(password, str):
raise TypeError("Password values to check must be strings.") raise TypeError("Password values to check must be strings.")
password_hash = hashlib.sha1(utf8bytes(password)).hexdigest().upper() password_hash = hashlib.sha1(utf8bytes(password)).hexdigest().upper()
prefix, suffix = password_hash[:5], password_hash[5:] prefix, suffix = password_hash[:5], password_hash[5:]
@ -107,7 +106,7 @@ class PwnedPasswordsValidator(object):
error_message = error_message or self.DEFAULT_PWNED_MESSAGE error_message = error_message or self.DEFAULT_PWNED_MESSAGE
# If there is no plural, use the same message for both forms. # If there is no plural, use the same message for both forms.
if isinstance(error_message, string_types): if isinstance(error_message, str):
singular, plural = error_message, error_message singular, plural = error_message, error_message
else: else:
singular, plural = error_message singular, plural = error_message

View file

@ -1,40 +1,10 @@
from copy import copy
from django.db import connections from django.db import connections
from django.db.models import Field
from django.db.models.expressions import RawSQL
from django.db.models.sql.constants import INNER, LOUTER from django.db.models.sql.constants import INNER, LOUTER
from django.db.models.sql.datastructures import Join from django.db.models.sql.datastructures import Join
from django.utils import six
from judge.utils.cachedict import CacheDict from judge.utils.cachedict import CacheDict
def unique_together_left_join(
queryset, model, link_field_name, filter_field_name, filter_value, parent_model=None
):
link_field = copy(model._meta.get_field(link_field_name).remote_field)
filter_field = model._meta.get_field(filter_field_name)
def restrictions(where_class, alias, related_alias):
cond = where_class()
cond.add(
filter_field.get_lookup("exact")(filter_field.get_col(alias), filter_value),
"AND",
)
return cond
link_field.get_extra_restriction = restrictions
if parent_model is not None:
parent_alias = parent_model._meta.db_table
else:
parent_alias = queryset.query.get_initial_alias()
return queryset.query.join(
Join(model._meta.db_table, parent_alias, None, LOUTER, link_field, True)
)
class RawSQLJoin(Join): class RawSQLJoin(Join):
def __init__( def __init__(
self, self,
@ -65,8 +35,9 @@ class RawSQLJoin(Join):
class FakeJoinField: class FakeJoinField:
def __init__(self, joining_columns): def __init__(self, joining_columns, related_model):
self.joining_columns = joining_columns self.joining_columns = joining_columns
self.related_model = related_model
def get_joining_columns(self): def get_joining_columns(self):
return self.joining_columns return self.joining_columns
@ -76,35 +47,36 @@ class FakeJoinField:
def join_sql_subquery( def join_sql_subquery(
queryset, subquery, params, join_fields, alias, join_type=INNER, parent_model=None queryset,
subquery,
params,
join_fields,
alias,
related_model,
join_type=INNER,
parent_model=None,
): ):
if parent_model is not None: if parent_model is not None:
parent_alias = parent_model._meta.db_table parent_alias = parent_model._meta.db_table
else: else:
parent_alias = queryset.query.get_initial_alias() parent_alias = queryset.query.get_initial_alias()
queryset.query.external_aliases.add(alias) if isinstance(queryset.query.external_aliases, dict): # Django 3.x
queryset.query.external_aliases[alias] = True
else:
queryset.query.external_aliases.add(alias)
join = RawSQLJoin( join = RawSQLJoin(
subquery, subquery,
params, params,
parent_alias, parent_alias,
alias, alias,
join_type, join_type,
FakeJoinField(join_fields), FakeJoinField(join_fields, related_model),
join_type == LOUTER, join_type == LOUTER,
) )
queryset.query.join(join) queryset.query.join(join)
join.table_alias = alias join.table_alias = alias
def RawSQLColumn(model, field=None):
if isinstance(model, Field):
field = model
model = field.model
if isinstance(field, six.string_types):
field = model._meta.get_field(field)
return RawSQL("%s.%s" % (model._meta.db_table, field.get_attname_column()[1]), ())
def make_straight_join_query(QueryType): def make_straight_join_query(QueryType):
class Query(QueryType): class Query(QueryType):
def join(self, join, *args, **kwargs): def join(self, join, *args, **kwargs):

View file

@ -1,17 +1,37 @@
from django.utils import six from typing import AnyStr, Optional, overload
@overload
def utf8bytes(maybe_text: AnyStr) -> bytes:
pass
@overload
def utf8bytes(maybe_text: None) -> None:
pass
def utf8bytes(maybe_text): def utf8bytes(maybe_text):
if maybe_text is None: if maybe_text is None:
return return None
if isinstance(maybe_text, six.binary_type): if isinstance(maybe_text, bytes):
return maybe_text return maybe_text
return maybe_text.encode("utf-8") return maybe_text.encode("utf-8")
def utf8text(maybe_bytes, errors="strict"): @overload
def utf8text(maybe_bytes: AnyStr, errors="strict") -> str:
pass
@overload
def utf8text(maybe_bytes: None, errors="strict") -> None:
pass
def utf8text(maybe_bytes, errors="strict") -> Optional[str]:
if maybe_bytes is None: if maybe_bytes is None:
return return None
if isinstance(maybe_bytes, six.text_type): if isinstance(maybe_bytes, str):
return maybe_bytes return maybe_bytes
return maybe_bytes.decode("utf-8", errors) return maybe_bytes.decode("utf-8", errors)

View file

@ -11,7 +11,19 @@ from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.db import transaction from django.db import transaction
from django.db.models import Count, F, Prefetch, Q, Sum, Case, When, IntegerField from django.db.models import (
BooleanField,
Case,
CharField,
Count,
F,
FilteredRelation,
Prefetch,
Q,
When,
IntegerField,
)
from django.db.models.functions import Coalesce
from django.db.utils import ProgrammingError from django.db.utils import ProgrammingError
from django.http import ( from django.http import (
Http404, Http404,
@ -49,7 +61,6 @@ from judge.models import (
Solution, Solution,
Submission, Submission,
SubmissionSource, SubmissionSource,
TranslatedProblemForeignKeyQuerySet,
Organization, Organization,
VolunteerProblemVote, VolunteerProblemVote,
Profile, Profile,
@ -498,11 +509,23 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
.defer("problem__description") .defer("problem__description")
.order_by("problem__code") .order_by("problem__code")
.annotate(user_count=Count("submission__participation", distinct=True)) .annotate(user_count=Count("submission__participation", distinct=True))
.annotate(
i18n_translation=FilteredRelation(
"problem__translations",
condition=Q(
problem__translations__language=self.request.LANGUAGE_CODE
),
)
)
.annotate(
i18n_name=Coalesce(
F("i18n_translation__name"),
F("problem__name"),
output_field=CharField(),
)
)
.order_by("order") .order_by("order")
) )
queryset = TranslatedProblemForeignKeyQuerySet.add_problem_i18n_name(
queryset, "i18n_name", self.request.LANGUAGE_CODE, "problem__name"
)
return [ return [
{ {
"id": p["problem_id"], "id": p["problem_id"],
@ -593,12 +616,14 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
if self.point_end is not None: if self.point_end is not None:
queryset = queryset.filter(points__lte=self.point_end) queryset = queryset.filter(points__lte=self.point_end)
queryset = queryset.annotate( queryset = queryset.annotate(
has_public_editorial=Sum( has_public_editorial=Case(
Case( When(
When(solution__is_public=True, then=1), solution__is_public=True,
default=0, solution__publish_on__lte=timezone.now(),
output_field=IntegerField(), then=True,
) ),
default=False,
output_field=BooleanField(),
) )
) )

View file

@ -27,7 +27,7 @@ class RankedSubmissions(ProblemSubmissions):
constraint = "" constraint = ""
queryset = ( queryset = (
super(RankedSubmissions, self) super(RankedSubmissions, self)
.get_queryset() ._get_queryset()
.filter(user__is_unlisted=False) .filter(user__is_unlisted=False)
) )
join_sql_subquery( join_sql_subquery(
@ -57,6 +57,7 @@ class RankedSubmissions(ProblemSubmissions):
else [self.problem.id] * 3, else [self.problem.id] * 3,
alias="best_subs", alias="best_subs",
join_fields=[("id", "id")], join_fields=[("id", "id")],
related_model=Submission,
) )
if self.in_contest: if self.in_contest:
@ -75,7 +76,9 @@ class RankedSubmissions(ProblemSubmissions):
) )
def _get_result_data(self): def _get_result_data(self):
return get_result_data(super(RankedSubmissions, self).get_queryset().order_by()) return get_result_data(
super(RankedSubmissions, self)._get_queryset().order_by()
)
class ContestRankedSubmission(ForceContestMixin, RankedSubmissions): class ContestRankedSubmission(ForceContestMixin, RankedSubmissions):

View file

@ -2,7 +2,6 @@ from collections import defaultdict
from functools import partial from functools import partial
from django.shortcuts import render from django.shortcuts import render
from django.utils import six
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from packaging import version from packaging import version
@ -74,12 +73,12 @@ def version_matrix(request):
): ):
matrix[runtime.judge_id][runtime.language_id].append(runtime) matrix[runtime.judge_id][runtime.language_id].append(runtime)
for judge, data in six.iteritems(matrix): for judge, data in matrix.items():
name_tuple = judges[judge].rpartition(".") name_tuple = judges[judge].rpartition(".")
groups[name_tuple[0] or name_tuple[-1]].append((judges[judge], data)) groups[name_tuple[0] or name_tuple[-1]].append((judges[judge], data))
matrix = {} matrix = {}
for group, data in six.iteritems(groups): for group, data in groups.items():
if len(data) == 1: if len(data) == 1:
judge, data = data[0] judge, data = data[0]
matrix[judge] = data matrix[judge] = data
@ -102,14 +101,14 @@ def version_matrix(request):
if ds[i] != rep: if ds[i] != rep:
matrix[j] = x matrix[j] = x
for data in six.itervalues(matrix): for data in matrix.values():
for language, versions in six.iteritems(data): for language, versions in data.items():
versions.versions = [version.parse(runtime.version) for runtime in versions] versions.versions = [version.parse(runtime.version) for runtime in versions]
if versions.versions > latest[language]: if versions.versions > latest[language]:
latest[language] = versions.versions latest[language] = versions.versions
for data in six.itervalues(matrix): for data in matrix.values():
for language, versions in six.iteritems(data): for language, versions in data.items():
versions.is_latest = versions.versions == latest[language] versions.is_latest = versions.versions == latest[language]
languages = sorted(languages, key=lambda lang: version.parse(lang.name)) languages = sorted(languages, key=lambda lang: version.parse(lang.name))

View file

@ -391,6 +391,7 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
params=[], params=[],
join_fields=[("problem_id", "id")], join_fields=[("problem_id", "id")],
alias="visible_problems", alias="visible_problems",
related_model=Problem,
) )
return queryset return queryset

View file

@ -232,7 +232,10 @@ class HeavySelect2Mixin(Select2Mixin):
chosen.queryset = chosen.queryset.filter( chosen.queryset = chosen.queryset.filter(
pk__in=[int(i) for i in result if isinstance(i, int) or i.isdigit()] pk__in=[int(i) for i in result if isinstance(i, int) or i.isdigit()]
) )
self.choices = set(chosen) self.choices = {
(value if isinstance(value, str) else value.value, label)
for value, label in chosen
}
return result return result

View file

@ -1,12 +1,12 @@
Django>=2.2,<3 Django>=3.2,<4
django_compressor django_compressor>=3
django-mptt django-mptt>=0.13
django-pagedown django-pagedown
django-registration-redux django-registration-redux>=2.10
django-reversion django-reversion>=3.0.5,<4
django-reversion-compare django-reversion-compare
django-social-share django-social-share
django-sortedm2m @ git+https://github.com/DMOJ/django-sortedm2m.git django-sortedm2m>=3.1.0
django-impersonate django-impersonate
dmoj-wpadmin @ git+https://github.com/LQDJudge/dmoj-wpadmin.git dmoj-wpadmin @ git+https://github.com/LQDJudge/dmoj-wpadmin.git
lxml lxml
@ -18,13 +18,13 @@ pika
ua-parser ua-parser
pyyaml pyyaml
jinja2 jinja2
django_jinja django_jinja>=2.5.0
llist llist
requests requests
django-fernet-fields django-fernet-fields
pyotp pyotp
qrcode[pil] qrcode[pil]
jsonfield jsonfield @ git+https://github.com/DMOJ/jsonfield.git
pymoss pymoss
packaging packaging
celery celery