]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
fix: quick and dirty update to django 4.2
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Wed, 25 Oct 2023 09:14:06 +0000 (10:14 +0100)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Wed, 25 Oct 2023 09:14:06 +0000 (10:14 +0100)
13 files changed:
sommitrealweird/blog/migrations/0003_alter_blogentry_id_alter_blogsection_id.py [new file with mode: 0644]
sommitrealweird/blog/templates/blog/blog_index.html
sommitrealweird/blog/urls.py
sommitrealweird/bpcms/context_processors.py
sommitrealweird/bpcms/migrations/0003_alter_cssdocument_id_alter_document_folder_and_more.py [new file with mode: 0644]
sommitrealweird/bpcms/urls.py
sommitrealweird/generic/templatetags/xhtml11rst.py
sommitrealweird/photo/migrations/0002_alter_album_id_alter_photo_id.py [new file with mode: 0644]
sommitrealweird/photo/templates/photo/album_list.html
sommitrealweird/photo/templates/photo/photo_list.html
sommitrealweird/photo/urls.py
sommitrealweird/settings.py
sommitrealweird/urls.py

diff --git a/sommitrealweird/blog/migrations/0003_alter_blogentry_id_alter_blogsection_id.py b/sommitrealweird/blog/migrations/0003_alter_blogentry_id_alter_blogsection_id.py
new file mode 100644 (file)
index 0000000..ae77d7c
--- /dev/null
@@ -0,0 +1,23 @@
+# Generated by Django 4.2.6 on 2023-10-25 09:33
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('blog', '0002_auto_20190723_1612'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='blogentry',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+        ),
+        migrations.AlterField(
+            model_name='blogsection',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+        ),
+    ]
index f2ede847ed3117dfc7a9e1b96c191d6c1e67bad5..1773278128bd19f0290a9a6f09aba24df70e9b99 100644 (file)
                 {% else %}
                     |
                 {% endif %}
-                {% ifequal paginator_page page %}
+                {% if paginator_page == page %}
                     {{ page }}
                 {% else %}
                     <a href="?page={{ paginator_page }}">{{ paginator_page }}</a>
-                {% endifequal %}
+                {% endif %}
             {% endfor %}
             {% if has_next %}
                 | <a href="?page={{ next }}">Next</a>
index eeeb25be827f69b892a6aeea1c58641faf260309..7ce99ef3885fcc285cc367742b490478baca5982 100644 (file)
@@ -1,14 +1,14 @@
-from django.conf.urls import url
+from django.urls import re_path
 import blog.views
 from settings import MEDIA_ROOT, MEDIA_URL
 
 urlpatterns = [
-    url(r'^(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/(?P<slug>[^/]+)(/|)$', blog.views.blog_view),
-    url(r'^(?P<year>[0-9]{4})(?P<month>[0-9]{2})(?P<day>[0-9]{2})-(?P<slug>[^/]+)\.html$', blog.views.blog_view),
-    url(r'^(?P<year>[0-9]{4})(?P<month>[0-9]{2})(?P<day>[0-9]{2})(?P<hour>[0-9]{2})(?P<minutes>[0-9]{2})-(?P<slug>[^/]+)\.html$', blog.views.blog_view),
-    url(r'^(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$', blog.views.blog_view),
-    url(r'^(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', blog.views.blog_view),
-    url(r'^(?P<year>[0-9]{4})/$', blog.views.blog_view),
-    url(r'^section/(?P<section>[^/]*)/$', blog.views.blog_index),
-    url(r'^$', blog.views.blog_index),
+    re_path(r'^(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/(?P<slug>[^/]+)(/|)$', blog.views.blog_view),
+    re_path(r'^(?P<year>[0-9]{4})(?P<month>[0-9]{2})(?P<day>[0-9]{2})-(?P<slug>[^/]+)\.html$', blog.views.blog_view),
+    re_path(r'^(?P<year>[0-9]{4})(?P<month>[0-9]{2})(?P<day>[0-9]{2})(?P<hour>[0-9]{2})(?P<minutes>[0-9]{2})-(?P<slug>[^/]+)\.html$', blog.views.blog_view),
+    re_path(r'^(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$', blog.views.blog_view),
+    re_path(r'^(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', blog.views.blog_view),
+    re_path(r'^(?P<year>[0-9]{4})/$', blog.views.blog_view),
+    re_path(r'^section/(?P<section>[^/]*)/$', blog.views.blog_index),
+    re_path(r'^$', blog.views.blog_index),
 ]
index e92e8cef2db13b0bacd88139c687fa12c2ed2dd9..1d254b1b1f063ab4b13f5b29d43361a80ea1abcb 100644 (file)
@@ -44,9 +44,16 @@ def content_submenu(request):
     # find where we are in the tree first
     folderpath = request.path
     folderpath = re.sub(u'^%s' %(settings.BPCMS_ROOT), '', folderpath)
+
     # right - that should be any prefix got rid of, now traverse the tree till
     # we've got something
