diff --git a/requirements.txt b/requirements.txt
index 491ac6446d..658cff9b06 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-Django==2.2.14
+Django==3.2.6
future
captcha
django-statici18n
@@ -8,7 +8,7 @@ mysqlclient
django-picklefield==2.1.1
openpyxl
qrcode
-django-formtools
+django-formtools==2.3
django-simple-captcha
djangorestframework==3.11.1
python-dateutil
diff --git a/seahub/auth/decorators.py b/seahub/auth/decorators.py
index b291847137..feaa219b62 100644
--- a/seahub/auth/decorators.py
+++ b/seahub/auth/decorators.py
@@ -6,7 +6,6 @@ except ImportError:
from seahub.auth import REDIRECT_FIELD_NAME
from django.http import HttpResponseRedirect, HttpResponse, Http404
-from django.utils.decorators import available_attrs
from django.utils.http import urlquote
import json
from django.utils.translation import ugettext as _
@@ -28,7 +27,7 @@ def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIE
path = urlquote(request.get_full_path())
tup = login_url, redirect_field_name, path
return HttpResponseRedirect('%s?%s=%s' % tup)
- return wraps(view_func, assigned=available_attrs(view_func))(_wrapped_view)
+ return wraps(view_func)(_wrapped_view)
return decorator
diff --git a/seahub/auth/forms.py b/seahub/auth/forms.py
index 52817b1757..8ae51b9a28 100644
--- a/seahub/auth/forms.py
+++ b/seahub/auth/forms.py
@@ -3,6 +3,7 @@ from django.conf import settings
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.http import int_to_base36
+from collections import OrderedDict
from seaserv import ccnet_api
@@ -215,7 +216,11 @@ class PasswordChangeForm(SetPasswordForm):
if not self.user.check_password(old_password):
raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again."))
return old_password
-PasswordChangeForm.base_fields.keyOrder = ['old_password', 'new_password1', 'new_password2']
+
+
+field_order = ['old_password', 'new_password1', 'new_password2']
+PasswordChangeForm.base_fields = OrderedDict((k, PasswordChangeForm.base_fields[k]) for k in field_order)
+
class AdminPasswordChangeForm(forms.Form):
"""
diff --git a/seahub/auth/tokens.py b/seahub/auth/tokens.py
index 823cba4ae1..80a0f59511 100644
--- a/seahub/auth/tokens.py
+++ b/seahub/auth/tokens.py
@@ -3,8 +3,7 @@ from datetime import date
from django.conf import settings
from django.utils.http import int_to_base36, base36_to_int
from django.utils.crypto import constant_time_compare, salted_hmac
-from django.utils import six
-
+import six
from seahub.base.models import UserLastLogin
class PasswordResetTokenGenerator(object):
diff --git a/seahub/avatar/views.py b/seahub/avatar/views.py
index 9ec8c1af0e..5388891284 100644
--- a/seahub/avatar/views.py
+++ b/seahub/avatar/views.py
@@ -2,8 +2,7 @@
# encoding: utf-8
from django.core.cache import cache
from django.http import HttpResponseRedirect, Http404
-from django.shortcuts import render_to_response
-from django.template import RequestContext
+from django.shortcuts import render
from django.utils.translation import ugettext as _
from django.conf import settings
from django.contrib import messages
@@ -86,18 +85,6 @@ def add(request, extra_context=None, next_override=None,
# Only allow post request to change avatar.
raise Http404
- # return render_to_response(
- # 'avatar/add.html',
- # extra_context,
- # context_instance = RequestContext(
- # request,
- # { 'avatar': avatar,
- # 'avatars': avatars,
- # 'upload_avatar_form': upload_avatar_form,
- # 'next': next_override or _get_next(request), }
- # )
- # )
-
@login_required
def change(request, extra_context=None, next_override=None,
@@ -125,17 +112,15 @@ def change(request, extra_context=None, next_override=None,
if updated:
avatar_updated.send(sender=Avatar, user=request.user, avatar=avatar)
return HttpResponseRedirect(next_override or _get_next(request))
- return render_to_response(
+ return render(
+ request,
'avatar/change.html',
- extra_context,
- context_instance = RequestContext(
- request,
- { 'avatar': avatar,
- 'avatars': avatars,
- 'upload_avatar_form': upload_avatar_form,
- 'primary_avatar_form': primary_avatar_form,
- 'next': next_override or _get_next(request), }
- )
+ extra_context.update({
+ 'avatar': avatar,
+ 'avatars': avatars,
+ 'upload_avatar_form': upload_avatar_form,
+ 'primary_avatar_form': primary_avatar_form,
+ 'next': next_override or _get_next(request), }),
)
@login_required
@@ -165,16 +150,14 @@ def delete(request, extra_context=None, next_override=None, *args, **kwargs):
messages.success(request, _("Successfully deleted the requested avatars."))
return HttpResponseRedirect(next_override or _get_next(request))
- return render_to_response(
+ return render(
+ request,
'avatar/confirm_delete.html',
- extra_context,
- context_instance = RequestContext(
- request,
- { 'avatar': avatar,
- 'avatars': avatars,
- 'delete_avatar_form': delete_avatar_form,
- 'next': next_override or _get_next(request), }
- )
+ extra_context.update({
+ 'avatar': avatar,
+ 'avatars': avatars,
+ 'delete_avatar_form': delete_avatar_form,
+ 'next': next_override or _get_next(request), }),
)
def render_primary(request, extra_context={}, user=None, size=AVATAR_DEFAULT_SIZE, *args, **kwargs):
diff --git a/seahub/drafts/apps.py b/seahub/drafts/apps.py
deleted file mode 100644
index 2620014c5e..0000000000
--- a/seahub/drafts/apps.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# -*- coding: utf-8 -*-
-
-
-from django.apps import AppConfig
-
-
-class DraftsConfig(AppConfig):
- name = 'drafts'
diff --git a/seahub/file_tags/apps.py b/seahub/file_tags/apps.py
deleted file mode 100644
index 6b3c0a68ed..0000000000
--- a/seahub/file_tags/apps.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# -*- coding: utf-8 -*-
-
-
-from django.apps import AppConfig
-
-
-class FileTagsConfig(AppConfig):
- name = 'file_tags'
diff --git a/seahub/institutions/templates/institutions/user_info.html b/seahub/institutions/templates/institutions/user_info.html
index 05df1979f1..b73c892a11 100644
--- a/seahub/institutions/templates/institutions/user_info.html
+++ b/seahub/institutions/templates/institutions/user_info.html
@@ -1,6 +1,6 @@
{% extends "institutions/base.html" %}
{% load i18n avatar_tags seahub_tags %}
-{% load staticfiles %}
+{% load static %}
{% block right_panel %}
diff --git a/seahub/related_files/apps.py b/seahub/related_files/apps.py
deleted file mode 100644
index 1c3c3c9d89..0000000000
--- a/seahub/related_files/apps.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# -*- coding: utf-8 -*-
-
-
-from django.apps import AppConfig
-
-
-class RelatedFilesConfig(AppConfig):
- name = 'related_files'
diff --git a/seahub/settings.py b/seahub/settings.py
index 2bb0502580..cf975aa011 100644
--- a/seahub/settings.py
+++ b/seahub/settings.py
@@ -35,6 +35,10 @@ DATABASES = {
}
}
+# New in Django 3.2
+# Default primary key field type to use for models that don’t have a field with primary_key=True.
+DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
+
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
diff --git a/seahub/templates/base.html b/seahub/templates/base.html
index 28c0d358b9..075e425765 100644
--- a/seahub/templates/base.html
+++ b/seahub/templates/base.html
@@ -1,4 +1,4 @@
-{% load seahub_tags i18n staticfiles %}
+{% load seahub_tags i18n static %}
diff --git a/seahub/templates/base_for_react.html b/seahub/templates/base_for_react.html
index ec81d94774..d78fc2e0f5 100644
--- a/seahub/templates/base_for_react.html
+++ b/seahub/templates/base_for_react.html
@@ -1,4 +1,4 @@
-{% load seahub_tags i18n staticfiles %}
+{% load seahub_tags i18n static %}
{% load render_bundle from webpack_loader %}
diff --git a/seahub/templates/view_file_onlyoffice.html b/seahub/templates/view_file_onlyoffice.html
index d498351be9..748c4ca27f 100644
--- a/seahub/templates/view_file_onlyoffice.html
+++ b/seahub/templates/view_file_onlyoffice.html
@@ -1,4 +1,4 @@
-{% load seahub_tags i18n staticfiles %}
+{% load seahub_tags i18n static %}
diff --git a/seahub/templates/view_file_wopi.html b/seahub/templates/view_file_wopi.html
index b67c7fb923..2a8a044254 100644
--- a/seahub/templates/view_file_wopi.html
+++ b/seahub/templates/view_file_wopi.html
@@ -1,5 +1,5 @@
-{% load i18n staticfiles %}
+{% load i18n static %}
{{doc_title}}
diff --git a/seahub/test_utils.py b/seahub/test_utils.py
index 07f327bb0e..75087298aa 100644
--- a/seahub/test_utils.py
+++ b/seahub/test_utils.py
@@ -9,7 +9,6 @@ from django.conf import settings
from django.http import SimpleCookie
from django.test import RequestFactory
from django.test import TestCase
-from django.test import override_settings
from exam.decorators import fixture
from exam.cases import Exam
import seaserv
diff --git a/seahub/trusted_ip/middleware.py b/seahub/trusted_ip/middleware.py
index 4da9673eec..b0fa4470a3 100644
--- a/seahub/trusted_ip/middleware.py
+++ b/seahub/trusted_ip/middleware.py
@@ -2,7 +2,7 @@
import json
from django.http import HttpResponse
-from django.shortcuts import render_to_response
+from django.shortcuts import render
from django.utils.deprecation import MiddlewareMixin
from seahub.utils.ip import get_remote_ip
@@ -25,5 +25,5 @@ class LimitIpMiddleware(MiddlewareMixin):
content_type='application/json; charset=utf-8'
)
else:
- return render_to_response('trusted_ip/403_trusted_ip.html',
- status=403)
+ return render(request, 'trusted_ip/403_trusted_ip.html',
+ status=403)
diff --git a/seahub/two_factor/conf.py b/seahub/two_factor/conf.py
index 839de5d4f3..6142d36fa9 100644
--- a/seahub/two_factor/conf.py
+++ b/seahub/two_factor/conf.py
@@ -1,6 +1,6 @@
# Copyright (c) 2012-2016 Seafile Ltd.
import django.conf
-from django.utils.six import iteritems
+from six import iteritems
class Settings(object):
diff --git a/seahub/two_factor/models/base.py b/seahub/two_factor/models/base.py
index ea52862852..716f6ce4d9 100644
--- a/seahub/two_factor/models/base.py
+++ b/seahub/two_factor/models/base.py
@@ -1,18 +1,13 @@
# Copyright (c) 2012-2016 Seafile Ltd.
-
-from binascii import unhexlify
import logging
from django.conf import settings
-from django.core.exceptions import ObjectDoesNotExist
from django.db import models
-from django.utils import six
from django.utils.translation import ugettext_lazy as _
from seahub.base.fields import LowerCaseCharField
-from seahub.two_factor.oath import totp
-from seahub.two_factor.utils import hex_validator, random_hex
+from seahub.two_factor.utils import hex_validator
logger = logging.getLogger(__name__)
diff --git a/seahub/two_factor/oath.py b/seahub/two_factor/oath.py
index 582dff2dac..a89de6213d 100644
--- a/seahub/two_factor/oath.py
+++ b/seahub/two_factor/oath.py
@@ -6,7 +6,7 @@ import hmac
from struct import pack
from time import time
-from django.utils import six
+import six
if six.PY3:
iterbytes = iter
diff --git a/seahub/two_factor/utils.py b/seahub/two_factor/utils.py
index 82f247df99..60aa16779b 100644
--- a/seahub/two_factor/utils.py
+++ b/seahub/two_factor/utils.py
@@ -12,7 +12,7 @@ except ImportError:
from django.conf import settings
from django.core.exceptions import ValidationError
-from django.utils import six
+import six
def get_otpauth_url(accountname, secret, issuer=None, digits=None):
# For a complete run-through of all the parameters, have a look at the
diff --git a/seahub/two_factor/views/core.py b/seahub/two_factor/views/core.py
index f9a90a2cfb..2be8384f9c 100644
--- a/seahub/two_factor/views/core.py
+++ b/seahub/two_factor/views/core.py
@@ -20,12 +20,6 @@ from django.views.generic.base import View
import qrcode
import qrcode.image.svg
-try:
- from formtools.wizard.views import SessionWizardView
-except ImportError:
- # pylint: disable=import-error,no-name-in-module
- from django.contrib.formtools.wizard.views import SessionWizardView
-
from seahub.auth import login as login, REDIRECT_FIELD_NAME
from seahub.auth.decorators import login_required
from seahub.auth.forms import AuthenticationForm
diff --git a/seahub/two_factor/views/utils.py b/seahub/two_factor/views/utils.py
index bb52940e48..dd0304b88f 100644
--- a/seahub/two_factor/views/utils.py
+++ b/seahub/two_factor/views/utils.py
@@ -8,15 +8,9 @@ from django.utils.translation import ugettext as _
from django.urls import reverse
from django.http import HttpResponseRedirect
-try:
- from formtools.wizard.forms import ManagementForm
- from formtools.wizard.views import SessionWizardView
- from formtools.wizard.storage.session import SessionStorage
-except ImportError:
- # pylint: disable=import-error,no-name-in-module
- from django.contrib.formtools.wizard.forms import ManagementForm
- from django.contrib.formtools.wizard.views import SessionWizardView
- from django.contrib.formtools.wizard.storage.session import SessionStorage
+from formtools.wizard.forms import ManagementForm
+from formtools.wizard.views import SessionWizardView
+from formtools.wizard.storage.session import SessionStorage
logger = logging.getLogger(__name__)
diff --git a/seahub/urls.py b/seahub/urls.py
index 928dc63ff8..782f27dc84 100644
--- a/seahub/urls.py
+++ b/seahub/urls.py
@@ -1,7 +1,5 @@
# Copyright (c) 2012-2016 Seafile Ltd.
-from django.conf import settings
from django.conf.urls import url, include
-# from django.views.generic.simple import direct_to_template
from django.views.generic import TemplateView
from seahub.views import *
diff --git a/seahub/utils/timeutils.py b/seahub/utils/timeutils.py
index a0cc505090..abf9b43132 100644
--- a/seahub/utils/timeutils.py
+++ b/seahub/utils/timeutils.py
@@ -3,7 +3,7 @@ import logging
import pytz
import datetime
from django.conf import settings
-from django.utils import six
+import six
from django.utils import timezone
from django.utils.timezone import get_current_timezone
diff --git a/tests/api/endpoints/admin/test_groups.py b/tests/api/endpoints/admin/test_groups.py
index c5cd08acd0..4cc14d5b75 100644
--- a/tests/api/endpoints/admin/test_groups.py
+++ b/tests/api/endpoints/admin/test_groups.py
@@ -4,6 +4,7 @@ from django.urls import reverse
from seahub.test_utils import BaseTestCase
from tests.common.utils import randstring
+
class GroupsTest(BaseTestCase):
def setUp(self):
diff --git a/thirdpart/registration/backends/default/urls.py b/thirdpart/registration/backends/default/urls.py
index e0ca9e92c3..57eb1be4e0 100644
--- a/thirdpart/registration/backends/default/urls.py
+++ b/thirdpart/registration/backends/default/urls.py
@@ -19,7 +19,7 @@ up your own URL patterns for these views instead.
from django.conf.urls import url, include
-from django.views.generic.simple import direct_to_template
+from django.views.generic import TemplateView
from registration.views import activate
from registration.views import register
@@ -27,8 +27,7 @@ from registration.views import register
urlpatterns = [
url(r'^activate/complete/$',
- direct_to_template,
- { 'template': 'registration/activation_complete.html' },
+ TemplateView.as_view(template_name='registration/activation_complete.html'),
name='registration_activation_complete'),
# Activation keys get matched by \w+ instead of the more specific
# [a-fA-F0-9]{40} because a bad activation key should still get to the view;
@@ -43,12 +42,10 @@ urlpatterns = [
{ 'backend': 'registration.backends.default.DefaultBackend' },
name='registration_register'),
url(r'^register/complete/$',
- direct_to_template,
- { 'template': 'registration/registration_complete.html' },
+ TemplateView.as_view(template_name='registration/registration_complete.html'),
name='registration_complete'),
url(r'^register/closed/$',
- direct_to_template,
- { 'template': 'registration/registration_closed.html' },
+ TemplateView.as_view(template_name='registration/registration_closed.html'),
name='registration_disallowed'),
url(r'', include('registration.auth_urls')),
]
diff --git a/thirdpart/termsandconditions/decorators.py b/thirdpart/termsandconditions/decorators.py
index 26aaf58e84..e9768cbfb5 100644
--- a/thirdpart/termsandconditions/decorators.py
+++ b/thirdpart/termsandconditions/decorators.py
@@ -5,7 +5,6 @@ except ImportError:
from urllib.parse import urlparse, urlunparse
from functools import wraps
from django.http import HttpResponseRedirect, QueryDict
-from django.utils.decorators import available_attrs
from .models import TermsAndConditions
from .middleware import ACCEPT_TERMS_PATH
@@ -15,7 +14,7 @@ def terms_required(view_func):
This decorator checks to see if the user is logged in, and if so, if they have accepted the site terms.
"""
- @wraps(view_func, assigned=available_attrs(view_func))
+ @wraps(view_func)
def _wrapped_view(request, *args, **kwargs):
"""Method to wrap the view passed in"""
if not request.user.is_authenticated or TermsAndConditions.agreed_to_latest(request.user):
diff --git a/thirdpart/termsandconditions/templates/termsandconditions/snippets/termsandconditions.html b/thirdpart/termsandconditions/templates/termsandconditions/snippets/termsandconditions.html
index 2611fbf2cc..f6e021395d 100644
--- a/thirdpart/termsandconditions/templates/termsandconditions/snippets/termsandconditions.html
+++ b/thirdpart/termsandconditions/templates/termsandconditions/snippets/termsandconditions.html
@@ -1,4 +1,4 @@
-{% load staticfiles %}
+{% load static %}
{% load i18n %}
{% if terms %}