summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/welco.cron.d2
-rw-r--r--debian/welco.cron.hourly2
-rw-r--r--setup.py6
-rw-r--r--tests/test_mail_manager.py4
-rw-r--r--tests/test_source_maarch.py12
-rw-r--r--tests/test_source_phone.py32
-rw-r--r--tox.ini9
-rw-r--r--welco/apps.py6
-rw-r--r--welco/contacts/forms.py2
-rw-r--r--welco/forms.py2
-rw-r--r--welco/kb/models.py2
-rw-r--r--welco/monkeypatch.py6
-rw-r--r--welco/qualif/models.py2
-rw-r--r--welco/settings.py2
-rw-r--r--welco/sources/counter/models.py2
-rw-r--r--welco/sources/counter/urls.py4
-rw-r--r--welco/sources/mail/forms.py2
-rw-r--r--welco/sources/mail/models.py2
-rw-r--r--welco/sources/mail/urls.py18
-rw-r--r--welco/sources/mail/views.py2
-rw-r--r--welco/sources/phone/models.py2
-rw-r--r--welco/sources/phone/urls.py14
-rw-r--r--welco/sources/phone/views.py14
-rw-r--r--welco/urls.py62
-rw-r--r--welco/views.py8
25 files changed, 111 insertions, 108 deletions
diff --git a/debian/welco.cron.d b/debian/welco.cron.d
index 8d9b8b6..43927e6 100644
--- a/debian/welco.cron.d
+++ b/debian/welco.cron.d
@@ -1,4 +1,4 @@
SHELL=/bin/sh
PATH=/usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin
-*/10 6-22 * * * welco /usr/bin/welco-manage tenant_command feed_mail_maarch --all-tenants
+*/10 6-22 * * * welco /usr/bin/welco-manage tenant_command feed_mail_maarch --all-tenants -v0
diff --git a/debian/welco.cron.hourly b/debian/welco.cron.hourly
index bc04b6c..764f4fd 100644
--- a/debian/welco.cron.hourly
+++ b/debian/welco.cron.hourly
@@ -1,3 +1,3 @@
#!/bin/sh
-/sbin/runuser -u welco /usr/bin/welco-manage -- tenant_command clearsessions --all-tenants
+/sbin/runuser -u welco /usr/bin/welco-manage -- tenant_command clearsessions --all-tenants -v0
diff --git a/setup.py b/setup.py
index d2039c9..eba0f43 100644
--- a/setup.py
+++ b/setup.py
@@ -108,11 +108,11 @@ setup(
'Programming Language :: Python',
],
install_requires=[
- 'django>=2.2,<2.3',
+ 'django>=2.2,<3.3',
'gadjo',
'django-ckeditor<4.5.4',
- 'django-haystack<2.8',
- 'django-taggit',
+ 'django-haystack<3.2',
+ 'django-taggit<3',
'djangorestframework>=3.3,<3.13',
'requests',
'whoosh',
diff --git a/tests/test_mail_manager.py b/tests/test_mail_manager.py
index 265aa32..1e0f9c5 100644
--- a/tests/test_mail_manager.py
+++ b/tests/test_mail_manager.py
@@ -20,7 +20,7 @@ import httmock
import requests
from django.contrib.contenttypes.models import ContentType
from django.core.files.base import ContentFile
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
from webtest import Upload
from welco.sources.mail.models import Mail
@@ -134,7 +134,7 @@ def test_reject_view(settings, app, user):
@httmock.urlmatch(netloc='maarch.example.net', path='/rest/res/resource/status', method='PUT')
def response_ok(url, request):
- assert json.loads(force_text(request.body)) == {'status': 'FOO', 'resId': ['42']}
+ assert json.loads(force_str(request.body)) == {'status': 'FOO', 'resId': ['42']}
headers = {'content-type': 'application/json'}
content = {"maarch_say": "ok"}
return httmock.response(200, content, headers)
diff --git a/tests/test_source_maarch.py b/tests/test_source_maarch.py
index c783fe8..791f395 100644
--- a/tests/test_source_maarch.py
+++ b/tests/test_source_maarch.py
@@ -18,7 +18,7 @@ import json
import pytest
from django.contrib.auth.models import User
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
from httmock import HTTMock, urlmatch
@@ -49,7 +49,7 @@ class BaseMock:
class MaarchMock(BaseMock):
def list_endpoint(self, url, request):
- self.requests.append(('list_endpoint', url, request, json.loads(force_text(request.body))))
+ self.requests.append(('list_endpoint', url, request, json.loads(force_str(request.body))))
return {
'content': json.dumps(self.next_response()),
'headers': {
@@ -61,13 +61,13 @@ class MaarchMock(BaseMock):
list_endpoint.path = '^/rest/res/list$'
def update_external_infos(self, url, request):
- self.requests.append(('update_external_infos', url, request, json.loads(force_text(request.body))))
+ self.requests.append(('update_external_infos', url, request, json.loads(force_str(request.body))))
return json.dumps({})
update_external_infos.path = '^/rest/res/externalInfos$'
def update_status(self, url, request):
- self.requests.append(('update_status', url, request, json.loads(force_text(request.body))))
+ self.requests.append(('update_status', url, request, json.loads(force_str(request.body))))
return {
'content': json.dumps(self.next_response()),
'headers': {
@@ -79,7 +79,7 @@ class MaarchMock(BaseMock):
update_status.path = '^/rest/res/resource/status$'
def post_courrier(self, url, request):
- self.requests.append(('post_courrier', url, request, json.loads(force_text(request.body))))
+ self.requests.append(('post_courrier', url, request, json.loads(force_str(request.body))))
post_courrier.path = '^/rest/res$'
@@ -194,7 +194,7 @@ def test_feed(settings, app, maarch, wcs, user):
'resources': [
{
'res_id': 1,
- 'fileBase64Content': force_text(base64.b64encode(PDF_MOCK)),
+ 'fileBase64Content': force_str(base64.b64encode(PDF_MOCK)),
}
],
}
diff --git a/tests/test_source_phone.py b/tests/test_source_phone.py
index 9952179..f0493ba 100644
--- a/tests/test_source_phone.py
+++ b/tests/test_source_phone.py
@@ -20,7 +20,7 @@ import re
import pytest
from django.test import override_settings
from django.urls import reverse
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
from django.utils.timezone import now, timedelta
from welco.sources.phone import models
@@ -227,18 +227,18 @@ def test_phone_zone(user, client):
client.login(username='toto', password='toto')
response = client.get(reverse('phone-zone'))
assert response.status_code == 200
- assert 'You do not have a phoneline configured' in force_text(response.content)
+ assert 'You do not have a phoneline configured' in force_str(response.content)
models.PhoneLine.take(callee='102', user=user)
response = client.get(reverse('phone-zone'))
assert response.status_code == 200
- assert 'You do not have a phoneline configured' not in force_text(response.content)
- assert '<li>102' in force_text(response.content)
- assert 'data-callee="102"' in force_text(response.content)
+ assert 'You do not have a phoneline configured' not in force_str(response.content)
+ assert '<li>102' in force_str(response.content)
+ assert 'data-callee="102"' in force_str(response.content)
currents = re.search(
'<div id="source-mainarea" ' 'data-current-calls="/api/phone/current-calls/">' '(.*?)</div>',
- force_text(response.content),
+ force_str(response.content),
flags=re.DOTALL,
)
assert currents.group(1).strip() == ''
@@ -249,7 +249,7 @@ def test_phone_zone(user, client):
assert response.status_code == 200
response = client.get(reverse('phone-zone'))
assert response.status_code == 200
- assert '<h1>Current Call: <strong>003369999999</strong></h1>' in force_text(response.content)
+ assert '<h1>Current Call: <strong>003369999999</strong></h1>' in force_str(response.content)
# simulate a mellon user
session = client.session
@@ -257,19 +257,19 @@ def test_phone_zone(user, client):
session.save()
response = client.get(reverse('phone-zone'))
assert response.status_code == 200
- assert 'agent007' not in force_text(response.content)
- assert 'data-callee="agent007"' not in force_text(response.content)
- assert '<li>102' in force_text(response.content)
- assert 'data-callee="102"' in force_text(response.content)
+ assert 'agent007' not in force_str(response.content)
+ assert 'data-callee="agent007"' not in force_str(response.content)
+ assert '<li>102' in force_str(response.content)
+ assert 'data-callee="102"' in force_str(response.content)
with override_settings(PHONE_AUTOTAKE_MELLON_USERNAME=True):
response = client.get(reverse('phone-zone'))
assert response.status_code == 200
- assert '<h1>Current Call: <strong>003369999999</strong></h1>' in force_text(response.content)
- assert 'agent007' in force_text(response.content)
- assert 'data-callee="agent007"' in force_text(response.content)
- assert '<li>102' in force_text(response.content)
- assert 'data-callee="102"' in force_text(response.content)
+ assert '<h1>Current Call: <strong>003369999999</strong></h1>' in force_str(response.content)
+ assert 'agent007' in force_str(response.content)
+ assert 'data-callee="agent007"' in force_str(response.content)
+ assert '<li>102' in force_str(response.content)
+ assert 'data-callee="102"' in force_str(response.content)
def test_call_expiration(user, client):
diff --git a/tox.ini b/tox.ini
index 90c8887..f5117dd 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,8 @@
[tox]
envlist =
- py3-django22-black-coverage-pylint-drf39
- py3-django22-black-coverage-pylint-drf312
+ py3-django22-drf39
+ py3-django22-drf312
+ py3-django32-black-coverage-pylint-drf312
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/welco/{env:BRANCH_NAME:}
[testenv]
@@ -15,6 +16,8 @@ setenv =
coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov-report html --cov=welco/
deps =
django22: django>=2.2,<2.3
+ django32: django>=3.2,<3.3
+ django22: django-haystack<2.8
pytest-cov
pytest-django
pytest!=5.3.3
@@ -29,7 +32,7 @@ deps =
lxml
git+https://git.entrouvert.org/debian/django-ckeditor.git
black: pre-commit
- drf39: djangorestframework>=3.9.2,<3.10
+ drf39: djangorestframework>=3.9,<3.10
drf312: djangorestframework>=3.12,<3.13
commands =
pylint: ./pylint.sh welco/
diff --git a/welco/apps.py b/welco/apps.py
index 6a6c832..ac43808 100644
--- a/welco/apps.py
+++ b/welco/apps.py
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.apps import apps
-from django.conf.urls import include, url
+from django.urls import include, re_path
def register_urls(urlpatterns):
@@ -25,9 +25,9 @@ def register_urls(urlpatterns):
if hasattr(app, 'get_before_urls'):
urls = app.get_before_urls()
if urls:
- pre_urls.append(url('^', include(urls)))
+ pre_urls.append(re_path('^', include(urls)))
if hasattr(app, 'get_after_urls'):
urls = app.get_after_urls()
if urls:
- post_urls.append(url('^', include(urls)))
+ post_urls.append(re_path('^', include(urls)))
return pre_urls + urlpatterns + post_urls
diff --git a/welco/contacts/forms.py b/welco/contacts/forms.py
index 2aa1976..2230109 100644
--- a/welco/contacts/forms.py
+++ b/welco/contacts/forms.py
@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django import forms
+from django.utils.translation import gettext_lazy as _
from django.utils.translation import pgettext_lazy
-from django.utils.translation import ugettext_lazy as _
DEFAULT_TITLE_CHOICES = (
('', ''),
diff --git a/welco/forms.py b/welco/forms.py
index b0cac84..99487b7 100644
--- a/welco/forms.py
+++ b/welco/forms.py
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django import forms
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from .utils import get_wcs_options
diff --git a/welco/kb/models.py b/welco/kb/models.py
index bd6370f..f098c96 100644
--- a/welco/kb/models.py
+++ b/welco/kb/models.py
@@ -17,7 +17,7 @@
from ckeditor.fields import RichTextField
from django.db import models
from django.urls import reverse
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from taggit.managers import TaggableManager
diff --git a/welco/monkeypatch.py b/welco/monkeypatch.py
index c70bfbb..2d4340d 100644
--- a/welco/monkeypatch.py
+++ b/welco/monkeypatch.py
@@ -18,7 +18,7 @@ import ckeditor.widgets
from django.forms.utils import flatatt
from django.template.loader import render_to_string
from django.urls import reverse
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from django.utils.translation import get_language
@@ -41,7 +41,7 @@ def ckeditor_render(self, name, value, attrs=None, renderer=None):
# Force to text to evaluate possible lazy objects
external_plugin_resources = [
- [force_text(a), force_text(b), force_text(c)] for a, b, c in self.external_plugin_resources
+ [force_str(a), force_str(b), force_str(c)] for a, b, c in self.external_plugin_resources
]
return mark_safe(
@@ -49,7 +49,7 @@ def ckeditor_render(self, name, value, attrs=None, renderer=None):
'ckeditor/widget.html',
{
'final_attrs': flatatt(final_attrs),
- 'value': conditional_escape(force_text(value)),
+ 'value': conditional_escape(force_str(value)),
'id': final_attrs['id'],
'config': ckeditor.widgets.json_encode(self.config),
'external_plugin_resources': ckeditor.widgets.json_encode(external_plugin_resources),
diff --git a/welco/qualif/models.py b/welco/qualif/models.py
index 0da32c4..b744de9 100644
--- a/welco/qualif/models.py
+++ b/welco/qualif/models.py
@@ -18,7 +18,7 @@ from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.urls import reverse
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from welco.utils import get_wcs_formdef_details, get_wcs_services, push_wcs_formdata
diff --git a/welco/settings.py b/welco/settings.py
index cfe3dc0..5421f2a 100644
--- a/welco/settings.py
+++ b/welco/settings.py
@@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
import os
from django.conf import global_settings
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
diff --git a/welco/sources/counter/models.py b/welco/sources/counter/models.py
index 5048d1e..b3ea19f 100644
--- a/welco/sources/counter/models.py
+++ b/welco/sources/counter/models.py
@@ -16,7 +16,7 @@
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from welco.qualif.models import Association
diff --git a/welco/sources/counter/urls.py b/welco/sources/counter/urls.py
index f9a9d04..db27026 100644
--- a/welco/sources/counter/urls.py
+++ b/welco/sources/counter/urls.py
@@ -14,10 +14,10 @@
# 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/>.
-from django.conf.urls import url
+from django.urls import path
from . import views
urlpatterns = [
- url(r'^ajax/counter/zone/$', views.zone, name='counter-zone'),
+ path('ajax/counter/zone/', views.zone, name='counter-zone'),
]
diff --git a/welco/sources/mail/forms.py b/welco/sources/mail/forms.py
index 351496a..62d3f1c 100644
--- a/welco/sources/mail/forms.py
+++ b/welco/sources/mail/forms.py
@@ -16,7 +16,7 @@
from django import forms
from django.conf import settings
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
class MailQualificationForm(forms.Form):
diff --git a/welco/sources/mail/models.py b/welco/sources/mail/models.py
index ea185e0..0dad414 100644
--- a/welco/sources/mail/models.py
+++ b/welco/sources/mail/models.py
@@ -25,7 +25,7 @@ from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.urls import reverse
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from welco.qualif.models import Association
from welco.utils import get_wcs_data
diff --git a/welco/sources/mail/urls.py b/welco/sources/mail/urls.py
index a12c355..db95ce6 100644
--- a/welco/sources/mail/urls.py
+++ b/welco/sources/mail/urls.py
@@ -14,17 +14,17 @@
# 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/>.
-from django.conf.urls import url
+from django.urls import path, re_path
from .views import edit_note, feeder, mail_count, mail_response, note, qualification_save, reject, viewer
urlpatterns = [
- url(r'^mail/viewer/$', viewer, name='mail-viewer'),
- url(r'^mail/feeder/$', feeder, name='mail-feeder'),
- url(r'^ajax/mail/reject$', reject, name='mail-reject'),
- url(r'^ajax/qualification-mail-save$', qualification_save, name='qualif-mail-save'),
- url(r'^ajax/mail/edit-note/$', edit_note, name='mail-edit-note'),
- url(r'^ajax/mail/note/(?P<pk>\w+)$', note, name='mail-note'),
- url(r'^ajax/count/mail/$', mail_count, name='mail-count'),
- url(r'^api/mail/response/$', mail_response, name='mail-api-response'),
+ path('mail/viewer/', viewer, name='mail-viewer'),
+ path('mail/feeder/', feeder, name='mail-feeder'),
+ path('ajax/mail/reject', reject, name='mail-reject'),
+ path('ajax/qualification-mail-save', qualification_save, name='qualif-mail-save'),
+ path('ajax/mail/edit-note/', edit_note, name='mail-edit-note'),
+ re_path(r'^ajax/mail/note/(?P<pk>\w+)$', note, name='mail-note'),
+ path('ajax/count/mail/', mail_count, name='mail-count'),
+ path('api/mail/response/', mail_response, name='mail-api-response'),
]
diff --git a/welco/sources/mail/views.py b/welco/sources/mail/views.py
index bccd171..73aaeed 100644
--- a/welco/sources/mail/views.py
+++ b/welco/sources/mail/views.py
@@ -25,7 +25,7 @@ from django.db.transaction import atomic
from django.http import HttpResponse, HttpResponseRedirect
from django.template import RequestContext
from django.urls import reverse
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
from rest_framework import authentication, permissions, serializers, status
diff --git a/welco/sources/phone/models.py b/welco/sources/phone/models.py
index c3f0c67..4174050 100644
--- a/welco/sources/phone/models.py
+++ b/welco/sources/phone/models.py
@@ -21,7 +21,7 @@ from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from django.urls import reverse
from django.utils.timezone import now, timedelta
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from welco.qualif.models import Association
diff --git a/welco/sources/phone/urls.py b/welco/sources/phone/urls.py
index ad16b9c..bb62798 100644
--- a/welco/sources/phone/urls.py
+++ b/welco/sources/phone/urls.py
@@ -14,15 +14,15 @@
# 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/>.
-from django.conf.urls import url
+from django.urls import path, re_path
from . import views
urlpatterns = [
- url(r'^ajax/phone/zone/$', views.zone, name='phone-zone'),
- url(r'^api/phone/call-event/$', views.call_event, name='phone-call-event'),
- url(r'^api/phone/active-call/(?P<pk>\w+)/$', views.active_call, name='phone-active-call'),
- url(r'^api/phone/current-calls/$', views.current_calls, name='phone-current-calls'),
- url(r'^api/phone/take-line/$', views.take_line, name='phone-take-line'),
- url(r'^api/phone/release-line/$', views.release_line, name='phone-release-line'),
+ path('ajax/phone/zone/', views.zone, name='phone-zone'),
+ path('api/phone/call-event/', views.call_event, name='phone-call-event'),
+ re_path(r'^api/phone/active-call/(?P<pk>\w+)/$', views.active_call, name='phone-active-call'),
+ path('api/phone/current-calls/', views.current_calls, name='phone-current-calls'),
+ path('api/phone/take-line/', views.take_line, name='phone-take-line'),
+ path('api/phone/release-line/', views.release_line, name='phone-release-line'),
]
diff --git a/welco/sources/phone/views.py b/welco/sources/phone/views.py
index 3e85734..f258b60 100644
--- a/welco/sources/phone/views.py
+++ b/welco/sources/phone/views.py
@@ -23,7 +23,7 @@ from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
from django.http import HttpResponse, HttpResponseBadRequest
from django.template import RequestContext
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
from django.utils.timezone import now
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
@@ -84,7 +84,7 @@ def call_event(request):
"""
logger = logging.getLogger(__name__)
try:
- payload = json.loads(force_text(request.body))
+ payload = json.loads(force_str(request.body))
assert isinstance(payload, dict), 'payload is not a JSON object'
assert set(payload.keys()) <= {
'event',
@@ -102,7 +102,7 @@ def call_event(request):
assert isinstance(payload['data'], dict), 'data must be a JSON object'
except (TypeError, ValueError, AssertionError) as e:
return HttpResponseBadRequest(
- json.dumps({'err': 1, 'msg': force_text(e)}), content_type='application/json'
+ json.dumps({'err': 1, 'msg': force_str(e)}), content_type='application/json'
)
# janitoring: stop active calls to the callee
if settings.PHONE_ONE_CALL_PER_CALLEE:
@@ -202,12 +202,12 @@ def take_line(request):
"""
logger = logging.getLogger(__name__)
try:
- payload = json.loads(force_text(request.body))
+ payload = json.loads(force_str(request.body))
assert isinstance(payload, dict), 'payload is not a JSON object'
assert list(payload.keys()) == ['callee'], 'payload must have only one key: callee'
except (TypeError, ValueError, AssertionError) as e:
return HttpResponseBadRequest(
- json.dumps({'err': 1, 'msg': force_text(e)}), content_type='application/json'
+ json.dumps({'err': 1, 'msg': force_str(e)}), content_type='application/json'
)
PhoneLine.take(payload['callee'], request.user)
logger.info('user %s took line %s', request.user, payload['callee'])
@@ -223,12 +223,12 @@ def release_line(request):
"""
logger = logging.getLogger(__name__)
try:
- payload = json.loads(force_text(request.body))
+ payload = json.loads(force_str(request.body))
assert isinstance(payload, dict), 'payload is not a JSON object'
assert list(payload.keys()) == ['callee'], 'payload must have only one key: callee'
except (TypeError, ValueError, AssertionError) as e:
return HttpResponseBadRequest(
- json.dumps({'err': 1, 'msg': force_text(e)}), content_type='application/json'
+ json.dumps({'err': 1, 'msg': force_str(e)}), content_type='application/json'
)
PhoneLine.release(payload['callee'], request.user)
logger.info('user %s released line %s', request.user, payload['callee'])
diff --git a/welco/urls.py b/welco/urls.py
index db0400e..8128bfc 100644
--- a/welco/urls.py
+++ b/welco/urls.py
@@ -16,10 +16,10 @@
from ckeditor import views as ckeditor_views
from django.conf import settings
-from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+from django.urls import include, path, re_path
from django.views.decorators.cache import never_cache
import welco.contacts.views
@@ -30,53 +30,53 @@ from . import apps
from .kb.views import kb_manager_required
urlpatterns = [
- url(r'^$', welco.views.home, name='home'),
- url(r'^mail/$', welco.views.home_mail, name='home-mail'),
- url(r'^phone/$', welco.views.home_phone, name='home-phone'),
- url(r'^counter/$', welco.views.home_counter, name='home-counter'),
- url(r'^', include('welco.sources.phone.urls')),
- url(r'^', include('welco.sources.counter.urls')),
- url(r'^ajax/qualification$', welco.views.qualification, name='qualif-zone'),
- url(
+ path('', welco.views.home, name='home'),
+ path('mail/', welco.views.home_mail, name='home-mail'),
+ path('phone/', welco.views.home_phone, name='home-phone'),
+ path('counter/', welco.views.home_counter, name='home-counter'),
+ re_path(r'^', include('welco.sources.phone.urls')),
+ re_path(r'^', include('welco.sources.counter.urls')),
+ path('ajax/qualification', welco.views.qualification, name='qualif-zone'),
+ re_path(
r'^ajax/remove-association/(?P<pk>\w+)$',
welco.views.remove_association,
name='ajax-remove-association',
),
- url(r'^ajax/create-formdata/(?P<pk>\w+)$', welco.views.create_formdata, name='ajax-create-formdata'),
- url(r'^ajax/kb$', welco.kb.views.zone, name='kb-zone'),
- url(r'^kb/$', welco.kb.views.page_list, name='kb-home'),
- url(r'^kb/add/$', welco.kb.views.page_add, name='kb-page-add'),
- url(r'^kb/search/$', welco.kb.views.page_search, name='kb-page-search'),
- url(r'^kb/search/json/$', welco.kb.views.page_search_json, name='kb-page-search-json'),
- url(r'^kb/(?P<slug>[\w-]+)/$', welco.kb.views.page_detail, name='kb-page-view'),
- url(r'^ajax/kb/(?P<slug>[\w-]+)/$', welco.kb.views.page_detail_fragment, name='kb-page-fragment'),
- url(r'^kb/(?P<slug>[\w-]+)/edit$', welco.kb.views.page_edit, name='kb-page-edit'),
- url(r'^kb/(?P<slug>[\w-]+)/delete$', welco.kb.views.page_delete, name='kb-page-delete'),
- url(r'^ajax/contacts$', welco.contacts.views.zone, name='contacts-zone'),
- url(r'^contacts/search/json/$', welco.contacts.views.search_json, name='contacts-search-json'),
- url(
+ re_path(r'^ajax/create-formdata/(?P<pk>\w+)$', welco.views.create_formdata, name='ajax-create-formdata'),
+ path('ajax/kb', welco.kb.views.zone, name='kb-zone'),
+ path('kb/', welco.kb.views.page_list, name='kb-home'),
+ path('kb/add/', welco.kb.views.page_add, name='kb-page-add'),
+ path('kb/search/', welco.kb.views.page_search, name='kb-page-search'),
+ path('kb/search/json/', welco.kb.views.page_search_json, name='kb-page-search-json'),
+ re_path(r'^kb/(?P<slug>[\w-]+)/$', welco.kb.views.page_detail, name='kb-page-view'),
+ re_path(r'^ajax/kb/(?P<slug>[\w-]+)/$', welco.kb.views.page_detail_fragment, name='kb-page-fragment'),
+ re_path(r'^kb/(?P<slug>[\w-]+)/edit$', welco.kb.views.page_edit, name='kb-page-edit'),
+ re_path(r'^kb/(?P<slug>[\w-]+)/delete$', welco.kb.views.page_delete, name='kb-page-delete'),
+ path('ajax/contacts', welco.contacts.views.zone, name='contacts-zone'),
+ path('contacts/search/json/', welco.contacts.views.search_json, name='contacts-search-json'),
+ re_path(
r'^ajax/contacts/(?P<slug>[\w-]+)/$',
welco.contacts.views.contact_detail_fragment,
name='contact-page-fragment',
),
- url(r'^contacts/add/$', welco.contacts.views.contact_add, name='contacts-add'),
- url(
+ path('contacts/add/', welco.contacts.views.contact_add, name='contacts-add'),
+ re_path(
r'^ajax/summary/(?P<source_type>\w+)/(?P<source_pk>\w+)/$',
welco.views.wcs_summary,
name='wcs-summary',
),
- url(r'^admin/', admin.site.urls),
- url(r'^logout/$', welco.views.logout, name='auth_logout'),
- url(r'^login/$', welco.views.login, name='auth_login'),
- url(r'^menu.json$', welco.views.menu_json, name='menu_json'),
- url(r'^ckeditor/upload/', kb_manager_required(ckeditor_views.upload), name='ckeditor_upload'),
- url(
+ re_path(r'^admin/', admin.site.urls),
+ path('logout/', welco.views.logout, name='auth_logout'),
+ path('login/', welco.views.login, name='auth_login'),
+ re_path(r'^menu.json$', welco.views.menu_json, name='menu_json'),
+ re_path(r'^ckeditor/upload/', kb_manager_required(ckeditor_views.upload), name='ckeditor_upload'),
+ re_path(
r'^ckeditor/browse/', never_cache(kb_manager_required(ckeditor_views.browse)), name='ckeditor_browse'
),
]
if 'mellon' in settings.INSTALLED_APPS:
- urlpatterns.append(url(r'^accounts/mellon/', include('mellon.urls')))
+ urlpatterns.append(re_path(r'^accounts/mellon/', include('mellon.urls')))
# static and media files
urlpatterns += staticfiles_urlpatterns()
diff --git a/welco/views.py b/welco/views.py
index 860a549..4dca18e 100644
--- a/welco/views.py
+++ b/welco/views.py
@@ -27,9 +27,9 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import resolve_url
from django.template import RequestContext
from django.urls import reverse
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
from django.utils.http import quote
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
@@ -222,7 +222,7 @@ def menu_json(request):
if user_groups.intersection(channel_groups):
menu.append(
{
- 'label': force_text(labels.get(channel)),
+ 'label': force_str(labels.get(channel)),
'slug': channel,
'url': request.build_absolute_uri(reverse('home-%s' % channel)),
}
@@ -230,7 +230,7 @@ def menu_json(request):
if check_kb_user_perms(request.user, access=True):
menu.append(
{
- 'label': force_text(_('Knowledge Base')),
+ 'label': force_str(_('Knowledge Base')),
'slug': 'book',
'url': request.build_absolute_uri(reverse('kb-home')),
}