From c4ca6c62fbc28fc81a472b1917c36af4228a6d32 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Tue, 14 Feb 2017 15:45:45 +0100 Subject: [PATCH] django 1.9 --- .../templates/catalogue/document_list.html | 18 -- apps/catalogue/urls.py | 40 ++-- apps/catalogue/views.py | 6 - apps/forms_builder/forms/admin.py | 12 +- apps/forms_builder/forms/urls.py | 11 +- apps/organizations/urls.py | 5 +- apps/wiki/urls.py | 24 +-- redakcja/settings/common.py | 39 ++-- redakcja/settings/compress.py | 196 +++++++++--------- redakcja/urls.py | 36 ++-- requirements.txt | 6 +- 11 files changed, 176 insertions(+), 217 deletions(-) delete mode 100644 apps/catalogue/templates/catalogue/document_list.html diff --git a/apps/catalogue/templates/catalogue/document_list.html b/apps/catalogue/templates/catalogue/document_list.html deleted file mode 100644 index 294c6299..00000000 --- a/apps/catalogue/templates/catalogue/document_list.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "catalogue/base.html" %} - -{% load i18n %} -{% load catalogue book_list %} -{% load compressed %} - - -{% block add_js %} -{% compressed_js 'book_list' %} -{% endblock %} - -{% block add_css %} -{% compressed_css 'book_list' %} -{% endblock %} - -{% block content %} - {% book_list %} -{% endblock content %} diff --git a/apps/catalogue/urls.py b/apps/catalogue/urls.py index 2a306e53..19b9d0b1 100644 --- a/apps/catalogue/urls.py +++ b/apps/catalogue/urls.py @@ -1,38 +1,38 @@ # -*- coding: utf-8 -from django.conf.urls import patterns, url +from django.conf.urls import url from django.contrib.auth.decorators import login_required from catalogue.views import GalleryView +from catalogue import views -urlpatterns = patterns( - 'catalogue.views', +urlpatterns = ( # url(r'^$', RedirectView.as_view(url='catalogue/')), - url(r'^upcoming/$', 'upcoming', name='catalogue_upcoming'), - url(r'^finished/$', 'finished', name='catalogue_finished'), + url(r'^upcoming/$', views.upcoming, name='catalogue_upcoming'), + url(r'^finished/$', views.finished, name='catalogue_finished'), - url(r'^user/$', 'my', name='catalogue_user'), - url(r'^user/(?P[^/]+)/$', 'user', name='catalogue_user'), + url(r'^user/$', views.my, name='catalogue_user'), + url(r'^user/(?P[^/]+)/$', views.user, name='catalogue_user'), url(r'^create/', - 'create_missing', name='catalogue_create_missing'), + views.create_missing, name='catalogue_create_missing'), url(r'^fork/(?P\d+)/', - 'fork', name='catalogue_fork'), + views.fork, name='catalogue_fork'), - url(r'^doc/(?P\d+)/publish$', 'publish', name="catalogue_publish"), - url(r'^doc/(?P\d+)/unpublish$', 'unpublish', name="catalogue_unpublish"), + url(r'^doc/(?P\d+)/publish$', views.publish, name="catalogue_publish"), + url(r'^doc/(?P\d+)/unpublish$', views.unpublish, name="catalogue_unpublish"), - url(r'^(?P[^/]+)/schedule/$', 'book_schedule', name="catalogue_book_schedule"), - url(r'^(?P[^/]+)/owner/$', 'book_owner', name="catalogue_book_owner"), - url(r'^(?P[^/]+)/delete/$', 'book_delete', name="catalogue_book_delete"), + url(r'^(?P[^/]+)/schedule/$', views.book_schedule, name="catalogue_book_schedule"), + url(r'^(?P[^/]+)/owner/$', views.book_owner, name="catalogue_book_owner"), + url(r'^(?P[^/]+)/delete/$', views.book_delete, name="catalogue_book_delete"), url(r'^(?P[^/]+)/attachments/$', login_required()(GalleryView.as_view()), name="catalogue_book_gallery"), - url(r'^(?P\d+)/$', 'book_html', name="catalogue_html"), - url(r'^(?P\d+)/preview/$', 'book_html', {'preview': True}, name="catalogue_preview"), - url(r'^(?P\d+)/rev(?P\d+)/preview/$', 'book_html', {'preview': True}, name="catalogue_preview_rev"), - url(r'^(?P\d+)/rev(?P\d+)/pdf/$', 'book_pdf', name="catalogue_pdf"), - url(r'^(?P\d+)/rev(?P\d+)/epub/$', 'book_epub', name="catalogue_epub"), - url(r'^(?P\d+)/rev(?P\d+)/mobi/$', 'book_mobi', name="catalogue_mobi"), + url(r'^(?P\d+)/$', views.book_html, name="catalogue_html"), + url(r'^(?P\d+)/preview/$', views.book_html, {'preview': True}, name="catalogue_preview"), + url(r'^(?P\d+)/rev(?P\d+)/preview/$', views.book_html, {'preview': True}, name="catalogue_preview_rev"), + url(r'^(?P\d+)/rev(?P\d+)/pdf/$', views.book_pdf, name="catalogue_pdf"), + url(r'^(?P\d+)/rev(?P\d+)/epub/$', views.book_epub, name="catalogue_epub"), + url(r'^(?P\d+)/rev(?P\d+)/mobi/$', views.book_mobi, name="catalogue_mobi"), ) diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index fc06c2cf..b8b6b89e 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -43,12 +43,6 @@ from django.views.decorators.cache import never_cache logger = logging.getLogger("fnp.catalogue") -@active_tab('all') -@never_cache -def document_list(request): - return render(request, 'catalogue/document_list.html') - - @never_cache def user(request, username): user = get_object_or_404(User, username=username) diff --git a/apps/forms_builder/forms/admin.py b/apps/forms_builder/forms/admin.py index 61a6d0b9..e1dd26df 100644 --- a/apps/forms_builder/forms/admin.py +++ b/apps/forms_builder/forms/admin.py @@ -84,20 +84,20 @@ class FormAdmin(admin.ModelAdmin): Add the entries view to urls. """ urls = super(FormAdmin, self).get_urls() - extra_urls = patterns("", - url("^(?P\d+)/entries/$", + extra_urls = [ + url(r"^(?P\d+)/entries/$", self.admin_site.admin_view(self.entries_view), name="form_entries"), - url("^(?P\d+)/entries/show/$", + url(r"^(?P\d+)/entries/show/$", self.admin_site.admin_view(self.entries_view), {"show": True}, name="form_entries_show"), - url("^(?P\d+)/entries/export/$", + url(r"^(?P\d+)/entries/export/$", self.admin_site.admin_view(self.entries_view), {"export": True}, name="form_entries_export"), - url("^file/(?P\d+)/$", + url(r"^file/(?P\d+)/$", self.admin_site.admin_view(self.file_view), name="form_file"), - ) + ] return extra_urls + urls def entries_view(self, request, form_id, show=False, export=False, diff --git a/apps/forms_builder/forms/urls.py b/apps/forms_builder/forms/urls.py index ead64268..b68654ad 100644 --- a/apps/forms_builder/forms/urls.py +++ b/apps/forms_builder/forms/urls.py @@ -1,9 +1,12 @@ +# -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.conf.urls import patterns, url +from django.conf.urls import url +from forms_builder.forms import views -urlpatterns = patterns("forms_builder.forms.views", - url(r"(?P.*)/sent/$", "form_sent", name="form_sent"), - url(r"(?P.*)/$", "form_detail", name="form_detail"), + +urlpatterns = ( + url(r"(?P.*)/sent/$", views.form_sent, name="form_sent"), + url(r"(?P.*)/$", views.form_detail, name="form_detail"), ) diff --git a/apps/organizations/urls.py b/apps/organizations/urls.py index 33945f16..507bc8c8 100644 --- a/apps/organizations/urls.py +++ b/apps/organizations/urls.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -from django.conf.urls import patterns, url +from django.conf.urls import url from organizations import views -urlpatterns = patterns( - '', +urlpatterns = ( url(r'^$', views.organizations, name="organizations"), url(r'^new/$', views.org_new, name="organizations_new"), url(r'^(?P\d+)/$', views.main, name="organizations_main"), diff --git a/apps/wiki/urls.py b/apps/wiki/urls.py index 69472103..40e1d502 100644 --- a/apps/wiki/urls.py +++ b/apps/wiki/urls.py @@ -1,23 +1,17 @@ # -*- coding: utf-8 -from django.conf.urls import patterns, url +from django.conf.urls import url +from wiki import views +urlpatterns = ( + url(r'^edit/(?P[^/]+)/$', views.editor, name="wiki_editor"), -urlpatterns = patterns( - 'wiki.views', - url(r'^edit/(?P[^/]+)/$', - 'editor', name="wiki_editor"), + url(r'^gallery/(?P[^/]+)/$', views.gallery, name="wiki_gallery"), - url(r'^gallery/(?P[^/]+)/$', - 'gallery', name="wiki_gallery"), + url(r'^history/(?P\d+)/$', views.history, name="wiki_history"), - url(r'^history/(?P\d+)/$', - 'history', name="wiki_history"), + url(r'^text/(?P\d+)/$', views.text, name="wiki_text"), - url(r'^text/(?P\d+)/$', - 'text', name="wiki_text"), + url(r'^revert/(?P\d+)/$', views.revert, name='wiki_revert'), - url(r'^revert/(?P\d+)/$', - 'revert', name='wiki_revert'), - - url(r'^diff/(?P\d+)/$', 'diff', name="wiki_diff"), + url(r'^diff/(?P\d+)/$', views.diff, name="wiki_diff"), ) diff --git a/redakcja/settings/common.py b/redakcja/settings/common.py index e2a0a2d9..3d19bd98 100644 --- a/redakcja/settings/common.py +++ b/redakcja/settings/common.py @@ -5,7 +5,6 @@ import os.path PROJECT_ROOT = os.path.realpath(os.path.dirname(os.path.dirname(__file__))) DEBUG = False -TEMPLATE_DEBUG = DEBUG MAINTENANCE_MODE = False @@ -61,21 +60,25 @@ STATIC_URL = '/media/static/' SESSION_COOKIE_NAME = "redakcja_sessionid" -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -) - -TEMPLATE_CONTEXT_PROCESSORS = ( - "django.contrib.auth.context_processors.auth", - "django.core.context_processors.debug", - "django.core.context_processors.i18n", - "redakcja.context_processors.settings", # this is instead of media - 'django.core.context_processors.csrf', - "django.core.context_processors.request", -) - +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + os.path.join(PROJECT_ROOT, 'templates'), + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + "django.contrib.auth.context_processors.auth", + "django.template.context_processors.debug", + "django.template.context_processors.i18n", + "redakcja.context_processors.settings", # this is instead of media + 'django.template.context_processors.csrf', + "django.template.context_processors.request", + ], + }, + }, +] MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', @@ -100,10 +103,6 @@ MIDDLEWARE_CLASSES = ( ROOT_URLCONF = 'redakcja.urls' -TEMPLATE_DIRS = ( - PROJECT_ROOT + '/templates', -) - FIREPYTHON_LOGGER_NAME = "fnp" INSTALLED_APPS = ( diff --git a/redakcja/settings/compress.py b/redakcja/settings/compress.py index decfa166..a66b0492 100644 --- a/redakcja/settings/compress.py +++ b/redakcja/settings/compress.py @@ -9,112 +9,110 @@ STATICFILES_FINDERS = ( # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) - STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' -PIPELINE_CSS_COMPRESSOR = None -PIPELINE_JS_COMPRESSOR = None -PIPELINE_STORAGE = 'pipeline.storage.PipelineFinderStorage' - -# CSS and JS files to compress -PIPELINE_CSS = { - 'detail': { - 'source_filenames': ( - 'css/master.css', - 'css/toolbar.css', - 'css/gallery.css', - 'css/history.css', - 'css/summary.css', - 'css/html.css', - 'css/jquery.autocomplete.css', - 'css/dialogs.css', - ), - 'output_filename': 'compressed/detail_styles.css', - }, - 'catalogue': { - 'source_filenames': ( - # 'css/filelist.css', - 'css/base.css', - 'datepicker/css/datepicker.css', - ), - 'output_filename': 'compressed/catalogue_styles.css', - }, - 'book': { - 'source_filenames': ( - 'css/book.css', - ), - 'output_filename': 'compressed/book.css', +PIPELINE = { + 'PIPELINE_ENABLED': True, + 'CSS_COMPRESSOR': None, + 'JS_COMPRESSOR': None, + 'STYLESHEETS': { + 'detail': { + 'source_filenames': ( + 'css/master.css', + 'css/toolbar.css', + 'css/gallery.css', + 'css/history.css', + 'css/summary.css', + 'css/html.css', + 'css/jquery.autocomplete.css', + 'css/dialogs.css', + ), + 'output_filename': 'compressed/detail_styles.css', + }, + 'catalogue': { + 'source_filenames': ( + # 'css/filelist.css', + 'css/base.css', + 'datepicker/css/datepicker.css', + ), + 'output_filename': 'compressed/catalogue_styles.css', + }, + 'book': { + 'source_filenames': ( + 'css/book.css', + ), + 'output_filename': 'compressed/book.css', + }, + 'book_list': { + 'source_filenames': ( + 'contextmenu/jquery.contextMenu.css', + 'css/book_list.css', + ), + 'output_filename': 'compressed/book_list.css', + }, }, - 'book_list': { - 'source_filenames': ( - 'contextmenu/jquery.contextMenu.css', - 'css/book_list.css', - ), - 'output_filename': 'compressed/book_list.css', - }, -} + 'JAVASCRIPT': { + # everything except codemirror + 'detail': { + 'source_filenames': ( + # libraries + 'js/lib/jquery/jquery.autocomplete.js', + 'js/lib/jquery/jquery.blockui.js', + 'js/lib/jquery/jquery.elastic.js', + 'js/lib/jquery/jquery.xmlns.js', + 'js/button_scripts.js', + 'js/slugify.js', -PIPELINE_JS = { - # everything except codemirror - 'detail': { - 'source_filenames': ( - # libraries - 'js/lib/jquery/jquery.autocomplete.js', - 'js/lib/jquery/jquery.blockui.js', - 'js/lib/jquery/jquery.elastic.js', - 'js/lib/jquery/jquery.xmlns.js', - 'js/button_scripts.js', - 'js/slugify.js', + # wiki scripts + 'js/wiki/wikiapi.js', + 'js/wiki/xslt.js', - # wiki scripts - 'js/wiki/wikiapi.js', - 'js/wiki/xslt.js', + # base UI + 'js/wiki/base.js', + 'js/wiki/toolbar.js', - # base UI - 'js/wiki/base.js', - 'js/wiki/toolbar.js', + # dialogs + 'js/wiki/dialog_save.js', + 'js/wiki/dialog_revert.js', + 'js/wiki/dialog_pubmark.js', - # dialogs - 'js/wiki/dialog_save.js', - 'js/wiki/dialog_revert.js', - 'js/wiki/dialog_pubmark.js', - - # views - 'js/wiki/view_history.js', - 'js/wiki/view_summary.js', - 'js/wiki/view_editor_source.js', - 'js/wiki/view_editor_wysiwyg.js', - 'js/wiki/view_gallery.js', - 'js/wiki/view_annotations.js', - 'js/wiki/view_search.js', - 'js/wiki/view_column_diff.js', - ), - 'output_filename': 'compressed/detail_scripts.js', - }, - 'catalogue': { - 'source_filenames': ( - 'js/catalogue/catalogue.js', - 'js/slugify.js', - 'email_mangler/email_mangler.js', - 'datepicker/js/bootstrap-datepicker.js', - ), - 'output_filename': 'compressed/catalogue_scripts.js', - }, - 'book': { - 'source_filenames': ( - 'js/book_text/jquery.eventdelegation.js', - 'js/book_text/jquery.scrollto.js', - 'js/book_text/jquery.highlightfade.js', - 'js/book_text/book.js', - ), - 'output_filename': 'compressed/book.js', + # views + 'js/wiki/view_history.js', + 'js/wiki/view_summary.js', + 'js/wiki/view_editor_source.js', + 'js/wiki/view_editor_wysiwyg.js', + 'js/wiki/view_gallery.js', + 'js/wiki/view_annotations.js', + 'js/wiki/view_search.js', + 'js/wiki/view_column_diff.js', + ), + 'output_filename': 'compressed/detail_scripts.js', }, - 'book_list': { - 'source_filenames': ( - 'contextmenu/jquery.ui.position.js', - 'contextmenu/jquery.contextMenu.js', - 'js/catalogue/book_list.js', - ), - 'output_filename': 'compressed/book_list.js', + 'catalogue': { + 'source_filenames': ( + 'js/catalogue/catalogue.js', + 'js/slugify.js', + 'email_mangler/email_mangler.js', + 'datepicker/js/bootstrap-datepicker.js', + ), + 'output_filename': 'compressed/catalogue_scripts.js', + }, + 'book': { + 'source_filenames': ( + 'js/book_text/jquery.eventdelegation.js', + 'js/book_text/jquery.scrollto.js', + 'js/book_text/jquery.highlightfade.js', + 'js/book_text/book.js', + ), + 'output_filename': 'compressed/book.js', + }, + 'book_list': { + 'source_filenames': ( + 'contextmenu/jquery.ui.position.js', + 'contextmenu/jquery.contextMenu.js', + 'js/catalogue/book_list.js', + ), + 'output_filename': 'compressed/book_list.js', + } } } diff --git a/redakcja/urls.py b/redakcja/urls.py index da12c29b..0fe2aac7 100644 --- a/redakcja/urls.py +++ b/redakcja/urls.py @@ -1,51 +1,43 @@ # -*- coding: utf-8 -*- -from django.conf.urls import include, patterns, url +from django.conf.urls import include, url from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from django.contrib.staticfiles.urls import staticfiles_urlpatterns +from django.views.i18n import javascript_catalog import forms_builder.forms.urls +import redakcja.views admin.autodiscover() -urlpatterns = patterns( - '', +urlpatterns = ( # Auth - # url(r'^accounts/login/$', 'django_cas.views.login', name='login'), - # url(r'^accounts/logout/$', 'django_cas.views.logout', name='logout'), - # url(r'^accounts/login/$', 'django.contrib.auth.views.login', name='login'), - # url(r'^accounts/logout/$', 'django.contrib.auth.views.login', name='logout'), - # url(r'^admin/login/$', 'django_cas.views.login', name='login'), - # url(r'^admin/logout/$', 'django_cas.views.logout', name='logout'), url('^accounts/', include('django.contrib.auth.urls')), # Admin panel url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - (r'^admin/', include(admin.site.urls)), + url(r'^admin/', admin.site.urls), - url(r'^$', 'redakcja.views.main'), - url(r'^register$', 'redakcja.views.register', name='register'), + url(r'^$', redakcja.views.main), + url(r'^register$', redakcja.views.register, name='register'), url(r'^documents/', include('catalogue.urls')), url(r'^editor/', include('wiki.urls')), url(r'^organizations/', include('organizations.urls')), url(r'^forms/', include(forms_builder.forms.urls)), url(r'^i18n/', include('django.conf.urls.i18n')), - (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', dict(packages=['wiki'])), - + url(r'^jsi18n/$', javascript_catalog, {'packages': ['wiki']}, name='javascript_catalog'), ) if settings.DEBUG: - urlpatterns += staticfiles_urlpatterns() - urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns += tuple(staticfiles_urlpatterns()) + urlpatterns += tuple(static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)) if getattr(settings, 'SERVE_FILES_WITH_DEBUG_FALSE', False): - urlpatterns += patterns( - '', - (r'^%s(?P.*)$' % settings.STATIC_URL[1:], - 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}), - (r'^%s(?P.*)$' % settings.MEDIA_URL[1:], - 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), + from django.views.static import serve + urlpatterns += ( + (r'^%s(?P.*)$' % settings.STATIC_URL[1:], serve, {'document_root': settings.STATIC_ROOT}), + (r'^%s(?P.*)$' % settings.MEDIA_URL[1:], serve, {'document_root': settings.MEDIA_ROOT}), ) diff --git a/requirements.txt b/requirements.txt index 3941b77b..641eb4ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,9 +12,9 @@ httplib2 # oauth2 dependency # git+git://github.com/fnp/librarian.git@master#egg=librarian ## Django -Django>=1.8,<1.9 +Django>=1.9,<1.10 fnpdjango>=0.2,<0.3 -django-pipeline>=1.4.7,<1.5 +django-pipeline>=1.6,<1.7 sorl-thumbnail>=12.2,<13 #django-maintenancemode>=0.9 django-pagination @@ -29,8 +29,6 @@ django-constance[database] celery>=3.1.12,<3.2 kombu>3.0,<3.1 -South>=1.0.2 - Embeder future -- 2.20.1