X-Git-Url: https://git.mdrn.pl/koed-quiz.git/blobdiff_plain/10dda5cd1e5bd650c06d5629dd56160ea446082a..4c14e51225e284c5b81d53e7f6a5cd0f46ec4d05:/apps/quiz/models.py diff --git a/apps/quiz/models.py b/apps/quiz/models.py index 9043b74..74142da 100644 --- a/apps/quiz/models.py +++ b/apps/quiz/models.py @@ -1,5 +1,10 @@ +# -*- 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.utils.translation import ugettext_lazy as _ from django.conf import settings @@ -7,6 +12,7 @@ from django.conf import settings class Quiz(Site): description = models.TextField() + footer = models.TextField(null=True, blank=True) class Meta: verbose_name = _('quiz') @@ -31,6 +37,7 @@ class Quiz(Site): return self.get_absolute_url() +@python_2_unicode_compatible class Result(models.Model): quiz = models.ForeignKey(Quiz) slug = models.SlugField(db_index=True) @@ -42,7 +49,7 @@ class Result(models.Model): verbose_name_plural = _('results') ordering = ['quiz', 'title'] - def __unicode__(self): + def __str__(self): return self.title @models.permalink @@ -50,6 +57,7 @@ class Result(models.Model): return ('quiz_result', [self.slug]) +@python_2_unicode_compatible class Question(models.Model): quiz = models.ForeignKey(Quiz) slug = models.SlugField(db_index=True) @@ -64,7 +72,7 @@ class Question(models.Model): ordering = ['quiz', 'ordering'] unique_together = [['quiz', 'slug'], ['quiz', 'ordering']] - def __unicode__(self): + def __str__(self): return self.title @models.permalink @@ -79,7 +87,7 @@ class Question(models.Model): return self.quiz.where_to() - +@python_2_unicode_compatible class Answer(models.Model): title = models.CharField(max_length=255) question = models.ForeignKey(Question) @@ -93,7 +101,7 @@ class Answer(models.Model): verbose_name_plural = _('answers') ordering = ['question', 'ordering'] - def __unicode__(self): + def __str__(self): return self.title def where_to(self):