KOED-Quiz
- Copyright © 2011,2012 Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org.pl>
+ Copyright © 2011,2012,2014,2019 Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org.pl>
For full list of contributors see AUTHORS section in README.
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
\ No newline at end of file
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
License
-------
- Copyright © 2011,2012 Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org.pl>
+ Copyright © 2011,2012,2014,2019 Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org.pl>
For full list of contributors see AUTHORS section at the end.
-# -*- coding: utf-8 -*-
# This file is part of KOED-Quiz, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
-# -*- coding: utf-8 -*-
# This file is part of KOED-Quiz, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
+from django.utils.deprecation import MiddlewareMixin
from .models import Quiz
-class CurrentQuizMiddleware(object):
+class CurrentQuizMiddleware(MiddlewareMixin):
def process_request(self, request):
request.current_quiz = Quiz.current(request)
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from django.db import models, migrations
migrations.CreateModel(
name='Quiz',
fields=[
- ('site_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='sites.Site')),
+ ('site_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='sites.Site', on_delete=models.CASCADE)),
('description', models.TextField()),
('footer', models.TextField(null=True, blank=True)),
],
('slug', models.SlugField()),
('title', models.CharField(max_length=255)),
('text', models.TextField()),
- ('quiz', models.ForeignKey(to='quiz.Quiz')),
+ ('quiz', models.ForeignKey(to='quiz.Quiz', on_delete=models.CASCADE)),
],
options={
'ordering': ['quiz', 'title'],
migrations.AddField(
model_name='question',
name='quiz',
- field=models.ForeignKey(to='quiz.Quiz'),
+ field=models.ForeignKey(to='quiz.Quiz', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AlterUniqueTogether(
migrations.AddField(
model_name='answer',
name='go_to',
- field=models.ForeignKey(related_name='go_tos', blank=True, to='quiz.Question', null=True),
+ field=models.ForeignKey(related_name='go_tos', blank=True, to='quiz.Question', null=True, on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='answer',
name='question',
- field=models.ForeignKey(to='quiz.Question'),
+ field=models.ForeignKey(to='quiz.Question', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='answer',
name='result',
- field=models.ForeignKey(blank=True, to='quiz.Result', null=True),
+ field=models.ForeignKey(blank=True, to='quiz.Result', null=True, on_delete=models.CASCADE),
preserve_default=True,
),
]
--- /dev/null
+# Generated by Django 2.2.5 on 2019-09-22 22:20
+
+import django.contrib.sites.models
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('quiz', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterModelManagers(
+ name='quiz',
+ managers=[
+ ('objects', django.contrib.sites.models.SiteManager()),
+ ],
+ ),
+ migrations.AlterField(
+ model_name='answer',
+ name='go_to',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='go_tos', to='quiz.Question'),
+ ),
+ migrations.AlterField(
+ model_name='answer',
+ name='result',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='quiz.Result'),
+ ),
+ ]
-# -*- coding: utf-8 -*-
# This file is part of KOED-Quiz, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from django.db import models
from django.contrib.sites.models import Site
-from django.utils.encoding import python_2_unicode_compatible
+from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
@classmethod
def current(cls, request):
- return cls.objects.get(domain=request.get_host().rstrip('.'))
+ try:
+ return cls.objects.get(domain=request.get_host().rstrip('.'))
+ except cls.DoesNotExist:
+ pass
def start(self):
return self.question_set.all()[0]
- @models.permalink
def get_absolute_url(self):
- return ('quiz', )
+ return reverse('quiz')
def where_to(self):
try:
return self.get_absolute_url()
-@python_2_unicode_compatible
class Result(models.Model):
- quiz = models.ForeignKey(Quiz)
+ quiz = models.ForeignKey(Quiz, models.CASCADE)
slug = models.SlugField(db_index=True)
title = models.CharField(max_length=255)
text = models.TextField()
def __str__(self):
return self.title
- @models.permalink
def get_absolute_url(self):
- return ('quiz_result', [self.slug])
+ return reverse('quiz_result', args=[self.slug])
-@python_2_unicode_compatible
class Question(models.Model):
- quiz = models.ForeignKey(Quiz)
+ quiz = models.ForeignKey(Quiz, models.CASCADE)
slug = models.SlugField(db_index=True)
ordering = models.SmallIntegerField()
title = models.CharField(max_length=255)
def __str__(self):
return self.title
- @models.permalink
def get_absolute_url(self):
- return ('quiz', [self.slug])
+ return reverse('quiz', args=[self.slug])
def where_to(self):
later = self.quiz.question_set.filter(ordering__gt=self.ordering)
return self.quiz.where_to()
-@python_2_unicode_compatible
class Answer(models.Model):
title = models.CharField(max_length=255)
- question = models.ForeignKey(Question)
- go_to = models.ForeignKey(Question, null=True, blank=True,
+ question = models.ForeignKey(Question, models.CASCADE)
+ go_to = models.ForeignKey(Question, models.SET_NULL, null=True, blank=True,
related_name='go_tos')
- result = models.ForeignKey(Result, null=True, blank=True)
+ result = models.ForeignKey(Result, models.SET_NULL, null=True, blank=True)
ordering = models.SmallIntegerField()
class Meta:
-# -*- coding: utf-8 -*-
# This file is part of KOED-Quiz, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
-# -*- coding: utf-8 -*-
# This file is part of KOED-Quiz, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
-from django.conf.urls import patterns, url
+from django.urls import path
+from . import views
-urlpatterns = patterns('quiz.views',
- url(r'^$', 'question', name='quiz'),
- url(r'^q/(?P<slug>[^/]*)/$', 'question', name='quiz'),
- url(r'^r/(?P<slug>[^/]*)/$', 'result', name='quiz_result'),
-)
+urlpatterns = [
+ path('', views.question, name='quiz'),
+ path('q/<slug>/', views.question, name='quiz'),
+ path('r/<slug>/', views.result, name='quiz_result'),
+]
-# -*- coding: utf-8 -*-
# This file is part of KOED-Quiz, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
+++ /dev/null
-from fnpdjango.deploy import *
-
-
-env.project_name = 'koedquiz'
-env.hosts = ['giewont.icm.edu.pl']
-env.user = 'rczajka'
-env.app_path = '/srv/koedquiz'
-env.services = [
- Supervisord('koedquiz'),
- ]
-
-# -*- coding: utf-8 -*-
# This file is part of KOED-Quiz, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
DEBUG = False
-TEMPLATE_DEBUG = DEBUG
ADMINS = [
# ('Your Name', 'your_email@domain.com'),
}
}
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be available on all operating systems.
-# On Unix systems, a value of None will cause Django to use the same
-# timezone as the operating system.
-# If running in a Windows environment this must be set to the same as your
-# system time zone.
-TIME_ZONE = None
+TIME_ZONE = 'Europe/Warsaw'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
-# URL prefix for admin static files -- CSS, JavaScript and images.
-# Make sure to use a trailing slash.
-# Examples: "http://foo.com/static/admin/", "/static/admin/".
-ADMIN_MEDIA_PREFIX = '/static/admin/'
-
-# Additional locations of static files
-STATICFILES_DIRS = (
- # Put strings here, like "/home/html/static" or "C:/www/django/static".
- # Always use forward slashes, even on Windows.
- # Don't forget to use absolute paths, not relative paths.
-)
-
-# List of finder classes that know how to find static files in
-# various locations.
-STATICFILES_FINDERS = (
- 'django.contrib.staticfiles.finders.FileSystemFinder',
- 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
-# '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',
+ 'DIRS': [
+ os.path.join(PROJECT_DIR, 'templates'),
+ ],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ "django.contrib.auth.context_processors.auth",
+ "django.template.context_processors.debug",
+ "django.template.context_processors.i18n",
+ "django.template.context_processors.media",
+ "django.template.context_processors.static",
+ "django.template.context_processors.tz",
+ "django.contrib.messages.context_processors.messages",
+ "django.template.context_processors.request",
+ ]
+ },
+ },
]
-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.core.context_processors.tz",
- "django.contrib.messages.context_processors.messages",
- "django.core.context_processors.request",
-)
-
-MIDDLEWARE_CLASSES = [
+MIDDLEWARE = [
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
ROOT_URLCONF = 'koedquiz.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'),
-]
+SITE_ID = 1
INSTALLED_APPS = [
'django.contrib.auth',
'quiz',
]
-# 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,
- },
- }
-}
-
# Load localsettings, if they exist
try:
from .localsettings import *
-# -*- coding: utf-8 -*-
# This file is part of KOED-Quiz, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
-from django.conf.urls import patterns, include, url
+from django.urls import include, path
from django.views.generic import TemplateView
from django.contrib import admin
-admin.autodiscover()
-urlpatterns = patterns('',
- url(r'^$', TemplateView.as_view(template_name="quiz/home.html"), name='main_page'),
+urlpatterns = [
+ path('', TemplateView.as_view(template_name="quiz/home.html"), name='main_page'),
- url(r'^quiz/', include('quiz.urls')),
+ path('quiz/', include('quiz.urls')),
- url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
- url(r'^admin/', include(admin.site.urls)),
-)
+ path('admin/', admin.site.urls),
+]
+++ /dev/null
--i http://pypi.nowoczesnapolska.org.pl/simple
-
-django-debug-toolbar
-fnpdjango
-Fabric
-# Django basics
-Django>=1.7,<1.8
+Django==2.2.5