Commit e6ce8bfc authored by Claude Paroz's avatar Claude Paroz

Replace deprecated urlresolvers references

parent bde51747
......@@ -3,8 +3,8 @@ from datetime import datetime, timedelta
from unittest import skipUnless
from unittest.mock import MagicMock, patch
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.urls import reverse
from django.utils import translation
from people.models import Person
......
from django.conf import settings
from django.contrib.auth import login, authenticate, logout
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render
from django.template.loader import get_template, TemplateDoesNotExist
from django.urls import reverse
from django.utils.http import is_safe_url
from django.utils.translation import ugettext as _
......
......@@ -126,7 +126,6 @@ MIDDLEWARE = [
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
......
from django.core.urlresolvers import NoReverseMatch
from django.db import models
from django.db.models import Q
from django.utils.translation import ugettext as _
from django.urls import NoReverseMatch
from teams.models import Team, FakeTeam
......
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.test import TestCase
from languages.models import Language
class LanguageTestCase(TestCase):
fixtures = ['sample_data.json']
......@@ -15,9 +16,10 @@ class LanguageTestCase(TestCase):
Language.objects.create(name='French (Belgium)', locale='fr_BE')
Language.objects.create(name='Chinese (Taiwan)', locale='zh_TW')
self.assertEqual(Language.get_language_from_ianacode('fr-ch').locale, 'fr')
self.assertEqual(Language.get_language_from_ianacode('fr-be').locale, 'fr_BE')
self.assertEqual(Language.get_language_from_ianacode('be').locale, 'be')
self.assertEqual(Language.get_language_from_ianacode('be-latin-RU').locale, 'be')
self.assertEqual(Language.get_language_from_ianacode('zh-tw').locale, 'zh_TW')
self.assertEqual(Language.get_language_from_ianacode('xx'), None)
func = Language.get_language_from_ianacode
self.assertEqual(func('fr-ch').locale, 'fr')
self.assertEqual(func('fr-be').locale, 'fr_BE')
self.assertEqual(func('be').locale, 'be')
self.assertEqual(func('be-latin-RU').locale, 'be')
self.assertEqual(func('zh-tw').locale, 'zh_TW')
self.assertEqual(func('xx'), None)
......@@ -6,7 +6,7 @@ from django import forms
from django.conf import settings
from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.encoding import force_bytes
from django.utils.translation import ugettext_lazy, ugettext as _
......
import datetime
import re
from django.contrib.auth.models import User, UserManager
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.db import models
from django.urls import reverse
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User, UserManager
AVATAR_SERVICES = {
'gravatar.com': 'https://secure.gravatar.com/avatar/{hash}.jpg?{qs}',
......@@ -72,7 +73,7 @@ class Person(User):
@classmethod
def get_by_user(cls, user):
if user.is_anonymous():
if user.is_anonymous:
return None
try:
return user.person
......
......@@ -4,7 +4,7 @@ from unittest import skipUnless
from django.test import TestCase
from django.core import mail
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.safestring import SafeData
from django.utils.translation import ugettext as _
......
......@@ -6,10 +6,10 @@ from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib import messages
from django.contrib.sites.shortcuts import get_current_site
from django.core import urlresolvers
from django.db import IntegrityError
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.urls import reverse
from django.utils.translation import ugettext_lazy, ugettext as _
from django.views.decorators.http import require_POST
from django.views.generic import ListView, DetailView, UpdateView
......@@ -109,8 +109,9 @@ def person_team_leave(request, team_slug):
# Message no i18n'ed, should never happen under normal conditions
messages.error(request, _("You are not a member of this team."))
# redirect to normal person detail
return HttpResponseRedirect(urlresolvers.reverse('person_detail_username',
args=(person.username,)))
return HttpResponseRedirect(
reverse('person_detail_username', args=(person.username,))
)
@login_required
def person_password_change(request):
......
......@@ -14,8 +14,8 @@ from urllib.error import URLError
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.management import call_command
from django.core.urlresolvers import reverse
from django.core.validators import RegexValidator
from django.urls import reverse
from django.utils.encoding import force_text
from django.utils.functional import cached_property
from django.utils.translation import ungettext, ugettext as _, ugettext_noop
......
......@@ -9,7 +9,7 @@ from django.conf import settings
from django.contrib.auth.models import User
from django.core import mail
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.test import TestCase
from stats.models import (
......
......@@ -5,9 +5,9 @@ from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.core import serializers
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseForbidden, HttpResponseRedirect, Http404
from django.shortcuts import render, get_object_or_404
from django.urls import reverse
from django.utils.translation import ugettext as _
from common.utils import MIME_TYPES, get_user_locale
......
from datetime import datetime, timedelta
from django.conf import settings
from django.contrib.sites.models import Site
from django.db import models
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils import translation
from django.utils.translation import ugettext_lazy, ugettext as _
from django.conf import settings
from django.contrib.sites.models import Site
from common.utils import send_mail
from people.models import Person
......
from datetime import datetime, timedelta
from django.conf import settings
from django.core.urlresolvers import reverse
from django.core import mail
from django.test import TestCase
from django.urls import reverse
from django.utils.translation import ugettext_lazy
from people.models import Person
......
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponseForbidden
from django.shortcuts import render, get_object_or_404
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from common import utils
......
from django.core import urlresolvers
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed, FeedDoesNotExist
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from languages.models import Language
......@@ -36,11 +36,12 @@ class LatestActionsByLanguage(Feed):
return actions.order_by('-created')[:20]
def item_link(self, item):
link = urlresolvers.reverse('vertimus_by_names',
args=(item.state_db.branch.module.name,
item.state_db.branch.name,
item.state_db.domain.name,
item.state_db.language.locale))
link = reverse('vertimus_by_names', args=(
item.state_db.branch.module.name,
item.state_db.branch.name,
item.state_db.domain.name,
item.state_db.language.locale,
))
return "%s#%d" % (link, item.id)
def item_pubdate(self, item):
......@@ -78,11 +79,12 @@ class LatestActionsByTeam(Feed):
return actions.order_by('-created')[:20]
def item_link(self, item):
link = urlresolvers.reverse('vertimus_by_names',
args=(item.state_db.branch.module.name,
item.state_db.branch.name,
item.state_db.domain.name,
item.state_db.language.locale))
link = reverse('vertimus_by_names', args=(
item.state_db.branch.module.name,
item.state_db.branch.name,
item.state_db.domain.name,
item.state_db.language.locale,
))
return "%s#%d" % (link, item.id)
def item_pubdate(self, item):
......
......@@ -2,9 +2,10 @@ import os
from django import forms
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.html import format_html
from django.utils.translation import ugettext, ugettext_lazy as _
from vertimus.models import Action, ActionCI, ActionSeparator
from stats.models import Person
from stats.utils import po_file_stats
......
......@@ -4,11 +4,11 @@ from datetime import datetime, timedelta
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import Max
from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
from django.urls import reverse
from django.utils.translation import override, ugettext, ugettext_noop, ugettext_lazy as _
from common.utils import send_mail
......
......@@ -6,9 +6,9 @@ from django.conf import settings
from django.core.files.base import File, ContentFile
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core import mail
from django.core.urlresolvers import reverse
from django.http import QueryDict
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.datastructures import MultiValueDict
from people.models import Person
......
......@@ -3,10 +3,10 @@ import os
from django.conf import settings
from django.contrib import messages
from django.core import urlresolvers
from django.db import IntegrityError
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render, get_object_or_404
from django.urls import reverse
from django.utils.translation import ugettext as _
from stats.models import Statistics, FakeLangStatistics, Module, Branch, Domain, Language
......@@ -114,7 +114,7 @@ def vertimus(request, branch, domain, language, stats=None, level="0"):
messages.success(request, msg)
return HttpResponseRedirect(
urlresolvers.reverse('vertimus_by_names',
reverse('vertimus_by_names',
args=(branch.module.name, branch.name, domain.name,
language.locale)))
elif available_actions:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment