]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
Initial port to django-1.7
authorBrett Parker <brettp@mythic-beasts.com>
Fri, 22 May 2015 15:18:32 +0000 (16:18 +0100)
committerBrett Parker <brettp@mythic-beasts.com>
Fri, 22 May 2015 15:18:32 +0000 (16:18 +0100)
sommitrealweird/blog/models.py
sommitrealweird/blog/urls.py
sommitrealweird/bpcms/context_processors.py
sommitrealweird/bpcms/models.py
sommitrealweird/bpcms/urls.py
sommitrealweird/manage.py
sommitrealweird/photo/templates/photo/album_list.html [moved from sommitrealweird/photo/templates/photo/album_index.html with 94% similarity]
sommitrealweird/photo/urls.py
sommitrealweird/photo/views.py
sommitrealweird/settings.py
sommitrealweird/urls.py

index f76de3080a29322905960213437ff166333cba37..fa2e954f49e8319a031b93a3ea5174c758eab730 100644 (file)
@@ -10,7 +10,7 @@ FORMAT_CHOICES = (
 
 class BlogEntry(models.Model):
     title = models.CharField(max_length=150)
-    islive = models.BooleanField()
+    islive = models.BooleanField(default=False)
     sections = models.ManyToManyField('BlogSection')
     format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
     slug = models.SlugField()
index 2ec24bd5da34fa2c9dc9103a25e5e07d47e43ee5..19678eb6d1c31bc23f62ecfb67c86c4229e2e8f8 100644 (file)
@@ -1,4 +1,4 @@
-from django.conf.urls.defaults import *
+from django.conf.urls import patterns
 from settings import MEDIA_ROOT, MEDIA_URL
 
 urlpatterns = patterns('',
index bf0b8f2400383ae950776737d38c9ce03a712685..2df38ae886c5bea4492c633be356b4c73c004a35 100644 (file)
@@ -2,14 +2,20 @@ from bpcms.models import Document, Folder
 from django.conf import settings
 from django.core.cache import cache
 import re
+import sys
 
 def content_menu(request):
+
+    print >>sys.stderr, "Trying to get menu items from cache"
+
     menu_items = cache.get('bpcms_mainmenu')
 
     if not menu_items:
+        print >>sys.stderr, "Generating menu items"
         items = Document.objects.filter(folder__isnull=True, islive__exact=True)
         menu_items = []
         for item in items:
+            print >>sys.stderr, "Found: %s" %(item.slug)
             if item.slug != 'index':
                 menu_items.append(
                     {
@@ -17,8 +23,11 @@ def content_menu(request):
                         'url': item.get_absolute_url(),
                     }
                 )
+        print >>sys.stderr, "Now looking for folders"
         folders = Folder.objects.filter(parent__isnull=True)
         for folder in folders:
+            print >>sys.stderr, "Found: %s" %(folder)
+            print >>sys.stderr, "folder path: %s" %(folder.get_absolute_url())
             try:
                 items = Document.objects.filter(folder__exact=folder, islive__exact=True, slug__exact='index')
                 item = items[0]
@@ -29,6 +38,7 @@ def content_menu(request):
                     }
                 )
             except:
+                print >>sys.stderr, "Failed to add: %s" %(folder)
                 pass
 
         menu_items.sort( \
index 0cb821bdfdd80a2b55054cc76b7a22727f6a424e..38f18ffe47b400d68327ebcf73535d3fbb0130cd 100644 (file)
@@ -22,7 +22,7 @@ class CSSDocument(models.Model):
 
 class Document(models.Model):
     title = models.CharField(max_length=150)
-    islive = models.BooleanField()
+    islive = models.BooleanField(default=False)
     extracss = models.ManyToManyField(CSSDocument, null=True, blank=True)
     folder = models.ForeignKey('Folder', null=True, blank=True)
     format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
index d29225af7e0dc49a1e3a10c70d32d474f1c4b02b..2d24d30236124a39ba983a142485b243b6a51da2 100644 (file)
@@ -1,8 +1,8 @@
-from django.conf.urls.defaults import *
+from django.conf.urls import patterns
 
 urlpatterns = patterns('',
     (r'^$', 'bpcms.views.document_view', {'slug': 'index'}),
-    (r'^css-docs/(?P<slug>.*)$', 'bpcms.views.css_view'),
+    (r'^css-docs/(?P<slug>[^/]+)$', 'bpcms.views.css_view'),
     (r'^(?P<slug>[^/]+)/$', 'bpcms.views.document_view'),
     (r'^(?P<folders>.*)/(?P<slug>[^/]+)/$', 'bpcms.views.document_view'),
 )
index bcdd55e27be9447bf6b224b8ba0cbc6802509862..f9726f9e67d10a596ac6efaeb114a6c479fa24ca 100755 (executable)
@@ -1,11 +1,10 @@
-#!/usr/bin/python
-from django.core.management import execute_manager
-try:
-    import settings # Assumed to be in the same directory.
-except ImportError:
-    import sys
-    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
-    sys.exit(1)
+#!/usr/bin/env python
+import os
+import sys
 
 if __name__ == "__main__":
-    execute_manager(settings)
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
+
+    from django.core.management import execute_from_command_line
+
+    execute_from_command_line(sys.argv)
similarity index 94%
rename from sommitrealweird/photo/templates/photo/album_index.html
rename to sommitrealweird/photo/templates/photo/album_list.html
index beaeacbd6300333795079ec794917138bc0528dc..ab5ae6ce2445e31c695864dfe817f2792dfd5abe 100644 (file)
@@ -32,8 +32,8 @@
                 {% else %}
                     |
                 {% endif %}
-                {% ifequal paginator_page page %}
-                    {{ page }}
+                {% ifequal paginator_page page_obj.number %}
+                    {{ paginator_page }}
                 {% else %}
                     <a href="?page={{ paginator_page }}">{{ paginator_page }}</a>
                 {% endifequal %}
index 12c8dfbba02250291d6abe4c8bac933af24aaf26..dbea64f99eca4e3d7560208fba04d33b857e1fbc 100644 (file)
@@ -1,8 +1,9 @@
-from django.conf.urls.defaults import *
+from django.conf.urls import url
 from models import Album
+from views import AlbumListView
 
-urlpatterns = patterns('',
-    (r'^$', 'django.views.generic.list_detail.object_list', { "paginate_by": 20, "queryset": Album.objects.all().order_by('name').reverse(), "template_name": "photo/album_index.html"}),
-    (r'^(?P<slug>[^/]*)/$', 'photo.views.album_view'),
-    (r'^(?P<slug>[^/]*)/(?P<id>[0-9]+)/$', 'photo.views.photo_view'),
-)
+urlpatterns = [
+    url(r'^$', AlbumListView.as_view()),
+    url(r'^(?P<slug>[^/]*)/$', 'photo.views.album_view'),
+    url(r'^(?P<slug>[^/]*)/(?P<id>[0-9]+)/$', 'photo.views.photo_view'),
+]
index 02d80e67be0435a7dd04554ac6f9cc5b5b7be9f6..77b4dd88c9e14134de991c1cc28c74de2557a623 100644 (file)
@@ -1,7 +1,16 @@
-import django.views.generic.list_detail
+from django.views.generic import ListView
 from django.http import Http404
 from models import Album, Photo
 
+class AlbumListView(ListView):
+    model = Album
+    queryset = Album.objects.order_by('-name')
+    paginate_by = 20
+
+    def get_context_data(self, **kwargs):
+        context = super(AlbumListView, self).get_context_data(**kwargs)
+        return context
+
 def album_view(request, slug):
     try:
         album = Album.objects.get(slug__exact=slug)
index 95ead0af9503abad2d07062952eb71ac66b1076c..497cad1c73e48ba2d872a9e8eb33c7919a04cd83 100644 (file)
@@ -26,6 +26,8 @@ LANGUAGE_CODE = 'en-gb'
 
 SITE_ID = 1
 
+TEST_RUNNER = 'django.test.runner.DiscoverRunner'
+
 # If you set this to False, Django will make some optimizations so as not
 # to load the internationalization machinery.
 USE_I18N = True
@@ -58,7 +60,7 @@ MIDDLEWARE_CLASSES = (
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
-    'django.middleware.doc.XViewMiddleware',
+    'django.contrib.admindocs.middleware.XViewMiddleware',
 )
 
 ROOT_URLCONF = 'urls'
@@ -73,7 +75,6 @@ INSTALLED_APPS = (
     'django.contrib.sessions',
     'django.contrib.sites',
     'django.contrib.admin',
-    'django.contrib.markup',
     'django.contrib.comments',
     'bpcms',
     'generic',
index 2aaf73df89820e2b37a9a5ed59d1586c7dde3961..6c9c00621bbc13a04da8bc5581d79bb6c1e2b5ac 100644 (file)
@@ -1,4 +1,5 @@
-from django.conf.urls.defaults import *
+from django.conf.urls import include, url
+from django.conf.urls.static import static
 from settings import MEDIA_ROOT, MEDIA_URL
 from blog.feeds import LatestBlogEntries, LatestBlogEntriesRss
 from django.contrib import admin
@@ -15,20 +16,20 @@ rssfeeds_dict = {
 
 admin.autodiscover()
 
-urlpatterns = patterns('',
+urlpatterns = [
     # Example:
     # (r'^sommitrealweird/', include('sommitrealweird.foo.urls')),
 
     # Uncomment this for admin:
-    (r'^$', 'bpcms.views.document_view', {'slug': 'index'}),
-    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': MEDIA_ROOT, 'show_indexes': True}),
-    (r'^admin/', include(admin.site.urls)),
-    (r'^blog/', include('blog.urls')),
-    (r'^photo/', include('photo.urls')),
-    (r'^photos/', include('photo.urls')),
-    (r'^css-doc/(?P<slug>.*)$', 'bpcms.views.css_view'),
-    (r'^feeds/rss/blog/', LatestBlogEntriesRss()),
-    (r'^feeds/blog/', LatestBlogEntries()),
-    (r'^comments/', include('django.contrib.comments.urls')),
-    (r'^(?:content/|)', include('bpcms.urls'))
-)
+    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'^blog/', include('blog.urls')),
+    url(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'^comments/', include('django.contrib.comments.urls')),
+    url(r'^', include('bpcms.urls'))
+] + static(MEDIA_URL, MEDIA_ROOT)