-    menu_items = cache.get('bpcms_contentmenu_%s' %(folderpath))
+    try:
+        menu_items = cache.get('bpcms_contentmenu_%s' %(folderpath))
+    except:
+        # fail on cache engine or bad key, ignore
+        return {
+            'content_submenu': {},
+        }
 
     if not menu_items:
         folder = None
diff --git a/sommitrealweird/bpcms/migrations/0003_alter_cssdocument_id_alter_document_folder_and_more.py b/sommitrealweird/bpcms/migrations/0003_alter_cssdocument_id_alter_document_folder_and_more.py
new file mode 100644 (file)
index 0000000..7a6220d
--- /dev/null
@@ -0,0 +1,39 @@
+# Generated by Django 4.2.6 on 2023-10-25 09:33
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('bpcms', '0002_auto_20190723_1612'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='cssdocument',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+        ),
+        migrations.AlterField(
+            model_name='document',
+            name='folder',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='bpcms.folder'),
+        ),
+        migrations.AlterField(
+            model_name='document',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+        ),
+        migrations.AlterField(
+            model_name='folder',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+        ),
+        migrations.AlterField(
+            model_name='folder',
+            name='parent',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='bpcms.folder'),
+        ),
+    ]
index 1a9111f3183e406acef207b3a789071414a80a06..264af0ab5c9ba482c67e1facb7a6a1c57f4b65d3 100644 (file)
@@ -1,10 +1,10 @@
-from django.conf.urls import url
+from django.urls import re_path
 import bpcms.views
 
 urlpatterns = [
-    url(r'^$', bpcms.views.document_view, {'slug': 'index'}, name='bpcms-document-view'),
-    url(r'^css-docs/(?P<slug>[^/]+)$', bpcms.views.css_view),
-    url(r'^(?P<slug>[^/]+)/$', bpcms.views.document_view, name='bpcms-document-view'),
-    url(r'^(?P<folders>.*)/(?P<slug>[^/]+)/$', bpcms.views.document_view, name='bpcms-document-view'),
+    re_path(r'^$', bpcms.views.document_view, {'slug': 'index'}, name='bpcms-document-view'),
+    re_path(r'^css-docs/(?P<slug>[^/]+)$', bpcms.views.css_view),
+    re_path(r'^(?P<slug>[^/]+)/$', bpcms.views.document_view, name='bpcms-document-view'),
+    re_path(r'^(?P<folders>.*)/(?P<slug>[^/]+)/$', bpcms.views.document_view, name='bpcms-document-view'),
 ]
 
index 6d122ba67d89ef69db035bdc93eff367099a6dc1..c3621d4faa67a357990f073564efcaf87059a85c 100644 (file)
@@ -1,6 +1,6 @@
 from django import template
 from django.conf import settings
-from django.utils.encoding import smart_bytes, force_text
+from django.utils.encoding import smart_bytes, force_str
 from django.utils.safestring import mark_safe
 from generic import docutils_xhtml11
 
@@ -12,11 +12,11 @@ def restructuredtext(value):
     except ImportError:
         if settings.DEBUG:
             raise template.TemplateSyntaxError("Error in {% restructuredtext %} filter: The Python docutils library isn't installed.")
-        return force_text(value)
+        return force_str(value)
     else:
         docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
         parts = publish_parts(source=smart_bytes(value), writer=docutils_xhtml11.Writer(), settings_overrides=docutils_settings)
-        return mark_safe(force_text(parts["fragment"]))
+        return mark_safe(force_str(parts["fragment"]))
 restructuredtext.is_safe = True
 
 register.filter(restructuredtext)
diff --git a/sommitrealweird/photo/migrations/0002_alter_album_id_alter_photo_id.py b/sommitrealweird/photo/migrations/0002_alter_album_id_alter_photo_id.py
new file mode 100644 (file)
index 0000000..1d15883
--- /dev/null
@@ -0,0 +1,23 @@
+# Generated by Django 4.2.6 on 2023-10-25 09:33
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('photo', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='album',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+        ),
+        migrations.AlterField(
+            model_name='photo',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+        ),
+    ]
index ab5ae6ce2445e31c695864dfe817f2792dfd5abe..9314827e4cc9764cc95758185b6febd77402d6f3 100644 (file)
                 {% else %}
                     |
                 {% endif %}
-                {% ifequal paginator_page page_obj.number %}
+                {% if paginator_page == page_obj.number %}
                     {{ paginator_page }}
                 {% else %}
                     <a href="?page={{ paginator_page }}">{{ paginator_page }}</a>
-                {% endifequal %}
+                {% endif %}
             {% endfor %}
             {% if page_obj.has_next %}
                 | <a href="?page={{ page_obj.next_page_number }}">Next</a>
index 558124307560aeedf937ad8a4acfd9abf3a936dd..8ccd2dda7fdb974d057608199a05c6e1e540da1a 100644 (file)
                 {% else %}
                     |
                 {% endif %}
-                {% ifequal paginator_page page_obj.number %}
+                {% if paginator_page == page_obj.number %}
                     {{ paginator_page }}
                 {% else %}
                     <a href="?page={{ paginator_page }}">{{ paginator_page }}</a>
