From 5a2af77d44955e454adb6ca7e88f5c89f4f658f6 Mon Sep 17 00:00:00 2001 From: zhengxie Date: Tue, 26 Jul 2016 10:47:45 +0800 Subject: [PATCH] Add copyright header --- fabfile/__init__.py | 3 +- fabfile/copyright.py | 92 ++++++ fabfile/locale.py | 1 + seahub/__init__.py | 1 + seahub/api2/__init__.py | 1 + seahub/api2/authentication.py | 1 + seahub/api2/base.py | 1 + seahub/api2/endpoints/account.py | 1 + seahub/api2/endpoints/admin/device_errors.py | 1 + seahub/api2/endpoints/admin/devices.py | 1 + seahub/api2/endpoints/admin/file_audit.py | 1 + seahub/api2/endpoints/admin/file_update.py | 1 + seahub/api2/endpoints/admin/libraries.py | 1 + .../api2/endpoints/admin/library_dirents.py | 1 + seahub/api2/endpoints/admin/login.py | 1 + seahub/api2/endpoints/admin/perm_audit.py | 1 + seahub/api2/endpoints/admin/sysinfo.py | 1 + seahub/api2/endpoints/admin/system_library.py | 1 + .../api2/endpoints/admin/trash_libraries.py | 1 + seahub/api2/endpoints/admin/utils.py | 1 + seahub/api2/endpoints/be_shared_repo.py | 1 + seahub/api2/endpoints/dir.py | 1 + seahub/api2/endpoints/dir_shared_items.py | 1 + .../api2/endpoints/dirents_download_link.py | 1 + seahub/api2/endpoints/file.py | 1 + seahub/api2/endpoints/file_comment.py | 1 + seahub/api2/endpoints/file_comments.py | 1 + seahub/api2/endpoints/file_comments_counts.py | 1 + seahub/api2/endpoints/group_discussion.py | 1 + seahub/api2/endpoints/group_discussions.py | 1 + seahub/api2/endpoints/group_members.py | 1 + seahub/api2/endpoints/groups.py | 1 + seahub/api2/endpoints/invitation.py | 1 + seahub/api2/endpoints/invitations.py | 1 + seahub/api2/endpoints/query_zip_progress.py | 1 + seahub/api2/endpoints/repo_set_password.py | 1 + seahub/api2/endpoints/search_user.py | 1 + .../api2/endpoints/send_share_link_email.py | 1 + .../api2/endpoints/send_upload_link_email.py | 1 + seahub/api2/endpoints/share_link_zip_task.py | 1 + seahub/api2/endpoints/share_links.py | 1 + seahub/api2/endpoints/shared_folders.py | 1 + seahub/api2/endpoints/shared_repos.py | 1 + seahub/api2/endpoints/shared_upload_links.py | 1 + seahub/api2/endpoints/upload_links.py | 1 + seahub/api2/endpoints/utils.py | 1 + seahub/api2/endpoints/zip_task.py | 1 + seahub/api2/models.py | 1 + seahub/api2/permissions.py | 1 + seahub/api2/serializers.py | 1 + seahub/api2/status.py | 1 + seahub/api2/tests.py | 1 + seahub/api2/throttling.py | 1 + seahub/api2/urls.py | 1 + seahub/api2/utils.py | 1 + seahub/api2/views.py | 1 + seahub/api2/views_auth.py | 1 + seahub/api2/views_misc.py | 1 + seahub/auth/__init__.py | 1 + seahub/auth/admin.py | 1 + seahub/auth/decorators.py | 1 + seahub/auth/forms.py | 1 + seahub/auth/handlers/modpython.py | 1 + seahub/auth/management/__init__.py | 1 + .../management/commands/changepassword.py | 1 + .../management/commands/createsuperuser.py | 1 + seahub/auth/middleware.py | 1 + seahub/auth/models.py | 1 + seahub/auth/signals.py | 1 + seahub/auth/tests/__init__.py | 17 -- seahub/auth/tests/auth_backends.py | 247 ---------------- seahub/auth/tests/basic.py | 77 ----- seahub/auth/tests/decorators.py | 25 -- seahub/auth/tests/forms.py | 252 ---------------- seahub/auth/tests/models.py | 35 --- seahub/auth/tests/remote_user.py | 170 ----------- .../tests/templates/registration/login.html | 1 - .../registration/password_reset_complete.html | 1 - .../registration/password_reset_confirm.html | 5 - .../registration/password_reset_done.html | 1 - .../registration/password_reset_email.html | 1 - .../registration/password_reset_form.html | 1 - seahub/auth/tests/tokens.py | 42 --- seahub/auth/tests/urls.py | 18 -- seahub/auth/tests/views.py | 274 ------------------ seahub/auth/tokens.py | 1 + seahub/auth/urls.py | 1 + seahub/auth/views.py | 1 + seahub/avatar/admin.py | 1 + seahub/avatar/forms.py | 1 + seahub/avatar/management/commands/__init__.py | 1 + .../management/commands/rebuild_avatars.py | 1 + seahub/avatar/models.py | 1 + seahub/avatar/settings.py | 1 + seahub/avatar/signals.py | 1 + seahub/avatar/templatetags/avatar_tags.py | 1 + .../avatar/templatetags/group_avatar_tags.py | 1 + seahub/avatar/tests.py | 1 + seahub/avatar/urls.py | 1 + seahub/avatar/util.py | 1 + seahub/avatar/views.py | 1 + seahub/base/__init__.py | 1 + seahub/base/accounts.py | 1 + seahub/base/apps.py | 1 + seahub/base/context_processors.py | 1 + seahub/base/database_storage/__init__.py | 1 + .../base/database_storage/database_storage.py | 1 + seahub/base/decorators.py | 1 + seahub/base/fields.py | 1 + seahub/base/generic.py | 1 + .../management/commands/changepassword.py | 1 + .../management/commands/createsuperuser.py | 1 + seahub/base/middleware.py | 1 + seahub/base/mixins.py | 1 + seahub/base/models.py | 1 + seahub/base/profile.py | 27 +- seahub/base/registration_urls.py | 1 + seahub/base/sudo_mode.py | 1 + seahub/base/templatetags/rest_framework.py | 1 + seahub/base/templatetags/seahub_tags.py | 1 + seahub/base/templatetags/upload_tags.py | 1 + seahub/base/tests.py | 1 + seahub/base/utils.py | 1 + seahub/base/views.py | 1 + seahub/constants.py | 1 + seahub/contacts/__init__.py | 1 + seahub/contacts/handlers.py | 1 + seahub/contacts/models.py | 1 + seahub/contacts/settings.py | 1 + seahub/contacts/signals.py | 1 + seahub/contacts/urls.py | 1 + seahub/contacts/views.py | 1 + seahub/forms.py | 1 + seahub/group/decorators.py | 1 + seahub/group/error_msg.py | 1 + seahub/group/forms.py | 1 + seahub/group/models.py | 1 + seahub/group/settings.py | 1 + seahub/group/signals.py | 1 + seahub/group/tests/__init__.py | 1 + seahub/group/tests/tests.py | 1 + seahub/group/urls.py | 1 + seahub/group/utils.py | 1 + seahub/group/views.py | 1 + seahub/handlers.py | 1 + seahub/help/models.py | 1 + seahub/help/tests.py | 1 + seahub/help/urls.py | 1 + seahub/help/views.py | 1 + seahub/institutions/admin.py | 1 + seahub/institutions/decorators.py | 1 + seahub/institutions/middleware.py | 1 + seahub/institutions/models.py | 1 + seahub/institutions/tests.py | 1 + seahub/institutions/urls.py | 1 + seahub/institutions/views.py | 1 + seahub/invitations/admin.py | 1 + seahub/invitations/models.py | 1 + seahub/invitations/settings.py | 1 + seahub/invitations/urls.py | 1 + seahub/invitations/views.py | 1 + .../management/commands/send_user_messages.py | 1 + seahub/message/message.py | 1 + seahub/message/models.py | 1 + seahub/message/signals.py | 1 + seahub/message/urls.py | 1 + seahub/message/views.py | 1 + .../commands/notify_admins_on_virus.py | 1 + .../management/commands/send_notices.py | 1 + seahub/notifications/models.py | 1 + seahub/notifications/settings.py | 1 + seahub/notifications/tests.py | 1 + seahub/notifications/urls.py | 1 + seahub/notifications/utils.py | 1 + seahub/notifications/views.py | 1 + seahub/options/models.py | 1 + seahub/options/tests.py | 1 + seahub/options/urls.py | 1 + seahub/options/views.py | 1 + seahub/password_session/__init__.py | 1 + seahub/password_session/handlers.py | 1 + seahub/password_session/middleware.py | 1 + seahub/password_session/models.py | 1 - seahub/password_session/tests/__init__.py | 1 - seahub/password_session/tests/test_urls.py | 16 - seahub/password_session/tests/test_views.py | 13 - seahub/password_session/tests/tests.py | 47 --- seahub/profile/admin.py | 1 + seahub/profile/forms.py | 1 + seahub/profile/models.py | 1 + seahub/profile/settings.py | 1 + seahub/profile/tests.py | 1 + seahub/profile/urls.py | 1 + seahub/profile/utils.py | 1 + seahub/profile/views.py | 1 + seahub/role_permissions/admin.py | 1 + seahub/role_permissions/models.py | 1 + seahub/role_permissions/settings.py | 1 + seahub/role_permissions/utils.py | 1 + seahub/role_permissions/views.py | 1 + seahub/settings.py | 1 + seahub/share/decorators.py | 1 + seahub/share/forms.py | 1 + seahub/share/models.py | 1 + seahub/share/signals.py | 1 + seahub/share/tests.py | 1 + seahub/share/urls.py | 1 + seahub/share/views.py | 1 + seahub/shortcuts.py | 2 +- seahub/signals.py | 1 + seahub/test_utils.py | 1 + .../management/commands/clean_thumbnail.py | 1 + seahub/thumbnail/models.py | 1 + seahub/thumbnail/tests.py | 1 + seahub/thumbnail/urls.py | 1 + seahub/thumbnail/utils.py | 1 + seahub/thumbnail/views.py | 1 + seahub/urls.py | 1 + seahub/utils/__init__.py | 1 + seahub/utils/devices.py | 1 + seahub/utils/file_size.py | 1 + seahub/utils/file_types.py | 1 + seahub/utils/html.py | 1 + seahub/utils/http.py | 1 + seahub/utils/ip.py | 1 + seahub/utils/licenseparse.py | 1 + seahub/utils/logger.py | 1 + seahub/utils/mail.py | 1 + seahub/utils/ms_excel.py | 1 + seahub/utils/paginator.py | 1 + seahub/utils/repo.py | 1 + seahub/utils/rooturl.py | 1 + seahub/utils/rpc.py | 1 + seahub/utils/slugify/__init__.py | 1 + seahub/utils/star.py | 1 + seahub/utils/sysinfo.py | 1 + seahub/utils/timeutils.py | 1 + seahub/utils/two_factor_auth.py | 1 + seahub/utils/user_permissions.py | 1 + seahub/views/__init__.py | 1 + seahub/views/ajax.py | 1 + seahub/views/file.py | 1 + seahub/views/i18n.py | 1 + seahub/views/modules.py | 1 + seahub/views/repo.py | 1 + seahub/views/sysadmin.py | 1 + seahub/views/tests/__init__.py | 1 + seahub/views/wiki.py | 1 + seahub/wiki/__init__.py | 1 + seahub/wiki/forms.py | 1 + seahub/wiki/models.py | 1 + seahub/wiki/utils.py | 1 + seahub/wsgi.py | 1 + tools/avatar_migration.py | 1 + tools/batch-delete.py | 1 + tools/gen-tarball.py | 1 + tools/seahub-admin.py | 1 + tools/secret_key_generator.py | 4 +- tools/update-seahub-db_0.9.4_to_0.9.5.py | 1 + 259 files changed, 355 insertions(+), 1251 deletions(-) create mode 100644 fabfile/copyright.py delete mode 100644 seahub/auth/tests/__init__.py delete mode 100644 seahub/auth/tests/auth_backends.py delete mode 100644 seahub/auth/tests/basic.py delete mode 100644 seahub/auth/tests/decorators.py delete mode 100644 seahub/auth/tests/forms.py delete mode 100644 seahub/auth/tests/models.py delete mode 100644 seahub/auth/tests/remote_user.py delete mode 100644 seahub/auth/tests/templates/registration/login.html delete mode 100644 seahub/auth/tests/templates/registration/password_reset_complete.html delete mode 100644 seahub/auth/tests/templates/registration/password_reset_confirm.html delete mode 100644 seahub/auth/tests/templates/registration/password_reset_done.html delete mode 100644 seahub/auth/tests/templates/registration/password_reset_email.html delete mode 100644 seahub/auth/tests/templates/registration/password_reset_form.html delete mode 100644 seahub/auth/tests/tokens.py delete mode 100644 seahub/auth/tests/urls.py delete mode 100644 seahub/auth/tests/views.py delete mode 100644 seahub/password_session/models.py delete mode 100644 seahub/password_session/tests/__init__.py delete mode 100644 seahub/password_session/tests/test_urls.py delete mode 100644 seahub/password_session/tests/test_views.py delete mode 100644 seahub/password_session/tests/tests.py diff --git a/fabfile/__init__.py b/fabfile/__init__.py index a75f7cb9c7..0967deca44 100644 --- a/fabfile/__init__.py +++ b/fabfile/__init__.py @@ -1 +1,2 @@ -from . import locale +# Copyright (c) 2012-2016 Seafile Ltd. +from . import locale, copyright diff --git a/fabfile/copyright.py b/fabfile/copyright.py new file mode 100644 index 0000000000..bf7670cfde --- /dev/null +++ b/fabfile/copyright.py @@ -0,0 +1,92 @@ +# Copyright (c) 2012-2016 Seafile Ltd. + +import os +from fabric.api import task + +@task +def update(path): + """Add copyright stuff to the begining of files. + """ + for filename in path_to_pyfile_list(path): + do_update(filename) + +@task +def check(path): + """Check copyright stuff for files. + """ + for filename in path_to_pyfile_list(path): + do_check(filename) + +def do_update(filename): + if 'migrations' in filename: + print 'skip migration file: %s' % filename + return + + with open(filename) as f: + # try read first line of file + try: + head = [next(f) for x in xrange(1)] + except StopIteration: + print '%s is empty, skip' % filename + return + + copy_str = '# Copyright (c) 2012-2016 Seafile Ltd.' + + need_update = True + for line in head: + line = line.lower() + if 'seafile ltd.' in line: + need_update = False + + if not need_update: + print '%s is ok.' % filename + return + + line_prepender(filename, copy_str) + print '%s Done.' % filename + +def path_to_pyfile_list(path): + is_dir = False + if os.path.isdir(path): + is_dir = True + + if not is_dir: + py_files = [path] + else: + py_files = [] + for root, directories, filenames in os.walk(path): + for directory in directories: + f = os.path.join(root, directory) + if f.endswith('.py'): + py_files.append(f) + for filename in filenames: + if filename.endswith('.py'): + py_files.append(os.path.join(root, filename)) + return py_files + + +def line_prepender(filename, line): + with open(filename, 'r+') as f: + content = f.read() + f.seek(0, 0) + f.write(line.rstrip('\r\n') + '\n' + content) + +def do_check(filename): + if 'migrations' in filename: + return + + with open(filename) as f: + # try read first line of file + try: + head = [next(f) for x in xrange(1)] + except StopIteration: + return + + need_update = True + for line in head: + line = line.lower() + if 'seafile ltd.' in line: + need_update = False + + if need_update: + print 'No copyright info in %s.' % filename diff --git a/fabfile/locale.py b/fabfile/locale.py index 97c1129d63..f8daa1ea78 100644 --- a/fabfile/locale.py +++ b/fabfile/locale.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ Tools for i18n. """ diff --git a/seahub/__init__.py b/seahub/__init__.py index 75d8adbff4..c81728d88c 100644 --- a/seahub/__init__.py +++ b/seahub/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from signals import repo_created, repo_deleted from handlers import repo_created_cb, repo_deleted_cb diff --git a/seahub/api2/__init__.py b/seahub/api2/__init__.py index 8b13789179..f46dd29f4b 100644 --- a/seahub/api2/__init__.py +++ b/seahub/api2/__init__.py @@ -1 +1,2 @@ +# Copyright (c) 2012-2016 Seafile Ltd. diff --git a/seahub/api2/authentication.py b/seahub/api2/authentication.py index 995b5fc380..2ecaddb0dd 100644 --- a/seahub/api2/authentication.py +++ b/seahub/api2/authentication.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import datetime import logging from rest_framework import status diff --git a/seahub/api2/base.py b/seahub/api2/base.py index b6d54952d0..52bfa6a226 100644 --- a/seahub/api2/base.py +++ b/seahub/api2/base.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. #coding: UTF-8 from rest_framework.views import APIView as RestFrameworkAPIView diff --git a/seahub/api2/endpoints/account.py b/seahub/api2/endpoints/account.py index de9d1128c9..73fcdfb0a9 100644 --- a/seahub/api2/endpoints/account.py +++ b/seahub/api2/endpoints/account.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from dateutil.relativedelta import relativedelta diff --git a/seahub/api2/endpoints/admin/device_errors.py b/seahub/api2/endpoints/admin/device_errors.py index c5273b8b13..307a6687b5 100644 --- a/seahub/api2/endpoints/admin/device_errors.py +++ b/seahub/api2/endpoints/admin/device_errors.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/admin/devices.py b/seahub/api2/endpoints/admin/devices.py index f488a98bfb..c77bd7f12b 100644 --- a/seahub/api2/endpoints/admin/devices.py +++ b/seahub/api2/endpoints/admin/devices.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/admin/file_audit.py b/seahub/api2/endpoints/admin/file_audit.py index d8968ed224..f9ee05e90a 100644 --- a/seahub/api2/endpoints/admin/file_audit.py +++ b/seahub/api2/endpoints/admin/file_audit.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAdminUser from rest_framework.response import Response diff --git a/seahub/api2/endpoints/admin/file_update.py b/seahub/api2/endpoints/admin/file_update.py index 03870c9af3..969497d4cc 100644 --- a/seahub/api2/endpoints/admin/file_update.py +++ b/seahub/api2/endpoints/admin/file_update.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAdminUser from rest_framework.response import Response diff --git a/seahub/api2/endpoints/admin/libraries.py b/seahub/api2/endpoints/admin/libraries.py index 85b4a331f1..edef4b6d89 100644 --- a/seahub/api2/endpoints/admin/libraries.py +++ b/seahub/api2/endpoints/admin/libraries.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/admin/library_dirents.py b/seahub/api2/endpoints/admin/library_dirents.py index b7b9cfc9e2..e6c3548a95 100644 --- a/seahub/api2/endpoints/admin/library_dirents.py +++ b/seahub/api2/endpoints/admin/library_dirents.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os import stat import logging diff --git a/seahub/api2/endpoints/admin/login.py b/seahub/api2/endpoints/admin/login.py index 500eafaae2..6dd18bf706 100644 --- a/seahub/api2/endpoints/admin/login.py +++ b/seahub/api2/endpoints/admin/login.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/admin/perm_audit.py b/seahub/api2/endpoints/admin/perm_audit.py index 37ca3201f5..67f0cd12e3 100644 --- a/seahub/api2/endpoints/admin/perm_audit.py +++ b/seahub/api2/endpoints/admin/perm_audit.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAdminUser from rest_framework.response import Response diff --git a/seahub/api2/endpoints/admin/sysinfo.py b/seahub/api2/endpoints/admin/sysinfo.py index 336e34425c..b0d0583540 100644 --- a/seahub/api2/endpoints/admin/sysinfo.py +++ b/seahub/api2/endpoints/admin/sysinfo.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging import os diff --git a/seahub/api2/endpoints/admin/system_library.py b/seahub/api2/endpoints/admin/system_library.py index 447e4b0cf0..73c731e6e5 100644 --- a/seahub/api2/endpoints/admin/system_library.py +++ b/seahub/api2/endpoints/admin/system_library.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/admin/trash_libraries.py b/seahub/api2/endpoints/admin/trash_libraries.py index 784b1d475e..6d94833e99 100644 --- a/seahub/api2/endpoints/admin/trash_libraries.py +++ b/seahub/api2/endpoints/admin/trash_libraries.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/admin/utils.py b/seahub/api2/endpoints/admin/utils.py index 8bf342fe3d..a6c0f21b38 100644 --- a/seahub/api2/endpoints/admin/utils.py +++ b/seahub/api2/endpoints/admin/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import re import datetime import time diff --git a/seahub/api2/endpoints/be_shared_repo.py b/seahub/api2/endpoints/be_shared_repo.py index d3402231ef..efeffbb1f0 100644 --- a/seahub/api2/endpoints/be_shared_repo.py +++ b/seahub/api2/endpoints/be_shared_repo.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response diff --git a/seahub/api2/endpoints/dir.py b/seahub/api2/endpoints/dir.py index d5c8112ac2..7d8b6433b8 100644 --- a/seahub/api2/endpoints/dir.py +++ b/seahub/api2/endpoints/dir.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os import logging import posixpath diff --git a/seahub/api2/endpoints/dir_shared_items.py b/seahub/api2/endpoints/dir_shared_items.py index c646330533..735104ada5 100644 --- a/seahub/api2/endpoints/dir_shared_items.py +++ b/seahub/api2/endpoints/dir_shared_items.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging import json diff --git a/seahub/api2/endpoints/dirents_download_link.py b/seahub/api2/endpoints/dirents_download_link.py index 26025d6260..9a0a50e57a 100644 --- a/seahub/api2/endpoints/dirents_download_link.py +++ b/seahub/api2/endpoints/dirents_download_link.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import stat import logging import json diff --git a/seahub/api2/endpoints/file.py b/seahub/api2/endpoints/file.py index 57d2d0f1ff..cddecfc246 100644 --- a/seahub/api2/endpoints/file.py +++ b/seahub/api2/endpoints/file.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os import logging import posixpath diff --git a/seahub/api2/endpoints/file_comment.py b/seahub/api2/endpoints/file_comment.py index 87c13df30c..b8fe2f1bc9 100644 --- a/seahub/api2/endpoints/file_comment.py +++ b/seahub/api2/endpoints/file_comment.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework import status diff --git a/seahub/api2/endpoints/file_comments.py b/seahub/api2/endpoints/file_comments.py index 5bcfad5b7f..d6f15c2221 100644 --- a/seahub/api2/endpoints/file_comments.py +++ b/seahub/api2/endpoints/file_comments.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework import status diff --git a/seahub/api2/endpoints/file_comments_counts.py b/seahub/api2/endpoints/file_comments_counts.py index a0a74b79fd..f96026685a 100644 --- a/seahub/api2/endpoints/file_comments_counts.py +++ b/seahub/api2/endpoints/file_comments_counts.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from django.db.models import Count diff --git a/seahub/api2/endpoints/group_discussion.py b/seahub/api2/endpoints/group_discussion.py index e4fdd27837..ce25a669ed 100644 --- a/seahub/api2/endpoints/group_discussion.py +++ b/seahub/api2/endpoints/group_discussion.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from rest_framework import status from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAuthenticated diff --git a/seahub/api2/endpoints/group_discussions.py b/seahub/api2/endpoints/group_discussions.py index 6015326a24..6e7d27cb1e 100644 --- a/seahub/api2/endpoints/group_discussions.py +++ b/seahub/api2/endpoints/group_discussions.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import json from django.core.paginator import EmptyPage, InvalidPage diff --git a/seahub/api2/endpoints/group_members.py b/seahub/api2/endpoints/group_members.py index 235f895ae9..eb4f57bfd1 100644 --- a/seahub/api2/endpoints/group_members.py +++ b/seahub/api2/endpoints/group_members.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from django.utils.translation import ugettext as _ diff --git a/seahub/api2/endpoints/groups.py b/seahub/api2/endpoints/groups.py index 6e670a0fbf..7186c2ace3 100644 --- a/seahub/api2/endpoints/groups.py +++ b/seahub/api2/endpoints/groups.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from django.utils.translation import ugettext as _ diff --git a/seahub/api2/endpoints/invitation.py b/seahub/api2/endpoints/invitation.py index f78ee90ef7..21b945294a 100644 --- a/seahub/api2/endpoints/invitation.py +++ b/seahub/api2/endpoints/invitation.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.shortcuts import get_object_or_404 from rest_framework import status from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/invitations.py b/seahub/api2/endpoints/invitations.py index 3e48c88550..f06e13abb4 100644 --- a/seahub/api2/endpoints/invitations.py +++ b/seahub/api2/endpoints/invitations.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.utils.translation import ugettext as _ from rest_framework import status from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/query_zip_progress.py b/seahub/api2/endpoints/query_zip_progress.py index af63340581..06b7b48f32 100644 --- a/seahub/api2/endpoints/query_zip_progress.py +++ b/seahub/api2/endpoints/query_zip_progress.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging import json diff --git a/seahub/api2/endpoints/repo_set_password.py b/seahub/api2/endpoints/repo_set_password.py index ea36ed1e4c..0988f002d1 100644 --- a/seahub/api2/endpoints/repo_set_password.py +++ b/seahub/api2/endpoints/repo_set_password.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response diff --git a/seahub/api2/endpoints/search_user.py b/seahub/api2/endpoints/search_user.py index 4c1497c806..2f8deb1fd7 100644 --- a/seahub/api2/endpoints/search_user.py +++ b/seahub/api2/endpoints/search_user.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import json from django.db.models import Q diff --git a/seahub/api2/endpoints/send_share_link_email.py b/seahub/api2/endpoints/send_share_link_email.py index a5e3aafc23..6ecb83083d 100644 --- a/seahub/api2/endpoints/send_share_link_email.py +++ b/seahub/api2/endpoints/send_share_link_email.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os import logging diff --git a/seahub/api2/endpoints/send_upload_link_email.py b/seahub/api2/endpoints/send_upload_link_email.py index 23dffd108e..e067c44c29 100644 --- a/seahub/api2/endpoints/send_upload_link_email.py +++ b/seahub/api2/endpoints/send_upload_link_email.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/share_link_zip_task.py b/seahub/api2/endpoints/share_link_zip_task.py index be11d9666e..2be17c8d8a 100644 --- a/seahub/api2/endpoints/share_link_zip_task.py +++ b/seahub/api2/endpoints/share_link_zip_task.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging import os import json diff --git a/seahub/api2/endpoints/share_links.py b/seahub/api2/endpoints/share_links.py index 4cf510ad9b..bda9c18594 100644 --- a/seahub/api2/endpoints/share_links.py +++ b/seahub/api2/endpoints/share_links.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os import logging from constance import config diff --git a/seahub/api2/endpoints/shared_folders.py b/seahub/api2/endpoints/shared_folders.py index 31f6f693e6..fbd6ba1135 100644 --- a/seahub/api2/endpoints/shared_folders.py +++ b/seahub/api2/endpoints/shared_folders.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/shared_repos.py b/seahub/api2/endpoints/shared_repos.py index 50cb081a6d..7b41d2256a 100644 --- a/seahub/api2/endpoints/shared_repos.py +++ b/seahub/api2/endpoints/shared_repos.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication diff --git a/seahub/api2/endpoints/shared_upload_links.py b/seahub/api2/endpoints/shared_upload_links.py index 4c55c949e8..60d71c2ad5 100644 --- a/seahub/api2/endpoints/shared_upload_links.py +++ b/seahub/api2/endpoints/shared_upload_links.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import json import os diff --git a/seahub/api2/endpoints/upload_links.py b/seahub/api2/endpoints/upload_links.py index a2fb9e5a7d..c12b6dff49 100644 --- a/seahub/api2/endpoints/upload_links.py +++ b/seahub/api2/endpoints/upload_links.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os import logging from constance import config diff --git a/seahub/api2/endpoints/utils.py b/seahub/api2/endpoints/utils.py index 86fca46cb4..eaff6f054d 100644 --- a/seahub/api2/endpoints/utils.py +++ b/seahub/api2/endpoints/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework import status diff --git a/seahub/api2/endpoints/zip_task.py b/seahub/api2/endpoints/zip_task.py index 17115f259d..b36d7c1387 100644 --- a/seahub/api2/endpoints/zip_task.py +++ b/seahub/api2/endpoints/zip_task.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging import json import stat diff --git a/seahub/api2/models.py b/seahub/api2/models.py index f67e7a0983..d1be29c1f0 100644 --- a/seahub/api2/models.py +++ b/seahub/api2/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import uuid import hmac import datetime diff --git a/seahub/api2/permissions.py b/seahub/api2/permissions.py index 9518cbd05f..492d45d9e4 100644 --- a/seahub/api2/permissions.py +++ b/seahub/api2/permissions.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ Provides a set of pluggable permission policies. """ diff --git a/seahub/api2/serializers.py b/seahub/api2/serializers.py index d087321c02..7856044103 100644 --- a/seahub/api2/serializers.py +++ b/seahub/api2/serializers.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from rest_framework import serializers from seahub.auth import authenticate diff --git a/seahub/api2/status.py b/seahub/api2/status.py index df7baf9acd..721f59fd7e 100644 --- a/seahub/api2/status.py +++ b/seahub/api2/status.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # Define custom HTTP status code. 4xx starts from 440, 5xx starts from 520. HTTP_440_REPO_PASSWD_REQUIRED = 440 HTTP_441_REPO_PASSWD_MAGIC_REQUIRED = 441 diff --git a/seahub/api2/tests.py b/seahub/api2/tests.py index 501deb776c..dc3548eb40 100644 --- a/seahub/api2/tests.py +++ b/seahub/api2/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ This file demonstrates writing tests using the unittest module. These will pass when you run "manage.py test". diff --git a/seahub/api2/throttling.py b/seahub/api2/throttling.py index 0f10136d69..357d88aa15 100644 --- a/seahub/api2/throttling.py +++ b/seahub/api2/throttling.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ Provides various throttling policies. """ diff --git a/seahub/api2/urls.py b/seahub/api2/urls.py index c9f74c332a..6d37cc0cc6 100644 --- a/seahub/api2/urls.py +++ b/seahub/api2/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url, include from .views import * diff --git a/seahub/api2/utils.py b/seahub/api2/utils.py index bac044734e..19ecdccc6f 100644 --- a/seahub/api2/utils.py +++ b/seahub/api2/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 # Utility functions for api2 diff --git a/seahub/api2/views.py b/seahub/api2/views.py index 52fbf0b41d..960bb9f932 100644 --- a/seahub/api2/views.py +++ b/seahub/api2/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import logging import os diff --git a/seahub/api2/views_auth.py b/seahub/api2/views_auth.py index a338861f49..7f4b6a8e22 100644 --- a/seahub/api2/views_auth.py +++ b/seahub/api2/views_auth.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from rest_framework import status from rest_framework.permissions import IsAuthenticated diff --git a/seahub/api2/views_misc.py b/seahub/api2/views_misc.py index af67aa23a4..97e9dd579d 100644 --- a/seahub/api2/views_misc.py +++ b/seahub/api2/views_misc.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from seahub.api2.base import APIView from seahub.api2.utils import json_response, is_seafile_pro from seahub import settings diff --git a/seahub/auth/__init__.py b/seahub/auth/__init__.py index 3086e3950f..8a9b7e56bd 100644 --- a/seahub/auth/__init__.py +++ b/seahub/auth/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import datetime from warnings import warn from django.conf import settings diff --git a/seahub/auth/admin.py b/seahub/auth/admin.py index 61bae28052..2ba6078951 100644 --- a/seahub/auth/admin.py +++ b/seahub/auth/admin.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django import template from django.db import transaction from django.conf import settings diff --git a/seahub/auth/decorators.py b/seahub/auth/decorators.py index e471091a86..35d8636f41 100644 --- a/seahub/auth/decorators.py +++ b/seahub/auth/decorators.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. try: from functools import update_wrapper, wraps except ImportError: diff --git a/seahub/auth/forms.py b/seahub/auth/forms.py index a6f81785f7..af81db1e68 100644 --- a/seahub/auth/forms.py +++ b/seahub/auth/forms.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.contrib.sites.models import Site from django import forms from django.utils.translation import ugettext_lazy as _ diff --git a/seahub/auth/handlers/modpython.py b/seahub/auth/handlers/modpython.py index de961fa4dd..3ce4b7dccb 100644 --- a/seahub/auth/handlers/modpython.py +++ b/seahub/auth/handlers/modpython.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from mod_python import apache import os diff --git a/seahub/auth/management/__init__.py b/seahub/auth/management/__init__.py index 01fa52430f..585e010c63 100644 --- a/seahub/auth/management/__init__.py +++ b/seahub/auth/management/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ Creates permissions for all installed apps that need permissions. """ diff --git a/seahub/auth/management/commands/changepassword.py b/seahub/auth/management/commands/changepassword.py index 56448f1424..216d64cecf 100644 --- a/seahub/auth/management/commands/changepassword.py +++ b/seahub/auth/management/commands/changepassword.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.core.management.base import BaseCommand, CommandError from django.contrib.auth.models import User import getpass diff --git a/seahub/auth/management/commands/createsuperuser.py b/seahub/auth/management/commands/createsuperuser.py index 695dc0b91d..9dd5c39f45 100644 --- a/seahub/auth/management/commands/createsuperuser.py +++ b/seahub/auth/management/commands/createsuperuser.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ Management utility to create superusers. """ diff --git a/seahub/auth/middleware.py b/seahub/auth/middleware.py index cfc7cbe66b..ebf7f92829 100644 --- a/seahub/auth/middleware.py +++ b/seahub/auth/middleware.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.contrib import auth from django.core.exceptions import ImproperlyConfigured diff --git a/seahub/auth/models.py b/seahub/auth/models.py index 62a70df553..800cc2b1fb 100644 --- a/seahub/auth/models.py +++ b/seahub/auth/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import datetime import hashlib import urllib diff --git a/seahub/auth/signals.py b/seahub/auth/signals.py index 527bc60f07..496ac49cd1 100644 --- a/seahub/auth/signals.py +++ b/seahub/auth/signals.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.dispatch import Signal user_logged_in = Signal(providing_args=['request', 'user']) diff --git a/seahub/auth/tests/__init__.py b/seahub/auth/tests/__init__.py deleted file mode 100644 index dfda022a35..0000000000 --- a/seahub/auth/tests/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -from auth.tests.auth_backends import BackendTest, RowlevelBackendTest, AnonymousUserBackendTest, NoAnonymousUserBackendTest -from auth.tests.basic import BASIC_TESTS -from auth.tests.decorators import LoginRequiredTestCase -from auth.tests.forms import UserCreationFormTest, AuthenticationFormTest, SetPasswordFormTest, PasswordChangeFormTest, UserChangeFormTest, PasswordResetFormTest -from auth.tests.remote_user \ - import RemoteUserTest, RemoteUserNoCreateTest, RemoteUserCustomTest -from auth.tests.models import ProfileTestCase -from auth.tests.tokens import TOKEN_GENERATOR_TESTS -from auth.tests.views \ - import PasswordResetTest, ChangePasswordTest, LoginTest, LogoutTest - -# The password for the fixture data users is 'password' - -__test__ = { - 'BASIC_TESTS': BASIC_TESTS, - 'TOKEN_GENERATOR_TESTS': TOKEN_GENERATOR_TESTS, -} diff --git a/seahub/auth/tests/auth_backends.py b/seahub/auth/tests/auth_backends.py deleted file mode 100644 index 8eaf2cb3e7..0000000000 --- a/seahub/auth/tests/auth_backends.py +++ /dev/null @@ -1,247 +0,0 @@ -from django.conf import settings -from django.contrib.auth.models import User, Group, Permission, AnonymousUser -from django.contrib.contenttypes.models import ContentType -from django.test import TestCase - - -class BackendTest(TestCase): - - backend = 'django.contrib.auth.backends.ModelBackend' - - def setUp(self): - self.curr_auth = settings.AUTHENTICATION_BACKENDS - settings.AUTHENTICATION_BACKENDS = (self.backend,) - User.objects.create_user('test', 'test@example.com', 'test') - - def tearDown(self): - settings.AUTHENTICATION_BACKENDS = self.curr_auth - - def test_has_perm(self): - user = User.objects.get(username='test') - self.assertEqual(user.has_perm('auth.test'), False) - user.is_staff = True - user.save() - self.assertEqual(user.has_perm('auth.test'), False) - user.is_superuser = True - user.save() - self.assertEqual(user.has_perm('auth.test'), True) - user.is_staff = False - user.is_superuser = False - user.save() - self.assertEqual(user.has_perm('auth.test'), False) - user.is_staff = True - user.is_superuser = True - user.is_active = False - user.save() - self.assertEqual(user.has_perm('auth.test'), False) - - def test_custom_perms(self): - user = User.objects.get(username='test') - content_type=ContentType.objects.get_for_model(Group) - perm = Permission.objects.create(name='test', content_type=content_type, codename='test') - user.user_permissions.add(perm) - user.save() - - # reloading user to purge the _perm_cache - user = User.objects.get(username='test') - self.assertEqual(user.get_all_permissions() == set([u'auth.test']), True) - self.assertEqual(user.get_group_permissions(), set([])) - self.assertEqual(user.has_module_perms('Group'), False) - self.assertEqual(user.has_module_perms('auth'), True) - perm = Permission.objects.create(name='test2', content_type=content_type, codename='test2') - user.user_permissions.add(perm) - user.save() - perm = Permission.objects.create(name='test3', content_type=content_type, codename='test3') - user.user_permissions.add(perm) - user.save() - user = User.objects.get(username='test') - self.assertEqual(user.get_all_permissions(), set([u'auth.test2', u'auth.test', u'auth.test3'])) - self.assertEqual(user.has_perm('test'), False) - self.assertEqual(user.has_perm('auth.test'), True) - self.assertEqual(user.has_perms(['auth.test2', 'auth.test3']), True) - perm = Permission.objects.create(name='test_group', content_type=content_type, codename='test_group') - group = Group.objects.create(name='test_group') - group.permissions.add(perm) - group.save() - user.groups.add(group) - user = User.objects.get(username='test') - exp = set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group']) - self.assertEqual(user.get_all_permissions(), exp) - self.assertEqual(user.get_group_permissions(), set([u'auth.test_group'])) - self.assertEqual(user.has_perms(['auth.test3', 'auth.test_group']), True) - - user = AnonymousUser() - self.assertEqual(user.has_perm('test'), False) - self.assertEqual(user.has_perms(['auth.test2', 'auth.test3']), False) - - def test_has_no_object_perm(self): - """Regressiontest for #12462""" - user = User.objects.get(username='test') - content_type=ContentType.objects.get_for_model(Group) - perm = Permission.objects.create(name='test', content_type=content_type, codename='test') - user.user_permissions.add(perm) - user.save() - - self.assertEqual(user.has_perm('auth.test', 'object'), False) - self.assertEqual(user.get_all_permissions('object'), set([])) - self.assertEqual(user.has_perm('auth.test'), True) - self.assertEqual(user.get_all_permissions(), set(['auth.test'])) - - -class TestObj(object): - pass - - -class SimpleRowlevelBackend(object): - supports_object_permissions = True - - # This class also supports tests for anonymous user permissions, - # via subclasses which just set the 'supports_anonymous_user' attribute. - - def has_perm(self, user, perm, obj=None): - if not obj: - return # We only support row level perms - - if isinstance(obj, TestObj): - if user.username == 'test2': - return True - elif user.is_anonymous() and perm == 'anon': - # not reached due to supports_anonymous_user = False - return True - return False - - def has_module_perms(self, user, app_label): - return app_label == "app1" - - def get_all_permissions(self, user, obj=None): - if not obj: - return [] # We only support row level perms - - if not isinstance(obj, TestObj): - return ['none'] - - if user.is_anonymous(): - return ['anon'] - if user.username == 'test2': - return ['simple', 'advanced'] - else: - return ['simple'] - - def get_group_permissions(self, user, obj=None): - if not obj: - return # We only support row level perms - - if not isinstance(obj, TestObj): - return ['none'] - - if 'test_group' in [group.name for group in user.groups.all()]: - return ['group_perm'] - else: - return ['none'] - - -class RowlevelBackendTest(TestCase): - """ - Tests for auth backend that supports object level permissions - """ - backend = 'django.contrib.auth.tests.auth_backends.SimpleRowlevelBackend' - - def setUp(self): - self.curr_auth = settings.AUTHENTICATION_BACKENDS - settings.AUTHENTICATION_BACKENDS = self.curr_auth + (self.backend,) - self.user1 = User.objects.create_user('test', 'test@example.com', 'test') - self.user2 = User.objects.create_user('test2', 'test2@example.com', 'test') - self.user3 = User.objects.create_user('test3', 'test3@example.com', 'test') - - def tearDown(self): - settings.AUTHENTICATION_BACKENDS = self.curr_auth - - def test_has_perm(self): - self.assertEqual(self.user1.has_perm('perm', TestObj()), False) - self.assertEqual(self.user2.has_perm('perm', TestObj()), True) - self.assertEqual(self.user2.has_perm('perm'), False) - self.assertEqual(self.user2.has_perms(['simple', 'advanced'], TestObj()), True) - self.assertEqual(self.user3.has_perm('perm', TestObj()), False) - self.assertEqual(self.user3.has_perm('anon', TestObj()), False) - self.assertEqual(self.user3.has_perms(['simple', 'advanced'], TestObj()), False) - - def test_get_all_permissions(self): - self.assertEqual(self.user1.get_all_permissions(TestObj()), set(['simple'])) - self.assertEqual(self.user2.get_all_permissions(TestObj()), set(['simple', 'advanced'])) - self.assertEqual(self.user2.get_all_permissions(), set([])) - - def test_get_group_permissions(self): - content_type=ContentType.objects.get_for_model(Group) - group = Group.objects.create(name='test_group') - self.user3.groups.add(group) - self.assertEqual(self.user3.get_group_permissions(TestObj()), set(['group_perm'])) - - -class AnonymousUserBackend(SimpleRowlevelBackend): - - supports_anonymous_user = True - - -class NoAnonymousUserBackend(SimpleRowlevelBackend): - - supports_anonymous_user = False - - -class AnonymousUserBackendTest(TestCase): - """ - Tests for AnonymousUser delegating to backend if it has 'supports_anonymous_user' = True - """ - - backend = 'django.contrib.auth.tests.auth_backends.AnonymousUserBackend' - - def setUp(self): - self.curr_auth = settings.AUTHENTICATION_BACKENDS - settings.AUTHENTICATION_BACKENDS = (self.backend,) - self.user1 = AnonymousUser() - - def tearDown(self): - settings.AUTHENTICATION_BACKENDS = self.curr_auth - - def test_has_perm(self): - self.assertEqual(self.user1.has_perm('perm', TestObj()), False) - self.assertEqual(self.user1.has_perm('anon', TestObj()), True) - - def test_has_perms(self): - self.assertEqual(self.user1.has_perms(['anon'], TestObj()), True) - self.assertEqual(self.user1.has_perms(['anon', 'perm'], TestObj()), False) - - def test_has_module_perms(self): - self.assertEqual(self.user1.has_module_perms("app1"), True) - self.assertEqual(self.user1.has_module_perms("app2"), False) - - def test_get_all_permissions(self): - self.assertEqual(self.user1.get_all_permissions(TestObj()), set(['anon'])) - - -class NoAnonymousUserBackendTest(TestCase): - """ - Tests that AnonymousUser does not delegate to backend if it has 'supports_anonymous_user' = False - """ - backend = 'django.contrib.auth.tests.auth_backends.NoAnonymousUserBackend' - - def setUp(self): - self.curr_auth = settings.AUTHENTICATION_BACKENDS - settings.AUTHENTICATION_BACKENDS = self.curr_auth + (self.backend,) - self.user1 = AnonymousUser() - - def tearDown(self): - settings.AUTHENTICATION_BACKENDS = self.curr_auth - - def test_has_perm(self): - self.assertEqual(self.user1.has_perm('perm', TestObj()), False) - self.assertEqual(self.user1.has_perm('anon', TestObj()), False) - - def test_has_perms(self): - self.assertEqual(self.user1.has_perms(['anon'], TestObj()), False) - - def test_has_module_perms(self): - self.assertEqual(self.user1.has_module_perms("app1"), False) - self.assertEqual(self.user1.has_module_perms("app2"), False) - - def test_get_all_permissions(self): - self.assertEqual(self.user1.get_all_permissions(TestObj()), set()) diff --git a/seahub/auth/tests/basic.py b/seahub/auth/tests/basic.py deleted file mode 100644 index ffa11d5d0e..0000000000 --- a/seahub/auth/tests/basic.py +++ /dev/null @@ -1,77 +0,0 @@ - -BASIC_TESTS = """ ->>> from django.contrib.auth.models import User, AnonymousUser ->>> u = User.objects.create_user('testuser', 'test@example.com', 'testpw') ->>> u.has_usable_password() -True ->>> u.check_password('bad') -False ->>> u.check_password('testpw') -True ->>> u.set_unusable_password() ->>> u.save() ->>> u.check_password('testpw') -False ->>> u.has_usable_password() -False ->>> u2 = User.objects.create_user('testuser2', 'test2@example.com') ->>> u2.has_usable_password() -False - ->>> u.is_authenticated() -True ->>> u.is_staff -False ->>> u.is_active -True ->>> u.is_superuser -False - ->>> a = AnonymousUser() ->>> a.is_authenticated() -False ->>> a.is_staff -False ->>> a.is_active -False ->>> a.is_superuser -False ->>> a.groups.all() -[] ->>> a.user_permissions.all() -[] - -# superuser tests. ->>> super = User.objects.create_superuser('super', 'super@example.com', 'super') ->>> super.is_superuser -True ->>> super.is_active -True ->>> super.is_staff -True - -# -# Tests for createsuperuser management command. -# It's nearly impossible to test the interactive mode -- a command test helper -# would be needed (and *awesome*) -- so just test the non-interactive mode. -# This covers most of the important validation, but not all. -# ->>> from django.core.management import call_command - ->>> call_command("createsuperuser", interactive=False, username="joe", email="joe@somewhere.org") -Superuser created successfully. - ->>> u = User.objects.get(username="joe") ->>> u.email -u'joe@somewhere.org' ->>> u.password -u'!' ->>> call_command("createsuperuser", interactive=False, username="joe+admin@somewhere.org", email="joe@somewhere.org") -Superuser created successfully. - ->>> u = User.objects.get(username="joe+admin@somewhere.org") ->>> u.email -u'joe@somewhere.org' ->>> u.password -u'!' -""" diff --git a/seahub/auth/tests/decorators.py b/seahub/auth/tests/decorators.py deleted file mode 100644 index 7efd9d8ccf..0000000000 --- a/seahub/auth/tests/decorators.py +++ /dev/null @@ -1,25 +0,0 @@ -from unittest import TestCase - -from django.contrib.auth.decorators import login_required - - -class LoginRequiredTestCase(TestCase): - """ - Tests the login_required decorators - """ - def testCallable(self): - """ - Check that login_required is assignable to callable objects. - """ - class CallableView(object): - def __call__(self, *args, **kwargs): - pass - login_required(CallableView()) - - def testView(self): - """ - Check that login_required is assignable to normal views. - """ - def normal_view(request): - pass - login_required(normal_view) \ No newline at end of file diff --git a/seahub/auth/tests/forms.py b/seahub/auth/tests/forms.py deleted file mode 100644 index 5aa49e09c3..0000000000 --- a/seahub/auth/tests/forms.py +++ /dev/null @@ -1,252 +0,0 @@ -from django.contrib.auth.models import User -from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm -from django.test import TestCase - - -class UserCreationFormTest(TestCase): - - fixtures = ['authtestdata.json'] - - def test_user_already_exists(self): - data = { - 'username': 'testclient', - 'password1': 'test123', - 'password2': 'test123', - } - form = UserCreationForm(data) - self.assertFalse(form.is_valid()) - self.assertEqual(form["username"].errors, - [u'A user with that username already exists.']) - - def test_invalid_data(self): - data = { - 'username': 'jsmith!', - 'password1': 'test123', - 'password2': 'test123', - } - form = UserCreationForm(data) - self.assertFalse(form.is_valid()) - self.assertEqual(form["username"].errors, - [u'This value may contain only letters, numbers and @/./+/-/_ characters.']) - - - def test_password_verification(self): - # The verification password is incorrect. - data = { - 'username': 'jsmith', - 'password1': 'test123', - 'password2': 'test', - } - form = UserCreationForm(data) - self.assertFalse(form.is_valid()) - self.assertEqual(form["password2"].errors, - [u"The two password fields didn't match."]) - - - def test_both_passwords(self): - # One (or both) passwords weren't given - data = {'username': 'jsmith'} - form = UserCreationForm(data) - self.assertFalse(form.is_valid()) - self.assertEqual(form['password1'].errors, - [u'This field is required.']) - self.assertEqual(form['password2'].errors, - [u'This field is required.']) - - - data['password2'] = 'test123' - form = UserCreationForm(data) - self.assertFalse(form.is_valid()) - self.assertEqual(form['password1'].errors, - [u'This field is required.']) - - def test_success(self): - # The success case. - - data = { - 'username': 'jsmith@example.com', - 'password1': 'test123', - 'password2': 'test123', - } - form = UserCreationForm(data) - self.assertTrue(form.is_valid()) - u = form.save() - self.assertEqual(repr(u), '') - - -class AuthenticationFormTest(TestCase): - - fixtures = ['authtestdata.json'] - - def test_invalid_username(self): - # The user submits an invalid username. - - data = { - 'username': 'jsmith_does_not_exist', - 'password': 'test123', - } - form = AuthenticationForm(None, data) - self.assertFalse(form.is_valid()) - self.assertEqual(form.non_field_errors(), - [u'Please enter a correct username and password. Note that both fields are case-sensitive.']) - - def test_inactive_user(self): - # The user is inactive. - data = { - 'username': 'inactive', - 'password': 'password', - } - form = AuthenticationForm(None, data) - self.assertFalse(form.is_valid()) - self.assertEqual(form.non_field_errors(), - [u'This account is inactive.']) - - - def test_success(self): - # The success case - data = { - 'username': 'testclient', - 'password': 'password', - } - form = AuthenticationForm(None, data) - self.assertTrue(form.is_valid()) - self.assertEqual(form.non_field_errors(), []) - - -class SetPasswordFormTest(TestCase): - - fixtures = ['authtestdata.json'] - - def test_password_verification(self): - # The two new passwords do not match. - user = User.objects.get(username='testclient') - data = { - 'new_password1': 'abc123', - 'new_password2': 'abc', - } - form = SetPasswordForm(user, data) - self.assertFalse(form.is_valid()) - self.assertEqual(form["new_password2"].errors, - [u"The two password fields didn't match."]) - - def test_success(self): - user = User.objects.get(username='testclient') - data = { - 'new_password1': 'abc123', - 'new_password2': 'abc123', - } - form = SetPasswordForm(user, data) - self.assertTrue(form.is_valid()) - - -class PasswordChangeFormTest(TestCase): - - fixtures = ['authtestdata.json'] - - def test_incorrect_password(self): - user = User.objects.get(username='testclient') - data = { - 'old_password': 'test', - 'new_password1': 'abc123', - 'new_password2': 'abc123', - } - form = PasswordChangeForm(user, data) - self.assertFalse(form.is_valid()) - self.assertEqual(form["old_password"].errors, - [u'Your old password was entered incorrectly. Please enter it again.']) - - - def test_password_verification(self): - # The two new passwords do not match. - user = User.objects.get(username='testclient') - data = { - 'old_password': 'password', - 'new_password1': 'abc123', - 'new_password2': 'abc', - } - form = PasswordChangeForm(user, data) - self.assertFalse(form.is_valid()) - self.assertEqual(form["new_password2"].errors, - [u"The two password fields didn't match."]) - - - def test_success(self): - # The success case. - user = User.objects.get(username='testclient') - data = { - 'old_password': 'password', - 'new_password1': 'abc123', - 'new_password2': 'abc123', - } - form = PasswordChangeForm(user, data) - self.assertTrue(form.is_valid()) - - def test_field_order(self): - # Regression test - check the order of fields: - user = User.objects.get(username='testclient') - self.assertEqual(PasswordChangeForm(user, {}).fields.keys(), - ['old_password', 'new_password1', 'new_password2']) - -class UserChangeFormTest(TestCase): - - fixtures = ['authtestdata.json'] - - def test_username_validity(self): - user = User.objects.get(username='testclient') - data = {'username': 'not valid'} - form = UserChangeForm(data, instance=user) - self.assertFalse(form.is_valid()) - self.assertEqual(form['username'].errors, - [u'This value may contain only letters, numbers and @/./+/-/_ characters.']) - - def test_bug_14242(self): - # A regression test, introduce by adding an optimization for the - # UserChangeForm. - - class MyUserForm(UserChangeForm): - def __init__(self, *args, **kwargs): - super(MyUserForm, self).__init__(*args, **kwargs) - self.fields['groups'].help_text = 'These groups give users different permissions' - - class Meta(UserChangeForm.Meta): - fields = ('groups',) - - # Just check we can create it - form = MyUserForm({}) - - -class PasswordResetFormTest(TestCase): - - fixtures = ['authtestdata.json'] - - def test_invalid_email(self): - data = {'email':'not valid'} - form = PasswordResetForm(data) - self.assertFalse(form.is_valid()) - self.assertEqual(form['email'].errors, - [u'Enter a valid e-mail address.']) - - def test_nonexistant_email(self): - # Test nonexistant email address - data = {'email':'foo@bar.com'} - form = PasswordResetForm(data) - self.assertFalse(form.is_valid()) - self.assertEqual(form.errors, - {'email': [u"That e-mail address doesn't have an associated user account. Are you sure you've registered?"]}) - - def test_cleaned_data(self): - # Regression test - user = User.objects.create_user("jsmith3", "jsmith3@example.com", "test123") - data = {'email':'jsmith3@example.com'} - form = PasswordResetForm(data) - self.assertTrue(form.is_valid()) - self.assertEqual(form.cleaned_data['email'], u'jsmith3@example.com') - - - def test_bug_5605(self): - # bug #5605, preserve the case of the user name (before the @ in the - # email address) when creating a user. - user = User.objects.create_user('forms_test2', 'tesT@EXAMple.com', 'test') - self.assertEqual(user.email, 'tesT@example.com') - user = User.objects.create_user('forms_test3', 'tesT', 'test') - self.assertEqual(user.email, 'tesT') diff --git a/seahub/auth/tests/models.py b/seahub/auth/tests/models.py deleted file mode 100644 index 754c6db7b4..0000000000 --- a/seahub/auth/tests/models.py +++ /dev/null @@ -1,35 +0,0 @@ -from django.conf import settings -from django.test import TestCase -from django.contrib.auth.models import User, SiteProfileNotAvailable - -class ProfileTestCase(TestCase): - fixtures = ['authtestdata.json'] - def setUp(self): - """Backs up the AUTH_PROFILE_MODULE""" - self.old_AUTH_PROFILE_MODULE = getattr(settings, - 'AUTH_PROFILE_MODULE', None) - - def tearDown(self): - """Restores the AUTH_PROFILE_MODULE -- if it was not set it is deleted, - otherwise the old value is restored""" - if self.old_AUTH_PROFILE_MODULE is None and \ - hasattr(settings, 'AUTH_PROFILE_MODULE'): - del settings.AUTH_PROFILE_MODULE - - if self.old_AUTH_PROFILE_MODULE is not None: - settings.AUTH_PROFILE_MODULE = self.old_AUTH_PROFILE_MODULE - - def test_site_profile_not_available(self): - # calling get_profile without AUTH_PROFILE_MODULE set - if hasattr(settings, 'AUTH_PROFILE_MODULE'): - del settings.AUTH_PROFILE_MODULE - user = User.objects.get(username='testclient') - self.assertRaises(SiteProfileNotAvailable, user.get_profile) - - # Bad syntax in AUTH_PROFILE_MODULE: - settings.AUTH_PROFILE_MODULE = 'foobar' - self.assertRaises(SiteProfileNotAvailable, user.get_profile) - - # module that doesn't exist - settings.AUTH_PROFILE_MODULE = 'foo.bar' - self.assertRaises(SiteProfileNotAvailable, user.get_profile) diff --git a/seahub/auth/tests/remote_user.py b/seahub/auth/tests/remote_user.py deleted file mode 100644 index 6115edcfd0..0000000000 --- a/seahub/auth/tests/remote_user.py +++ /dev/null @@ -1,170 +0,0 @@ -from datetime import datetime - -from django.conf import settings -from django.contrib.auth.backends import RemoteUserBackend -from django.contrib.auth.models import User -from django.test import TestCase - - -class RemoteUserTest(TestCase): - - urls = 'django.contrib.auth.tests.urls' - middleware = 'django.contrib.auth.middleware.RemoteUserMiddleware' - backend = 'django.contrib.auth.backends.RemoteUserBackend' - - # Usernames to be passed in REMOTE_USER for the test_known_user test case. - known_user = 'knownuser' - known_user2 = 'knownuser2' - - def setUp(self): - self.curr_middleware = settings.MIDDLEWARE_CLASSES - self.curr_auth = settings.AUTHENTICATION_BACKENDS - settings.MIDDLEWARE_CLASSES += (self.middleware,) - settings.AUTHENTICATION_BACKENDS = (self.backend,) - - def test_no_remote_user(self): - """ - Tests requests where no remote user is specified and insures that no - users get created. - """ - num_users = User.objects.count() - - response = self.client.get('/remote_user/') - self.assert_(response.context['user'].is_anonymous()) - self.assertEqual(User.objects.count(), num_users) - - response = self.client.get('/remote_user/', REMOTE_USER=None) - self.assert_(response.context['user'].is_anonymous()) - self.assertEqual(User.objects.count(), num_users) - - response = self.client.get('/remote_user/', REMOTE_USER='') - self.assert_(response.context['user'].is_anonymous()) - self.assertEqual(User.objects.count(), num_users) - - def test_unknown_user(self): - """ - Tests the case where the username passed in the header does not exist - as a User. - """ - num_users = User.objects.count() - response = self.client.get('/remote_user/', REMOTE_USER='newuser') - self.assertEqual(response.context['user'].username, 'newuser') - self.assertEqual(User.objects.count(), num_users + 1) - User.objects.get(username='newuser') - - # Another request with same user should not create any new users. - response = self.client.get('/remote_user/', REMOTE_USER='newuser') - self.assertEqual(User.objects.count(), num_users + 1) - - def test_known_user(self): - """ - Tests the case where the username passed in the header is a valid User. - """ - User.objects.create(username='knownuser') - User.objects.create(username='knownuser2') - num_users = User.objects.count() - response = self.client.get('/remote_user/', REMOTE_USER=self.known_user) - self.assertEqual(response.context['user'].username, 'knownuser') - self.assertEqual(User.objects.count(), num_users) - # Test that a different user passed in the headers causes the new user - # to be logged in. - response = self.client.get('/remote_user/', REMOTE_USER=self.known_user2) - self.assertEqual(response.context['user'].username, 'knownuser2') - self.assertEqual(User.objects.count(), num_users) - - def test_last_login(self): - """ - Tests that a user's last_login is set the first time they make a - request but not updated in subsequent requests with the same session. - """ - user = User.objects.create(username='knownuser') - # Set last_login to something so we can determine if it changes. - default_login = datetime(2000, 1, 1) - user.last_login = default_login - user.save() - - response = self.client.get('/remote_user/', REMOTE_USER=self.known_user) - self.assertNotEqual(default_login, response.context['user'].last_login) - - user = User.objects.get(username='knownuser') - user.last_login = default_login - user.save() - response = self.client.get('/remote_user/', REMOTE_USER=self.known_user) - self.assertEqual(default_login, response.context['user'].last_login) - - def tearDown(self): - """Restores settings to avoid breaking other tests.""" - settings.MIDDLEWARE_CLASSES = self.curr_middleware - settings.AUTHENTICATION_BACKENDS = self.curr_auth - - -class RemoteUserNoCreateBackend(RemoteUserBackend): - """Backend that doesn't create unknown users.""" - create_unknown_user = False - - -class RemoteUserNoCreateTest(RemoteUserTest): - """ - Contains the same tests as RemoteUserTest, but using a custom auth backend - class that doesn't create unknown users. - """ - - backend =\ - 'django.contrib.auth.tests.remote_user.RemoteUserNoCreateBackend' - - def test_unknown_user(self): - num_users = User.objects.count() - response = self.client.get('/remote_user/', REMOTE_USER='newuser') - self.assert_(response.context['user'].is_anonymous()) - self.assertEqual(User.objects.count(), num_users) - - -class CustomRemoteUserBackend(RemoteUserBackend): - """ - Backend that overrides RemoteUserBackend methods. - """ - - def clean_username(self, username): - """ - Grabs username before the @ character. - """ - return username.split('@')[0] - - def configure_user(self, user): - """ - Sets user's email address. - """ - user.email = 'user@example.com' - user.save() - return user - - -class RemoteUserCustomTest(RemoteUserTest): - """ - Tests a custom RemoteUserBackend subclass that overrides the clean_username - and configure_user methods. - """ - - backend =\ - 'django.contrib.auth.tests.remote_user.CustomRemoteUserBackend' - # REMOTE_USER strings with e-mail addresses for the custom backend to - # clean. - known_user = 'knownuser@example.com' - known_user2 = 'knownuser2@example.com' - - def test_known_user(self): - """ - The strings passed in REMOTE_USER should be cleaned and the known users - should not have been configured with an email address. - """ - super(RemoteUserCustomTest, self).test_known_user() - self.assertEqual(User.objects.get(username='knownuser').email, '') - self.assertEqual(User.objects.get(username='knownuser2').email, '') - - def test_unknown_user(self): - """ - The unknown user created should be configured with an email address. - """ - super(RemoteUserCustomTest, self).test_unknown_user() - newuser = User.objects.get(username='newuser') - self.assertEqual(newuser.email, 'user@example.com') diff --git a/seahub/auth/tests/templates/registration/login.html b/seahub/auth/tests/templates/registration/login.html deleted file mode 100644 index 027da717d9..0000000000 --- a/seahub/auth/tests/templates/registration/login.html +++ /dev/null @@ -1 +0,0 @@ -{{ form.as_ul }} \ No newline at end of file diff --git a/seahub/auth/tests/templates/registration/password_reset_complete.html b/seahub/auth/tests/templates/registration/password_reset_complete.html deleted file mode 100644 index 3dd79d86a4..0000000000 --- a/seahub/auth/tests/templates/registration/password_reset_complete.html +++ /dev/null @@ -1 +0,0 @@ -Password reset successfully \ No newline at end of file diff --git a/seahub/auth/tests/templates/registration/password_reset_confirm.html b/seahub/auth/tests/templates/registration/password_reset_confirm.html deleted file mode 100644 index 8f06c57793..0000000000 --- a/seahub/auth/tests/templates/registration/password_reset_confirm.html +++ /dev/null @@ -1,5 +0,0 @@ -{% if validlink %} -Please enter your new password: {{ form }} -{% else %} -The password reset link was invalid -{% endif %} \ No newline at end of file diff --git a/seahub/auth/tests/templates/registration/password_reset_done.html b/seahub/auth/tests/templates/registration/password_reset_done.html deleted file mode 100644 index d56b10f0d5..0000000000 --- a/seahub/auth/tests/templates/registration/password_reset_done.html +++ /dev/null @@ -1 +0,0 @@ -E-mail sent \ No newline at end of file diff --git a/seahub/auth/tests/templates/registration/password_reset_email.html b/seahub/auth/tests/templates/registration/password_reset_email.html deleted file mode 100644 index 1b9a48255a..0000000000 --- a/seahub/auth/tests/templates/registration/password_reset_email.html +++ /dev/null @@ -1 +0,0 @@ -{{ protocol }}://{{ domain }}/reset/{{ uid }}-{{ token }}/ \ No newline at end of file diff --git a/seahub/auth/tests/templates/registration/password_reset_form.html b/seahub/auth/tests/templates/registration/password_reset_form.html deleted file mode 100644 index d960111992..0000000000 --- a/seahub/auth/tests/templates/registration/password_reset_form.html +++ /dev/null @@ -1 +0,0 @@ -{{ form }} \ No newline at end of file diff --git a/seahub/auth/tests/tokens.py b/seahub/auth/tests/tokens.py deleted file mode 100644 index 7a641fd818..0000000000 --- a/seahub/auth/tests/tokens.py +++ /dev/null @@ -1,42 +0,0 @@ -TOKEN_GENERATOR_TESTS = """ ->>> from django.contrib.auth.models import User, AnonymousUser ->>> from django.contrib.auth.tokens import PasswordResetTokenGenerator ->>> from django.conf import settings ->>> u = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw') ->>> p0 = PasswordResetTokenGenerator() ->>> tk1 = p0.make_token(u) ->>> p0.check_token(u, tk1) -True - ->>> u = User.objects.create_user('comebackkid', 'test3@example.com', 'testpw') ->>> p0 = PasswordResetTokenGenerator() ->>> tk1 = p0.make_token(u) ->>> reload = User.objects.get(username='comebackkid') ->>> tk2 = p0.make_token(reload) ->>> tk1 == tk2 -True - -Tests to ensure we can use the token after n days, but no greater. -Use a mocked version of PasswordResetTokenGenerator so we can change -the value of 'today' - ->>> class Mocked(PasswordResetTokenGenerator): -... def __init__(self, today): -... self._today_val = today -... def _today(self): -... return self._today_val - ->>> from datetime import date, timedelta ->>> p1 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS)) ->>> p1.check_token(u, tk1) -True ->>> p2 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS + 1)) ->>> p2.check_token(u, tk1) -False - -This will put a 14-digit base36 timestamp into the token, which is too large. ->>> tk1 = p0._make_token_with_timestamp(u, 175455491841851871349) ->>> p0.check_token(u, tk1) -False - -""" diff --git a/seahub/auth/tests/urls.py b/seahub/auth/tests/urls.py deleted file mode 100644 index f94b8daa7f..0000000000 --- a/seahub/auth/tests/urls.py +++ /dev/null @@ -1,18 +0,0 @@ -from django.conf.urls.defaults import patterns -from django.contrib.auth.urls import urlpatterns -from django.http import HttpResponse -from django.template import Template, RequestContext - -def remote_user_auth_view(request): - "Dummy view for remote user tests" - t = Template("Username is {{ user }}.") - c = RequestContext(request, {}) - return HttpResponse(t.render(c)) - -# special urls for auth test cases -urlpatterns += patterns('', - (r'^logout/custom_query/$', 'django.contrib.auth.views.logout', dict(redirect_field_name='follow')), - (r'^logout/next_page/$', 'django.contrib.auth.views.logout', dict(next_page='/somewhere/')), - (r'^remote_user/$', remote_user_auth_view), -) - diff --git a/seahub/auth/tests/views.py b/seahub/auth/tests/views.py deleted file mode 100644 index d894e6dafd..0000000000 --- a/seahub/auth/tests/views.py +++ /dev/null @@ -1,274 +0,0 @@ -import os -import re -import urllib - -from django.conf import settings -from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME -from django.contrib.auth.forms import AuthenticationForm -from django.contrib.sites.models import Site, RequestSite -from django.contrib.auth.models import User -from django.test import TestCase -from django.core import mail -from django.core.urlresolvers import reverse - -class AuthViewsTestCase(TestCase): - """ - Helper base class for all the follow test cases. - """ - fixtures = ['authtestdata.json'] - urls = 'django.contrib.auth.urls' - - def setUp(self): - self.old_LANGUAGES = settings.LANGUAGES - self.old_LANGUAGE_CODE = settings.LANGUAGE_CODE - settings.LANGUAGES = (('en', 'English'),) - settings.LANGUAGE_CODE = 'en' - self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS - settings.TEMPLATE_DIRS = ( - os.path.join( - os.path.dirname(__file__), - 'templates' - ) - ,) - - def tearDown(self): - settings.LANGUAGES = self.old_LANGUAGES - settings.LANGUAGE_CODE = self.old_LANGUAGE_CODE - settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS - -class PasswordResetTest(AuthViewsTestCase): - - def test_email_not_found(self): - "Error is raised if the provided email address isn't currently registered" - response = self.client.get('/password_reset/') - self.assertEquals(response.status_code, 200) - response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'}) - self.assertContains(response, "That e-mail address doesn't have an associated user account") - self.assertEquals(len(mail.outbox), 0) - - def test_email_found(self): - "Email is sent if a valid email address is provided for password reset" - response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'}) - self.assertEquals(response.status_code, 302) - self.assertEquals(len(mail.outbox), 1) - self.assert_("http://" in mail.outbox[0].body) - - def _test_confirm_start(self): - # Start by creating the email - response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'}) - self.assertEquals(response.status_code, 302) - self.assertEquals(len(mail.outbox), 1) - return self._read_signup_email(mail.outbox[0]) - - def _read_signup_email(self, email): - urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body) - self.assert_(urlmatch is not None, "No URL found in sent email") - return urlmatch.group(), urlmatch.groups()[0] - - def test_confirm_valid(self): - url, path = self._test_confirm_start() - response = self.client.get(path) - # redirect to a 'complete' page: - self.assertEquals(response.status_code, 200) - self.assert_("Please enter your new password" in response.content) - - def test_confirm_invalid(self): - url, path = self._test_confirm_start() - # Let's munge the token in the path, but keep the same length, - # in case the URLconf will reject a different length. - path = path[:-5] + ("0"*4) + path[-1] - - response = self.client.get(path) - self.assertEquals(response.status_code, 200) - self.assert_("The password reset link was invalid" in response.content) - - def test_confirm_invalid_post(self): - # Same as test_confirm_invalid, but trying - # to do a POST instead. - url, path = self._test_confirm_start() - path = path[:-5] + ("0"*4) + path[-1] - - response = self.client.post(path, {'new_password1': 'anewpassword', - 'new_password2':' anewpassword'}) - # Check the password has not been changed - u = User.objects.get(email='staffmember@example.com') - self.assert_(not u.check_password("anewpassword")) - - def test_confirm_complete(self): - url, path = self._test_confirm_start() - response = self.client.post(path, {'new_password1': 'anewpassword', - 'new_password2': 'anewpassword'}) - # It redirects us to a 'complete' page: - self.assertEquals(response.status_code, 302) - # Check the password has been changed - u = User.objects.get(email='staffmember@example.com') - self.assert_(u.check_password("anewpassword")) - - # Check we can't use the link again - response = self.client.get(path) - self.assertEquals(response.status_code, 200) - self.assert_("The password reset link was invalid" in response.content) - - def test_confirm_different_passwords(self): - url, path = self._test_confirm_start() - response = self.client.post(path, {'new_password1': 'anewpassword', - 'new_password2':' x'}) - self.assertEquals(response.status_code, 200) - self.assert_("The two password fields didn't match" in response.content) - -class ChangePasswordTest(AuthViewsTestCase): - - def login(self, password='password'): - response = self.client.post('/login/', { - 'username': 'testclient', - 'password': password - } - ) - self.assertEquals(response.status_code, 302) - self.assert_(response['Location'].endswith(settings.LOGIN_REDIRECT_URL)) - - def fail_login(self, password='password'): - response = self.client.post('/login/', { - 'username': 'testclient', - 'password': password - } - ) - self.assertEquals(response.status_code, 200) - self.assert_("Please enter a correct username and password. Note that both fields are case-sensitive." in response.content) - - def logout(self): - response = self.client.get('/logout/') - - def test_password_change_fails_with_invalid_old_password(self): - self.login() - response = self.client.post('/password_change/', { - 'old_password': 'donuts', - 'new_password1': 'password1', - 'new_password2': 'password1', - } - ) - self.assertEquals(response.status_code, 200) - self.assert_("Your old password was entered incorrectly. Please enter it again." in response.content) - - def test_password_change_fails_with_mismatched_passwords(self): - self.login() - response = self.client.post('/password_change/', { - 'old_password': 'password', - 'new_password1': 'password1', - 'new_password2': 'donuts', - } - ) - self.assertEquals(response.status_code, 200) - self.assert_("The two password fields didn't match." in response.content) - - def test_password_change_succeeds(self): - self.login() - response = self.client.post('/password_change/', { - 'old_password': 'password', - 'new_password1': 'password1', - 'new_password2': 'password1', - } - ) - self.assertEquals(response.status_code, 302) - self.assert_(response['Location'].endswith('/password_change/done/')) - self.fail_login() - self.login(password='password1') - -class LoginTest(AuthViewsTestCase): - - def test_current_site_in_context_after_login(self): - response = self.client.get(reverse('django.contrib.auth.views.login')) - self.assertEquals(response.status_code, 200) - site = Site.objects.get_current() - self.assertEquals(response.context['site'], site) - self.assertEquals(response.context['site_name'], site.name) - self.assert_(isinstance(response.context['form'], AuthenticationForm), - 'Login form is not an AuthenticationForm') - - def test_security_check(self, password='password'): - login_url = reverse('django.contrib.auth.views.login') - - # Those URLs should not pass the security check - for bad_url in ('http://example.com', - 'https://example.com', - 'ftp://exampel.com', - '//example.com'): - - nasty_url = '%(url)s?%(next)s=%(bad_url)s' % { - 'url': login_url, - 'next': REDIRECT_FIELD_NAME, - 'bad_url': urllib.quote(bad_url) - } - response = self.client.post(nasty_url, { - 'username': 'testclient', - 'password': password, - } - ) - self.assertEquals(response.status_code, 302) - self.assertFalse(bad_url in response['Location'], "%s should be blocked" % bad_url) - - # Now, these URLs have an other URL as a GET parameter and therefore - # should be allowed - for url_ in ('http://example.com', 'https://example.com', - 'ftp://exampel.com', '//example.com'): - safe_url = '%(url)s?%(next)s=/view/?param=%(safe_param)s' % { - 'url': login_url, - 'next': REDIRECT_FIELD_NAME, - 'safe_param': urllib.quote(url_) - } - response = self.client.post(safe_url, { - 'username': 'testclient', - 'password': password, - } - ) - self.assertEquals(response.status_code, 302) - self.assertTrue('/view/?param=%s' % url_ in response['Location'], "/view/?param=%s should be allowed" % url_) - - -class LogoutTest(AuthViewsTestCase): - urls = 'django.contrib.auth.tests.urls' - - def login(self, password='password'): - response = self.client.post('/login/', { - 'username': 'testclient', - 'password': password - } - ) - self.assertEquals(response.status_code, 302) - self.assert_(response['Location'].endswith(settings.LOGIN_REDIRECT_URL)) - self.assert_(SESSION_KEY in self.client.session) - - def confirm_logged_out(self): - self.assert_(SESSION_KEY not in self.client.session) - - def test_logout_default(self): - "Logout without next_page option renders the default template" - self.login() - response = self.client.get('/logout/') - self.assertEquals(200, response.status_code) - self.assert_('Logged out' in response.content) - self.confirm_logged_out() - - def test_logout_with_next_page_specified(self): - "Logout with next_page option given redirects to specified resource" - self.login() - response = self.client.get('/logout/next_page/') - self.assertEqual(response.status_code, 302) - self.assert_(response['Location'].endswith('/somewhere/')) - self.confirm_logged_out() - - def test_logout_with_redirect_argument(self): - "Logout with query string redirects to specified resource" - self.login() - response = self.client.get('/logout/?next=/login/') - self.assertEqual(response.status_code, 302) - self.assert_(response['Location'].endswith('/login/')) - self.confirm_logged_out() - - def test_logout_with_custom_redirect_argument(self): - "Logout with custom query string redirects to specified resource" - self.login() - response = self.client.get('/logout/custom_query/?follow=/somewhere/') - self.assertEqual(response.status_code, 302) - self.assert_(response['Location'].endswith('/somewhere/')) - self.confirm_logged_out() diff --git a/seahub/auth/tokens.py b/seahub/auth/tokens.py index 91bb013a89..c307dfc575 100644 --- a/seahub/auth/tokens.py +++ b/seahub/auth/tokens.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from datetime import date from django.conf import settings from django.utils.http import int_to_base36, base36_to_int diff --git a/seahub/auth/urls.py b/seahub/auth/urls.py index 42b4e8f212..74082c49db 100644 --- a/seahub/auth/urls.py +++ b/seahub/auth/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # These URLs are normally mapped to /admin/urls.py. This URLs file is # provided as a convenience to those who want to deploy these URLs elsewhere. # This file is also used to provide a reliable view deployment for test purposes. diff --git a/seahub/auth/views.py b/seahub/auth/views.py index 151c22f46c..e23c8f5ad5 100644 --- a/seahub/auth/views.py +++ b/seahub/auth/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import hashlib import re import logging diff --git a/seahub/avatar/admin.py b/seahub/avatar/admin.py index 80ea70f816..8a945916c8 100644 --- a/seahub/avatar/admin.py +++ b/seahub/avatar/admin.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.contrib import admin from seahub.avatar.models import Avatar diff --git a/seahub/avatar/forms.py b/seahub/avatar/forms.py index 3fd1e1ae08..044606bfe1 100644 --- a/seahub/avatar/forms.py +++ b/seahub/avatar/forms.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os from django import forms diff --git a/seahub/avatar/management/commands/__init__.py b/seahub/avatar/management/commands/__init__.py index 8b13789179..f46dd29f4b 100644 --- a/seahub/avatar/management/commands/__init__.py +++ b/seahub/avatar/management/commands/__init__.py @@ -1 +1,2 @@ +# Copyright (c) 2012-2016 Seafile Ltd. diff --git a/seahub/avatar/management/commands/rebuild_avatars.py b/seahub/avatar/management/commands/rebuild_avatars.py index 3a1d7d3db0..5986c0cd3c 100644 --- a/seahub/avatar/management/commands/rebuild_avatars.py +++ b/seahub/avatar/management/commands/rebuild_avatars.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.core.management.base import NoArgsCommand from seahub.avatar.models import Avatar diff --git a/seahub/avatar/models.py b/seahub/avatar/models.py index 75565857ea..7efea06f5c 100644 --- a/seahub/avatar/models.py +++ b/seahub/avatar/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from abc import abstractmethod import datetime import hashlib diff --git a/seahub/avatar/settings.py b/seahub/avatar/settings.py index cdc384b4a9..7fb436230a 100644 --- a/seahub/avatar/settings.py +++ b/seahub/avatar/settings.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings try: diff --git a/seahub/avatar/signals.py b/seahub/avatar/signals.py index 9394445c1a..487bf5cb26 100644 --- a/seahub/avatar/signals.py +++ b/seahub/avatar/signals.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import django.dispatch diff --git a/seahub/avatar/templatetags/avatar_tags.py b/seahub/avatar/templatetags/avatar_tags.py index b59a6f1eb8..afdc27a803 100644 --- a/seahub/avatar/templatetags/avatar_tags.py +++ b/seahub/avatar/templatetags/avatar_tags.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging import urllib import hashlib diff --git a/seahub/avatar/templatetags/group_avatar_tags.py b/seahub/avatar/templatetags/group_avatar_tags.py index 9eb5623ce0..42caeba301 100644 --- a/seahub/avatar/templatetags/group_avatar_tags.py +++ b/seahub/avatar/templatetags/group_avatar_tags.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from django.conf import settings diff --git a/seahub/avatar/tests.py b/seahub/avatar/tests.py index 16046a37ec..7168d7205b 100644 --- a/seahub/avatar/tests.py +++ b/seahub/avatar/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os.path from django.test import TestCase diff --git a/seahub/avatar/urls.py b/seahub/avatar/urls.py index 36d50f312f..cfa50f8849 100644 --- a/seahub/avatar/urls.py +++ b/seahub/avatar/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url urlpatterns = patterns('seahub.avatar.views', diff --git a/seahub/avatar/util.py b/seahub/avatar/util.py index 11ffa4566e..436001bad7 100644 --- a/seahub/avatar/util.py +++ b/seahub/avatar/util.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings from django.core.cache import cache from django.core.files.storage import default_storage, get_storage_class diff --git a/seahub/avatar/views.py b/seahub/avatar/views.py index b373d6ecaf..2373c57b1c 100644 --- a/seahub/avatar/views.py +++ b/seahub/avatar/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 from django.core.cache import cache from django.http import HttpResponseRedirect, Http404 diff --git a/seahub/base/__init__.py b/seahub/base/__init__.py index eab07383d4..c8cfde2bce 100644 --- a/seahub/base/__init__.py +++ b/seahub/base/__init__.py @@ -1 +1,2 @@ +# Copyright (c) 2012-2016 Seafile Ltd. default_app_config = 'seahub.base.apps.BaseConfig' diff --git a/seahub/base/accounts.py b/seahub/base/accounts.py index c2ea62cba0..50f731b165 100644 --- a/seahub/base/accounts.py +++ b/seahub/base/accounts.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import re diff --git a/seahub/base/apps.py b/seahub/base/apps.py index 5b6f66702b..e07f74f375 100644 --- a/seahub/base/apps.py +++ b/seahub/base/apps.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.apps import AppConfig from django.core.cache import cache diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py index f2766a3ca9..81e07e6e21 100644 --- a/seahub/base/context_processors.py +++ b/seahub/base/context_processors.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ A set of request processors that return dictionaries to be merged into a template context. Each function takes the request object as its only parameter diff --git a/seahub/base/database_storage/__init__.py b/seahub/base/database_storage/__init__.py index 2c59e78865..19adf1f5eb 100644 --- a/seahub/base/database_storage/__init__.py +++ b/seahub/base/database_storage/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # Allow users to: from database_storage import DatabaseStorage # (reduce redundancy a little bit) diff --git a/seahub/base/database_storage/database_storage.py b/seahub/base/database_storage/database_storage.py index e428d03f2c..2a50de1200 100644 --- a/seahub/base/database_storage/database_storage.py +++ b/seahub/base/database_storage/database_storage.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # DatabaseStorage for django. # 2011 (c) Mike Mueller # 2009 (c) GameKeeper Gambling Ltd, Ivanov E. diff --git a/seahub/base/decorators.py b/seahub/base/decorators.py index 22068ff906..dff8b366aa 100644 --- a/seahub/base/decorators.py +++ b/seahub/base/decorators.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.core.urlresolvers import reverse from django.http import Http404, HttpResponseRedirect, HttpResponseNotAllowed from django.shortcuts import render_to_response diff --git a/seahub/base/fields.py b/seahub/base/fields.py index c55fc95d4e..83de5a8e07 100644 --- a/seahub/base/fields.py +++ b/seahub/base/fields.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.db.models import CharField class ModifyingFieldDescriptor(object): diff --git a/seahub/base/generic.py b/seahub/base/generic.py index 8f6f1ac4f5..fefe731a2d 100644 --- a/seahub/base/generic.py +++ b/seahub/base/generic.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.views.generic import TemplateView from constance import config diff --git a/seahub/base/management/commands/changepassword.py b/seahub/base/management/commands/changepassword.py index 51079ea5d3..c6e6df4171 100644 --- a/seahub/base/management/commands/changepassword.py +++ b/seahub/base/management/commands/changepassword.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.core.management.base import BaseCommand, CommandError from seahub.base.accounts import User import getpass diff --git a/seahub/base/management/commands/createsuperuser.py b/seahub/base/management/commands/createsuperuser.py index d776ae449a..7a284dbe1f 100644 --- a/seahub/base/management/commands/createsuperuser.py +++ b/seahub/base/management/commands/createsuperuser.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ Management utility to create superusers. """ diff --git a/seahub/base/middleware.py b/seahub/base/middleware.py index 4ae43a154f..d82175b4df 100644 --- a/seahub/base/middleware.py +++ b/seahub/base/middleware.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import re from django.core.cache import cache diff --git a/seahub/base/mixins.py b/seahub/base/mixins.py index fa2afe2c6b..1b55d12360 100644 --- a/seahub/base/mixins.py +++ b/seahub/base/mixins.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.utils.decorators import method_decorator from seahub.auth.decorators import login_required diff --git a/seahub/base/models.py b/seahub/base/models.py index a260afcd2b..2da95c2bf1 100644 --- a/seahub/base/models.py +++ b/seahub/base/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os import datetime import hashlib diff --git a/seahub/base/profile.py b/seahub/base/profile.py index 31908d7c4d..79b52191dc 100644 --- a/seahub/base/profile.py +++ b/seahub/base/profile.py @@ -1,4 +1,27 @@ -"""Adapted from https://github.com/omarish/django-cprofile-middleware/""" +# Copyright (c) 2012-2016 Seafile Ltd. +""" +The MIT License (MIT) + +Copyright (c) 2013 Omar Bohsali + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" try: import cProfile as profile @@ -59,4 +82,4 @@ class ProfilerMiddleware(object): stats.print_stats(int(request.GET.get('count', 100))) response.content = '
%s
' % io.getvalue() - return response \ No newline at end of file + return response diff --git a/seahub/base/registration_urls.py b/seahub/base/registration_urls.py index cdc6d91c8b..4b11d7d29e 100644 --- a/seahub/base/registration_urls.py +++ b/seahub/base/registration_urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url, include from django.views.generic import TemplateView from django.conf import settings diff --git a/seahub/base/sudo_mode.py b/seahub/base/sudo_mode.py index 0ae61381fc..492f68c288 100644 --- a/seahub/base/sudo_mode.py +++ b/seahub/base/sudo_mode.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """Ask the admin to provide his password before visiting sysadmin-only pages. When an admin visist to the syadmin related pages, seahub would ask him to diff --git a/seahub/base/templatetags/rest_framework.py b/seahub/base/templatetags/rest_framework.py index 4e0181ee0a..91a0dcc971 100644 --- a/seahub/base/templatetags/rest_framework.py +++ b/seahub/base/templatetags/rest_framework.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django import template from django.core.urlresolvers import reverse from django.http import QueryDict diff --git a/seahub/base/templatetags/seahub_tags.py b/seahub/base/templatetags/seahub_tags.py index 85672e2e7f..92f9a6ccb4 100644 --- a/seahub/base/templatetags/seahub_tags.py +++ b/seahub/base/templatetags/seahub_tags.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import datetime as dt from datetime import datetime diff --git a/seahub/base/templatetags/upload_tags.py b/seahub/base/templatetags/upload_tags.py index 72a522af15..a5ece2a93a 100644 --- a/seahub/base/templatetags/upload_tags.py +++ b/seahub/base/templatetags/upload_tags.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django import template register = template.Library() diff --git a/seahub/base/tests.py b/seahub/base/tests.py index 4703ad6b5a..4115d06860 100644 --- a/seahub/base/tests.py +++ b/seahub/base/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ This file demonstrates two different styles of tests (one doctest and one unittest). These will both pass when you run "manage.py test". diff --git a/seahub/base/utils.py b/seahub/base/utils.py index c8864e5e7b..d578579760 100644 --- a/seahub/base/utils.py +++ b/seahub/base/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import re import string diff --git a/seahub/base/views.py b/seahub/base/views.py index 60f00ef0ef..f6d461202e 100644 --- a/seahub/base/views.py +++ b/seahub/base/views.py @@ -1 +1,2 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # Create your views here. diff --git a/seahub/constants.py b/seahub/constants.py index 4dfc870a38..3c76773d83 100644 --- a/seahub/constants.py +++ b/seahub/constants.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # Default user have common operations, like creating group and library. DEFAULT_USER = 'default' diff --git a/seahub/contacts/__init__.py b/seahub/contacts/__init__.py index 695d9d63ef..126d2e35e2 100644 --- a/seahub/contacts/__init__.py +++ b/seahub/contacts/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from signals import * from handlers import * diff --git a/seahub/contacts/handlers.py b/seahub/contacts/handlers.py index 45b873fde4..1db13071a2 100644 --- a/seahub/contacts/handlers.py +++ b/seahub/contacts/handlers.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from signals import mail_sended from models import Contact diff --git a/seahub/contacts/models.py b/seahub/contacts/models.py index bbfaecbb0e..30cd5a87f7 100644 --- a/seahub/contacts/models.py +++ b/seahub/contacts/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 from django import forms from django.db import models diff --git a/seahub/contacts/settings.py b/seahub/contacts/settings.py index 525e331730..41904f2526 100644 --- a/seahub/contacts/settings.py +++ b/seahub/contacts/settings.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings # Some databases impose limitations to indexes columns (like MySQL InnoDB), diff --git a/seahub/contacts/signals.py b/seahub/contacts/signals.py index 1943638c27..a88237d53c 100644 --- a/seahub/contacts/signals.py +++ b/seahub/contacts/signals.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import django.dispatch mail_sended = django.dispatch.Signal(providing_args=["user", "email"]) diff --git a/seahub/contacts/urls.py b/seahub/contacts/urls.py index 04c58dd08f..58afc12c26 100644 --- a/seahub/contacts/urls.py +++ b/seahub/contacts/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url from views import * diff --git a/seahub/contacts/views.py b/seahub/contacts/views.py index 9adf8c1f87..ebf6680faa 100644 --- a/seahub/contacts/views.py +++ b/seahub/contacts/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import logging import json diff --git a/seahub/forms.py b/seahub/forms.py index 838521e5c9..fd4a2a1289 100644 --- a/seahub/forms.py +++ b/seahub/forms.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 from django.conf import settings from django import forms diff --git a/seahub/group/decorators.py b/seahub/group/decorators.py index 31445ce4e0..7f5bf58069 100644 --- a/seahub/group/decorators.py +++ b/seahub/group/decorators.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.http import Http404 from seaserv import check_group_staff diff --git a/seahub/group/error_msg.py b/seahub/group/error_msg.py index 59757e2dc6..155114fc12 100644 --- a/seahub/group/error_msg.py +++ b/seahub/group/error_msg.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ This file contains error messages from ccnet or seafile that will be translated. """ diff --git a/seahub/group/forms.py b/seahub/group/forms.py index d0c5699055..65a7fbf243 100644 --- a/seahub/group/forms.py +++ b/seahub/group/forms.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import os diff --git a/seahub/group/models.py b/seahub/group/models.py index cc1470d110..3c8f51f96d 100644 --- a/seahub/group/models.py +++ b/seahub/group/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import datetime import os import re diff --git a/seahub/group/settings.py b/seahub/group/settings.py index a4d247b1eb..eee1891553 100644 --- a/seahub/group/settings.py +++ b/seahub/group/settings.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings GROUP_MEMBERS_DEFAULT_DISPLAY = getattr(settings, 'GROUP_MEMBERS_DEFAULT_DISPLAY', 10) diff --git a/seahub/group/signals.py b/seahub/group/signals.py index 88d47460a0..e78e31fc1b 100644 --- a/seahub/group/signals.py +++ b/seahub/group/signals.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import django.dispatch grpmsg_added = django.dispatch.Signal(providing_args=["group_id", "from_email", "message"]) diff --git a/seahub/group/tests/__init__.py b/seahub/group/tests/__init__.py index 30282be68b..769bc15633 100644 --- a/seahub/group/tests/__init__.py +++ b/seahub/group/tests/__init__.py @@ -1 +1,2 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from group.tests.tests import * diff --git a/seahub/group/tests/tests.py b/seahub/group/tests/tests.py index 9f099cb74c..502876e591 100644 --- a/seahub/group/tests/tests.py +++ b/seahub/group/tests/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 from datetime import datetime import os diff --git a/seahub/group/urls.py b/seahub/group/urls.py index af1ba00089..6eea3fcc8e 100644 --- a/seahub/group/urls.py +++ b/seahub/group/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url from views import group_wiki, group_wiki_create, \ diff --git a/seahub/group/utils.py b/seahub/group/utils.py index 1c1cb5a9bc..9a4bb05bd8 100644 --- a/seahub/group/utils.py +++ b/seahub/group/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import re import logging diff --git a/seahub/group/views.py b/seahub/group/views.py index 4709bf3d0d..251fc3a83a 100644 --- a/seahub/group/views.py +++ b/seahub/group/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import logging import os diff --git a/seahub/handlers.py b/seahub/handlers.py index 0b46275830..7ece0288d7 100644 --- a/seahub/handlers.py +++ b/seahub/handlers.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import settings if not hasattr(settings, 'EVENTS_CONFIG_FILE'): diff --git a/seahub/help/models.py b/seahub/help/models.py index 71a8362390..0069a69c28 100644 --- a/seahub/help/models.py +++ b/seahub/help/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.db import models # Create your models here. diff --git a/seahub/help/tests.py b/seahub/help/tests.py index 501deb776c..dc3548eb40 100644 --- a/seahub/help/tests.py +++ b/seahub/help/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ This file demonstrates writing tests using the unittest module. These will pass when you run "manage.py test". diff --git a/seahub/help/urls.py b/seahub/help/urls.py index 649d776674..ff797efe31 100644 --- a/seahub/help/urls.py +++ b/seahub/help/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url, include from django.views.generic import TemplateView diff --git a/seahub/help/views.py b/seahub/help/views.py index 60f00ef0ef..f6d461202e 100644 --- a/seahub/help/views.py +++ b/seahub/help/views.py @@ -1 +1,2 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # Create your views here. diff --git a/seahub/institutions/admin.py b/seahub/institutions/admin.py index 8c38f3f3da..550882e106 100644 --- a/seahub/institutions/admin.py +++ b/seahub/institutions/admin.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.contrib import admin # Register your models here. diff --git a/seahub/institutions/decorators.py b/seahub/institutions/decorators.py index 5be2405418..7a76d08bcb 100644 --- a/seahub/institutions/decorators.py +++ b/seahub/institutions/decorators.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.http import Http404 from seahub.profile.models import Profile diff --git a/seahub/institutions/middleware.py b/seahub/institutions/middleware.py index ca75c6ddeb..6a609e6f46 100644 --- a/seahub/institutions/middleware.py +++ b/seahub/institutions/middleware.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings from seahub.institutions.models import InstitutionAdmin diff --git a/seahub/institutions/models.py b/seahub/institutions/models.py index 6b4288f0c1..f3eea40bec 100644 --- a/seahub/institutions/models.py +++ b/seahub/institutions/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.db import models from django.utils import timezone diff --git a/seahub/institutions/tests.py b/seahub/institutions/tests.py index 7ce503c2dd..efeee469d3 100644 --- a/seahub/institutions/tests.py +++ b/seahub/institutions/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.test import TestCase # Create your tests here. diff --git a/seahub/institutions/urls.py b/seahub/institutions/urls.py index c1f828af2c..c245906b67 100644 --- a/seahub/institutions/urls.py +++ b/seahub/institutions/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url from .views import (info, useradmin, user_info, user_remove, useradmin_search, diff --git a/seahub/institutions/views.py b/seahub/institutions/views.py index 316cf1530a..4870850886 100644 --- a/seahub/institutions/views.py +++ b/seahub/institutions/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import json import logging diff --git a/seahub/invitations/admin.py b/seahub/invitations/admin.py index 8c38f3f3da..550882e106 100644 --- a/seahub/invitations/admin.py +++ b/seahub/invitations/admin.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.contrib import admin # Register your models here. diff --git a/seahub/invitations/models.py b/seahub/invitations/models.py index 71e02193d6..84a867ee25 100644 --- a/seahub/invitations/models.py +++ b/seahub/invitations/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from datetime import timedelta from django.db import models diff --git a/seahub/invitations/settings.py b/seahub/invitations/settings.py index 264bdafa75..dfd28bee44 100644 --- a/seahub/invitations/settings.py +++ b/seahub/invitations/settings.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings INVITATIONS_TOKEN_AGE = getattr(settings, 'INVITATIONS_TOKEN_AGE', 72) # hours diff --git a/seahub/invitations/urls.py b/seahub/invitations/urls.py index 6f0e168d6e..3695fb512c 100644 --- a/seahub/invitations/urls.py +++ b/seahub/invitations/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url from .views import token_view diff --git a/seahub/invitations/views.py b/seahub/invitations/views.py index 47800bf650..39b4d063ea 100644 --- a/seahub/invitations/views.py +++ b/seahub/invitations/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.contrib import messages from django.http import HttpResponseRedirect, Http404 from django.shortcuts import get_object_or_404, render_to_response diff --git a/seahub/message/management/commands/send_user_messages.py b/seahub/message/management/commands/send_user_messages.py index 1199d8e875..1c8278f41f 100644 --- a/seahub/message/management/commands/send_user_messages.py +++ b/seahub/message/management/commands/send_user_messages.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import logging import string diff --git a/seahub/message/message.py b/seahub/message/message.py index 97ed3cf1b0..e35f0ea6d2 100644 --- a/seahub/message/message.py +++ b/seahub/message/message.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- def msg_info_list(msgs, user): diff --git a/seahub/message/models.py b/seahub/message/models.py index 37aa8e4708..7fed64bf1c 100755 --- a/seahub/message/models.py +++ b/seahub/message/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import datetime diff --git a/seahub/message/signals.py b/seahub/message/signals.py index 53c2c07cf9..b6f2eab126 100644 --- a/seahub/message/signals.py +++ b/seahub/message/signals.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import django.dispatch user_message_sent = django.dispatch.Signal(providing_args=["msg"]) diff --git a/seahub/message/urls.py b/seahub/message/urls.py index 4692c83983..d75f93d99d 100644 --- a/seahub/message/urls.py +++ b/seahub/message/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url from django.views.generic.base import RedirectView diff --git a/seahub/message/views.py b/seahub/message/views.py index fcb003caf0..2a5520a0be 100755 --- a/seahub/message/views.py +++ b/seahub/message/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import os import datetime diff --git a/seahub/notifications/management/commands/notify_admins_on_virus.py b/seahub/notifications/management/commands/notify_admins_on_virus.py index f355e7e379..413f8d44fe 100644 --- a/seahub/notifications/management/commands/notify_admins_on_virus.py +++ b/seahub/notifications/management/commands/notify_admins_on_virus.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import logging diff --git a/seahub/notifications/management/commands/send_notices.py b/seahub/notifications/management/commands/send_notices.py index 08bac8b01a..00d1369395 100644 --- a/seahub/notifications/management/commands/send_notices.py +++ b/seahub/notifications/management/commands/send_notices.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import datetime import logging diff --git a/seahub/notifications/models.py b/seahub/notifications/models.py index c50f79f35a..997372ea2b 100644 --- a/seahub/notifications/models.py +++ b/seahub/notifications/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import datetime import os diff --git a/seahub/notifications/settings.py b/seahub/notifications/settings.py index d82a3c78fe..f9c9a145ad 100644 --- a/seahub/notifications/settings.py +++ b/seahub/notifications/settings.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings NOTIFICATION_CACHE_TIMEOUT = getattr(settings, 'NOTIFICATION_CACHE_TIMEOUT', 0) diff --git a/seahub/notifications/tests.py b/seahub/notifications/tests.py index 1d38bc7889..6c94fb1b78 100644 --- a/seahub/notifications/tests.py +++ b/seahub/notifications/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.core.urlresolvers import reverse from django.test import TestCase, Client diff --git a/seahub/notifications/urls.py b/seahub/notifications/urls.py index 6bb778a126..4b7be35a12 100644 --- a/seahub/notifications/urls.py +++ b/seahub/notifications/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url urlpatterns = patterns('seahub.notifications.views', diff --git a/seahub/notifications/utils.py b/seahub/notifications/utils.py index 70927203d7..02edc74861 100644 --- a/seahub/notifications/utils.py +++ b/seahub/notifications/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.core.cache import cache from seahub.notifications.models import Notification diff --git a/seahub/notifications/views.py b/seahub/notifications/views.py index 9780ee093e..2a8f2bb3cc 100644 --- a/seahub/notifications/views.py +++ b/seahub/notifications/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import json import logging diff --git a/seahub/options/models.py b/seahub/options/models.py index bddd90fcbe..3ca5adc90f 100644 --- a/seahub/options/models.py +++ b/seahub/options/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- from django.db import models diff --git a/seahub/options/tests.py b/seahub/options/tests.py index 501deb776c..dc3548eb40 100644 --- a/seahub/options/tests.py +++ b/seahub/options/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ This file demonstrates writing tests using the unittest module. These will pass when you run "manage.py test". diff --git a/seahub/options/urls.py b/seahub/options/urls.py index 3af2a492e5..070982c3d3 100644 --- a/seahub/options/urls.py +++ b/seahub/options/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url from views import * diff --git a/seahub/options/views.py b/seahub/options/views.py index bc4c563764..d810076274 100644 --- a/seahub/options/views.py +++ b/seahub/options/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- from django.http import HttpResponse, HttpResponseBadRequest, \ HttpResponseRedirect , Http404 diff --git a/seahub/password_session/__init__.py b/seahub/password_session/__init__.py index 6e7304d9fb..345c898718 100644 --- a/seahub/password_session/__init__.py +++ b/seahub/password_session/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. VERSION = '0.3.3' from .handlers import update_session_auth_hash diff --git a/seahub/password_session/handlers.py b/seahub/password_session/handlers.py index 0616800160..48a436810e 100644 --- a/seahub/password_session/handlers.py +++ b/seahub/password_session/handlers.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings from django.dispatch import receiver from hashlib import md5 diff --git a/seahub/password_session/middleware.py b/seahub/password_session/middleware.py index 8df50c0852..10893dc2f9 100644 --- a/seahub/password_session/middleware.py +++ b/seahub/password_session/middleware.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.contrib.auth import logout from .handlers import get_password_hash, PASSWORD_HASH_KEY diff --git a/seahub/password_session/models.py b/seahub/password_session/models.py deleted file mode 100644 index f13ad83603..0000000000 --- a/seahub/password_session/models.py +++ /dev/null @@ -1 +0,0 @@ -# This file needs for tests \ No newline at end of file diff --git a/seahub/password_session/tests/__init__.py b/seahub/password_session/tests/__init__.py deleted file mode 100644 index b8f079e045..0000000000 --- a/seahub/password_session/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .tests import * \ No newline at end of file diff --git a/seahub/password_session/tests/test_urls.py b/seahub/password_session/tests/test_urls.py deleted file mode 100644 index ca17771931..0000000000 --- a/seahub/password_session/tests/test_urls.py +++ /dev/null @@ -1,16 +0,0 @@ -try: - from django.conf.urls import url, patterns, include -except ImportError: # for Django 1.3 compatibility - from django.conf.urls.defaults import url, patterns, include - -from django.contrib import admin - -from .test_views import change_password_view - -admin.autodiscover() - -urlpatterns = patterns( - '', - url(r'^password/change/', change_password_view), - url(r'^admin/', include(admin.site.urls)), -) \ No newline at end of file diff --git a/seahub/password_session/tests/test_views.py b/seahub/password_session/tests/test_views.py deleted file mode 100644 index e448998c4a..0000000000 --- a/seahub/password_session/tests/test_views.py +++ /dev/null @@ -1,13 +0,0 @@ -from django.contrib.auth.decorators import login_required -from django.http import HttpResponse - -from password_session import update_session_auth_hash - - -@login_required(login_url='/admin/') -def change_password_view(request): - user = request.user - user.set_password(request.POST.get('password')) - user.save() - update_session_auth_hash(request, user) - return HttpResponse("Hello, %s! Your password has been changed!" % user.username) \ No newline at end of file diff --git a/seahub/password_session/tests/tests.py b/seahub/password_session/tests/tests.py deleted file mode 100644 index 977d07eb8b..0000000000 --- a/seahub/password_session/tests/tests.py +++ /dev/null @@ -1,47 +0,0 @@ -from django.test import TestCase, Client - -try: - from django.contrib.auth import get_user_model -except ImportError: # for Django 1.3 compatibility - from django.contrib.auth.models import User as OldUser - get_user_model = lambda: OldUser - -User = get_user_model() - - -class PasswordSessionTest(TestCase): - def setUp(self): - self.password = 'qwe123' - self.user = User.objects.create_user(email='albert@tugushev.ru', username='albert', password=self.password) - self.user.is_superuser = True - self.user.is_staff = True - self.user.save() - - def tearDown(self): - self.user.delete() - - def test_invalidate_session_after_change_password(self): - # Test clients - client1 = Client() - client2 = Client() - - # Auth client1 through django.test.client.login - self.assertTrue(client1.login(username=self.user.username, password=self.password)) - - # Auth client2 through admin view - response = client2.post('/admin/', follow=True, data={'username': self.user.username, - 'password': self.password, - 'this_is_the_login_form': 1, - 'next': '/admin/'},) - self.assertEqual(response.status_code, 200) - self.assertNotContains(response, 'this_is_the_login_form') - - # Change password for client1 - response = client1.post('/password/change/', data={'password': '123qwe'}) - self.assertEqual(response.status_code, 200) - self.assertContains(response, 'Hello') - - # client2 should be logged out - response = client2.get('/admin/') - self.assertEqual(response.status_code, 200) - self.assertContains(response, 'this_is_the_login_form') \ No newline at end of file diff --git a/seahub/profile/admin.py b/seahub/profile/admin.py index 8d871edd0e..0535dd2e65 100644 --- a/seahub/profile/admin.py +++ b/seahub/profile/admin.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.contrib import admin #from profile.models import UserProfile diff --git a/seahub/profile/forms.py b/seahub/profile/forms.py index d9c800b517..00ccf525fb 100644 --- a/seahub/profile/forms.py +++ b/seahub/profile/forms.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 from django import forms from django.utils.translation import ugettext_lazy as _ diff --git a/seahub/profile/models.py b/seahub/profile/models.py index 1c8b6ed11d..41234edb32 100644 --- a/seahub/profile/models.py +++ b/seahub/profile/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from django.conf import settings diff --git a/seahub/profile/settings.py b/seahub/profile/settings.py index 1e41ac4cb1..6c2dc1d899 100644 --- a/seahub/profile/settings.py +++ b/seahub/profile/settings.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings NICKNAME_CACHE_TIMEOUT = getattr(settings, 'NICKNAME_CACHE_TIMEOUT', 14 * 24 * 60 * 60) diff --git a/seahub/profile/tests.py b/seahub/profile/tests.py index 2247054b35..114eb031ba 100644 --- a/seahub/profile/tests.py +++ b/seahub/profile/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ This file demonstrates two different styles of tests (one doctest and one unittest). These will both pass when you run "manage.py test". diff --git a/seahub/profile/urls.py b/seahub/profile/urls.py index ca6aecede4..91a742d0b8 100644 --- a/seahub/profile/urls.py +++ b/seahub/profile/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url, include from seahub.utils.two_factor_auth import HAS_TWO_FACTOR_AUTH diff --git a/seahub/profile/utils.py b/seahub/profile/utils.py index 7ba2b92c6b..4cff6e079e 100644 --- a/seahub/profile/utils.py +++ b/seahub/profile/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.core.cache import cache from models import Profile diff --git a/seahub/profile/views.py b/seahub/profile/views.py index e4ab87a6eb..6f11837d34 100644 --- a/seahub/profile/views.py +++ b/seahub/profile/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 from constance import config from django.conf import settings diff --git a/seahub/role_permissions/admin.py b/seahub/role_permissions/admin.py index 8c38f3f3da..550882e106 100644 --- a/seahub/role_permissions/admin.py +++ b/seahub/role_permissions/admin.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.contrib import admin # Register your models here. diff --git a/seahub/role_permissions/models.py b/seahub/role_permissions/models.py index 71a8362390..0069a69c28 100644 --- a/seahub/role_permissions/models.py +++ b/seahub/role_permissions/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.db import models # Create your models here. diff --git a/seahub/role_permissions/settings.py b/seahub/role_permissions/settings.py index 220bdc9ced..d3bb3bcf59 100644 --- a/seahub/role_permissions/settings.py +++ b/seahub/role_permissions/settings.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging from django.conf import settings diff --git a/seahub/role_permissions/utils.py b/seahub/role_permissions/utils.py index 4d23a7a1fc..f32c716421 100644 --- a/seahub/role_permissions/utils.py +++ b/seahub/role_permissions/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from .settings import ENABLED_ROLE_PERMISSIONS from seahub.constants import DEFAULT_USER diff --git a/seahub/role_permissions/views.py b/seahub/role_permissions/views.py index 91ea44a218..910716f63f 100644 --- a/seahub/role_permissions/views.py +++ b/seahub/role_permissions/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.shortcuts import render # Create your views here. diff --git a/seahub/settings.py b/seahub/settings.py index 9e28a83bfa..6c5e17d1b4 100644 --- a/seahub/settings.py +++ b/seahub/settings.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- # Django settings for seahub project. diff --git a/seahub/share/decorators.py b/seahub/share/decorators.py index ef4cac37f5..6a3a64744c 100644 --- a/seahub/share/decorators.py +++ b/seahub/share/decorators.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.core.cache import cache from django.conf import settings from django.http import Http404 diff --git a/seahub/share/forms.py b/seahub/share/forms.py index 72e0ffd372..53708ce7c7 100644 --- a/seahub/share/forms.py +++ b/seahub/share/forms.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django import forms from django.utils.translation import ugettext_lazy as _ diff --git a/seahub/share/models.py b/seahub/share/models.py index 3259491536..940c4e95ab 100644 --- a/seahub/share/models.py +++ b/seahub/share/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import datetime import logging diff --git a/seahub/share/signals.py b/seahub/share/signals.py index f9dbddaa6e..ccdeecb04a 100644 --- a/seahub/share/signals.py +++ b/seahub/share/signals.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import django.dispatch share_repo_to_user_successful = django.dispatch.Signal(providing_args=["from_user", "to_user", "repo"]) diff --git a/seahub/share/tests.py b/seahub/share/tests.py index 2247054b35..114eb031ba 100644 --- a/seahub/share/tests.py +++ b/seahub/share/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ This file demonstrates two different styles of tests (one doctest and one unittest). These will both pass when you run "manage.py test". diff --git a/seahub/share/urls.py b/seahub/share/urls.py index d808f13a90..7e65573071 100644 --- a/seahub/share/urls.py +++ b/seahub/share/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url from views import * diff --git a/seahub/share/views.py b/seahub/share/views.py index 218d782884..cbd796c1ae 100644 --- a/seahub/share/views.py +++ b/seahub/share/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import os import logging diff --git a/seahub/shortcuts.py b/seahub/shortcuts.py index 942f5f91ba..445483edc8 100644 --- a/seahub/shortcuts.py +++ b/seahub/shortcuts.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 def get_first_object_or_none(queryset): diff --git a/seahub/signals.py b/seahub/signals.py index a8c5053642..08afee8382 100644 --- a/seahub/signals.py +++ b/seahub/signals.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import django.dispatch # Use org_id = -1 if it's not an org repo diff --git a/seahub/test_utils.py b/seahub/test_utils.py index 0ebb88fd16..46baef1f84 100644 --- a/seahub/test_utils.py +++ b/seahub/test_utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os from uuid import uuid4 diff --git a/seahub/thumbnail/management/commands/clean_thumbnail.py b/seahub/thumbnail/management/commands/clean_thumbnail.py index 3ced61247c..626771a6f5 100644 --- a/seahub/thumbnail/management/commands/clean_thumbnail.py +++ b/seahub/thumbnail/management/commands/clean_thumbnail.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import shutil diff --git a/seahub/thumbnail/models.py b/seahub/thumbnail/models.py index 71a8362390..0069a69c28 100644 --- a/seahub/thumbnail/models.py +++ b/seahub/thumbnail/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.db import models # Create your models here. diff --git a/seahub/thumbnail/tests.py b/seahub/thumbnail/tests.py index 501deb776c..dc3548eb40 100644 --- a/seahub/thumbnail/tests.py +++ b/seahub/thumbnail/tests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ This file demonstrates writing tests using the unittest module. These will pass when you run "manage.py test". diff --git a/seahub/thumbnail/urls.py b/seahub/thumbnail/urls.py index 2bcc831b06..b6c3adb2d0 100644 --- a/seahub/thumbnail/urls.py +++ b/seahub/thumbnail/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf.urls import patterns, url, include from views import thumbnail_create, thumbnail_get, share_link_thumbnail_get, \ diff --git a/seahub/thumbnail/utils.py b/seahub/thumbnail/utils.py index 35e3d1fc01..7fec20b2d6 100644 --- a/seahub/thumbnail/utils.py +++ b/seahub/thumbnail/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os import posixpath import urllib2 diff --git a/seahub/thumbnail/views.py b/seahub/thumbnail/views.py index a29fab5102..cc77b36006 100644 --- a/seahub/thumbnail/views.py +++ b/seahub/thumbnail/views.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import os import json import logging diff --git a/seahub/urls.py b/seahub/urls.py index e36e26694f..67ca4e700d 100644 --- a/seahub/urls.py +++ b/seahub/urls.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.conf import settings from django.conf.urls import patterns, url, include # from django.views.generic.simple import direct_to_template diff --git a/seahub/utils/__init__.py b/seahub/utils/__init__.py index ba659ffac9..475c0a01d0 100644 --- a/seahub/utils/__init__.py +++ b/seahub/utils/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import os import re diff --git a/seahub/utils/devices.py b/seahub/utils/devices.py index 55b5a6abd9..18fc8f4a77 100644 --- a/seahub/utils/devices.py +++ b/seahub/utils/devices.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging import datetime diff --git a/seahub/utils/file_size.py b/seahub/utils/file_size.py index 406c6f437d..2848f60821 100644 --- a/seahub/utils/file_size.py +++ b/seahub/utils/file_size.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. def get_file_size_unit(unit_type): """ File size unit according to https://en.wikipedia.org/wiki/Kibibyte. diff --git a/seahub/utils/file_types.py b/seahub/utils/file_types.py index a7fdc153b4..7e0b026a5f 100644 --- a/seahub/utils/file_types.py +++ b/seahub/utils/file_types.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. TEXT = 'Text' IMAGE = 'Image' DOCUMENT = 'Document' diff --git a/seahub/utils/html.py b/seahub/utils/html.py index 0ca7147a76..50ad9301f4 100644 --- a/seahub/utils/html.py +++ b/seahub/utils/html.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from __future__ import unicode_literals def avoid_wrapping(value): diff --git a/seahub/utils/http.py b/seahub/utils/http.py index e22c65c379..f78da1263e 100644 --- a/seahub/utils/http.py +++ b/seahub/utils/http.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from __future__ import unicode_literals import unicodedata diff --git a/seahub/utils/ip.py b/seahub/utils/ip.py index 15a59d4d96..b5cca3ff70 100644 --- a/seahub/utils/ip.py +++ b/seahub/utils/ip.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. def get_remote_ip(request): x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') if x_forwarded_for: diff --git a/seahub/utils/licenseparse.py b/seahub/utils/licenseparse.py index 558e87a354..38b16f8d16 100644 --- a/seahub/utils/licenseparse.py +++ b/seahub/utils/licenseparse.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging logger = logging.getLogger(__name__) diff --git a/seahub/utils/logger.py b/seahub/utils/logger.py index 6b683545c4..d4e38193d0 100644 --- a/seahub/utils/logger.py +++ b/seahub/utils/logger.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging import time import fpformat diff --git a/seahub/utils/mail.py b/seahub/utils/mail.py index fbd563f008..56ef37a413 100644 --- a/seahub/utils/mail.py +++ b/seahub/utils/mail.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.template import Context, loader from post_office import mail from post_office.models import PRIORITY diff --git a/seahub/utils/ms_excel.py b/seahub/utils/ms_excel.py index ce0b7c6d81..e73dab43b7 100644 --- a/seahub/utils/ms_excel.py +++ b/seahub/utils/ms_excel.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import logging import openpyxl diff --git a/seahub/utils/paginator.py b/seahub/utils/paginator.py index fe441bf7e8..20ed38c3d9 100644 --- a/seahub/utils/paginator.py +++ b/seahub/utils/paginator.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.core.paginator import Paginator as DefaultPaginator def get_page_range(current_page, num_pages): diff --git a/seahub/utils/repo.py b/seahub/utils/repo.py index 3294756fcb..f8abb903a3 100644 --- a/seahub/utils/repo.py +++ b/seahub/utils/repo.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import logging from django.utils.translation import ugettext as _ diff --git a/seahub/utils/rooturl.py b/seahub/utils/rooturl.py index 077ce47ebc..26361cf838 100644 --- a/seahub/utils/rooturl.py +++ b/seahub/utils/rooturl.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # # rooturl.py -- URL patterns for rooted sites. # diff --git a/seahub/utils/rpc.py b/seahub/utils/rpc.py index 5e26d012fd..89e5fae60a 100644 --- a/seahub/utils/rpc.py +++ b/seahub/utils/rpc.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ Proxy RPC calls to seafile_api, silence RPC errors, emulating Ruby's "method_missing". diff --git a/seahub/utils/slugify/__init__.py b/seahub/utils/slugify/__init__.py index 2e8349635f..229f4eec95 100644 --- a/seahub/utils/slugify/__init__.py +++ b/seahub/utils/slugify/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import re import unicodedata diff --git a/seahub/utils/star.py b/seahub/utils/star.py index 3f9567b5b5..3a03e57402 100644 --- a/seahub/utils/star.py +++ b/seahub/utils/star.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import logging import urllib2 diff --git a/seahub/utils/sysinfo.py b/seahub/utils/sysinfo.py index 14775c5bd1..ac08932e92 100644 --- a/seahub/utils/sysinfo.py +++ b/seahub/utils/sysinfo.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. #coding: UTF-8 import platform diff --git a/seahub/utils/timeutils.py b/seahub/utils/timeutils.py index bf5a74ad47..f0848cb322 100644 --- a/seahub/utils/timeutils.py +++ b/seahub/utils/timeutils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. import pytz import datetime from django.conf import settings diff --git a/seahub/utils/two_factor_auth.py b/seahub/utils/two_factor_auth.py index 2132462c5e..764d06cdc2 100644 --- a/seahub/utils/two_factor_auth.py +++ b/seahub/utils/two_factor_auth.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 from constance import config diff --git a/seahub/utils/user_permissions.py b/seahub/utils/user_permissions.py index e68fd9a2e3..5fe118d5cf 100644 --- a/seahub/utils/user_permissions.py +++ b/seahub/utils/user_permissions.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from seahub.constants import DEFAULT_USER, GUEST_USER from seahub.utils import is_pro_version diff --git a/seahub/views/__init__.py b/seahub/views/__init__.py index 4fc4168254..b37be7e29b 100644 --- a/seahub/views/__init__.py +++ b/seahub/views/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import hashlib import os diff --git a/seahub/views/ajax.py b/seahub/views/ajax.py index 004c008439..84c9d91ccd 100644 --- a/seahub/views/ajax.py +++ b/seahub/views/ajax.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import os import stat diff --git a/seahub/views/file.py b/seahub/views/file.py index cd7edac4f6..a0bf95f533 100644 --- a/seahub/views/file.py +++ b/seahub/views/file.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- """ File related views, including view_file, view_history_file, view_trash_file, diff --git a/seahub/views/i18n.py b/seahub/views/i18n.py index 13081b9e06..85ce8bab86 100644 --- a/seahub/views/i18n.py +++ b/seahub/views/i18n.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.utils import timezone from django.views.decorators.http import last_modified from django.views.i18n import javascript_catalog diff --git a/seahub/views/modules.py b/seahub/views/modules.py index 684fecf932..96658f0425 100644 --- a/seahub/views/modules.py +++ b/seahub/views/modules.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from seahub.base.models import UserEnabledModule, GroupEnabledModule from seahub.wiki.models import PersonalWiki diff --git a/seahub/views/repo.py b/seahub/views/repo.py index 5b0076b341..306fa43072 100644 --- a/seahub/views/repo.py +++ b/seahub/views/repo.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import os import posixpath diff --git a/seahub/views/sysadmin.py b/seahub/views/sysadmin.py index be2b2c38b7..39295d7509 100644 --- a/seahub/views/sysadmin.py +++ b/seahub/views/sysadmin.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 import os diff --git a/seahub/views/tests/__init__.py b/seahub/views/tests/__init__.py index 4458ea9479..04559c5c1c 100644 --- a/seahub/views/tests/__init__.py +++ b/seahub/views/tests/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ This file demonstrates writing tests using the unittest module. These will pass when you run "manage.py test". diff --git a/seahub/views/wiki.py b/seahub/views/wiki.py index ead80f3cdf..c345cc7e34 100644 --- a/seahub/views/wiki.py +++ b/seahub/views/wiki.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- """ File related views, including view_file, edit_file, view_history_file, diff --git a/seahub/wiki/__init__.py b/seahub/wiki/__init__.py index 7cbe949b20..ba8405b62a 100644 --- a/seahub/wiki/__init__.py +++ b/seahub/wiki/__init__.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- from utils import get_personal_wiki_page, get_personal_wiki_repo, \ diff --git a/seahub/wiki/forms.py b/seahub/wiki/forms.py index 8834b89245..7c6ba13f35 100644 --- a/seahub/wiki/forms.py +++ b/seahub/wiki/forms.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 from django import forms diff --git a/seahub/wiki/models.py b/seahub/wiki/models.py index 66942cb03a..0949d8a811 100644 --- a/seahub/wiki/models.py +++ b/seahub/wiki/models.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. from django.db import models from seahub.base.fields import LowerCaseCharField diff --git a/seahub/wiki/utils.py b/seahub/wiki/utils.py index 03670020d4..11303195ee 100644 --- a/seahub/wiki/utils.py +++ b/seahub/wiki/utils.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. # -*- coding: utf-8 -*- import os import stat diff --git a/seahub/wsgi.py b/seahub/wsgi.py index bed0cfcb73..416e12aa93 100644 --- a/seahub/wsgi.py +++ b/seahub/wsgi.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. """ WSGI config for seahub project. diff --git a/tools/avatar_migration.py b/tools/avatar_migration.py index 2e7f518338..824b73b8d7 100755 --- a/tools/avatar_migration.py +++ b/tools/avatar_migration.py @@ -1,3 +1,4 @@ +# Copyright (c) 2012-2016 Seafile Ltd. #!/usr/bin/env python """ Migrate seahub avatar files from file system to MySQL. diff --git a/tools/batch-delete.py b/tools/batch-delete.py index ea69d7cf3b..19c3eaeed4 100644 --- a/tools/batch-delete.py +++ b/tools/batch-delete.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# Copyright (c) 2012-2016 Seafile Ltd. import os import sys diff --git a/tools/gen-tarball.py b/tools/gen-tarball.py index 24a4c326cd..3608c9be91 100755 --- a/tools/gen-tarball.py +++ b/tools/gen-tarball.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # coding: UTF-8 +# Copyright (c) 2012-2016 Seafile Ltd. import sys import os diff --git a/tools/seahub-admin.py b/tools/seahub-admin.py index 854a2851c5..aebb04e64f 100644 --- a/tools/seahub-admin.py +++ b/tools/seahub-admin.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # encoding: utf-8 +# Copyright (c) 2012-2016 Seafile Ltd. import sqlite3 import os diff --git a/tools/secret_key_generator.py b/tools/secret_key_generator.py index 6312637fae..de9e08bbcf 100644 --- a/tools/secret_key_generator.py +++ b/tools/secret_key_generator.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 -"""Lifted from https://github.com/django/django/blob/master/django/core/management/commands/startproject.py#L30 -""" +# Copyright (c) 2012-2016 Seafile Ltd. + import hashlib import random import sys diff --git a/tools/update-seahub-db_0.9.4_to_0.9.5.py b/tools/update-seahub-db_0.9.4_to_0.9.5.py index e565de0cf6..0616540ecf 100755 --- a/tools/update-seahub-db_0.9.4_to_0.9.5.py +++ b/tools/update-seahub-db_0.9.4_to_0.9.5.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # encoding: utf-8 +# Copyright (c) 2012-2016 Seafile Ltd. import sqlite3 import os