Django 2.2
authorRadek Czajka <rczajka@rczajka.pl>
Wed, 3 Apr 2019 10:22:54 +0000 (12:22 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Wed, 3 Apr 2019 10:25:15 +0000 (12:25 +0200)
12 files changed:
Makefile [new file with mode: 0644]
apps/edition1/urls.py [changed mode: 0755->0644]
apps/edition2/urls.py
apps/poetry/migrations/0001_initial.py
apps/poetry/models.py
apps/poetry/urls.py
apps/poetry/utils.py
fabfile.py [deleted file]
requirements-dev.txt [deleted file]
requirements.txt
turniej/settings.py
turniej/urls.py

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..434b784
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,7 @@
+.PHONY: deploy
+
+
+deploy: turniej/localsettings.py
+       pip install -r requirements.txt
+       ./manage.py migrate --noinput
+       ./manage.py collectstatic --noinput
old mode 100755 (executable)
new mode 100644 (file)
index 285808f..76dadd5
@@ -1,12 +1,14 @@
-from django.conf.urls import patterns, url
+from django.conf.urls import url
 from django.views.generic import TemplateView
+from . import views
 
-urlpatterns = patterns('',
-    url(r'^$', 'edition1.views.home', name='e1_main_page'),
+
+urlpatterns = [
+    url(r'^$', views.home, name='e1_main_page'),
     url(r'^regulamin/$', TemplateView.as_view(template_name='edition1/rules.html'),
         name='e1_rules_page'),
     url(r'^wiecej/$', TemplateView.as_view(template_name='edition1/more.html'),
         name='e1_more_page'),
     url(r'^technikalia/$', TemplateView.as_view(template_name='edition1/technical.html'),
         name='e1_technical_page'),
-)
+]
index 93c4c8c..0cb0f57 100755 (executable)
@@ -1,7 +1,7 @@
-from django.conf.urls import patterns, url
+from django.conf.urls import url
 from django.views.generic import TemplateView
 
-urlpatterns = patterns('',
+urlpatterns = [
     url(r'^$', TemplateView.as_view(template_name='edition2/home.html'),
         name='e2_main_page'),
     url(r'^regulamin/$', TemplateView.as_view(template_name='edition2/rules.html'),
@@ -10,4 +10,4 @@ urlpatterns = patterns('',
         name='e2_more_page'),
     url(r'^technikalia/$', TemplateView.as_view(template_name='edition2/technical.html'),
         name='e2_technical_page'),
-)
+]
index 0586896..81c630c 100644 (file)
@@ -47,7 +47,7 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='poem',
             name='poet',
-            field=models.ForeignKey(to='poetry.Poet'),
+            field=models.ForeignKey(to='poetry.Poet', on_delete=models.CASCADE),
             preserve_default=True,
         ),
     ]
index c0e6c93..58b8caf 100644 (file)
@@ -1,8 +1,7 @@
-# -*- coding: utf-8 -*-
 import os
 import subprocess
 from django.db import models
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.conf import settings
 from poetry.utils import get_hash
 
@@ -61,7 +60,7 @@ class Poem(models.Model):
     slug = models.SlugField(max_length=50, db_index=True)
     title = models.CharField(max_length=255, null=True, blank=True)
     text = models.TextField()
-    poet = models.ForeignKey(Poet)
+    poet = models.ForeignKey(Poet, on_delete=models.CASCADE)
     created_at = models.DateTimeField(auto_now_add=True, editable=False, db_index=True)
     seen_at = models.DateTimeField(auto_now_add=True, editable=False)
     view_count = models.IntegerField(default=1)
index 50017a5..eb9b4f3 100644 (file)
@@ -1,12 +1,13 @@
-from django.conf.urls import patterns, url
+from django.conf.urls import url
+from . import views
 
-urlpatterns = patterns('poetry.views',
-    url(r'^wiersz/(?P<slug>[a-zA-Z0-9-]+)/$', 'poem', name='poetry_poem'),
 
-    url(r"^$", "main", name="poetry_main"),
-    url(r"^nowy/$", 'new', name="poetry_new"),
-    url(r"^konkurs/$", 'contest', name="poetry_contest"),
-    url(r"^(?P<slug>[a-zA-Z0-9-]+)/$", "poet", name="poetry_poet"),
-    url(r"^(?P<slug>[a-zA-Z0-9-]+)/nowy/$", 'new', name="poetry_new"),
+urlpatterns = [
+    url(r'^wiersz/(?P<slug>[a-zA-Z0-9-]+)/$', views.poem, name='poetry_poem'),
 
-)
+    url(r"^$", views.main, name="poetry_main"),
+    url(r"^nowy/$", views.new, name="poetry_new"),
+    url(r"^konkurs/$", views.contest, name="poetry_contest"),
+    url(r"^(?P<slug>[a-zA-Z0-9-]+)/$", views.poet, name="poetry_poet"),
+    url(r"^(?P<slug>[a-zA-Z0-9-]+)/nowy/$", views.new, name="poetry_new"),
+]
index 0286505..6366f08 100644 (file)
@@ -7,4 +7,4 @@ from hashlib import sha1
 def get_hash(seed):
     sha_digest = sha1(('%d%s' % (time.time(), str(seed))
         ).encode('utf-8', 'replace')).digest()