-                {% endifequal %}
+                {% endif %}
             {% endfor %}
             {% if page_obj.has_next %}
                 | <a href="?page={{ page_obj.next_page_number }}">Next</a>
index 3e9d28c6c921179c82a6ce128098d4c685c20571..c5de1db56b170bedfb9432ecc7f38d478009141d 100644 (file)
@@ -1,9 +1,9 @@
-from django.conf.urls import url
+from django.urls import re_path
 from photo.models import Album
 from photo.views import AlbumListView, PhotoListView, PhotoView
 
 urlpatterns = [
-    url(r'^$', AlbumListView.as_view()),
-    url(r'^(?P<slug>[^/]*)/$', PhotoListView.as_view()),
-    url(r'^(?P<slug>[^/]*)/(?P<id>[0-9]+)/$', PhotoView.as_view()),
+    re_path(r'^$', AlbumListView.as_view()),
+    re_path(r'^(?P<slug>[^/]*)/$', PhotoListView.as_view()),
+    re_path(r'^(?P<slug>[^/]*)/(?P<id>[0-9]+)/$', PhotoView.as_view()),
 ]
index 6eb539f2723bcc04c962b62c984cecbd68bbab75..0f8dae97106036169c75c64066a1af9d4a3c6f58 100644 (file)
@@ -15,6 +15,8 @@ ALLOWED_HOSTS = [
     "www.sommitrealweird.co.uk",
     "www.sommitrealweird.co.uk.",
     "10.0.3.191",
+    "127.0.0.1",
+    "localhost",
 ]
 
 MANAGERS = ADMINS
@@ -26,6 +28,11 @@ DATABASES = {
     }
 }
 
+DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
+
+DEBUG = True
+
+
 TIME_ZONE = 'Europe/London'
 
 LANGUAGE_CODE = 'en-gb'
@@ -41,7 +48,7 @@ USE_I18N = True
 MEDIA_ROOT = os.path.join(topdir, 'media') + os.sep
 MEDIA_URL = '/media/'
 
-STATIC_ROOT = '/usr/lib/python3/dist-packages/django/contrib/admin/static/'
+STATIC_ROOT = '/home/brettp/python-envs/django/lib/python3.11/site-packages/django/contrib/admin/static/'
 STATIC_URL = '/static/'
 
 import random
@@ -62,7 +69,6 @@ MIDDLEWARE = (
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
-    'django.contrib.admindocs.middleware.XViewMiddleware',
 )
 
 ROOT_URLCONF = 'urls'
@@ -74,6 +80,7 @@ TEMPLATES = [
         'APP_DIRS': True,
         'OPTIONS': {
             'context_processors': [
+                'django.template.context_processors.request',
                 'django.contrib.auth.context_processors.auth',
                 'django.contrib.messages.context_processors.messages',
                 'django.template.context_processors.debug',
index 6e7cf994fb33567c2b83f830bfa3cc17e9b6e0c4..73137930f7948749e5578e9f9a495046bcff7fe3 100644 (file)
@@ -1,4 +1,4 @@
-from django.conf.urls import include, url
+from django.urls import include, re_path
 from django.conf.urls.static import static
 import bpcms.views
 import django.views.static
@@ -23,15 +23,15 @@ urlpatterns = [
     # (r'^sommitrealweird/', include('sommitrealweird.foo.urls')),
 
     # Uncomment this for admin:
-    url(r'^$', bpcms.views.document_view, {'slug': 'index'}),
-    url(r'^media/(?P<path>.*)$', django.views.static.serve, {'document_root': MEDIA_ROOT, 'show_indexes': True}),
-    url(r'^static/(?P<path>.*)$', django.views.static.serve, {'document_root': STATIC_ROOT, 'show_indexes': True}),
-    url(r'^admin/', admin.site.urls),
-    url(r'^blog/', include('blog.urls')),
-    url(r'^photo/', include('photo.urls')),
+    re_path(r'^$', bpcms.views.document_view, {'slug': 'index'}),
+    re_path(r'^media/(?P<path>.*)$', django.views.static.serve, {'document_root': MEDIA_ROOT, 'show_indexes': True}),
+    re_path(r'^static/(?P<path>.*)$', django.views.static.serve, {'document_root': STATIC_ROOT, 'show_indexes': True}),
+    re_path(r'^admin/', admin.site.urls),
+    re_path(r'^blog/', include('blog.urls')),
+    re_path(r'^photo/', include('photo.urls')),
     #url(r'^photos/', include('photo.urls')),
-    url(r'^css-doc/(?P<slug>.*)$', bpcms.views.css_view),
-    url(r'^feeds/rss/blog/', LatestBlogEntriesRss()),
-    url(r'^feeds/blog/', LatestBlogEntries()),
-    url(r'^', include('bpcms.urls'))
+    re_path(r'^css-doc/(?P<slug>.*)$', bpcms.views.css_view),
+    re_path(r'^feeds/rss/blog/', LatestBlogEntriesRss()),
+    re_path(r'^feeds/blog/', LatestBlogEntries()),
+    re_path(r'^', include('bpcms.urls'))
 ]