From 512bc92116f32ac74cc908d5c99e4eaecca0c4d8 Mon Sep 17 00:00:00 2001 From: Zhao-Linux Date: Tue, 18 Oct 2022 03:48:07 +0700 Subject: [PATCH 1/2] Add recent view organization --- judge/migrations/0134_auto_20221018_0124.py | 27 ++++++++++++ judge/models/profile.py | 48 +++++++++++++++++++++ judge/views/blog.py | 3 ++ judge/views/organization.py | 3 +- templates/blog/list.html | 1 + templates/recent-organization.html | 20 +++++++++ 6 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 judge/migrations/0134_auto_20221018_0124.py create mode 100644 templates/recent-organization.html diff --git a/judge/migrations/0134_auto_20221018_0124.py b/judge/migrations/0134_auto_20221018_0124.py new file mode 100644 index 0000000..0a9fd56 --- /dev/null +++ b/judge/migrations/0134_auto_20221018_0124.py @@ -0,0 +1,27 @@ +# Generated by Django 2.2.28 on 2022-10-17 18:24 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('judge', '0133_auto_20221013_0850'), + ] + + 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'), + ), + migrations.CreateModel( + name='OrganizationProfile', + fields=[ + ('last_visit', models.AutoField(primary_key=True, serialize=False, verbose_name='last visit')), + ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='last_vist', to='judge.Organization', verbose_name='organization')), + ('users', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='last_visit', to='judge.Profile', verbose_name='user')), + ], + ), + ] diff --git a/judge/models/profile.py b/judge/models/profile.py index d9c6691..30f8d7e 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -9,6 +9,7 @@ from django.urls import reverse from django.utils.functional import cached_property from django.utils.timezone import now from django.utils.translation import gettext_lazy as _ +from requests import delete from fernet_fields import EncryptedCharField from sortedm2m.fields import SortedManyToManyField @@ -422,3 +423,50 @@ class Friend(models.Model): def __str__(self): return str(self.current_user) + + +class OrganizationProfile(models.Model): + users = models.ForeignKey( + Profile, + verbose_name=_("user"), + related_name="last_visit", + on_delete=models.CASCADE, + db_index=True, + ) + organization = models.ForeignKey( + Organization, + verbose_name=_("organization"), + related_name="last_vist", + on_delete=models.CASCADE, + db_index=True, + ) + last_visit = models.AutoField( + verbose_name=_("last visit"), + primary_key=True, + ) + + @classmethod + def is_organization(self, users, organization): + return ( + self.objects.filter(users=users) + .filter(organization=organization) + .exists() + ) + + @classmethod + def remove_organization(self, users, organization): + organizationprofile = self.objects.filter(users=users).filter( + organization=organization + ) + organizationprofile.delete() + + @classmethod + def add_organization(self, users, organization): + if self.is_organization(users, organization): + self.remove_organization(users, organization) + new_organization = OrganizationProfile(users=users, organization=organization) + new_organization.save() + + @classmethod + def get_organization(self, users): + return self.objects.filter(users=users).order_by("-last_visit")[:5] diff --git a/judge/views/blog.py b/judge/views/blog.py index 061fee0..5294fc0 100644 --- a/judge/views/blog.py +++ b/judge/views/blog.py @@ -19,6 +19,7 @@ from judge.models import ( Submission, Ticket, ) +from judge.models.profile import Organization, OrganizationProfile from judge.utils.cachedict import CacheDict from judge.utils.diggpaginator import DiggPaginator from judge.utils.problems import user_completed_ids @@ -74,10 +75,12 @@ class FeedView(ListView): .filter(is_visible=True) .order_by("start_time") ) + context["current_contests"] = visible_contests.filter( start_time__lte=now, end_time__gt=now ) context["future_contests"] = visible_contests.filter(start_time__gt=now) + context["recent_organizations"] = OrganizationProfile.get_organization(self.request.profile) context["top_rated"] = Profile.objects.filter(is_unlisted=False).order_by( "-rating" )[:10] diff --git a/judge/views/organization.py b/judge/views/organization.py index 5f8a0b2..73896c0 100644 --- a/judge/views/organization.py +++ b/judge/views/organization.py @@ -35,6 +35,7 @@ from django.views.generic.detail import ( SingleObjectTemplateResponseMixin, ) from django.core.paginator import Paginator +from judge.models.profile import OrganizationProfile from reversion import revisions from judge.forms import ( @@ -126,6 +127,7 @@ class OrganizationMixin(OrganizationBase): context["logo_override_image"] = self.organization.logo_override_image if "organizations" in context: context.pop("organizations") + OrganizationProfile.add_organization(self.request.profile, self.organization) return context def dispatch(self, request, *args, **kwargs): @@ -261,7 +263,6 @@ class OrganizationList(TitleMixin, ListView, OrganizationBase): class OrganizationHome(OrganizationDetailView): template_name = "organization/home.html" - def get_posts(self): posts = ( BlogPost.objects.filter( diff --git a/templates/blog/list.html b/templates/blog/list.html index 976e064..c4be4a9 100644 --- a/templates/blog/list.html +++ b/templates/blog/list.html @@ -123,6 +123,7 @@ {% endif %} {% include 'contests-countdown.html' %} + {% include 'recent-organization.html' %} {% include 'top-users.html' %} {% endblock %} \ No newline at end of file diff --git a/templates/recent-organization.html b/templates/recent-organization.html new file mode 100644 index 0000000..ff9bcbe --- /dev/null +++ b/templates/recent-organization.html @@ -0,0 +1,20 @@ +{% if recent_organizations %} + +{% endif %} \ No newline at end of file From 87eb082a188c2da82107f9b5ac5b976df31ed7aa Mon Sep 17 00:00:00 2001 From: Zhao-Linux Date: Tue, 18 Oct 2022 05:08:12 +0700 Subject: [PATCH 2/2] Fix recently visited organization --- judge/models/__init__.py | 2 +- judge/models/profile.py | 24 ++----- judge/views/blog.py | 2 +- judge/views/organization.py | 2 +- locale/vi/LC_MESSAGES/django.po | 107 ++++++++++++++++------------- templates/recent-organization.html | 52 +++++++++----- 6 files changed, 104 insertions(+), 85 deletions(-) diff --git a/judge/models/__init__.py b/judge/models/__init__.py index 166ec3b..35f600c 100644 --- a/judge/models/__init__.py +++ b/judge/models/__init__.py @@ -39,7 +39,7 @@ from judge.models.problem_data import ( problem_data_storage, problem_directory_file, ) -from judge.models.profile import Organization, OrganizationRequest, Profile, Friend +from judge.models.profile import Organization, OrganizationRequest, Profile, Friend, OrganizationProfile from judge.models.runtime import Judge, Language, RuntimeVersion from judge.models.submission import ( SUBMISSION_RESULT, diff --git a/judge/models/profile.py b/judge/models/profile.py index 30f8d7e..8e7ceb5 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -9,7 +9,6 @@ from django.urls import reverse from django.utils.functional import cached_property from django.utils.timezone import now from django.utils.translation import gettext_lazy as _ -from requests import delete from fernet_fields import EncryptedCharField from sortedm2m.fields import SortedManyToManyField @@ -438,35 +437,24 @@ class OrganizationProfile(models.Model): verbose_name=_("organization"), related_name="last_vist", on_delete=models.CASCADE, - db_index=True, ) last_visit = models.AutoField( - verbose_name=_("last visit"), + verbose_name=_("last visit"), primary_key=True, ) - @classmethod - def is_organization(self, users, organization): - return ( - self.objects.filter(users=users) - .filter(organization=organization) - .exists() - ) - @classmethod def remove_organization(self, users, organization): - organizationprofile = self.objects.filter(users=users).filter( - organization=organization - ) - organizationprofile.delete() + organizationprofile = self.objects.filter(users=users, organization=organization) + if organizationprofile.exists(): + organizationprofile.delete() @classmethod def add_organization(self, users, organization): - if self.is_organization(users, organization): - self.remove_organization(users, organization) + self.remove_organization(users, organization) new_organization = OrganizationProfile(users=users, organization=organization) new_organization.save() @classmethod - def get_organization(self, users): + def get_most_recent_organizations(self, users): return self.objects.filter(users=users).order_by("-last_visit")[:5] diff --git a/judge/views/blog.py b/judge/views/blog.py index 5294fc0..a7f1b1b 100644 --- a/judge/views/blog.py +++ b/judge/views/blog.py @@ -80,7 +80,7 @@ class FeedView(ListView): start_time__lte=now, end_time__gt=now ) context["future_contests"] = visible_contests.filter(start_time__gt=now) - context["recent_organizations"] = OrganizationProfile.get_organization(self.request.profile) + context["recent_organizations"] = OrganizationProfile.get_most_recent_organizations(self.request.profile) context["top_rated"] = Profile.objects.filter(is_unlisted=False).order_by( "-rating" )[:10] diff --git a/judge/views/organization.py b/judge/views/organization.py index 73896c0..ddda97b 100644 --- a/judge/views/organization.py +++ b/judge/views/organization.py @@ -35,7 +35,6 @@ from django.views.generic.detail import ( SingleObjectTemplateResponseMixin, ) from django.core.paginator import Paginator -from judge.models.profile import OrganizationProfile from reversion import revisions from judge.forms import ( @@ -58,6 +57,7 @@ from judge.models import ( Contest, Notification, ContestProblem, + OrganizationProfile, ) from judge import event_poster as event from judge.utils.ranker import ranker diff --git a/locale/vi/LC_MESSAGES/django.po b/locale/vi/LC_MESSAGES/django.po index ac4da17..22c17e3 100644 --- a/locale/vi/LC_MESSAGES/django.po +++ b/locale/vi/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: lqdoj2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-16 00:26+0700\n" +"POT-Creation-Date: 2022-10-18 05:05+0700\n" "PO-Revision-Date: 2021-07-20 03:44\n" "Last-Translator: Icyene\n" "Language-Team: Vietnamese\n" @@ -21,6 +21,7 @@ msgstr "" #: chat_box/models.py:31 chat_box/models.py:52 chat_box/models.py:63 #: judge/admin/interface.py:150 judge/models/contest.py:622 #: judge/models/contest.py:815 judge/models/profile.py:354 +#: judge/models/profile.py:430 msgid "user" msgstr "người dùng" @@ -474,7 +475,7 @@ msgstr "Đăng ký để nhận thông báo về các kỳ thi" msgid "Enable experimental features" msgstr "Sử dụng các tính năng thử nghiệm" -#: judge/forms.py:108 judge/views/organization.py:513 +#: judge/forms.py:108 judge/views/organization.py:514 #: judge/views/register.py:68 #, python-brace-format msgid "You may not be part of more than {count} public groups." @@ -1765,7 +1766,7 @@ msgid "" msgstr "Ảnh này sẽ thay thế logo mặc định khi ở trong tổ chức." #: judge/models/profile.py:125 judge/models/profile.py:154 -#: judge/models/profile.py:360 +#: judge/models/profile.py:360 judge/models/profile.py:437 msgid "organization" msgstr "" @@ -1899,6 +1900,12 @@ msgstr "đơn đăng ký tham gia" msgid "organization join requests" msgstr "đơn đăng ký tham gia" +#: judge/models/profile.py:442 +#, fuzzy +#| msgid "last seen" +msgid "last visit" +msgstr "xem lần cuối" + #: judge/models/runtime.py:21 msgid "short identifier" msgstr "tên ngắn" @@ -2448,16 +2455,16 @@ msgstr "Giới thiệu" msgid "Custom Checker Sample" msgstr "Hướng dẫn viết trình chấm" -#: judge/views/blog.py:111 +#: judge/views/blog.py:114 #, python-format msgid "Page %d of Posts" msgstr "Trang %d" -#: judge/views/blog.py:166 +#: judge/views/blog.py:169 msgid "Ticket feed" msgstr "Báo cáo" -#: judge/views/blog.py:184 +#: judge/views/blog.py:187 msgid "Comment feed" msgstr "Bình luận" @@ -2473,8 +2480,8 @@ msgstr "Bạn phải giải ít nhất 1 bài trước khi được vote." msgid "You already voted." msgstr "Bạn đã vote." -#: judge/views/comment.py:155 judge/views/organization.py:813 -#: judge/views/organization.py:959 judge/views/organization.py:1124 +#: judge/views/comment.py:155 judge/views/organization.py:814 +#: judge/views/organization.py:960 judge/views/organization.py:1125 msgid "Edited from site" msgstr "Chỉnh sửa từ web" @@ -2652,91 +2659,91 @@ msgstr "Runtimes" msgid "Notifications (%d unseen)" msgstr "Thông báo (%d chưa xem)" -#: judge/views/organization.py:140 judge/views/organization.py:146 +#: judge/views/organization.py:142 judge/views/organization.py:148 msgid "No such organization" msgstr "Không có tổ chức như vậy" -#: judge/views/organization.py:141 +#: judge/views/organization.py:143 #, python-format msgid "Could not find an organization with the key \"%s\"." msgstr "Không tìm thấy tổ chức với mã \"%s\"." -#: judge/views/organization.py:147 +#: judge/views/organization.py:149 msgid "Could not find such organization." msgstr "" -#: judge/views/organization.py:165 +#: judge/views/organization.py:167 msgid "Can't edit organization" msgstr "Không thể chỉnh sửa tổ chức" -#: judge/views/organization.py:166 +#: judge/views/organization.py:168 msgid "You are not allowed to edit this organization." msgstr "Bạn không được phép chỉnh sửa tổ chức này." -#: judge/views/organization.py:178 judge/views/organization.py:323 +#: judge/views/organization.py:180 judge/views/organization.py:324 #, fuzzy #| msgid "Can't edit organization" msgid "Can't access organization" msgstr "Không thể chỉnh sửa tổ chức" -#: judge/views/organization.py:179 judge/views/organization.py:324 +#: judge/views/organization.py:181 judge/views/organization.py:325 msgid "You are not allowed to access this organization." msgstr "Bạn không được phép chỉnh sửa tổ chức này." -#: judge/views/organization.py:237 judge/views/register.py:49 +#: judge/views/organization.py:239 judge/views/register.py:49 #: judge/views/stats.py:184 templates/contest/list.html:87 #: templates/problem/list-base.html:104 templates/stats/site.html:33 #: templates/user/user-left-sidebar.html:4 templates/user/user-list-tabs.html:6 msgid "Groups" msgstr "Nhóm" -#: judge/views/organization.py:330 +#: judge/views/organization.py:331 #, python-format msgid "%s Members" msgstr "%s Thành viên" -#: judge/views/organization.py:469 +#: judge/views/organization.py:470 #, python-brace-format msgid "All submissions in {0}" msgstr "Bài nộp trong {0}" -#: judge/views/organization.py:499 judge/views/organization.py:505 -#: judge/views/organization.py:512 +#: judge/views/organization.py:500 judge/views/organization.py:506 +#: judge/views/organization.py:513 msgid "Joining group" msgstr "Tham gia nhóm" -#: judge/views/organization.py:500 +#: judge/views/organization.py:501 msgid "You are already in the group." msgstr "Bạn đã ở trong nhóm." -#: judge/views/organization.py:505 +#: judge/views/organization.py:506 msgid "This group is not open." msgstr "Nhóm này là nhóm kín." -#: judge/views/organization.py:528 +#: judge/views/organization.py:529 msgid "Leaving group" msgstr "Rời nhóm" -#: judge/views/organization.py:529 +#: judge/views/organization.py:530 #, python-format msgid "You are not in \"%s\"." msgstr "Bạn không ở trong \"%s\"." -#: judge/views/organization.py:554 +#: judge/views/organization.py:555 #, python-format msgid "Request to join %s" msgstr "Đăng ký tham gia %s" -#: judge/views/organization.py:585 +#: judge/views/organization.py:586 msgid "Join request detail" msgstr "Chi tiết đơn đăng ký" -#: judge/views/organization.py:633 +#: judge/views/organization.py:634 #, python-format msgid "Managing join requests for %s" msgstr "Quản lý đơn đăng ký cho %s" -#: judge/views/organization.py:673 +#: judge/views/organization.py:674 #, python-format msgid "" "Your organization can only receive %d more members. You cannot approve %d " @@ -2745,96 +2752,96 @@ msgstr "" "Tổ chức chỉ có thể chứa %d thành viên. Bạn không thể chấp thuận nhiều hơn %d " "người." -#: judge/views/organization.py:691 +#: judge/views/organization.py:692 #, python-format msgid "Approved %d user." msgid_plural "Approved %d users." msgstr[0] "Đã chấp thuận %d người." -#: judge/views/organization.py:694 +#: judge/views/organization.py:695 #, python-format msgid "Rejected %d user." msgid_plural "Rejected %d users." msgstr[0] "Đã từ chối %d người." -#: judge/views/organization.py:734 +#: judge/views/organization.py:735 #, python-format msgid "Add member for %s" msgstr "Thêm thành viên cho %s" -#: judge/views/organization.py:746 +#: judge/views/organization.py:747 #, fuzzy #| msgid "Edited from site" msgid "Added members from site" msgstr "Chỉnh sửa từ web" -#: judge/views/organization.py:766 judge/views/organization.py:774 +#: judge/views/organization.py:767 judge/views/organization.py:775 msgid "Can't kick user" msgstr "Không thể đuổi" -#: judge/views/organization.py:767 +#: judge/views/organization.py:768 msgid "The user you are trying to kick does not exist!" msgstr "" -#: judge/views/organization.py:775 +#: judge/views/organization.py:776 #, python-format msgid "The user you are trying to kick is not in organization: %s." msgstr "" -#: judge/views/organization.py:796 judge/views/organization.py:948 +#: judge/views/organization.py:797 judge/views/organization.py:949 #, fuzzy, python-format #| msgid "Editing %s" msgid "Edit %s" msgstr "Đang chỉnh sửa %s" -#: judge/views/organization.py:824 templates/organization/list.html:59 +#: judge/views/organization.py:825 templates/organization/list.html:59 msgid "Create group" msgstr "Tạo nhóm" -#: judge/views/organization.py:839 +#: judge/views/organization.py:840 msgid "Exceeded limit" msgstr "" -#: judge/views/organization.py:840 +#: judge/views/organization.py:841 #, python-format msgid "You created too many groups. You can only create at most %d groups" msgstr "" -#: judge/views/organization.py:845 judge/views/organization.py:870 -#: judge/views/organization.py:1014 +#: judge/views/organization.py:846 judge/views/organization.py:871 +#: judge/views/organization.py:1015 msgid "Added from site" msgstr "Thêm từ web" -#: judge/views/organization.py:861 +#: judge/views/organization.py:862 #: templates/organization/org-right-sidebar.html:55 msgid "Add contest" msgstr "Thêm kỳ thi" -#: judge/views/organization.py:904 judge/views/organization.py:1066 +#: judge/views/organization.py:905 judge/views/organization.py:1067 msgid "Permission denied" msgstr "Truy cập bị từ chối" -#: judge/views/organization.py:905 +#: judge/views/organization.py:906 #, fuzzy #| msgid "You are not allowed to edit this organization." msgid "You are not allowed to edit this contest" msgstr "Bạn không được phép chỉnh sửa tổ chức này." -#: judge/views/organization.py:1003 +#: judge/views/organization.py:1004 #, python-format msgid "Add blog for %s" msgstr "Thêm bài đăng cho %s" -#: judge/views/organization.py:1067 +#: judge/views/organization.py:1068 msgid "Not allowed to edit this blog" msgstr "Bạn không được phép chỉnh sửa bài đăng này." -#: judge/views/organization.py:1099 +#: judge/views/organization.py:1100 #, python-format msgid "Edit blog %s" msgstr "Chỉnh sửa %s" -#: judge/views/organization.py:1150 +#: judge/views/organization.py:1151 #, python-format msgid "Pending blogs in %s" msgstr "Bài đang đợi duyệt trong %s" @@ -4738,6 +4745,10 @@ msgstr "Không có máy chấm có thể chấm bài này." msgid "Submit!" msgstr "Nộp bài!" +#: templates/recent-organization.html:30 +msgid "Recently visited organizations" +msgstr "Các nhóm thăm gần đây" + #: templates/registration/activate.html:3 #, python-format msgid "%(key)s is an invalid activation key." diff --git a/templates/recent-organization.html b/templates/recent-organization.html index ff9bcbe..974180a 100644 --- a/templates/recent-organization.html +++ b/templates/recent-organization.html @@ -1,20 +1,40 @@ +{% block two_col_media %} + +{% endblock %} + {% if recent_organizations %} {% endif %} \ No newline at end of file