Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making the apps django 3 safe #96

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions essay/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from quiz.models import Question


@python_2_unicode_compatible
class Essay_Question(Question):

def check_if_correct(self, guess):
Expand Down
4 changes: 1 addition & 3 deletions multichoice/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.db import models
from quiz.models import Question

Expand Down Expand Up @@ -54,7 +53,6 @@ class Meta:
verbose_name_plural = _("Multiple Choice Questions")


@python_2_unicode_compatible
class Answer(models.Model):
question = models.ForeignKey(MCQuestion, verbose_name=_("Question"), on_delete=models.CASCADE)

Expand Down
2 changes: 1 addition & 1 deletion multichoice/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.core.files.base import ContentFile
from django.db.models.fields.files import ImageFieldFile
from django.test import TestCase
from django.utils.six import StringIO
from six import StringIO

from .models import MCQuestion, Answer

Expand Down
2 changes: 1 addition & 1 deletion quiz/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django import forms
from django.contrib import admin
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from .models import Quiz, Category, SubCategory, Progress, Question
from multichoice.models import MCQuestion, Answer
Expand Down
7 changes: 1 addition & 6 deletions quiz/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
from django.core.validators import (
MaxValueValidator, validate_comma_separated_integer_list,
)
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.timezone import now
from django.utils.encoding import python_2_unicode_compatible
from django.conf import settings

from model_utils.managers import InheritanceManager
Expand All @@ -25,7 +24,6 @@ def new_category(self, category):
return new_category


@python_2_unicode_compatible
class Category(models.Model):

category = models.CharField(
Expand All @@ -43,7 +41,6 @@ def __str__(self):
return self.category


@python_2_unicode_compatible
class SubCategory(models.Model):

sub_category = models.CharField(
Expand All @@ -64,7 +61,6 @@ def __str__(self):
return self.sub_category + " (" + self.category.category + ")"


@python_2_unicode_compatible
class Quiz(models.Model):

title = models.CharField(
Expand Down Expand Up @@ -541,7 +537,6 @@ def progress(self):
return answered, total


@python_2_unicode_compatible
class Question(models.Model):
"""
Base class for all question types.
Expand Down
6 changes: 3 additions & 3 deletions quiz/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from django.http import HttpRequest
from django.template import Template, Context
from django.test import TestCase
from django.utils.six import StringIO
from django.utils.translation import ugettext_lazy as _
from six import StringIO
from django.utils.translation import gettext_lazy as _

from .models import Category, Quiz, Progress, Sitting, SubCategory
from .views import (anon_session_score, QuizListView, CategoriesListView,
Expand Down Expand Up @@ -57,7 +57,7 @@ def setUp(self):
self.quiz4 = Quiz.objects.create(id=4,
title='test quiz 4',
description='d4',
url='T-!�$%^&*Q4')
url='T-!�$%^&*Q4')

self.question1 = MCQuestion.objects.create(id=1,
content='squawk')
Expand Down
21 changes: 9 additions & 12 deletions quiz/urls.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
try:
from django.conf.urls import url
except ImportError:
from django.urls import re_path as url
from django.urls import path

from .views import QuizListView, CategoriesListView, \
ViewQuizListByCategory, QuizUserProgressView, QuizMarkingList, \
QuizMarkingDetail, QuizDetailView, QuizTake

urlpatterns = [

url(r'^$',
path('',
view=QuizListView.as_view(),
name='quiz_index'),

url(r'^category/$',
path('category/',
view=CategoriesListView.as_view(),
name='quiz_category_list_all'),

url(r'^category/(?P<category_name>[\w|\W-]+)/$',
path('category/<str:category_name>',
view=ViewQuizListByCategory.as_view(),
name='quiz_category_list_matching'),

url(r'^progress/$',
path('progress/',
view=QuizUserProgressView.as_view(),
name='quiz_progress'),

url(r'^marking/$',
path('marking/',
view=QuizMarkingList.as_view(),
name='quiz_marking'),

url(r'^marking/(?P<pk>[\d.]+)/$',
path('marking/<int:pk>/',
view=QuizMarkingDetail.as_view(),
name='quiz_marking_detail'),

# passes variable 'quiz_name' to quiz_take view
url(r'^(?P<slug>[\w-]+)/$',
path('<slug:slug>/',
view=QuizDetailView.as_view(),
name='quiz_start_page'),

url(r'^(?P<quiz_name>[\w-]+)/take/$',
path('<str:quiz_name>/take/',
view=QuizTake.as_view(),
name='quiz_question'),
]
3 changes: 1 addition & 2 deletions true_false/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.db import models
from quiz.models import Question

Expand Down