-    return urlsafe_b64encode(sha_digest).replace(b'=', b'').replace(b'_', b'-').lower()
+    return urlsafe_b64encode(sha_digest).decode('latin1').replace('=', '').replace('_', '-').lower()
diff --git a/fabfile.py b/fabfile.py
deleted file mode 100644 (file)
index 049085c..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-from fnpdjango.deploy import *
-
-env.project_name = 'turniej'
-env.hosts = ['giewont.icm.edu.pl']
-env.user = 'lektury'
-env.app_path = '/srv/turniej.wolnelektury.pl'
-env.services = [
-    DebianGunicorn('turniej'),
-]
diff --git a/requirements-dev.txt b/requirements-dev.txt
deleted file mode 100644 (file)
index aec394f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-django-debug-toolbar
index f7f889f..dcccc9b 100644 (file)
@@ -1,6 +1,6 @@
--i https://py.mdrn.pl:8443/simple
+-i https://py.mdrn.pl/simple
 
-Django>=1.7,<1.8
-fnpdjango>=0.2,<0.3
+Django>=2.2,<2.3
+fnpdjango==0.4
 
 django-piwik
index d09e780..03e2586 100644 (file)
@@ -1,11 +1,9 @@
-# -*- coding: utf-8 -*-
 # Django settings for turniej project.
 import os.path
 
 PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
 
 DEBUG = False
-TEMPLATE_DEBUG = DEBUG
 
 ADMINS = [
     # ('Your Name', 'your_email@domain.com'),
@@ -88,53 +86,36 @@ STATICFILES_FINDERS = (
 #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
 )
 
-# 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',
-#     'django.template.loaders.eggs.Loader',
+TEMPLATES = [
+    {
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'APP_DIRS': True,
+        'DIRS': [
+            os.path.join(PROJECT_DIR, 'templates'),
+        ],
+        'OPTIONS': {
+            'context_processors': [
+                "django.template.context_processors.debug",
+                "django.template.context_processors.i18n",
+                "django.template.context_processors.media",
+                "django.template.context_processors.static",
+                "django.contrib.messages.context_processors.messages",
+                "django.template.context_processors.request",
+            ],
+        },
+    },
 ]
 
-MIDDLEWARE_CLASSES = [
+MIDDLEWARE = [
     'django.middleware.common.CommonMiddleware',
-    #'django.contrib.sessions.middleware.SessionMiddleware',
-    #'django.middleware.csrf.CsrfViewMiddleware',
-    #'django.contrib.auth.middleware.AuthenticationMiddleware',
-    #'django.contrib.messages.middleware.MessageMiddleware',
 ]
 
 ROOT_URLCONF = 'turniej.urls'
 
-TEMPLATE_DIRS = [
-    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
-    # Always use forward slashes, even on Windows.
-    # Don't forget to use absolute paths, not relative paths.
-    os.path.join(PROJECT_DIR, 'templates'),
-]
-
-TEMPLATE_CONTEXT_PROCESSORS = (
-    #"django.contrib.auth.context_processors.auth",
-    "django.core.context_processors.debug",
-    "django.core.context_processors.i18n",
-    "django.core.context_processors.media",
-    "django.core.context_processors.static",
-    "django.contrib.messages.context_processors.messages",
-    "django.core.context_processors.request",
-)
-TEMPLATE_CONTEXT_PROCESSORS += (
-)
-
 INSTALLED_APPS = [
-    #'django.contrib.auth',
-    #'django.contrib.contenttypes',
-    #'django.contrib.sessions',
     'django.contrib.sites',
-    #'django.contrib.messages',
     'django.contrib.staticfiles',
 
-    # 'django.contrib.admin',
-    # 'django.contrib.admindocs',
-
     'piwik',
 
     'fnpdjango',
@@ -143,29 +124,6 @@ INSTALLED_APPS = [
     'edition2',
 ]
 
-# A sample logging configuration. The only tangible logging
-# performed by this configuration is to send an email to
-# the site admins on every HTTP 500 error.
-# See http://docs.djangoproject.com/en/dev/topics/logging for
-# more details on how to customize your logging configuration.
-LOGGING = {
-    'version': 1,
-    'disable_existing_loggers': False,
-    'handlers': {
-        'mail_admins': {
-            'level': 'ERROR',
-            'class': 'django.utils.log.AdminEmailHandler'
-        }
-    },
-    'loggers': {
-        'django.request': {
-            'handlers': ['mail_admins'],
-            'level': 'ERROR',
-            'propagate': True,
-        },
-    }
-}
-
 POETRY_POEMS_FOR_CONTEST = 20
 
 ALLOWED_HOSTS = [
index 56baf14..eafb8c9 100644 (file)
@@ -1,10 +1,8 @@
-from django.conf.urls import patterns, include, url
-from edition2.urls import urlpatterns as e2_urlpatterns
+from django.conf.urls import include, url
 
-# from django.contrib import admin
-# admin.autodiscover()
 
-urlpatterns = patterns('',
+urlpatterns = [
     url(r'^2011/', include('edition1.urls')),
     url(r'^poezja/', include('poetry.urls')),
-) + e2_urlpatterns
+    url(r'', include('edition2.urls')),
+]