]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
Changes to make it work with django 1.11 and python3
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Tue, 23 Jul 2019 17:45:13 +0000 (17:45 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Tue, 23 Jul 2019 17:45:13 +0000 (17:45 +0000)
16 files changed:
sommitrealweird/blog/admin.py
sommitrealweird/blog/migrations/0002_auto_20190723_1612.py [new file with mode: 0644]
sommitrealweird/bpcms/admin.py
sommitrealweird/bpcms/context_processors.py
sommitrealweird/bpcms/migrations/0002_auto_20190723_1612.py [new file with mode: 0644]
sommitrealweird/bpcms/models.py
sommitrealweird/generic/helpers.py
sommitrealweird/generic/templatetags/xhtml11rst.py
sommitrealweird/manage.py
sommitrealweird/photo/admin.py
sommitrealweird/photo/context_processors.py
sommitrealweird/photo/urls.py
sommitrealweird/photo/views.py
sommitrealweird/settings.py
sommitrealweird/urls.py
templates/base.html

index 88ebb87c49068864b51e0cab203db3830b40625e..daeaa504b54ae57fb9812ccf464bf1b8877bff9d 100644 (file)
@@ -1,4 +1,4 @@
-from models import BlogEntry, BlogSection
+from blog.models import BlogEntry, BlogSection
 from django.contrib import admin
 
 class BlogEntryAdmin(admin.ModelAdmin):
diff --git a/sommitrealweird/blog/migrations/0002_auto_20190723_1612.py b/sommitrealweird/blog/migrations/0002_auto_20190723_1612.py
new file mode 100644 (file)
index 0000000..fd86cdb
--- /dev/null
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.22 on 2019-07-23 16:12
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('blog', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='blogentry',
+            name='format',
+            field=models.CharField(choices=[('rst', 'reStructuredText'), ('html', 'HTML')], max_length=10),
+        ),
+    ]
index cb6d3960be874278fd7524ceb4735b50b7b587e7..972ca068b3729811ff7a6d427cfe5fab614f5e6f 100644 (file)
@@ -1,4 +1,4 @@
-from models import CSSDocument, Document, Folder
+from bpcms.models import CSSDocument, Document, Folder
 from django.contrib import admin
 
 class CSSDocumentAdmin(admin.ModelAdmin):
index 72c335d51e635d17a01253d7b5f5b28561706488..e92e8cef2db13b0bacd88139c687fa12c2ed2dd9 100644 (file)
@@ -33,7 +33,7 @@ def content_menu(request):
                 pass
 
         menu_items.sort( \
-            cmp=lambda x,y: cmp(x['title'].lower(), y['title'].lower()))
+            key=lambda x: x['title'].lower())
         cache.set('bpcms_mainmenu', menu_items, 3600)
 
     return {
@@ -87,7 +87,7 @@ def content_submenu(request):
                     )
 
         menu_items.sort( \
-            cmp=lambda x,y: cmp(x['title'].lower(), y['title'].lower()))
+            key=lambda x: x['title'].lower())
 
         cache.set('bpcms_contentmenu_%s' %("/".join(folderpath)), menu_items)
 
diff --git a/sommitrealweird/bpcms/migrations/0002_auto_20190723_1612.py b/sommitrealweird/bpcms/migrations/0002_auto_20190723_1612.py
new file mode 100644 (file)
index 0000000..4b0e00f
--- /dev/null
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.22 on 2019-07-23 16:12
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('bpcms', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='document',
+            name='extracss',
+            field=models.ManyToManyField(blank=True, to='bpcms.CSSDocument'),
+        ),
+        migrations.AlterField(
+            model_name='document',
+            name='format',
+            field=models.CharField(choices=[('rst', 'reStructuredText'), ('html', 'HTML')], max_length=10),
+        ),
+    ]
index 64939028a26fa30237d7edbf78802c7bc0f2cfdb..5df5a437bff6a78d08f27beb03dfec717f621337 100644 (file)
@@ -23,7 +23,7 @@ class CSSDocument(models.Model):
 class Document(models.Model):
     title = models.CharField(max_length=150)
     islive = models.BooleanField(default=False)
-    extracss = models.ManyToManyField(CSSDocument, null=True, blank=True)
+    extracss = models.ManyToManyField(CSSDocument, blank=True)
     folder = models.ForeignKey('Folder', null=True, blank=True)
     format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
     slug = models.SlugField()
index 6c85aa1a86b77ba38ce49b586a254d6dbe25db45..e095d12c4da1a621cb30b7fb04f611f5d3102321 100644 (file)
@@ -54,7 +54,7 @@ def make_thumbnail(imagefile,width=None,height=None):
                 newimg.save("%sw%d/%s" %(thumbs_dir, width, imagefile))
                 
                 return "%s%s/w%d/%s" %(settings.MEDIA_URL, thumbsdirectory, width, imagefile)
-            except Exception, e:
+            except Exception as e:
                 sys.stderr.write("Got exception: %s" %(e,))
 
     elif height != None:
index 3bc212a4c79f30b7347a6260e8d6cc7ff0966052..6d122ba67d89ef69db035bdc93eff367099a6dc1 100644 (file)
@@ -1,6 +1,6 @@
 from django import template
 from django.conf import settings
