Commit 0a55d58d authored by Antonio Terceiro's avatar Antonio Terceiro
Browse files

Merge branch 'django-3.2' into 'master'

Django 3.2 compatibility

See merge request lava/lava!1617
parents 609b59bb d68a8401
Pipeline #11814 passed with stages
in 21 minutes and 45 seconds
......@@ -17,7 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with LAVA. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import include, url
from django.conf.urls import include
from lava_server.compat import url
from lava_rest_app.base.views import LavaObtainAuthToken
from . import versions
......
......@@ -23,7 +23,7 @@ import xmlrpc.client
from linaro_django_xmlrpc.models import ExposedAPI
from django.db.models.fields import FieldDoesNotExist
from django.core.exceptions import FieldDoesNotExist
from lava_common.compat import yaml_dump
from lava_results_app.dbutils import export_testsuite, testsuite_export_fields
......
......@@ -45,7 +45,7 @@ from django.db.models.fields import Field
from django.db.models.signals import pre_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 django.utils import timezone
from lava_common.compat import yaml_load
......
......@@ -21,7 +21,7 @@
"""
URL mappings for the LAVA Results application
"""
from django.conf.urls import url
from lava_server.compat import url
from lava_results_app.views import (
index,
metadata_export,
......
......@@ -25,14 +25,14 @@ import logging
from django.db import DataError
from django.core.exceptions import PermissionDenied
from django.utils.translation import ungettext_lazy
from django.utils.translation import ngettext_lazy
from lava_common.compat import yaml_load
from linaro_django_xmlrpc.models import AuthToken
def help_max_length(max_length):
return ungettext_lazy(
return ngettext_lazy(
u"Maximum length: {0} character", u"Maximum length: {0} characters", max_length
).format(max_length)
......
......@@ -17,16 +17,16 @@
# You should have received a copy of the GNU Affero General Public License
# along with LAVA. If not, see <http://www.gnu.org/licenses/>.
from functools import wraps
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404
from django.utils.decorators import available_attrs
from django.utils.functional import wraps
from lava_results_app.models import Chart
def ownership_required(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
@wraps(view_func)
def wrapper(request, *args, **kwargs):
report_name = kwargs.get("name")
chart = get_object_or_404(Chart, name=report_name)
......
......@@ -17,16 +17,16 @@
# You should have received a copy of the GNU Affero General Public License
# along with LAVA. If not, see <http://www.gnu.org/licenses/>.
from functools import wraps
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404
from django.utils.decorators import available_attrs
from django.utils.functional import wraps
from lava_results_app.models import Query
def ownership_required(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
@wraps(view_func)
def wrapper(request, *args, **kwargs):
report_name = kwargs.get("name")
username = kwargs.get("username")
......
......@@ -47,7 +47,7 @@ from django.urls import reverse
from django.db import models
from django.utils import timezone
from django.utils.html import escape
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.safestring import mark_safe
from lava_common.compat import yaml_dump, yaml_safe_load, yaml_safe_dump
......
......@@ -18,7 +18,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with LAVA. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from lava_server.compat import url
from lava_scheduler_app.views import (
active_device_list,
active_jobs,
......
......@@ -68,7 +68,7 @@ from lava_common.version import __version__
from lava_results_app.dbutils import map_scanned_results, create_metadata_store
from lava_server.views import index as lava_index
from lava_server.bread_crumbs import BreadCrumb, BreadCrumbTrail
from lava_server.compat import djt2_paginator_class
from lava_server.compat import djt2_paginator_class, is_ajax
from lava_server.files import File
from lava_scheduler_app.models import (
......@@ -1575,7 +1575,7 @@ def job_submit(request):
}
if request.method == "POST" and request.user.is_authenticated:
if request.is_ajax():
if is_ajax(request):
warnings = ""
errors = ""
try:
......@@ -2258,7 +2258,7 @@ def job_resubmit(request, pk):
request, "lava_scheduler_app/job_submit.html", response_data
)
else:
if request.is_ajax():
if is_ajax(request):
warnings = ""
errors = ""
try:
......
......@@ -28,6 +28,13 @@ DJANGO_VERSION = get_version()
DRFE_VERSION = [int(n) for n in DRFE_VERSION_STR.split(".")]
try:
# pylint: disable=unused-import
from django.urls import re_path as url # noqa
except ImportError:
# pylint: disable=unused-import
from django.conf.urls import url # noqa
# Handles compatibility for django_restframework_filters
try:
from rest_framework_filters.backends import RestFrameworkFilterBackend # noqa
......@@ -220,3 +227,7 @@ except ImportError:
def djt2_paginator_class():
return {"klass": LazyPaginator}
def is_ajax(request):
return request.META.get("HTTP_X_REQUESTED_WITH") == "XMLHttpRequest"
......@@ -24,9 +24,14 @@ import contextlib
import imp
import re
from django.conf.global_settings import *
from django.core.exceptions import ImproperlyConfigured
# pylint: disable=unused-import
from django.conf.global_settings import DISALLOWED_USER_AGENTS
# pylint: disable=unused-import
from django.conf.global_settings import INTERNAL_IPS
from lava_common.version import __version__
from lava_common.compat import yaml_safe_load
from lava_rest_app.versions import versions as REST_VERSIONS
......@@ -158,6 +163,7 @@ CSRF_COOKIE_HTTPONLY = True
X_FRAME_OPTIONS = "DENY"
HTTPS_XML_RPC = True
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
########################
# LAVA custom settings #
......
......@@ -19,7 +19,8 @@
from django.views.generic import TemplateView
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls import include
from lava_server.compat import url
from django.contrib import admin
from linaro_django_xmlrpc.views import handler as linaro_django_xmlrpc_views_handler
from linaro_django_xmlrpc.views import help as linaro_django_xmlrpc_views_help
......
......@@ -30,7 +30,7 @@ from django.http import (
)
from django.shortcuts import render
from django.template import loader
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.decorators.csrf import requires_csrf_token
from django.views.decorators.http import require_POST
......
......@@ -17,7 +17,7 @@
# along with linaro-django-xmlrpc. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from lava_server.compat import url
from linaro_django_xmlrpc.views import (
create_token,
......
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