mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-17 16:52:09 +00:00
Merge pull request #4968 from haiwen/upgrade-django-to-3.2
upgrade django to 3.2
This commit is contained in:
commit
46fdbb282f
@ -1,4 +1,4 @@
|
|||||||
Django==2.2.14
|
Django==3.2.6
|
||||||
future
|
future
|
||||||
captcha
|
captcha
|
||||||
django-statici18n
|
django-statici18n
|
||||||
@ -8,7 +8,7 @@ mysqlclient
|
|||||||
django-picklefield==2.1.1
|
django-picklefield==2.1.1
|
||||||
openpyxl
|
openpyxl
|
||||||
qrcode
|
qrcode
|
||||||
django-formtools
|
django-formtools==2.3
|
||||||
django-simple-captcha
|
django-simple-captcha
|
||||||
djangorestframework==3.11.1
|
djangorestframework==3.11.1
|
||||||
python-dateutil
|
python-dateutil
|
||||||
|
@ -6,7 +6,6 @@ except ImportError:
|
|||||||
|
|
||||||
from seahub.auth import REDIRECT_FIELD_NAME
|
from seahub.auth import REDIRECT_FIELD_NAME
|
||||||
from django.http import HttpResponseRedirect, HttpResponse, Http404
|
from django.http import HttpResponseRedirect, HttpResponse, Http404
|
||||||
from django.utils.decorators import available_attrs
|
|
||||||
from django.utils.http import urlquote
|
from django.utils.http import urlquote
|
||||||
import json
|
import json
|
||||||
from django.utils.translation import ugettext as _
|
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())
|
path = urlquote(request.get_full_path())
|
||||||
tup = login_url, redirect_field_name, path
|
tup = login_url, redirect_field_name, path
|
||||||
return HttpResponseRedirect('%s?%s=%s' % tup)
|
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
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ from django.conf import settings
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils.http import int_to_base36
|
from django.utils.http import int_to_base36
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
from seaserv import ccnet_api
|
from seaserv import ccnet_api
|
||||||
|
|
||||||
@ -215,7 +216,11 @@ class PasswordChangeForm(SetPasswordForm):
|
|||||||
if not self.user.check_password(old_password):
|
if not self.user.check_password(old_password):
|
||||||
raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again."))
|
raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again."))
|
||||||
return old_password
|
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):
|
class AdminPasswordChangeForm(forms.Form):
|
||||||
"""
|
"""
|
||||||
|
@ -3,8 +3,7 @@ from datetime import date
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.http import int_to_base36, base36_to_int
|
from django.utils.http import int_to_base36, base36_to_int
|
||||||
from django.utils.crypto import constant_time_compare, salted_hmac
|
from django.utils.crypto import constant_time_compare, salted_hmac
|
||||||
from django.utils import six
|
import six
|
||||||
|
|
||||||
from seahub.base.models import UserLastLogin
|
from seahub.base.models import UserLastLogin
|
||||||
|
|
||||||
class PasswordResetTokenGenerator(object):
|
class PasswordResetTokenGenerator(object):
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.http import HttpResponseRedirect, Http404
|
from django.http import HttpResponseRedirect, Http404
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render
|
||||||
from django.template import RequestContext
|
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import messages
|
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.
|
# Only allow post request to change avatar.
|
||||||
raise Http404
|
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
|
@login_required
|
||||||
def change(request, extra_context=None, next_override=None,
|
def change(request, extra_context=None, next_override=None,
|
||||||
@ -125,17 +112,15 @@ def change(request, extra_context=None, next_override=None,
|
|||||||
if updated:
|
if updated:
|
||||||
avatar_updated.send(sender=Avatar, user=request.user, avatar=avatar)
|
avatar_updated.send(sender=Avatar, user=request.user, avatar=avatar)
|
||||||
return HttpResponseRedirect(next_override or _get_next(request))
|
return HttpResponseRedirect(next_override or _get_next(request))
|
||||||
return render_to_response(
|
return render(
|
||||||
'avatar/change.html',
|
|
||||||
extra_context,
|
|
||||||
context_instance = RequestContext(
|
|
||||||
request,
|
request,
|
||||||
{ 'avatar': avatar,
|
'avatar/change.html',
|
||||||
|
extra_context.update({
|
||||||
|
'avatar': avatar,
|
||||||
'avatars': avatars,
|
'avatars': avatars,
|
||||||
'upload_avatar_form': upload_avatar_form,
|
'upload_avatar_form': upload_avatar_form,
|
||||||
'primary_avatar_form': primary_avatar_form,
|
'primary_avatar_form': primary_avatar_form,
|
||||||
'next': next_override or _get_next(request), }
|
'next': next_override or _get_next(request), }),
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@login_required
|
@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."))
|
messages.success(request, _("Successfully deleted the requested avatars."))
|
||||||
return HttpResponseRedirect(next_override or _get_next(request))
|
return HttpResponseRedirect(next_override or _get_next(request))
|
||||||
return render_to_response(
|
return render(
|
||||||
'avatar/confirm_delete.html',
|
|
||||||
extra_context,
|
|
||||||
context_instance = RequestContext(
|
|
||||||
request,
|
request,
|
||||||
{ 'avatar': avatar,
|
'avatar/confirm_delete.html',
|
||||||
|
extra_context.update({
|
||||||
|
'avatar': avatar,
|
||||||
'avatars': avatars,
|
'avatars': avatars,
|
||||||
'delete_avatar_form': delete_avatar_form,
|
'delete_avatar_form': delete_avatar_form,
|
||||||
'next': next_override or _get_next(request), }
|
'next': next_override or _get_next(request), }),
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def render_primary(request, extra_context={}, user=None, size=AVATAR_DEFAULT_SIZE, *args, **kwargs):
|
def render_primary(request, extra_context={}, user=None, size=AVATAR_DEFAULT_SIZE, *args, **kwargs):
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
from django.utils.six.moves import urllib_parse
|
from six.moves import urllib_parse
|
||||||
|
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from django.conf import settings as django_settings
|
from django.conf import settings as django_settings
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from urllib import parse as urllib_parse
|
from six.moves import urllib_parse
|
||||||
from django.shortcuts import resolve_url
|
from django.shortcuts import resolve_url
|
||||||
|
|
||||||
from seahub.auth import REDIRECT_FIELD_NAME, SESSION_KEY, BACKEND_SESSION_KEY, load_backend
|
from seahub.auth import REDIRECT_FIELD_NAME, SESSION_KEY, BACKEND_SESSION_KEY, load_backend
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from django.utils.six.moves import urllib_parse
|
from six.moves import urllib_parse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class DraftsConfig(AppConfig):
|
|
||||||
name = 'drafts'
|
|
@ -1,8 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class FileTagsConfig(AppConfig):
|
|
||||||
name = 'file_tags'
|
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "institutions/base.html" %}
|
{% extends "institutions/base.html" %}
|
||||||
{% load i18n avatar_tags seahub_tags %}
|
{% load i18n avatar_tags seahub_tags %}
|
||||||
{% load staticfiles %}
|
{% load static %}
|
||||||
|
|
||||||
{% block right_panel %}
|
{% block right_panel %}
|
||||||
<p class="path-bar">
|
<p class="path-bar">
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class RelatedFilesConfig(AppConfig):
|
|
||||||
name = 'related_files'
|
|
@ -1,6 +1,6 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% load seahub_tags avatar_tags i18n staticfiles %}
|
{% load seahub_tags avatar_tags i18n static %}
|
||||||
|
|
||||||
|
|
||||||
{% block extra_style %}
|
{% block extra_style %}
|
||||||
|
@ -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:
|
# Local time zone for this installation. Choices can be found here:
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||||
# although not all choices may be available on all operating systems.
|
# although not all choices may be available on all operating systems.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load seahub_tags i18n staticfiles %}
|
{% load seahub_tags i18n static %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="{{ LANGUAGE_CODE }}">
|
<html lang="{{ LANGUAGE_CODE }}">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load seahub_tags i18n staticfiles %}
|
{% load seahub_tags i18n static %}
|
||||||
{% load render_bundle from webpack_loader %}
|
{% load render_bundle from webpack_loader %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load seahub_tags i18n staticfiles %}
|
{% load seahub_tags i18n static %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
{% load i18n staticfiles %}
|
{% load i18n static %}
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>{{doc_title}}</title>
|
<title>{{doc_title}}</title>
|
||||||
|
@ -9,7 +9,6 @@ from django.conf import settings
|
|||||||
from django.http import SimpleCookie
|
from django.http import SimpleCookie
|
||||||
from django.test import RequestFactory
|
from django.test import RequestFactory
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test import override_settings
|
|
||||||
from exam.decorators import fixture
|
from exam.decorators import fixture
|
||||||
from exam.cases import Exam
|
from exam.cases import Exam
|
||||||
import seaserv
|
import seaserv
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render
|
||||||
from django.utils.deprecation import MiddlewareMixin
|
from django.utils.deprecation import MiddlewareMixin
|
||||||
|
|
||||||
from seahub.utils.ip import get_remote_ip
|
from seahub.utils.ip import get_remote_ip
|
||||||
@ -25,5 +25,5 @@ class LimitIpMiddleware(MiddlewareMixin):
|
|||||||
content_type='application/json; charset=utf-8'
|
content_type='application/json; charset=utf-8'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return render_to_response('trusted_ip/403_trusted_ip.html',
|
return render(request, 'trusted_ip/403_trusted_ip.html',
|
||||||
status=403)
|
status=403)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Copyright (c) 2012-2016 Seafile Ltd.
|
# Copyright (c) 2012-2016 Seafile Ltd.
|
||||||
import django.conf
|
import django.conf
|
||||||
from django.utils.six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
|
|
||||||
class Settings(object):
|
class Settings(object):
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
# Copyright (c) 2012-2016 Seafile Ltd.
|
# Copyright (c) 2012-2016 Seafile Ltd.
|
||||||
|
|
||||||
|
|
||||||
from binascii import unhexlify
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import six
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from seahub.base.fields import LowerCaseCharField
|
from seahub.base.fields import LowerCaseCharField
|
||||||
from seahub.two_factor.oath import totp
|
from seahub.two_factor.utils import hex_validator
|
||||||
from seahub.two_factor.utils import hex_validator, random_hex
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import hmac
|
|||||||
from struct import pack
|
from struct import pack
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from django.utils import six
|
import six
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
iterbytes = iter
|
iterbytes = iter
|
||||||
|
@ -12,7 +12,7 @@ except ImportError:
|
|||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils import six
|
import six
|
||||||
|
|
||||||
def get_otpauth_url(accountname, secret, issuer=None, digits=None):
|
def get_otpauth_url(accountname, secret, issuer=None, digits=None):
|
||||||
# For a complete run-through of all the parameters, have a look at the
|
# For a complete run-through of all the parameters, have a look at the
|
||||||
|
@ -20,12 +20,6 @@ from django.views.generic.base import View
|
|||||||
import qrcode
|
import qrcode
|
||||||
import qrcode.image.svg
|
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 import login as login, REDIRECT_FIELD_NAME
|
||||||
from seahub.auth.decorators import login_required
|
from seahub.auth.decorators import login_required
|
||||||
from seahub.auth.forms import AuthenticationForm
|
from seahub.auth.forms import AuthenticationForm
|
||||||
|
@ -8,15 +8,9 @@ from django.utils.translation import ugettext as _
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
|
|
||||||
try:
|
from formtools.wizard.forms import ManagementForm
|
||||||
from formtools.wizard.forms import ManagementForm
|
from formtools.wizard.views import SessionWizardView
|
||||||
from formtools.wizard.views import SessionWizardView
|
from formtools.wizard.storage.session import SessionStorage
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
# Copyright (c) 2012-2016 Seafile Ltd.
|
# Copyright (c) 2012-2016 Seafile Ltd.
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
# from django.views.generic.simple import direct_to_template
|
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
from seahub.views import *
|
from seahub.views import *
|
||||||
@ -198,7 +196,6 @@ urlpatterns = [
|
|||||||
url(r'^thirdparty-editor/', include('seahub.thirdparty_editor.urls')),
|
url(r'^thirdparty-editor/', include('seahub.thirdparty_editor.urls')),
|
||||||
|
|
||||||
url(r'^$', react_fake_view, name='libraries'),
|
url(r'^$', react_fake_view, name='libraries'),
|
||||||
#url(r'^home/$', direct_to_template, { 'template': 'home.html' } ),
|
|
||||||
url(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
|
url(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
|
||||||
|
|
||||||
# revert repo
|
# revert repo
|
||||||
|
@ -3,7 +3,7 @@ import logging
|
|||||||
import pytz
|
import pytz
|
||||||
import datetime
|
import datetime
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils import six
|
import six
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.timezone import get_current_timezone
|
from django.utils.timezone import get_current_timezone
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ from django.urls import reverse
|
|||||||
from seahub.test_utils import BaseTestCase
|
from seahub.test_utils import BaseTestCase
|
||||||
from tests.common.utils import randstring
|
from tests.common.utils import randstring
|
||||||
|
|
||||||
|
|
||||||
class GroupsTest(BaseTestCase):
|
class GroupsTest(BaseTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -31,10 +31,8 @@ class FileCommentsTest(BaseTestCase):
|
|||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
|
|
||||||
json_resp = json.loads(resp.content)
|
json_resp = json.loads(resp.content)
|
||||||
assert len(resp._headers.get('links')) == 2
|
|
||||||
assert resp._headers.get('links')[0] == 'Links'
|
|
||||||
link = reverse('api2-file-comments', args=[self.repo.id]) + '?page=1&per_page=5'
|
link = reverse('api2-file-comments', args=[self.repo.id]) + '?page=1&per_page=5'
|
||||||
assert link in resp._headers.get('links')[1]
|
assert link in resp.headers.get('links')
|
||||||
assert len(json_resp['comments']) == 5
|
assert len(json_resp['comments']) == 5
|
||||||
assert json_resp['comments'][0]['comment'] == 'test comment5'
|
assert json_resp['comments'][0]['comment'] == 'test comment5'
|
||||||
assert json_resp['comments'][0]['user_email'] == self.tmp_user.email
|
assert json_resp['comments'][0]['user_email'] == self.tmp_user.email
|
||||||
|
@ -56,10 +56,10 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.assertRegex(resp._headers['location'][1],
|
self.assertRegex(resp.headers['location'],
|
||||||
r'http(.*)/f/(\w{10,100})/')
|
r'http(.*)/f/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
self.assertIsNotNone(FileShare.objects.get(token=token))
|
self.assertIsNotNone(FileShare.objects.get(token=token))
|
||||||
|
|
||||||
def test_can_create_file_download_link_with_exipre(self):
|
def test_can_create_file_download_link_with_exipre(self):
|
||||||
@ -72,10 +72,10 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.assertRegex(resp._headers['location'][1],
|
self.assertRegex(resp.headers['location'],
|
||||||
r'http(.*)/f/(\w{10,100})/')
|
r'http(.*)/f/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
fileshare = FileShare.objects.get(token=token)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.expire_date)
|
self.assertIsNotNone(fileshare.expire_date)
|
||||||
|
|
||||||
@ -89,10 +89,10 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.assertRegex(resp._headers['location'][1],
|
self.assertRegex(resp.headers['location'],
|
||||||
r'http(.*)/f/(\w{10,100})/')
|
r'http(.*)/f/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
fileshare = FileShare.objects.get(token=token)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.password)
|
self.assertIsNotNone(fileshare.password)
|
||||||
|
|
||||||
@ -106,10 +106,10 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.assertRegex(resp._headers['location'][1],
|
self.assertRegex(resp.headers['location'],
|
||||||
r'http(.*)/f/(\w{10,100})/')
|
r'http(.*)/f/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
fileshare = FileShare.objects.get(token=token)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.expire_date)
|
self.assertIsNotNone(fileshare.expire_date)
|
||||||
self.assertIsNotNone(fileshare.password)
|
self.assertIsNotNone(fileshare.password)
|
||||||
@ -124,11 +124,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.dir_link_location = resp._headers['location'][1]
|
self.dir_link_location = resp.headers['location']
|
||||||
self.assertRegex(self.dir_link_location,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/d/(\w{10,100})/')
|
r'http(.*)/d/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
self.assertIsNotNone(FileShare.objects.get(token=token))
|
self.assertIsNotNone(FileShare.objects.get(token=token))
|
||||||
|
|
||||||
def test_can_create_dir_download_link_with_exipre(self):
|
def test_can_create_dir_download_link_with_exipre(self):
|
||||||
@ -141,11 +141,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.dir_link_location = resp._headers['location'][1]
|
self.dir_link_location = resp.headers['location']
|
||||||
self.assertRegex(self.dir_link_location,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/d/(\w{10,100})/')
|
r'http(.*)/d/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
fileshare = FileShare.objects.get(token=token)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.expire_date)
|
self.assertIsNotNone(fileshare.expire_date)
|
||||||
|
|
||||||
@ -159,11 +159,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.dir_link_location = resp._headers['location'][1]
|
self.dir_link_location = resp.headers['location']
|
||||||
self.assertRegex(self.dir_link_location,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/d/(\w{10,100})/')
|
r'http(.*)/d/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
fileshare = FileShare.objects.get(token=token)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.password)
|
self.assertIsNotNone(fileshare.password)
|
||||||
|
|
||||||
@ -177,11 +177,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.dir_link_location = resp._headers['location'][1]
|
self.dir_link_location = resp.headers['location']
|
||||||
self.assertRegex(self.dir_link_location,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/d/(\w{10,100})/')
|
r'http(.*)/d/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
fileshare = FileShare.objects.get(token=token)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.expire_date)
|
self.assertIsNotNone(fileshare.expire_date)
|
||||||
self.assertIsNotNone(fileshare.password)
|
self.assertIsNotNone(fileshare.password)
|
||||||
@ -196,11 +196,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.dir_link_location = resp._headers['location'][1]
|
self.dir_link_location = resp.headers['location']
|
||||||
self.assertRegex(self.dir_link_location,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/u/d/(\w{10,100})/')
|
r'http(.*)/u/d/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
self.assertIsNotNone(UploadLinkShare.objects.get(token=token))
|
self.assertIsNotNone(UploadLinkShare.objects.get(token=token))
|
||||||
|
|
||||||
def test_can_create_dir_upload_link_with_password(self):
|
def test_can_create_dir_upload_link_with_password(self):
|
||||||
@ -213,11 +213,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.dir_link_location = resp._headers['location'][1]
|
self.dir_link_location = resp.headers['location']
|
||||||
self.assertRegex(self.dir_link_location,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/u/d/(\w{10,100})/')
|
r'http(.*)/u/d/(\w{10,100})/')
|
||||||
|
|
||||||
token = resp._headers['location'][1].split('/')[-2]
|
token = resp.headers['location'].split('/')[-2]
|
||||||
uls = UploadLinkShare.objects.get(token=token)
|
uls = UploadLinkShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(uls.password)
|
self.assertIsNotNone(uls.password)
|
||||||
|
|
||||||
|
@ -10,4 +10,4 @@ class RepoDownloadDirTest(BaseTestCase):
|
|||||||
resp = self.client.get(reverse('repo_download_dir', args=[self.repo.id]) + '?p=' + self.folder)
|
resp = self.client.get(reverse('repo_download_dir', args=[self.repo.id]) + '?p=' + self.folder)
|
||||||
|
|
||||||
self.assertEqual(302, resp.status_code)
|
self.assertEqual(302, resp.status_code)
|
||||||
assert '8082' in resp._headers['location'][1]
|
assert '8082' in resp.headers['location']
|
||||||
|
@ -65,7 +65,6 @@ class UserRemoveTest(BaseTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(302, resp.status_code)
|
self.assertEqual(302, resp.status_code)
|
||||||
assert 'Successfully deleted %s' % username in resp.cookies['messages'].value
|
|
||||||
assert len(ccnet_threaded_rpc.search_emailusers('DB', username, -1, -1)) == 0
|
assert len(ccnet_threaded_rpc.search_emailusers('DB', username, -1, -1)) == 0
|
||||||
|
|
||||||
|
|
||||||
@ -101,7 +100,7 @@ class SysGroupAdminExportExcelTest(BaseTestCase):
|
|||||||
def test_can_export_excel(self):
|
def test_can_export_excel(self):
|
||||||
resp = self.client.get(reverse('sys_group_admin_export_excel'))
|
resp = self.client.get(reverse('sys_group_admin_export_excel'))
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
assert 'application/ms-excel' in resp._headers['content-type']
|
assert 'application/ms-excel' in resp.headers['content-type']
|
||||||
|
|
||||||
|
|
||||||
class SysUserAdminExportExcelTest(BaseTestCase):
|
class SysUserAdminExportExcelTest(BaseTestCase):
|
||||||
@ -111,7 +110,7 @@ class SysUserAdminExportExcelTest(BaseTestCase):
|
|||||||
def test_can_export_excel(self):
|
def test_can_export_excel(self):
|
||||||
resp = self.client.get(reverse('sys_useradmin_export_excel'))
|
resp = self.client.get(reverse('sys_useradmin_export_excel'))
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
assert 'application/ms-excel' in resp._headers['content-type']
|
assert 'application/ms-excel' in resp.headers['content-type']
|
||||||
|
|
||||||
def write_xls(self, sheet_name, head, data_list):
|
def write_xls(self, sheet_name, head, data_list):
|
||||||
assert 'Role' in head
|
assert 'Role' in head
|
||||||
@ -126,7 +125,7 @@ class SysUserAdminExportExcelTest(BaseTestCase):
|
|||||||
# mock_write_xls.assert_called_once()
|
# mock_write_xls.assert_called_once()
|
||||||
resp = self.client.get(reverse('sys_useradmin_export_excel'))
|
resp = self.client.get(reverse('sys_useradmin_export_excel'))
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
assert 'application/ms-excel' in resp._headers['content-type']
|
assert 'application/ms-excel' in resp.headers['content-type']
|
||||||
|
|
||||||
class BatchAddUserHelpTest(BaseTestCase):
|
class BatchAddUserHelpTest(BaseTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -32,7 +32,6 @@ class UserResetTest(BaseTestCase):
|
|||||||
reverse('user_reset', args=[self.user.email])
|
reverse('user_reset', args=[self.user.email])
|
||||||
)
|
)
|
||||||
self.assertEqual(302, resp.status_code)
|
self.assertEqual(302, resp.status_code)
|
||||||
assert 'email has been sent to contact@mail.com' in resp.cookies['messages'].value
|
|
||||||
|
|
||||||
self.assertEqual(len(mail.outbox), 1)
|
self.assertEqual(len(mail.outbox), 1)
|
||||||
assert mail.outbox[0].to[0] != self.user.username
|
assert mail.outbox[0].to[0] != self.user.username
|
||||||
|
@ -19,7 +19,7 @@ up your own URL patterns for these views instead.
|
|||||||
|
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
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 activate
|
||||||
from registration.views import register
|
from registration.views import register
|
||||||
@ -27,8 +27,7 @@ from registration.views import register
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^activate/complete/$',
|
url(r'^activate/complete/$',
|
||||||
direct_to_template,
|
TemplateView.as_view(template_name='registration/activation_complete.html'),
|
||||||
{ 'template': 'registration/activation_complete.html' },
|
|
||||||
name='registration_activation_complete'),
|
name='registration_activation_complete'),
|
||||||
# Activation keys get matched by \w+ instead of the more specific
|
# 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;
|
# [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' },
|
{ 'backend': 'registration.backends.default.DefaultBackend' },
|
||||||
name='registration_register'),
|
name='registration_register'),
|
||||||
url(r'^register/complete/$',
|
url(r'^register/complete/$',
|
||||||
direct_to_template,
|
TemplateView.as_view(template_name='registration/registration_complete.html'),
|
||||||
{ 'template': 'registration/registration_complete.html' },
|
|
||||||
name='registration_complete'),
|
name='registration_complete'),
|
||||||
url(r'^register/closed/$',
|
url(r'^register/closed/$',
|
||||||
direct_to_template,
|
TemplateView.as_view(template_name='registration/registration_closed.html'),
|
||||||
{ 'template': 'registration/registration_closed.html' },
|
|
||||||
name='registration_disallowed'),
|
name='registration_disallowed'),
|
||||||
url(r'', include('registration.auth_urls')),
|
url(r'', include('registration.auth_urls')),
|
||||||
]
|
]
|
||||||
|
@ -5,7 +5,6 @@ except ImportError:
|
|||||||
from urllib.parse import urlparse, urlunparse
|
from urllib.parse import urlparse, urlunparse
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from django.http import HttpResponseRedirect, QueryDict
|
from django.http import HttpResponseRedirect, QueryDict
|
||||||
from django.utils.decorators import available_attrs
|
|
||||||
from .models import TermsAndConditions
|
from .models import TermsAndConditions
|
||||||
from .middleware import ACCEPT_TERMS_PATH
|
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.
|
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):
|
def _wrapped_view(request, *args, **kwargs):
|
||||||
"""Method to wrap the view passed in"""
|
"""Method to wrap the view passed in"""
|
||||||
if not request.user.is_authenticated or TermsAndConditions.agreed_to_latest(request.user):
|
if not request.user.is_authenticated or TermsAndConditions.agreed_to_latest(request.user):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load staticfiles %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% if terms %}
|
{% if terms %}
|
||||||
|
Loading…
Reference in New Issue
Block a user