-from django.utils.encoding import smart_str, force_unicode
+from django.utils.encoding import smart_bytes, force_text
 from django.utils.safestring import mark_safe
 from generic import docutils_xhtml11
 
@@ -11,12 +11,12 @@ def restructuredtext(value):
         from docutils.core import publish_parts
     except ImportError:
         if settings.DEBUG:
-            raise template.TemplateSyntaxError, "Error in {% restructuredtext %} filter: The Python docutils library isn't installed."
-        return force_unicode(value)
+            raise template.TemplateSyntaxError("Error in {% restructuredtext %} filter: The Python docutils library isn't installed.")
+        return force_text(value)
     else:
         docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
-        parts = publish_parts(source=smart_str(value), writer=docutils_xhtml11.Writer(), settings_overrides=docutils_settings)
-        return mark_safe(force_unicode(parts["fragment"]))
+        parts = publish_parts(source=smart_bytes(value), writer=docutils_xhtml11.Writer(), settings_overrides=docutils_settings)
+        return mark_safe(force_text(parts["fragment"]))
 restructuredtext.is_safe = True
 
 register.filter(restructuredtext)
index f9726f9e67d10a596ac6efaeb114a6c479fa24ca..4eb6f348a4764c6267d6dec9d17a60fdb2515faa 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import os
 import sys
 
index 6f71cbe91c6ccba4660a8a3d306217f7ef80b747..5a7ae2fb07c78ecf1919a5a3e6a84130eb21ba1f 100644 (file)
@@ -1,4 +1,4 @@
-from models import Album, Photo
+from photo.models import Album, Photo
 from django.contrib import admin
 
 class AlbumAdmin(admin.ModelAdmin):
index b00e5e113c4550a7b4298fa8b09cc2a5dd0d8eae..74e4f8f4d2a28234e11f06271900ca226b9773b7 100644 (file)
@@ -1,5 +1,5 @@
 from django.conf import settings
-from models import Album, Photo
+from photo.models import Album, Photo
 import re
 
 def content_breadcrumb(request):
index d5666e586103114c61938792e935b09efaa72a36..3e9d28c6c921179c82a6ce128098d4c685c20571 100644 (file)
@@ -1,6 +1,6 @@
 from django.conf.urls import url
-from models import Album
-from views import AlbumListView, PhotoListView, PhotoView
+from photo.models import Album
+from photo.views import AlbumListView, PhotoListView, PhotoView
 
 urlpatterns = [
     url(r'^$', AlbumListView.as_view()),
index 8501a6fef06677a1f74242a031f1912622a20832..fea7dd3750785654e2728d88d2a15771d1dadf87 100644 (file)
@@ -1,6 +1,6 @@
 from django.views.generic import ListView, DetailView
 from django.http import Http404
-from models import Album, Photo
+from photo.models import Album, Photo
 
 class AlbumListView(ListView):
     model = Album
index 70594da3096d7a5ff2c51baf8121f3864c086549..67b8f32b369f57abdd147862443ae3edb8ac4e88 100644 (file)
@@ -40,11 +40,12 @@ 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_URL = '/static/'
 
 import random
 import string
-key_chars = "%s%s%s" % (string.letters, string.digits, '+-()_#~')
+key_chars = "%s%s%s" % (string.ascii_letters, string.digits, '+-()_#~')
 SECRET_KEY = [random.choice(key_chars) for a in range(0,50)]
 
 CACHES = {
@@ -73,6 +74,7 @@ TEMPLATES = [
         'OPTIONS': {
             'context_processors': [
                 'django.contrib.auth.context_processors.auth',
+                'django.contrib.messages.context_processors.messages',
                 'django.template.context_processors.debug',
                 'django.template.context_processors.i18n',
                 'django.template.context_processors.media',
index 0a4b5f3a2c36d9d27e9eb3b446b3812f8a7b7550..6e7cf994fb33567c2b83f830bfa3cc17e9b6e0c4 100644 (file)
@@ -2,7 +2,7 @@ from django.conf.urls import include, url
 from django.conf.urls.static import static
 import bpcms.views
 import django.views.static
-from settings import MEDIA_ROOT, MEDIA_URL, STATIC_URL
+from settings import MEDIA_ROOT, MEDIA_URL, STATIC_ROOT, STATIC_URL
 from blog.feeds import LatestBlogEntries, LatestBlogEntriesRss
 from django.contrib import admin
 
@@ -25,7 +25,8 @@ urlpatterns = [
     # 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'^admin/', include(admin.site.urls)),
+    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')),
     #url(r'^photos/', include('photo.urls')),
@@ -33,4 +34,4 @@ urlpatterns = [
     url(r'^feeds/rss/blog/', LatestBlogEntriesRss()),
     url(r'^feeds/blog/', LatestBlogEntries()),
     url(r'^', include('bpcms.urls'))
-] + static(STATIC_URL, document_root=MEDIA_ROOT)
+]
index 552a510eb35e57fc0b77880f4470fb49d7a04f6a..eacc07e432fe9f08b4a0da82afccfb555e9f6afb 100644 (file)
@@ -3,7 +3,8 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
     <head>
         <title>{% block title %}{{ title }}{% endblock %}</title>
-        <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}style/main.css" />
+       {% load static %}
+        <link rel="stylesheet" type="text/css" href="{% get_media_prefix %}style/main.css" />
         {% block extrahead %}{% endblock %}
     </head>
     <body>