From 45c1aa577d41f217ca15da27a01d37bfbe2f8f35 Mon Sep 17 00:00:00 2001 From: predatell <898242+predatell@users.noreply.github.com> Date: Thu, 12 Jul 2018 09:33:02 +0000 Subject: [PATCH 01/11] Upper version of django-haystack in requirements --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8148d17c..96c4d464 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ Django>=1.8,<2.0 -django-haystack>=2.4,<2.5 +django-haystack>=2.4,<3.0 Pillow>=2.1.0 postmarkup pygments From 0f321a676a849339618d77b1071551bef1002f2c Mon Sep 17 00:00:00 2001 From: predatell Date: Thu, 27 Dec 2018 21:49:16 +0200 Subject: [PATCH 02/11] adding on_delete --- djangobb_forum/feeds.py | 5 +- djangobb_forum/migrations/0001_initial.py | 52 ++++++++++----------- djangobb_forum/models.py | 48 ++++++++++--------- djangobb_forum/subscription.py | 5 +- djangobb_forum/templatetags/forum_extras.py | 5 +- djangobb_forum/views.py | 5 +- 6 files changed, 67 insertions(+), 53 deletions(-) diff --git a/djangobb_forum/feeds.py b/djangobb_forum/feeds.py index 2349743e..5c8015eb 100644 --- a/djangobb_forum/feeds.py +++ b/djangobb_forum/feeds.py @@ -1,9 +1,12 @@ from django.contrib.syndication.views import Feed, FeedDoesNotExist from django.utils.feedgenerator import Atom1Feed -from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from django.db.models import Q from django.http import Http404 +try: + from django.core.urlresolvers import reverse +except ImportError: + from django.urls import reverse from djangobb_forum.models import Post, Topic, Forum, Category diff --git a/djangobb_forum/migrations/0001_initial.py b/djangobb_forum/migrations/0001_initial.py index 4d44d251..63330fb0 100644 --- a/djangobb_forum/migrations/0001_initial.py +++ b/djangobb_forum/migrations/0001_initial.py @@ -2,11 +2,9 @@ from __future__ import unicode_literals from django.db import models, migrations -from djangobb_forum.models import MARKUP_CHOICES, THEME_CHOICES, TZ_CHOICES import djangobb_forum.fields import django.utils.timezone from django.conf import settings -from djangobb_forum import settings as forum_settings class Migration(migrations.Migration): @@ -35,7 +33,7 @@ class Migration(migrations.Migration): ('ban_start', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Ban start')), ('ban_end', models.DateTimeField(null=True, verbose_name='Ban end', blank=True)), ('reason', models.TextField(verbose_name='Reason')), - ('user', models.OneToOneField(related_name='ban_users', verbose_name='Banned user', to=settings.AUTH_USER_MODEL)), + ('user', models.OneToOneField(related_name='ban_users', verbose_name='Banned user', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ 'verbose_name': 'Ban', @@ -67,7 +65,7 @@ class Migration(migrations.Migration): ('post_count', models.IntegerField(default=0, verbose_name='Post count', blank=True)), ('topic_count', models.IntegerField(default=0, verbose_name='Topic count', blank=True)), ('forum_logo', djangobb_forum.fields.ExtendedImageField(default='', upload_to=b'djangobb_forum/forum_logo', verbose_name='Forum Logo', blank=True)), - ('category', models.ForeignKey(related_name='forums', verbose_name='Category', to='djangobb_forum.Category')), + ('category', models.ForeignKey(related_name='forums', verbose_name='Category', to='djangobb_forum.Category', on_delete=models.CASCADE)), ], options={ 'ordering': ['position'], @@ -91,7 +89,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('choice', models.CharField(max_length=200)), ('votes', models.IntegerField(default=0, editable=False)), - ('poll', models.ForeignKey(related_name='choices', to='djangobb_forum.Poll')), + ('poll', models.ForeignKey(related_name='choices', to='djangobb_forum.Poll', on_delete=models.CASCADE)), ], ), migrations.CreateModel( @@ -100,7 +98,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('created', models.DateTimeField(auto_now_add=True, verbose_name='Created')), ('updated', models.DateTimeField(null=True, verbose_name='Updated', blank=True)), - ('markup', models.CharField(default=forum_settings.DEFAULT_MARKUP, max_length=15, verbose_name='Markup', choices=MARKUP_CHOICES)), + ('markup', models.CharField(default=b'bbcode', max_length=15, verbose_name='Markup', choices=[('bbcode', 'bbcode')])), ('body', models.TextField(verbose_name='Message')), ('body_html', models.TextField(verbose_name='HTML version')), ('user_ip', models.GenericIPAddressField(null=True, verbose_name='User IP', blank=True)), @@ -118,7 +116,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('topics', djangobb_forum.fields.JSONField(null=True, blank=True)), ('last_read', models.DateTimeField(null=True, blank=True)), - ('user', djangobb_forum.fields.AutoOneToOneField(to=settings.AUTH_USER_MODEL)), + ('user', djangobb_forum.fields.AutoOneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ 'verbose_name': 'Post tracking', @@ -139,18 +137,18 @@ class Migration(migrations.Migration): ('location', models.CharField(max_length=30, verbose_name='Location', blank=True)), ('signature', models.TextField(default='', max_length=1024, verbose_name='Signature', blank=True)), ('signature_html', models.TextField(default='', max_length=1024, verbose_name='Signature', blank=True)), - ('time_zone', models.CharField(default=settings.TIME_ZONE, max_length=50, verbose_name='Time zone', choices=TZ_CHOICES)), - ('language', models.CharField(default='', max_length=5, verbose_name='Language', choices=settings.LANGUAGES)), + ('time_zone', models.CharField(default=b'Europe/Kiev', max_length=50, verbose_name='Time zone', choices=[(b'Africa/Abidjan', b'Africa/Abidjan'), (b'Africa/Accra', b'Africa/Accra'), (b'Africa/Addis_Ababa', b'Africa/Addis_Ababa'), (b'Africa/Algiers', b'Africa/Algiers'), (b'Africa/Asmara', b'Africa/Asmara'), (b'Africa/Bamako', b'Africa/Bamako'), (b'Africa/Bangui', b'Africa/Bangui'), (b'Africa/Banjul', b'Africa/Banjul'), (b'Africa/Bissau', b'Africa/Bissau'), (b'Africa/Blantyre', b'Africa/Blantyre'), (b'Africa/Brazzaville', b'Africa/Brazzaville'), (b'Africa/Bujumbura', b'Africa/Bujumbura'), (b'Africa/Cairo', b'Africa/Cairo'), (b'Africa/Casablanca', b'Africa/Casablanca'), (b'Africa/Ceuta', b'Africa/Ceuta'), (b'Africa/Conakry', b'Africa/Conakry'), (b'Africa/Dakar', b'Africa/Dakar'), (b'Africa/Dar_es_Salaam', b'Africa/Dar_es_Salaam'), (b'Africa/Djibouti', b'Africa/Djibouti'), (b'Africa/Douala', b'Africa/Douala'), (b'Africa/El_Aaiun', b'Africa/El_Aaiun'), (b'Africa/Freetown', b'Africa/Freetown'), (b'Africa/Gaborone', b'Africa/Gaborone'), (b'Africa/Harare', b'Africa/Harare'), (b'Africa/Johannesburg', b'Africa/Johannesburg'), (b'Africa/Juba', b'Africa/Juba'), (b'Africa/Kampala', b'Africa/Kampala'), (b'Africa/Khartoum', b'Africa/Khartoum'), (b'Africa/Kigali', b'Africa/Kigali'), (b'Africa/Kinshasa', b'Africa/Kinshasa'), (b'Africa/Lagos', b'Africa/Lagos'), (b'Africa/Libreville', b'Africa/Libreville'), (b'Africa/Lome', b'Africa/Lome'), (b'Africa/Luanda', b'Africa/Luanda'), (b'Africa/Lubumbashi', b'Africa/Lubumbashi'), (b'Africa/Lusaka', b'Africa/Lusaka'), (b'Africa/Malabo', b'Africa/Malabo'), (b'Africa/Maputo', b'Africa/Maputo'), (b'Africa/Maseru', b'Africa/Maseru'), (b'Africa/Mbabane', b'Africa/Mbabane'), (b'Africa/Mogadishu', b'Africa/Mogadishu'), (b'Africa/Monrovia', b'Africa/Monrovia'), (b'Africa/Nairobi', b'Africa/Nairobi'), (b'Africa/Ndjamena', b'Africa/Ndjamena'), (b'Africa/Niamey', b'Africa/Niamey'), (b'Africa/Nouakchott', b'Africa/Nouakchott'), (b'Africa/Ouagadougou', b'Africa/Ouagadougou'), (b'Africa/Porto-Novo', b'Africa/Porto-Novo'), (b'Africa/Sao_Tome', b'Africa/Sao_Tome'), (b'Africa/Tripoli', b'Africa/Tripoli'), (b'Africa/Tunis', b'Africa/Tunis'), (b'Africa/Windhoek', b'Africa/Windhoek'), (b'America/Adak', b'America/Adak'), (b'America/Anchorage', b'America/Anchorage'), (b'America/Anguilla', b'America/Anguilla'), (b'America/Antigua', b'America/Antigua'), (b'America/Araguaina', b'America/Araguaina'), (b'America/Argentina/Buenos_Aires', b'America/Argentina/Buenos_Aires'), (b'America/Argentina/Catamarca', b'America/Argentina/Catamarca'), (b'America/Argentina/Cordoba', b'America/Argentina/Cordoba'), (b'America/Argentina/Jujuy', b'America/Argentina/Jujuy'), (b'America/Argentina/La_Rioja', b'America/Argentina/La_Rioja'), (b'America/Argentina/Mendoza', b'America/Argentina/Mendoza'), (b'America/Argentina/Rio_Gallegos', b'America/Argentina/Rio_Gallegos'), (b'America/Argentina/Salta', b'America/Argentina/Salta'), (b'America/Argentina/San_Juan', b'America/Argentina/San_Juan'), (b'America/Argentina/San_Luis', b'America/Argentina/San_Luis'), (b'America/Argentina/Tucuman', b'America/Argentina/Tucuman'), (b'America/Argentina/Ushuaia', b'America/Argentina/Ushuaia'), (b'America/Aruba', b'America/Aruba'), (b'America/Asuncion', b'America/Asuncion'), (b'America/Atikokan', b'America/Atikokan'), (b'America/Bahia', b'America/Bahia'), (b'America/Bahia_Banderas', b'America/Bahia_Banderas'), (b'America/Barbados', b'America/Barbados'), (b'America/Belem', b'America/Belem'), (b'America/Belize', b'America/Belize'), (b'America/Blanc-Sablon', b'America/Blanc-Sablon'), (b'America/Boa_Vista', b'America/Boa_Vista'), (b'America/Bogota', b'America/Bogota'), (b'America/Boise', b'America/Boise'), (b'America/Cambridge_Bay', b'America/Cambridge_Bay'), (b'America/Campo_Grande', b'America/Campo_Grande'), (b'America/Cancun', b'America/Cancun'), (b'America/Caracas', b'America/Caracas'), (b'America/Cayenne', b'America/Cayenne'), (b'America/Cayman', b'America/Cayman'), (b'America/Chicago', b'America/Chicago'), (b'America/Chihuahua', b'America/Chihuahua'), (b'America/Costa_Rica', b'America/Costa_Rica'), (b'America/Creston', b'America/Creston'), (b'America/Cuiaba', b'America/Cuiaba'), (b'America/Curacao', b'America/Curacao'), (b'America/Danmarkshavn', b'America/Danmarkshavn'), (b'America/Dawson', b'America/Dawson'), (b'America/Dawson_Creek', b'America/Dawson_Creek'), (b'America/Denver', b'America/Denver'), (b'America/Detroit', b'America/Detroit'), (b'America/Dominica', b'America/Dominica'), (b'America/Edmonton', b'America/Edmonton'), (b'America/Eirunepe', b'America/Eirunepe'), (b'America/El_Salvador', b'America/El_Salvador'), (b'America/Fortaleza', b'America/Fortaleza'), (b'America/Glace_Bay', b'America/Glace_Bay'), (b'America/Godthab', b'America/Godthab'), (b'America/Goose_Bay', b'America/Goose_Bay'), (b'America/Grand_Turk', b'America/Grand_Turk'), (b'America/Grenada', b'America/Grenada'), (b'America/Guadeloupe', b'America/Guadeloupe'), (b'America/Guatemala', b'America/Guatemala'), (b'America/Guayaquil', b'America/Guayaquil'), (b'America/Guyana', b'America/Guyana'), (b'America/Halifax', b'America/Halifax'), (b'America/Havana', b'America/Havana'), (b'America/Hermosillo', b'America/Hermosillo'), (b'America/Indiana/Indianapolis', b'America/Indiana/Indianapolis'), (b'America/Indiana/Knox', b'America/Indiana/Knox'), (b'America/Indiana/Marengo', b'America/Indiana/Marengo'), (b'America/Indiana/Petersburg', b'America/Indiana/Petersburg'), (b'America/Indiana/Tell_City', b'America/Indiana/Tell_City'), (b'America/Indiana/Vevay', b'America/Indiana/Vevay'), (b'America/Indiana/Vincennes', b'America/Indiana/Vincennes'), (b'America/Indiana/Winamac', b'America/Indiana/Winamac'), (b'America/Inuvik', b'America/Inuvik'), (b'America/Iqaluit', b'America/Iqaluit'), (b'America/Jamaica', b'America/Jamaica'), (b'America/Juneau', b'America/Juneau'), (b'America/Kentucky/Louisville', b'America/Kentucky/Louisville'), (b'America/Kentucky/Monticello', b'America/Kentucky/Monticello'), (b'America/Kralendijk', b'America/Kralendijk'), (b'America/La_Paz', b'America/La_Paz'), (b'America/Lima', b'America/Lima'), (b'America/Los_Angeles', b'America/Los_Angeles'), (b'America/Lower_Princes', b'America/Lower_Princes'), (b'America/Maceio', b'America/Maceio'), (b'America/Managua', b'America/Managua'), (b'America/Manaus', b'America/Manaus'), (b'America/Marigot', b'America/Marigot'), (b'America/Martinique', b'America/Martinique'), (b'America/Matamoros', b'America/Matamoros'), (b'America/Mazatlan', b'America/Mazatlan'), (b'America/Menominee', b'America/Menominee'), (b'America/Merida', b'America/Merida'), (b'America/Metlakatla', b'America/Metlakatla'), (b'America/Mexico_City', b'America/Mexico_City'), (b'America/Miquelon', b'America/Miquelon'), (b'America/Moncton', b'America/Moncton'), (b'America/Monterrey', b'America/Monterrey'), (b'America/Montevideo', b'America/Montevideo'), (b'America/Montserrat', b'America/Montserrat'), (b'America/Nassau', b'America/Nassau'), (b'America/New_York', b'America/New_York'), (b'America/Nipigon', b'America/Nipigon'), (b'America/Nome', b'America/Nome'), (b'America/Noronha', b'America/Noronha'), (b'America/North_Dakota/Beulah', b'America/North_Dakota/Beulah'), (b'America/North_Dakota/Center', b'America/North_Dakota/Center'), (b'America/North_Dakota/New_Salem', b'America/North_Dakota/New_Salem'), (b'America/Ojinaga', b'America/Ojinaga'), (b'America/Panama', b'America/Panama'), (b'America/Pangnirtung', b'America/Pangnirtung'), (b'America/Paramaribo', b'America/Paramaribo'), (b'America/Phoenix', b'America/Phoenix'), (b'America/Port-au-Prince', b'America/Port-au-Prince'), (b'America/Port_of_Spain', b'America/Port_of_Spain'), (b'America/Porto_Velho', b'America/Porto_Velho'), (b'America/Puerto_Rico', b'America/Puerto_Rico'), (b'America/Rainy_River', b'America/Rainy_River'), (b'America/Rankin_Inlet', b'America/Rankin_Inlet'), (b'America/Recife', b'America/Recife'), (b'America/Regina', b'America/Regina'), (b'America/Resolute', b'America/Resolute'), (b'America/Rio_Branco', b'America/Rio_Branco'), (b'America/Santa_Isabel', b'America/Santa_Isabel'), (b'America/Santarem', b'America/Santarem'), (b'America/Santiago', b'America/Santiago'), (b'America/Santo_Domingo', b'America/Santo_Domingo'), (b'America/Sao_Paulo', b'America/Sao_Paulo'), (b'America/Scoresbysund', b'America/Scoresbysund'), (b'America/Sitka', b'America/Sitka'), (b'America/St_Barthelemy', b'America/St_Barthelemy'), (b'America/St_Johns', b'America/St_Johns'), (b'America/St_Kitts', b'America/St_Kitts'), (b'America/St_Lucia', b'America/St_Lucia'), (b'America/St_Thomas', b'America/St_Thomas'), (b'America/St_Vincent', b'America/St_Vincent'), (b'America/Swift_Current', b'America/Swift_Current'), (b'America/Tegucigalpa', b'America/Tegucigalpa'), (b'America/Thule', b'America/Thule'), (b'America/Thunder_Bay', b'America/Thunder_Bay'), (b'America/Tijuana', b'America/Tijuana'), (b'America/Toronto', b'America/Toronto'), (b'America/Tortola', b'America/Tortola'), (b'America/Vancouver', b'America/Vancouver'), (b'America/Whitehorse', b'America/Whitehorse'), (b'America/Winnipeg', b'America/Winnipeg'), (b'America/Yakutat', b'America/Yakutat'), (b'America/Yellowknife', b'America/Yellowknife'), (b'Antarctica/Casey', b'Antarctica/Casey'), (b'Antarctica/Davis', b'Antarctica/Davis'), (b'Antarctica/DumontDUrville', b'Antarctica/DumontDUrville'), (b'Antarctica/Macquarie', b'Antarctica/Macquarie'), (b'Antarctica/Mawson', b'Antarctica/Mawson'), (b'Antarctica/McMurdo', b'Antarctica/McMurdo'), (b'Antarctica/Palmer', b'Antarctica/Palmer'), (b'Antarctica/Rothera', b'Antarctica/Rothera'), (b'Antarctica/Syowa', b'Antarctica/Syowa'), (b'Antarctica/Troll', b'Antarctica/Troll'), (b'Antarctica/Vostok', b'Antarctica/Vostok'), (b'Arctic/Longyearbyen', b'Arctic/Longyearbyen'), (b'Asia/Aden', b'Asia/Aden'), (b'Asia/Almaty', b'Asia/Almaty'), (b'Asia/Amman', b'Asia/Amman'), (b'Asia/Anadyr', b'Asia/Anadyr'), (b'Asia/Aqtau', b'Asia/Aqtau'), (b'Asia/Aqtobe', b'Asia/Aqtobe'), (b'Asia/Ashgabat', b'Asia/Ashgabat'), (b'Asia/Baghdad', b'Asia/Baghdad'), (b'Asia/Bahrain', b'Asia/Bahrain'), (b'Asia/Baku', b'Asia/Baku'), (b'Asia/Bangkok', b'Asia/Bangkok'), (b'Asia/Beirut', b'Asia/Beirut'), (b'Asia/Bishkek', b'Asia/Bishkek'), (b'Asia/Brunei', b'Asia/Brunei'), (b'Asia/Chita', b'Asia/Chita'), (b'Asia/Choibalsan', b'Asia/Choibalsan'), (b'Asia/Colombo', b'Asia/Colombo'), (b'Asia/Damascus', b'Asia/Damascus'), (b'Asia/Dhaka', b'Asia/Dhaka'), (b'Asia/Dili', b'Asia/Dili'), (b'Asia/Dubai', b'Asia/Dubai'), (b'Asia/Dushanbe', b'Asia/Dushanbe'), (b'Asia/Gaza', b'Asia/Gaza'), (b'Asia/Hebron', b'Asia/Hebron'), (b'Asia/Ho_Chi_Minh', b'Asia/Ho_Chi_Minh'), (b'Asia/Hong_Kong', b'Asia/Hong_Kong'), (b'Asia/Hovd', b'Asia/Hovd'), (b'Asia/Irkutsk', b'Asia/Irkutsk'), (b'Asia/Jakarta', b'Asia/Jakarta'), (b'Asia/Jayapura', b'Asia/Jayapura'), (b'Asia/Jerusalem', b'Asia/Jerusalem'), (b'Asia/Kabul', b'Asia/Kabul'), (b'Asia/Kamchatka', b'Asia/Kamchatka'), (b'Asia/Karachi', b'Asia/Karachi'), (b'Asia/Kathmandu', b'Asia/Kathmandu'), (b'Asia/Khandyga', b'Asia/Khandyga'), (b'Asia/Kolkata', b'Asia/Kolkata'), (b'Asia/Krasnoyarsk', b'Asia/Krasnoyarsk'), (b'Asia/Kuala_Lumpur', b'Asia/Kuala_Lumpur'), (b'Asia/Kuching', b'Asia/Kuching'), (b'Asia/Kuwait', b'Asia/Kuwait'), (b'Asia/Macau', b'Asia/Macau'), (b'Asia/Magadan', b'Asia/Magadan'), (b'Asia/Makassar', b'Asia/Makassar'), (b'Asia/Manila', b'Asia/Manila'), (b'Asia/Muscat', b'Asia/Muscat'), (b'Asia/Nicosia', b'Asia/Nicosia'), (b'Asia/Novokuznetsk', b'Asia/Novokuznetsk'), (b'Asia/Novosibirsk', b'Asia/Novosibirsk'), (b'Asia/Omsk', b'Asia/Omsk'), (b'Asia/Oral', b'Asia/Oral'), (b'Asia/Phnom_Penh', b'Asia/Phnom_Penh'), (b'Asia/Pontianak', b'Asia/Pontianak'), (b'Asia/Pyongyang', b'Asia/Pyongyang'), (b'Asia/Qatar', b'Asia/Qatar'), (b'Asia/Qyzylorda', b'Asia/Qyzylorda'), (b'Asia/Rangoon', b'Asia/Rangoon'), (b'Asia/Riyadh', b'Asia/Riyadh'), (b'Asia/Sakhalin', b'Asia/Sakhalin'), (b'Asia/Samarkand', b'Asia/Samarkand'), (b'Asia/Seoul', b'Asia/Seoul'), (b'Asia/Shanghai', b'Asia/Shanghai'), (b'Asia/Singapore', b'Asia/Singapore'), (b'Asia/Srednekolymsk', b'Asia/Srednekolymsk'), (b'Asia/Taipei', b'Asia/Taipei'), (b'Asia/Tashkent', b'Asia/Tashkent'), (b'Asia/Tbilisi', b'Asia/Tbilisi'), (b'Asia/Tehran', b'Asia/Tehran'), (b'Asia/Thimphu', b'Asia/Thimphu'), (b'Asia/Tokyo', b'Asia/Tokyo'), (b'Asia/Ulaanbaatar', b'Asia/Ulaanbaatar'), (b'Asia/Urumqi', b'Asia/Urumqi'), (b'Asia/Ust-Nera', b'Asia/Ust-Nera'), (b'Asia/Vientiane', b'Asia/Vientiane'), (b'Asia/Vladivostok', b'Asia/Vladivostok'), (b'Asia/Yakutsk', b'Asia/Yakutsk'), (b'Asia/Yekaterinburg', b'Asia/Yekaterinburg'), (b'Asia/Yerevan', b'Asia/Yerevan'), (b'Atlantic/Azores', b'Atlantic/Azores'), (b'Atlantic/Bermuda', b'Atlantic/Bermuda'), (b'Atlantic/Canary', b'Atlantic/Canary'), (b'Atlantic/Cape_Verde', b'Atlantic/Cape_Verde'), (b'Atlantic/Faroe', b'Atlantic/Faroe'), (b'Atlantic/Madeira', b'Atlantic/Madeira'), (b'Atlantic/Reykjavik', b'Atlantic/Reykjavik'), (b'Atlantic/South_Georgia', b'Atlantic/South_Georgia'), (b'Atlantic/St_Helena', b'Atlantic/St_Helena'), (b'Atlantic/Stanley', b'Atlantic/Stanley'), (b'Australia/Adelaide', b'Australia/Adelaide'), (b'Australia/Brisbane', b'Australia/Brisbane'), (b'Australia/Broken_Hill', b'Australia/Broken_Hill'), (b'Australia/Currie', b'Australia/Currie'), (b'Australia/Darwin', b'Australia/Darwin'), (b'Australia/Eucla', b'Australia/Eucla'), (b'Australia/Hobart', b'Australia/Hobart'), (b'Australia/Lindeman', b'Australia/Lindeman'), (b'Australia/Lord_Howe', b'Australia/Lord_Howe'), (b'Australia/Melbourne', b'Australia/Melbourne'), (b'Australia/Perth', b'Australia/Perth'), (b'Australia/Sydney', b'Australia/Sydney'), (b'Canada/Atlantic', b'Canada/Atlantic'), (b'Canada/Central', b'Canada/Central'), (b'Canada/Eastern', b'Canada/Eastern'), (b'Canada/Mountain', b'Canada/Mountain'), (b'Canada/Newfoundland', b'Canada/Newfoundland'), (b'Canada/Pacific', b'Canada/Pacific'), (b'Europe/Amsterdam', b'Europe/Amsterdam'), (b'Europe/Andorra', b'Europe/Andorra'), (b'Europe/Athens', b'Europe/Athens'), (b'Europe/Belgrade', b'Europe/Belgrade'), (b'Europe/Berlin', b'Europe/Berlin'), (b'Europe/Bratislava', b'Europe/Bratislava'), (b'Europe/Brussels', b'Europe/Brussels'), (b'Europe/Bucharest', b'Europe/Bucharest'), (b'Europe/Budapest', b'Europe/Budapest'), (b'Europe/Busingen', b'Europe/Busingen'), (b'Europe/Chisinau', b'Europe/Chisinau'), (b'Europe/Copenhagen', b'Europe/Copenhagen'), (b'Europe/Dublin', b'Europe/Dublin'), (b'Europe/Gibraltar', b'Europe/Gibraltar'), (b'Europe/Guernsey', b'Europe/Guernsey'), (b'Europe/Helsinki', b'Europe/Helsinki'), (b'Europe/Isle_of_Man', b'Europe/Isle_of_Man'), (b'Europe/Istanbul', b'Europe/Istanbul'), (b'Europe/Jersey', b'Europe/Jersey'), (b'Europe/Kaliningrad', b'Europe/Kaliningrad'), (b'Europe/Kiev', b'Europe/Kiev'), (b'Europe/Lisbon', b'Europe/Lisbon'), (b'Europe/Ljubljana', b'Europe/Ljubljana'), (b'Europe/London', b'Europe/London'), (b'Europe/Luxembourg', b'Europe/Luxembourg'), (b'Europe/Madrid', b'Europe/Madrid'), (b'Europe/Malta', b'Europe/Malta'), (b'Europe/Mariehamn', b'Europe/Mariehamn'), (b'Europe/Minsk', b'Europe/Minsk'), (b'Europe/Monaco', b'Europe/Monaco'), (b'Europe/Moscow', b'Europe/Moscow'), (b'Europe/Oslo', b'Europe/Oslo'), (b'Europe/Paris', b'Europe/Paris'), (b'Europe/Podgorica', b'Europe/Podgorica'), (b'Europe/Prague', b'Europe/Prague'), (b'Europe/Riga', b'Europe/Riga'), (b'Europe/Rome', b'Europe/Rome'), (b'Europe/Samara', b'Europe/Samara'), (b'Europe/San_Marino', b'Europe/San_Marino'), (b'Europe/Sarajevo', b'Europe/Sarajevo'), (b'Europe/Simferopol', b'Europe/Simferopol'), (b'Europe/Skopje', b'Europe/Skopje'), (b'Europe/Sofia', b'Europe/Sofia'), (b'Europe/Stockholm', b'Europe/Stockholm'), (b'Europe/Tallinn', b'Europe/Tallinn'), (b'Europe/Tirane', b'Europe/Tirane'), (b'Europe/Uzhgorod', b'Europe/Uzhgorod'), (b'Europe/Vaduz', b'Europe/Vaduz'), (b'Europe/Vatican', b'Europe/Vatican'), (b'Europe/Vienna', b'Europe/Vienna'), (b'Europe/Vilnius', b'Europe/Vilnius'), (b'Europe/Volgograd', b'Europe/Volgograd'), (b'Europe/Warsaw', b'Europe/Warsaw'), (b'Europe/Zagreb', b'Europe/Zagreb'), (b'Europe/Zaporozhye', b'Europe/Zaporozhye'), (b'Europe/Zurich', b'Europe/Zurich'), (b'GMT', b'GMT'), (b'Indian/Antananarivo', b'Indian/Antananarivo'), (b'Indian/Chagos', b'Indian/Chagos'), (b'Indian/Christmas', b'Indian/Christmas'), (b'Indian/Cocos', b'Indian/Cocos'), (b'Indian/Comoro', b'Indian/Comoro'), (b'Indian/Kerguelen', b'Indian/Kerguelen'), (b'Indian/Mahe', b'Indian/Mahe'), (b'Indian/Maldives', b'Indian/Maldives'), (b'Indian/Mauritius', b'Indian/Mauritius'), (b'Indian/Mayotte', b'Indian/Mayotte'), (b'Indian/Reunion', b'Indian/Reunion'), (b'Pacific/Apia', b'Pacific/Apia'), (b'Pacific/Auckland', b'Pacific/Auckland'), (b'Pacific/Bougainville', b'Pacific/Bougainville'), (b'Pacific/Chatham', b'Pacific/Chatham'), (b'Pacific/Chuuk', b'Pacific/Chuuk'), (b'Pacific/Easter', b'Pacific/Easter'), (b'Pacific/Efate', b'Pacific/Efate'), (b'Pacific/Enderbury', b'Pacific/Enderbury'), (b'Pacific/Fakaofo', b'Pacific/Fakaofo'), (b'Pacific/Fiji', b'Pacific/Fiji'), (b'Pacific/Funafuti', b'Pacific/Funafuti'), (b'Pacific/Galapagos', b'Pacific/Galapagos'), (b'Pacific/Gambier', b'Pacific/Gambier'), (b'Pacific/Guadalcanal', b'Pacific/Guadalcanal'), (b'Pacific/Guam', b'Pacific/Guam'), (b'Pacific/Honolulu', b'Pacific/Honolulu'), (b'Pacific/Johnston', b'Pacific/Johnston'), (b'Pacific/Kiritimati', b'Pacific/Kiritimati'), (b'Pacific/Kosrae', b'Pacific/Kosrae'), (b'Pacific/Kwajalein', b'Pacific/Kwajalein'), (b'Pacific/Majuro', b'Pacific/Majuro'), (b'Pacific/Marquesas', b'Pacific/Marquesas'), (b'Pacific/Midway', b'Pacific/Midway'), (b'Pacific/Nauru', b'Pacific/Nauru'), (b'Pacific/Niue', b'Pacific/Niue'), (b'Pacific/Norfolk', b'Pacific/Norfolk'), (b'Pacific/Noumea', b'Pacific/Noumea'), (b'Pacific/Pago_Pago', b'Pacific/Pago_Pago'), (b'Pacific/Palau', b'Pacific/Palau'), (b'Pacific/Pitcairn', b'Pacific/Pitcairn'), (b'Pacific/Pohnpei', b'Pacific/Pohnpei'), (b'Pacific/Port_Moresby', b'Pacific/Port_Moresby'), (b'Pacific/Rarotonga', b'Pacific/Rarotonga'), (b'Pacific/Saipan', b'Pacific/Saipan'), (b'Pacific/Tahiti', b'Pacific/Tahiti'), (b'Pacific/Tarawa', b'Pacific/Tarawa'), (b'Pacific/Tongatapu', b'Pacific/Tongatapu'), (b'Pacific/Wake', b'Pacific/Wake'), (b'Pacific/Wallis', b'Pacific/Wallis'), (b'US/Alaska', b'US/Alaska'), (b'US/Arizona', b'US/Arizona'), (b'US/Central', b'US/Central'), (b'US/Eastern', b'US/Eastern'), (b'US/Hawaii', b'US/Hawaii'), (b'US/Mountain', b'US/Mountain'), (b'US/Pacific', b'US/Pacific'), (b'UTC', b'UTC')])), + ('language', models.CharField(default='', max_length=5, verbose_name='Language', choices=[(b'ca', b'Catalan'), (b'cs', b'Czech'), (b'de', b'German'), (b'en', b'English'), (b'es', b'Spanish'), (b'fo', b'Faroese'), (b'fr', b'France'), (b'it', b'Italian'), (b'lt', b'Lithuanian'), (b'mn', b'Mongolian'), (b'nl', b'Dutch'), (b'pl', b'Polish'), (b'ru', b'Russian'), (b'uk_UA', b'Ukrainian'), (b'vi', b'Vietnamese'), (b'zh_CN', b'Chinese')])), ('avatar', djangobb_forum.fields.ExtendedImageField(default='', upload_to=b'djangobb_forum/avatars', verbose_name='Avatar', blank=True)), - ('theme', models.CharField(default='default', max_length=80, verbose_name='Theme', choices=THEME_CHOICES)), + ('theme', models.CharField(default='default', max_length=80, verbose_name='Theme')), ('show_avatar', models.BooleanField(default=True, verbose_name='Show avatar')), ('show_signatures', models.BooleanField(default=True, verbose_name='Show signatures')), ('show_smilies', models.BooleanField(default=True, verbose_name='Show smilies')), ('privacy_permission', models.IntegerField(default=1, verbose_name='Privacy permission', choices=[(0, 'Display your e-mail address.'), (1, 'Hide your e-mail address but allow form e-mail.'), (2, 'Hide your e-mail address and disallow form e-mail.')])), ('auto_subscribe', models.BooleanField(default=False, help_text='Auto subscribe all topics you have created or reply.', verbose_name='Auto subscribe')), - ('markup', models.CharField(default=forum_settings.DEFAULT_MARKUP, max_length=15, verbose_name='Default markup', choices=MARKUP_CHOICES)), + ('markup', models.CharField(default=b'bbcode', max_length=15, verbose_name='Default markup', choices=[('bbcode', 'bbcode')])), ('post_count', models.IntegerField(default=0, verbose_name='Post count', blank=True)), - ('user', djangobb_forum.fields.AutoOneToOneField(related_name='forum_profile', verbose_name='User', to=settings.AUTH_USER_MODEL)), + ('user', djangobb_forum.fields.AutoOneToOneField(related_name='forum_profile', verbose_name='User', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ 'verbose_name': 'Profile', @@ -164,9 +162,9 @@ class Migration(migrations.Migration): ('zapped', models.BooleanField(default=False, verbose_name='Zapped')), ('created', models.DateTimeField(verbose_name='Created', blank=True)), ('reason', models.TextField(default='', max_length='1000', verbose_name='Reason', blank=True)), - ('post', models.ForeignKey(verbose_name='Post', to='djangobb_forum.Post')), - ('reported_by', models.ForeignKey(related_name='reported_by', verbose_name='Reported by', to=settings.AUTH_USER_MODEL)), - ('zapped_by', models.ForeignKey(related_name='zapped_by', verbose_name='Zapped by', blank=True, to=settings.AUTH_USER_MODEL, null=True)), + ('post', models.ForeignKey(verbose_name='Post', to='djangobb_forum.Post', on_delete=models.CASCADE)), + ('reported_by', models.ForeignKey(related_name='reported_by', verbose_name='Reported by', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), + ('zapped_by', models.ForeignKey(related_name='zapped_by', verbose_name='Zapped by', blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL)), ], options={ 'verbose_name': 'Report', @@ -180,9 +178,9 @@ class Migration(migrations.Migration): ('time', models.DateTimeField(auto_now_add=True, verbose_name='Time')), ('sign', models.IntegerField(default=0, verbose_name='Sign', choices=[(1, 'PLUS'), (-1, 'MINUS')])), ('reason', models.TextField(max_length=1000, verbose_name='Reason')), - ('from_user', models.ForeignKey(related_name='reputations_from', verbose_name='From', to=settings.AUTH_USER_MODEL)), - ('post', models.ForeignKey(related_name='post', verbose_name='Post', to='djangobb_forum.Post')), - ('to_user', models.ForeignKey(related_name='reputations_to', verbose_name='To', to=settings.AUTH_USER_MODEL)), + ('from_user', models.ForeignKey(related_name='reputations_from', verbose_name='From', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), + ('post', models.ForeignKey(related_name='post', verbose_name='Post', to='djangobb_forum.Post', on_delete=models.CASCADE)), + ('to_user', models.ForeignKey(related_name='reputations_to', verbose_name='To', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ 'verbose_name': 'Reputation', @@ -200,10 +198,10 @@ class Migration(migrations.Migration): ('sticky', models.BooleanField(default=False, verbose_name='Sticky')), ('closed', models.BooleanField(default=False, verbose_name='Closed')), ('post_count', models.IntegerField(default=0, verbose_name='Post count', blank=True)), - ('forum', models.ForeignKey(related_name='topics', verbose_name='Forum', to='djangobb_forum.Forum')), - ('last_post', models.ForeignKey(related_name='last_topic_post', blank=True, to='djangobb_forum.Post', null=True)), + ('forum', models.ForeignKey(related_name='topics', verbose_name='Forum', to='djangobb_forum.Forum', on_delete=models.CASCADE)), + ('last_post', models.ForeignKey(related_name='last_topic_post', blank=True, to='djangobb_forum.Post', null=True, on_delete=models.SET_NULL)), ('subscribers', models.ManyToManyField(related_name='subscriptions', verbose_name='Subscribers', to=settings.AUTH_USER_MODEL, blank=True)), - ('user', models.ForeignKey(verbose_name='User', to=settings.AUTH_USER_MODEL)), + ('user', models.ForeignKey(verbose_name='User', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ 'ordering': ['-updated'], @@ -215,22 +213,22 @@ class Migration(migrations.Migration): migrations.AddField( model_name='post', name='topic', - field=models.ForeignKey(related_name='posts', verbose_name='Topic', to='djangobb_forum.Topic'), + field=models.ForeignKey(related_name='posts', verbose_name='Topic', to='djangobb_forum.Topic', on_delete=models.CASCADE), ), migrations.AddField( model_name='post', name='updated_by', - field=models.ForeignKey(verbose_name='Updated by', blank=True, to=settings.AUTH_USER_MODEL, null=True), + field=models.ForeignKey(verbose_name='Updated by', blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL), ), migrations.AddField( model_name='post', name='user', - field=models.ForeignKey(related_name='posts', verbose_name='User', to=settings.AUTH_USER_MODEL), + field=models.ForeignKey(related_name='posts', verbose_name='User', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE), ), migrations.AddField( model_name='poll', name='topic', - field=models.ForeignKey(to='djangobb_forum.Topic'), + field=models.ForeignKey(to='djangobb_forum.Topic', on_delete=models.CASCADE), ), migrations.AddField( model_name='poll', @@ -240,7 +238,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='forum', name='last_post', - field=models.ForeignKey(related_name='last_forum_post', blank=True, to='djangobb_forum.Post', null=True), + field=models.ForeignKey(related_name='last_forum_post', blank=True, to='djangobb_forum.Post', null=True, on_delete=models.SET_NULL), ), migrations.AddField( model_name='forum', @@ -250,7 +248,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='attachment', name='post', - field=models.ForeignKey(related_name='attachments', verbose_name='Post', to='djangobb_forum.Post'), + field=models.ForeignKey(related_name='attachments', verbose_name='Post', to='djangobb_forum.Post', on_delete=models.CASCADE), ), migrations.AlterUniqueTogether( name='reputation', diff --git a/djangobb_forum/models.py b/djangobb_forum/models.py index 1c917f3f..08a296a4 100644 --- a/djangobb_forum/models.py +++ b/djangobb_forum/models.py @@ -4,7 +4,6 @@ from hashlib import sha1 import os -from django.core.urlresolvers import reverse from django.conf import settings from django.contrib.auth.models import Group from django.db import models @@ -12,7 +11,10 @@ from django.utils import timezone from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ - +try: + from django.core.urlresolvers import reverse +except ImportError: + from django.urls import reverse import pytz @@ -88,7 +90,7 @@ def has_access(self, user): @python_2_unicode_compatible class Forum(models.Model): - category = models.ForeignKey(Category, related_name='forums', verbose_name=_('Category')) + category = models.ForeignKey(Category, related_name='forums', verbose_name=_('Category'), on_delete=models.CASCADE) name = models.CharField(_('Name'), max_length=80) position = models.IntegerField(_('Position'), blank=True, default=0) description = models.TextField(_('Description'), blank=True, default='') @@ -96,7 +98,7 @@ class Forum(models.Model): updated = models.DateTimeField(_('Updated'), auto_now=True) post_count = models.IntegerField(_('Post count'), blank=True, default=0) topic_count = models.IntegerField(_('Topic count'), blank=True, default=0) - last_post = models.ForeignKey('Post', related_name='last_forum_post', blank=True, null=True) + last_post = models.ForeignKey('Post', related_name='last_forum_post', blank=True, null=True, on_delete=models.SET_NULL) forum_logo = ExtendedImageField(_('Forum Logo'), blank=True, default='', upload_to=forum_settings.FORUM_LOGO_UPLOAD_TO, width=forum_settings.FORUM_LOGO_WIDTH, @@ -120,17 +122,17 @@ def posts(self): @python_2_unicode_compatible class Topic(models.Model): - forum = models.ForeignKey(Forum, related_name='topics', verbose_name=_('Forum')) + forum = models.ForeignKey(Forum, related_name='topics', verbose_name=_('Forum'), on_delete=models.CASCADE) name = models.CharField(_('Subject'), max_length=255) created = models.DateTimeField(_('Created'), auto_now_add=True) updated = models.DateTimeField(_('Updated'), null=True) - user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('User')) + user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('User'), on_delete=models.CASCADE) views = models.IntegerField(_('Views count'), blank=True, default=0) sticky = models.BooleanField(_('Sticky'), blank=True, default=False) closed = models.BooleanField(_('Closed'), blank=True, default=False) subscribers = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='subscriptions', verbose_name=_('Subscribers'), blank=True) post_count = models.IntegerField(_('Post count'), blank=True, default=0) - last_post = models.ForeignKey('Post', related_name='last_topic_post', blank=True, null=True) + last_post = models.ForeignKey('Post', related_name='last_topic_post', blank=True, null=True, on_delete=models.SET_NULL) class Meta: ordering = ['-updated'] @@ -196,11 +198,12 @@ def update_read(self, user): @python_2_unicode_compatible class Post(models.Model): - topic = models.ForeignKey(Topic, related_name='posts', verbose_name=_('Topic')) - user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='posts', verbose_name=_('User')) + topic = models.ForeignKey(Topic, related_name='posts', verbose_name=_('Topic'), on_delete=models.CASCADE) + user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='posts', verbose_name=_('User'), on_delete=models.CASCADE) created = models.DateTimeField(_('Created'), auto_now_add=True) updated = models.DateTimeField(_('Updated'), blank=True, null=True) - updated_by = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('Updated by'), blank=True, null=True) + updated_by = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('Updated by'), blank=True, null=True, + on_delete=models.SET_NULL) markup = models.CharField(_('Markup'), max_length=15, default=forum_settings.DEFAULT_MARKUP, choices=MARKUP_CHOICES) body = models.TextField(_('Message')) body_html = models.TextField(_('HTML version')) @@ -263,9 +266,9 @@ def summary(self): @python_2_unicode_compatible class Reputation(models.Model): - from_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='reputations_from', verbose_name=_('From')) - to_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='reputations_to', verbose_name=_('To')) - post = models.ForeignKey(Post, related_name='post', verbose_name=_('Post')) + from_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='reputations_from', verbose_name=_('From'), on_delete=models.CASCADE) + to_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='reputations_to', verbose_name=_('To'), on_delete=models.CASCADE) + post = models.ForeignKey(Post, related_name='post', verbose_name=_('Post'), on_delete=models.CASCADE) time = models.DateTimeField(_('Time'), auto_now_add=True) sign = models.IntegerField(_('Sign'), choices=SIGN_CHOICES, default=0) reason = models.TextField(_('Reason'), max_length=1000) @@ -294,7 +297,7 @@ def get_queryset(self): class Profile(models.Model): - user = AutoOneToOneField(settings.AUTH_USER_MODEL, related_name='forum_profile', verbose_name=_('User')) + user = AutoOneToOneField(settings.AUTH_USER_MODEL, related_name='forum_profile', verbose_name=_('User'), on_delete=models.CASCADE) status = models.CharField(_('Status'), max_length=30, blank=True) site = models.URLField(_('Site'), blank=True) jabber = models.CharField(_('Jabber'), max_length=80, blank=True) @@ -338,7 +341,7 @@ class PostTracking(models.Model): In topics stored ids of topics and last_posts as dict. """ - user = AutoOneToOneField(settings.AUTH_USER_MODEL) + user = AutoOneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) topics = JSONField(null=True, blank=True) last_read = models.DateTimeField(null=True, blank=True) @@ -352,10 +355,11 @@ def __str__(self): @python_2_unicode_compatible class Report(models.Model): - reported_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='reported_by', verbose_name=_('Reported by')) - post = models.ForeignKey(Post, verbose_name=_('Post')) + reported_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='reported_by', verbose_name=_('Reported by'), on_delete=models.CASCADE) + post = models.ForeignKey(Post, verbose_name=_('Post'), on_delete=models.CASCADE) zapped = models.BooleanField(_('Zapped'), blank=True, default=False) - zapped_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='zapped_by', blank=True, null=True, verbose_name=_('Zapped by')) + zapped_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='zapped_by', blank=True, null=True, + verbose_name=_('Zapped by'), on_delete=models.SET_NULL) created = models.DateTimeField(_('Created'), blank=True) reason = models.TextField(_('Reason'), blank=True, default='', max_length='1000') @@ -369,7 +373,7 @@ def __str__(self): @python_2_unicode_compatible class Ban(models.Model): - user = models.OneToOneField(settings.AUTH_USER_MODEL, verbose_name=_('Banned user'), related_name='ban_users') + user = models.OneToOneField(settings.AUTH_USER_MODEL, verbose_name=_('Banned user'), related_name='ban_users', on_delete=models.CASCADE) ban_start = models.DateTimeField(_('Ban start'), default=timezone.now) ban_end = models.DateTimeField(_('Ban end'), blank=True, null=True) reason = models.TextField(_('Reason')) @@ -394,7 +398,7 @@ def delete(self, *args, **kwargs): @python_2_unicode_compatible class Attachment(models.Model): - post = models.ForeignKey(Post, verbose_name=_('Post'), related_name='attachments') + post = models.ForeignKey(Post, verbose_name=_('Post'), related_name='attachments', on_delete=models.CASCADE) size = models.IntegerField(_('Size')) content_type = models.CharField(_('Content type'), max_length=255) path = models.CharField(_('Path'), max_length=255) @@ -420,7 +424,7 @@ def get_absolute_path(self): @python_2_unicode_compatible class Poll(models.Model): - topic = models.ForeignKey(Topic) + topic = models.ForeignKey(Topic, on_delete=models.CASCADE) question = models.CharField(max_length=200) choice_count = models.PositiveSmallIntegerField(default=1, help_text=_("How many choices are allowed simultaneously."), @@ -450,7 +454,7 @@ def __str__(self): @python_2_unicode_compatible class PollChoice(models.Model): - poll = models.ForeignKey(Poll, related_name="choices") + poll = models.ForeignKey(Poll, related_name="choices", on_delete=models.CASCADE) choice = models.CharField(max_length=200) votes = models.IntegerField(default=0, editable=False) diff --git a/djangobb_forum/subscription.py b/djangobb_forum/subscription.py index 49ca3492..98b0c702 100644 --- a/djangobb_forum/subscription.py +++ b/djangobb_forum/subscription.py @@ -2,8 +2,11 @@ from django.core.mail import EmailMultiAlternatives from django.conf import settings -from django.core.urlresolvers import reverse from django.utils.html import strip_tags +try: + from django.core.urlresolvers import reverse +except ImportError: + from django.urls import reverse from djangobb_forum import settings as forum_settings from djangobb_forum.util import absolute_url diff --git a/djangobb_forum/templatetags/forum_extras.py b/djangobb_forum/templatetags/forum_extras.py index 32c247ec..752e938a 100644 --- a/djangobb_forum/templatetags/forum_extras.py +++ b/djangobb_forum/templatetags/forum_extras.py @@ -4,7 +4,6 @@ import hashlib from django import template -from django.core.urlresolvers import reverse from django.core.cache import cache from django.utils.safestring import mark_safe from django.utils.encoding import smart_text @@ -13,6 +12,10 @@ from django.utils import timezone from django.contrib.humanize.templatetags.humanize import naturalday from django.utils.six.moves.urllib.parse import urlencode +try: + from django.core.urlresolvers import reverse +except ImportError: + from django.urls import reverse from djangobb_forum.models import Report from djangobb_forum import settings as forum_settings diff --git a/djangobb_forum/views.py b/djangobb_forum/views.py index 42ababce..05b60e56 100644 --- a/djangobb_forum/views.py +++ b/djangobb_forum/views.py @@ -11,7 +11,6 @@ from django.contrib.sites.models import Site from django.core.cache import cache from django.core.exceptions import SuspiciousOperation, PermissionDenied -from django.core.urlresolvers import reverse from django.db import transaction from django.db.models import Q, F from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseForbidden @@ -20,6 +19,10 @@ from django.utils.translation import ugettext as _ from django.views.decorators.csrf import csrf_exempt from django.conf import settings +try: + from django.core.urlresolvers import reverse +except ImportError: + from django.urls import reverse from haystack.query import SearchQuerySet, SQ From dd71f9d3755bc1e3051c4edaf4fdd23a695a3ff7 Mon Sep 17 00:00:00 2001 From: predatell <898242+predatell@users.noreply.github.com> Date: Fri, 28 Dec 2018 11:09:04 +0000 Subject: [PATCH 03/11] django requirement --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6685a144..9e12baa1 100755 --- a/setup.py +++ b/setup.py @@ -50,7 +50,7 @@ def run(self): author_email='Maranchuk Sergey ', packages=find_packages(), include_package_data=True, - setup_requires=['django>=1.8,<2.0'], + setup_requires=['django>=1.8'], install_requires=open('requirements.txt').readlines(), keywords='django forum bb', test_suite='runtests.runtests', From ef31676227c4f687e46f3b5bb7f31fea870e2b5e Mon Sep 17 00:00:00 2001 From: predatell <898242+predatell@users.noreply.github.com> Date: Fri, 28 Dec 2018 11:14:51 +0000 Subject: [PATCH 04/11] Django requirement --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 96c4d464..d7c13072 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django>=1.8,<2.0 +Django>=1.8 django-haystack>=2.4,<3.0 Pillow>=2.1.0 postmarkup From 7b776616df99efdff29e0c733f5812ca5aad9e9e Mon Sep 17 00:00:00 2001 From: predatell Date: Wed, 9 Jan 2019 17:24:58 +0200 Subject: [PATCH 05/11] is_authenticated is not function --- djangobb_forum/middleware.py | 8 ++++---- djangobb_forum/models.py | 2 +- djangobb_forum/templatetags/forum_extras.py | 6 +++--- djangobb_forum/views.py | 22 ++++++++++----------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/djangobb_forum/middleware.py b/djangobb_forum/middleware.py index a05298da..f4913b08 100644 --- a/djangobb_forum/middleware.py +++ b/djangobb_forum/middleware.py @@ -10,13 +10,13 @@ class LastLoginMiddleware(object): def process_request(self, request): - if request.user.is_authenticated(): + if request.user.is_authenticated: cache.set('djangobb_user%d' % request.user.id, True, forum_settings.USER_ONLINE_TIMEOUT) class ForumMiddleware(object): def process_request(self, request): - if request.user.is_authenticated(): + if request.user.is_authenticated: profile = request.user.forum_profile language = translation.get_language_from_request(request) @@ -37,7 +37,7 @@ def process_request(self, request): users_online = cache.get('djangobb_users_online', {}) guests_online = cache.get('djangobb_guests_online', {}) - if request.user.is_authenticated(): + if request.user.is_authenticated: users_online[request.user.id] = now else: guest_sid = request.COOKIES.get(global_settings.SESSION_COOKIE_NAME, '') @@ -57,7 +57,7 @@ def process_request(self, request): class TimezoneMiddleware(object): def process_request(self, request): - if request.user.is_authenticated(): + if request.user.is_authenticated: profile = request.user.forum_profile try: timezone.activate(profile.time_zone) diff --git a/djangobb_forum/models.py b/djangobb_forum/models.py index 08a296a4..3efde9ba 100644 --- a/djangobb_forum/models.py +++ b/djangobb_forum/models.py @@ -80,7 +80,7 @@ def has_access(self, user): if user.is_superuser: return True if self.groups.exists(): - if user.is_authenticated(): + if user.is_authenticated: if not self.groups.filter(user__pk=user.id).exists(): return False else: diff --git a/djangobb_forum/templatetags/forum_extras.py b/djangobb_forum/templatetags/forum_extras.py index 752e938a..c97fb1ee 100644 --- a/djangobb_forum/templatetags/forum_extras.py +++ b/djangobb_forum/templatetags/forum_extras.py @@ -81,7 +81,7 @@ def has_unreads(topic, user): """ Check if topic has messages which user didn't read. """ - if not user.is_authenticated() or\ + if not user.is_authenticated or\ (user.posttracking.last_read is not None and\ user.posttracking.last_read > topic.updated): return False @@ -98,7 +98,7 @@ def forum_unreads(forum, user): """ Check if forum has topic which user didn't read. """ - if not user.is_authenticated(): + if not user.is_authenticated: return False else: if isinstance(user.posttracking.topics, dict): @@ -229,7 +229,7 @@ def gravatar(context, email): def set_theme_style(user): theme_style = '' selected_theme = '' - if user.is_authenticated(): + if user.is_authenticated: selected_theme = user.forum_profile.theme theme_style = '' else: diff --git a/djangobb_forum/views.py b/djangobb_forum/views.py index 05b60e56..6196ecef 100644 --- a/djangobb_forum/views.py +++ b/djangobb_forum/views.py @@ -162,7 +162,7 @@ def _render_search_form(form=None): context["topics"] = topics.filter(Q(last_post__created__gte=date) | Q(last_post__updated__gte=date)) _generic_context = False elif action == 'show_new': - if not user.is_authenticated(): + if not user.is_authenticated: raise Http404("Search 'show_new' not available for anonymous user.") try: last_read = PostTracking.objects.get(user=user).last_read @@ -186,7 +186,7 @@ def _render_search_form(form=None): topics = topics.filter(subscribers__id=user.id) elif action == 'show_user': # Show all posts from user or topics started by user - if not user.is_authenticated(): + if not user.is_authenticated: raise Http404("Search 'show_user' not available for anonymous user.") user_id = request.GET.get("user_id", user.id) @@ -373,7 +373,7 @@ def show_topic(request, topic_id, full=True): TODO: Add reply in lofi mode """ post_request = request.method == "POST" - user_is_authenticated = request.user.is_authenticated() + user_is_authenticated = request.user.is_authenticated if post_request and not user_is_authenticated: # Info: only user that are logged in should get forms in the page. raise PermissionDenied @@ -385,7 +385,7 @@ def show_topic(request, topic_id, full=True): last_post = topic.last_post - if request.user.is_authenticated(): + if request.user.is_authenticated: topic.update_read(request.user) posts = topic.posts.all().select_related() @@ -535,7 +535,7 @@ def add_topic(request, forum_id): @transaction.atomic def upload_avatar(request, username, template=None, form_class=None): user = get_object_or_404(User, username=username) - if request.user.is_authenticated() and user == request.user or request.user.is_superuser: + if request.user.is_authenticated and user == request.user or request.user.is_superuser: form = build_form(form_class, request, instance=user.forum_profile) if request.method == 'POST' and form.is_valid(): form.save() @@ -547,7 +547,7 @@ def upload_avatar(request, username, template=None, form_class=None): }) else: topic_count = Topic.objects.filter(user__id=user.id).count() - if user.forum_profile.post_count < forum_settings.POST_USER_SEARCH and not request.user.is_authenticated(): + if user.forum_profile.post_count < forum_settings.POST_USER_SEARCH and not request.user.is_authenticated: messages.error(request, _("Please sign in.")) return HttpResponseRedirect(settings.LOGIN_URL + '?next=%s' % request.path) return render(request, template, {'profile': user, @@ -558,7 +558,7 @@ def upload_avatar(request, username, template=None, form_class=None): @transaction.atomic def user(request, username, section='essentials', action=None, template='djangobb_forum/profile/profile_essentials.html', form_class=EssentialsProfileForm): user = get_object_or_404(User, username=username) - if request.user.is_authenticated() and user == request.user or request.user.is_superuser: + if request.user.is_authenticated and user == request.user or request.user.is_superuser: form = build_form(form_class, request, instance=user.forum_profile, extra_args={'request': request}) if request.method == 'POST' and form.is_valid(): form.save() @@ -572,7 +572,7 @@ def user(request, username, section='essentials', action=None, template='djangob else: template = 'djangobb_forum/user.html' topic_count = Topic.objects.filter(user__id=user.id).count() - if user.forum_profile.post_count < forum_settings.POST_USER_SEARCH and not request.user.is_authenticated(): + if user.forum_profile.post_count < forum_settings.POST_USER_SEARCH and not request.user.is_authenticated: messages.error(request, _("Please sign in.")) return HttpResponseRedirect(settings.LOGIN_URL + '?next=%s' % request.path) return render(request, template, {'profile': user, @@ -674,19 +674,19 @@ def delete_posts(request, topic_id): last_post = topic.posts.latest() - if request.user.is_authenticated(): + if request.user.is_authenticated: topic.update_read(request.user) posts = topic.posts.all().select_related() initial = {} - if request.user.is_authenticated(): + if request.user.is_authenticated: initial = {'markup': request.user.forum_profile.markup} form = AddPostForm(topic=topic, initial=initial) moderator = request.user.is_superuser or\ request.user in topic.forum.moderators.all() - if request.user.is_authenticated() and request.user in topic.subscribers.all(): + if request.user.is_authenticated and request.user in topic.subscribers.all(): subscribed = True else: subscribed = False From 308033d46d2b4f3c48dcfae29860ffe54a562902 Mon Sep 17 00:00:00 2001 From: predatell Date: Sat, 4 Jul 2020 22:09:58 +0300 Subject: [PATCH 06/11] six not from django --- djangobb_forum/fields.py | 2 +- djangobb_forum/models.py | 2 +- djangobb_forum/templatetags/forum_extras.py | 2 +- djangobb_forum/util.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/djangobb_forum/fields.py b/djangobb_forum/fields.py index a6be3495..d6ec2a27 100644 --- a/djangobb_forum/fields.py +++ b/djangobb_forum/fields.py @@ -2,6 +2,7 @@ import random from hashlib import sha1 import json +import six from django.db.models import OneToOneField try: @@ -13,7 +14,6 @@ from django.core.serializers.json import DjangoJSONEncoder from django.conf import settings from django.forms.utils import ValidationError -from django.utils import six from django.utils.translation import ugettext_lazy as _ diff --git a/djangobb_forum/models.py b/djangobb_forum/models.py index 3efde9ba..235697b5 100644 --- a/djangobb_forum/models.py +++ b/djangobb_forum/models.py @@ -3,13 +3,13 @@ from hashlib import sha1 import os +from six import python_2_unicode_compatible from django.conf import settings from django.contrib.auth.models import Group from django.db import models from django.db.models import aggregates from django.utils import timezone -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ try: from django.core.urlresolvers import reverse diff --git a/djangobb_forum/templatetags/forum_extras.py b/djangobb_forum/templatetags/forum_extras.py index c97fb1ee..dc78d31e 100644 --- a/djangobb_forum/templatetags/forum_extras.py +++ b/djangobb_forum/templatetags/forum_extras.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import hashlib +from six.moves.urllib.parse import urlencode from django import template from django.core.cache import cache @@ -11,7 +12,6 @@ from django.utils.html import escape from django.utils import timezone from django.contrib.humanize.templatetags.humanize import naturalday -from django.utils.six.moves.urllib.parse import urlencode try: from django.core.urlresolvers import reverse except ImportError: diff --git a/djangobb_forum/util.py b/djangobb_forum/util.py index 7afb49b3..703b8bce 100644 --- a/djangobb_forum/util.py +++ b/djangobb_forum/util.py @@ -1,7 +1,7 @@ # coding: utf-8 import re -from django.utils.six.moves import html_parser +from six.moves import html_parser HTMLParser = html_parser.HTMLParser try: HTMLParseError = html_parser.HTMLParseError From 1d643ddf349c31b165f9e934b00ef5896e892779 Mon Sep 17 00:00:00 2001 From: predatell Date: Sat, 4 Jul 2020 22:11:44 +0300 Subject: [PATCH 07/11] haystack requirements --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d7c13072..26a2fa9a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ Django>=1.8 -django-haystack>=2.4,<3.0 +django-haystack>=2.4 Pillow>=2.1.0 postmarkup pygments From b22e6d0dab2a39c0ee83a9254a6e5f74a0b94dbb Mon Sep 17 00:00:00 2001 From: predatell Date: Thu, 1 Sep 2022 18:27:01 +0300 Subject: [PATCH 08/11] support django 4 --- djangobb_forum/admin.py | 2 +- djangobb_forum/feeds.py | 2 +- djangobb_forum/fields.py | 2 +- djangobb_forum/forms.py | 2 +- djangobb_forum/models.py | 2 +- djangobb_forum/templatetags/forum_extras.py | 6 +- djangobb_forum/urls.py | 74 ++++++++++----------- djangobb_forum/views.py | 2 +- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/djangobb_forum/admin.py b/djangobb_forum/admin.py index b63c5b0f..9476af91 100644 --- a/djangobb_forum/admin.py +++ b/djangobb_forum/admin.py @@ -1,7 +1,7 @@ # coding: utf-8 from django.contrib import admin -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.conf import settings from djangobb_forum.models import Category, Forum, Topic, Post, Profile, Reputation, \ Report, Ban, Attachment, Poll, PollChoice, PostTracking diff --git a/djangobb_forum/feeds.py b/djangobb_forum/feeds.py index 5c8015eb..e0f736e8 100644 --- a/djangobb_forum/feeds.py +++ b/djangobb_forum/feeds.py @@ -1,6 +1,6 @@ from django.contrib.syndication.views import Feed, FeedDoesNotExist from django.utils.feedgenerator import Atom1Feed -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.db.models import Q from django.http import Http404 try: diff --git a/djangobb_forum/fields.py b/djangobb_forum/fields.py index d6ec2a27..5c8eed52 100644 --- a/djangobb_forum/fields.py +++ b/djangobb_forum/fields.py @@ -14,7 +14,7 @@ from django.core.serializers.json import DjangoJSONEncoder from django.conf import settings from django.forms.utils import ValidationError -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class AutoReverseOneToOneDescriptor(ReverseOneToOneDescriptor): diff --git a/djangobb_forum/forms.py b/djangobb_forum/forms.py index 80940f0e..6db40034 100644 --- a/djangobb_forum/forms.py +++ b/djangobb_forum/forms.py @@ -8,7 +8,7 @@ from django.conf import settings from django.contrib.auth import get_user_model from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from djangobb_forum.models import Topic, Post, Profile, Reputation, Report, \ Attachment, Poll, PollChoice diff --git a/djangobb_forum/models.py b/djangobb_forum/models.py index 235697b5..8906f271 100644 --- a/djangobb_forum/models.py +++ b/djangobb_forum/models.py @@ -10,7 +10,7 @@ from django.db import models from django.db.models import aggregates from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ try: from django.core.urlresolvers import reverse except ImportError: diff --git a/djangobb_forum/templatetags/forum_extras.py b/djangobb_forum/templatetags/forum_extras.py index dc78d31e..5c17dc6e 100644 --- a/djangobb_forum/templatetags/forum_extras.py +++ b/djangobb_forum/templatetags/forum_extras.py @@ -7,7 +7,7 @@ from django import template from django.core.cache import cache from django.utils.safestring import mark_safe -from django.utils.encoding import smart_text +from django.utils.encoding import smart_str from django.conf import settings from django.utils.html import escape from django.utils import timezone @@ -61,7 +61,7 @@ def link(object, anchor=''): """ url = hasattr(object, 'get_absolute_url') and object.get_absolute_url() or None - anchor = anchor or smart_text(object) + anchor = anchor or smart_str(object) return mark_safe('%s' % (url, escape(anchor))) @@ -72,7 +72,7 @@ def lofi_link(object, anchor=''): """ url = hasattr(object, 'get_absolute_url') and object.get_absolute_url() or None - anchor = anchor or smart_text(object) + anchor = anchor or smart_str(object) return mark_safe('%s' % (url, escape(anchor))) diff --git a/djangobb_forum/urls.py b/djangobb_forum/urls.py index 6104060d..bf155e58 100644 --- a/djangobb_forum/urls.py +++ b/djangobb_forum/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.urls import re_path from djangobb_forum import settings as forum_settings from djangobb_forum import views as forum_views @@ -12,71 +12,71 @@ urlpatterns = [ # Forum - url('^$', forum_views.index, name='index'), - url('^(?P\d+)/$', forum_views.show_forum, name='forum'), - url('^moderate/(?P\d+)/$', forum_views.moderate, name='moderate'), - url('^search/$', forum_views.search, name='search'), - url('^misc/$', forum_views.misc, name='misc'), + re_path('^$', forum_views.index, name='index'), + re_path('^(?P\d+)/$', forum_views.show_forum, name='forum'), + re_path('^moderate/(?P\d+)/$', forum_views.moderate, name='moderate'), + re_path('^search/$', forum_views.search, name='search'), + re_path('^misc/$', forum_views.misc, name='misc'), # User - url('^user/(?P.*)/upload_avatar/$', forum_views.upload_avatar, { + re_path('^user/(?P.*)/upload_avatar/$', forum_views.upload_avatar, { 'form_class': UploadAvatarForm, 'template': 'djangobb_forum/upload_avatar.html' }, name='forum_profile_upload_avatar'), - url('^user/(?P.*)/privacy/$', forum_views.user, { + re_path('^user/(?P.*)/privacy/$', forum_views.user, { 'section': 'privacy', 'form_class': PrivacyProfileForm, 'template': 'djangobb_forum/profile/profile_privacy.html' }, name='forum_profile_privacy'), - url('^user/(?P.*)/display/$', forum_views.user, { + re_path('^user/(?P.*)/display/$', forum_views.user, { 'section': 'display', 'form_class': DisplayProfileForm, 'template': 'djangobb_forum/profile/profile_display.html' }, name='forum_profile_display'), - url('^user/(?P.*)/personality/$', forum_views.user, { + re_path('^user/(?P.*)/personality/$', forum_views.user, { 'section': 'personality', 'form_class': PersonalityProfileForm, 'template': 'djangobb_forum/profile/profile_personality.html' }, name='forum_profile_personality'), - url('^user/(?P.*)/messaging/$', forum_views.user, { + re_path('^user/(?P.*)/messaging/$', forum_views.user, { 'section': 'messaging', 'form_class': MessagingProfileForm, 'template': 'djangobb_forum/profile/profile_messaging.html' }, name='forum_profile_messaging'), - url('^user/(?P.*)/personal/$', forum_views.user, { + re_path('^user/(?P.*)/personal/$', forum_views.user, { 'section': 'personal', 'form_class': PersonalProfileForm, 'template': 'djangobb_forum/profile/profile_personal.html' }, name='forum_profile_personal'), - url('^user/(?P.*)/essentials/$', forum_views.user, name='forum_profile_essentials'), - url('^user/(?P.*)/$', forum_views.user, name='forum_profile'), - url('^users/$', forum_views.users, name='forum_users'), + re_path('^user/(?P.*)/essentials/$', forum_views.user, name='forum_profile_essentials'), + re_path('^user/(?P.*)/$', forum_views.user, name='forum_profile'), + re_path('^users/$', forum_views.users, name='forum_users'), # Topic - url('^topic/(?P\d+)/$', forum_views.show_topic, name='topic'), - url('^(?P\d+)/topic/add/$', forum_views.add_topic, name='add_topic'), - url('^topic/(?P\d+)/delete_posts/$', forum_views.delete_posts, name='delete_posts'), - url('^topic/move/$', forum_views.move_topic, name='move_topic'), - url('^topic/(?P\d+)/stick_unstick/(?P[s|u])/$', forum_views.stick_unstick_topic, name='stick_unstick_topic'), - url('^topic/(?P\d+)/open_close/(?P[c|o])/$', forum_views.open_close_topic, name='open_close_topic'), + re_path('^topic/(?P\d+)/$', forum_views.show_topic, name='topic'), + re_path('^(?P\d+)/topic/add/$', forum_views.add_topic, name='add_topic'), + re_path('^topic/(?P\d+)/delete_posts/$', forum_views.delete_posts, name='delete_posts'), + re_path('^topic/move/$', forum_views.move_topic, name='move_topic'), + re_path('^topic/(?P\d+)/stick_unstick/(?P[s|u])/$', forum_views.stick_unstick_topic, name='stick_unstick_topic'), + re_path('^topic/(?P\d+)/open_close/(?P[c|o])/$', forum_views.open_close_topic, name='open_close_topic'), # Post - url('^post/(?P\d+)/$', forum_views.show_post, name='post'), - url('^post/(?P\d+)/edit/$', forum_views.edit_post, name='edit_post'), - url('^post/(?P\d+)/delete/$', forum_views.delete_post, name='delete_post'), + re_path('^post/(?P\d+)/$', forum_views.show_post, name='post'), + re_path('^post/(?P\d+)/edit/$', forum_views.edit_post, name='edit_post'), + re_path('^post/(?P\d+)/delete/$', forum_views.delete_post, name='delete_post'), # Post preview - url(r'^preview/$', forum_views.post_preview, name='post_preview'), + re_path(r'^preview/$', forum_views.post_preview, name='post_preview'), # Subscription - url('^subscription/topic/(?P\d+)/delete/$', forum_views.delete_subscription, name='forum_delete_subscription'), - url('^subscription/topic/(?P\d+)/add/$', forum_views.add_subscription, name='forum_add_subscription'), + re_path('^subscription/topic/(?P\d+)/delete/$', forum_views.delete_subscription, name='forum_delete_subscription'), + re_path('^subscription/topic/(?P\d+)/add/$', forum_views.add_subscription, name='forum_add_subscription'), # Feeds - url(r'^feeds/posts/$', LastPosts(), name='forum_posts_feed'), - url(r'^feeds/topics/$', LastTopics(), name='forum_topics_feed'), - url(r'^feeds/topic/(?P\d+)/$', LastPostsOnTopic(), name='forum_topic_feed'), - url(r'^feeds/forum/(?P\d+)/$', LastPostsOnForum(), name='forum_forum_feed'), - url(r'^feeds/category/(?P\d+)/$', LastPostsOnCategory(), name='forum_category_feed'), + re_path(r'^feeds/posts/$', LastPosts(), name='forum_posts_feed'), + re_path(r'^feeds/topics/$', LastTopics(), name='forum_topics_feed'), + re_path(r'^feeds/topic/(?P\d+)/$', LastPostsOnTopic(), name='forum_topic_feed'), + re_path(r'^feeds/forum/(?P\d+)/$', LastPostsOnForum(), name='forum_forum_feed'), + re_path(r'^feeds/category/(?P\d+)/$', LastPostsOnCategory(), name='forum_category_feed'), ] ### EXTENSIONS ### @@ -84,19 +84,19 @@ # LOFI Extension if (forum_settings.LOFI_SUPPORT): urlpatterns += [ - url('^lofi/$', forum_views.index, {'full':False}, name='lofi_index'), - url('^(?P\d+)/lofi/$', forum_views.show_forum, {'full':False}, name='lofi_forum'), - url('^topic/(?P\d+)/lofi/$', forum_views.show_topic, {'full':False}, name='lofi_topic'), + re_path('^lofi/$', forum_views.index, {'full':False}, name='lofi_index'), + re_path('^(?P\d+)/lofi/$', forum_views.show_forum, {'full':False}, name='lofi_forum'), + re_path('^topic/(?P\d+)/lofi/$', forum_views.show_topic, {'full':False}, name='lofi_topic'), ] # REPUTATION Extension if (forum_settings.REPUTATION_SUPPORT): urlpatterns += [ - url('^reputation/(?P.*)/$', forum_views.reputation, name='reputation'), + re_path('^reputation/(?P.*)/$', forum_views.reputation, name='reputation'), ] # ATTACHMENT Extension if (forum_settings.ATTACHMENT_SUPPORT): urlpatterns += [ - url('^attachment/(?P\w+)/$', forum_views.show_attachment, name='forum_attachment'), + re_path('^attachment/(?P\w+)/$', forum_views.show_attachment, name='forum_attachment'), ] diff --git a/djangobb_forum/views.py b/djangobb_forum/views.py index 6196ecef..c30a9428 100644 --- a/djangobb_forum/views.py +++ b/djangobb_forum/views.py @@ -16,7 +16,7 @@ from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseForbidden from django.shortcuts import get_object_or_404, render from django.utils.encoding import smart_str -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.csrf import csrf_exempt from django.conf import settings try: From f0944a2309b23415c294c37c27e050584719b720 Mon Sep 17 00:00:00 2001 From: predatell Date: Thu, 1 Sep 2022 18:43:23 +0300 Subject: [PATCH 09/11] gettext instead ugettext --- djangobb_forum/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangobb_forum/apps.py b/djangobb_forum/apps.py index 9c49e230..5640617a 100644 --- a/djangobb_forum/apps.py +++ b/djangobb_forum/apps.py @@ -1,5 +1,5 @@ from django.apps import AppConfig -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class ForumConfig(AppConfig): From e6f3357792a914f4937b8d83a8e2bd1af8566528 Mon Sep 17 00:00:00 2001 From: predatell Date: Wed, 12 Jul 2023 11:41:31 +0300 Subject: [PATCH 10/11] remove postmarkup --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 26a2fa9a..5c57fa35 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ Django>=1.8 django-haystack>=2.4 Pillow>=2.1.0 -postmarkup pygments pytz>=2015.4 From 3b9a6f086352f33cc8d04c3030e5e9e889b99633 Mon Sep 17 00:00:00 2001 From: werty Date: Tue, 5 Sep 2023 21:54:27 +0300 Subject: [PATCH 11/11] bbcode instead postmarkup --- djangobb_forum/util.py | 4 ++-- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/djangobb_forum/util.py b/djangobb_forum/util.py index 703b8bce..fb0b15a2 100644 --- a/djangobb_forum/util.py +++ b/djangobb_forum/util.py @@ -10,7 +10,6 @@ class HTMLParseError(Exception): pass -from postmarkup import render_bbcode from json import JSONEncoder try: import markdown @@ -217,8 +216,9 @@ def set_language(request, language): def convert_text_to_html(text, markup): + import bbcode if markup == 'bbcode': - text = render_bbcode(text) + text = bbcode.render_html(text) elif markup == 'markdown': text = markdown.markdown(text, safe_mode='escape') else: diff --git a/requirements.txt b/requirements.txt index 26a2fa9a..a76ae51a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ Django>=1.8 django-haystack>=2.4 Pillow>=2.1.0 -postmarkup +bbcode pygments pytz>=2015.4