Commit 060e0878 authored by Abhilash Raj's avatar Abhilash Raj

Merge branch 'fix-imports' into 'master'

Sort imports using isort.

See merge request !399
parents dca35e49 571567ec
Pipeline #53795004 passed with stages
in 7 minutes and 3 seconds
#! /usr/bin/env python3
import datetime
import os
import re
import sys
import stat
import datetime
import sys
FSF = 'by the Free Software Foundation, Inc.'
......
......@@ -19,6 +19,7 @@
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
......
......@@ -29,6 +29,10 @@ https://docs.djangoproject.com/en/1.9/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
# Compatibility with Bootstrap 3
from django.contrib.messages import constants as messages
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
......@@ -191,8 +195,6 @@ LOGOUT_URL = 'account_logout'
DEFAULT_FROM_EMAIL = 'postorius@localhost.local'
# From Address for emails sent to admins
SERVER_EMAIL = 'root@localhost.local'
# Compatibility with Bootstrap 3
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
......
......@@ -22,6 +22,7 @@ Django test settings for postorius project.
from settings import *
TESTING = True
# Mailman API credentials for testing
......
......@@ -21,8 +21,8 @@ from django.conf.urls import include, url
from django.contrib import admin
from django.http import Http404
from django.urls import reverse_lazy
from django.views.generic import RedirectView
from django.views.defaults import server_error
from django.views.generic import RedirectView
def not_found(request):
......
......@@ -11,6 +11,7 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
application = get_wsgi_application()
......@@ -17,7 +17,9 @@
import re
import sys
from setuptools import setup, find_packages
from setuptools import find_packages, setup
# Calculate the version number without importing the postorius package.
with open('src/postorius/__init__.py') as fp:
......@@ -60,5 +62,6 @@ setup(
"mock",
"vcrpy",
"beautifulsoup4",
"isort",
],
)
......@@ -20,8 +20,10 @@
Authentication and authorization-related utilities.
"""
from allauth.account.models import EmailAddress
from django.utils import six
from allauth.account.models import EmailAddress
from postorius.models import Domain, List
......
......@@ -18,6 +18,7 @@
import logging
from postorius import __version__
......
......@@ -13,8 +13,9 @@
# serve to show the default.
import sys
import os
import sys
# add dummy settings environment variable so sphinx can import from Postorius.
os.environ['DJANGO_SETTINGS_MODULE'] = 'postorius.doc.settings'
......
......@@ -17,8 +17,8 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
#
from postorius.forms.domain_forms import * # noqa
from postorius.forms.fields import * # noqa
from postorius.forms.member_forms import * # noqa
from postorius.forms.list_forms import * # noqa
from postorius.forms.user_forms import * # noqa
from postorius.forms.domain_forms import * # noqa
from postorius.forms.fields import * # noqa
from postorius.forms.list_forms import * # noqa
from postorius.forms.member_forms import * # noqa
from postorius.forms.user_forms import * # noqa
......@@ -18,11 +18,11 @@
from django import forms
from django.core.validators import validate_email
from django.contrib.sites.models import Site
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.contrib.sites.models import Site
from postorius.forms.fields import SiteModelChoiceField
......
......@@ -18,10 +18,12 @@
#
import re
from django import forms
from django.core.validators import validate_email
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.utils.translation import ugettext_lazy as _
from django_mailman3.lib.mailman import get_mailman_client
from postorius.forms.fields import ListOfStringsField
......
......@@ -17,6 +17,7 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from django.core.management.base import BaseCommand
from django_mailman3.lib.mailman import get_mailman_client
......
......@@ -17,12 +17,14 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
#
import os
import base64
import os
from django.core.management.base import BaseCommand
from django_mailman3.lib.mailman import get_mailman_client
PASSWORD_BYTES = 32
......
......@@ -17,10 +17,13 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
import logging
from mailmanclient import MailmanConnectionError
from postorius import utils
from postorius.models import MailmanApiError
from mailmanclient import MailmanConnectionError
import logging
logger = logging.getLogger(__name__)
......
# -*- coding: utf-8 -*-
from django.db import models, migrations
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
......
......@@ -2,6 +2,7 @@
from django.db import migrations, models
# flake8: noqa
......
......@@ -2,6 +2,7 @@
from django.db import migrations, models
# flake8: noqa
......
......@@ -4,6 +4,7 @@ from __future__ import unicode_literals
from django.db import migrations, models
# flake8: noqa
......
......@@ -23,19 +23,21 @@ import logging
from urllib.parse import urljoin
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.contrib.auth.models import User
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.db.models.signals import post_save, post_delete
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from django.http import Http404
from django.urls import reverse
from django.utils.six.moves.urllib.error import HTTPError
from django.utils.translation import ugettext_lazy as _
from mailmanclient import MailmanConnectionError
from postorius.utils import get_mailman_client, LANGUAGES
from postorius.template_list import TEMPLATES_LIST
from postorius.utils import LANGUAGES, get_mailman_client
logger = logging.getLogger(__name__)
......
......@@ -17,6 +17,7 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from django import template
from readme_renderer import markdown as md_render
......
......@@ -19,10 +19,11 @@
from django import template
from mailmanclient import MailingList
from postorius.auth.utils import user_is_in_list_roster
from postorius.models import List
from mailmanclient import MailingList
register = template.Library()
......
import logging
logging.disable(logging.CRITICAL)
......@@ -16,10 +16,11 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.urls import reverse
from allauth.account.models import EmailAddress
from django_mailman3.models import MailDomain
from postorius.tests.utils import ViewTestCase
......
......@@ -16,10 +16,11 @@
# You should have received a copy of the GNU General Public License along with
# Postorius. If not, see <http://www.gnu.org/licenses/>.
#
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.urls import reverse
from allauth.account.models import EmailAddress
from django_mailman3.models import MailDomain
from postorius.tests.utils import ViewTestCase
......
......@@ -16,12 +16,13 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from django_mailman3.models import MailDomain
from django.utils.six.moves.urllib.error import HTTPError
from allauth.account.models import EmailAddress
from django_mailman3.models import MailDomain
from postorius.tests.utils import ViewTestCase
......
......@@ -16,9 +16,10 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from allauth.account.models import EmailAddress
from django_mailman3.models import MailDomain
from postorius.tests.utils import ViewTestCase
......
......@@ -18,11 +18,12 @@
"""Tests for ban lists"""
from allauth.account.models import EmailAddress
from bs4 import BeautifulSoup
from django.contrib.auth.models import User
from django.urls import reverse
from allauth.account.models import EmailAddress
from bs4 import BeautifulSoup
from postorius.tests.utils import ViewTestCase
......
......@@ -19,10 +19,11 @@
from __future__ import absolute_import, print_function, unicode_literals
from allauth.account.models import EmailAddress
from django.urls import reverse
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.urls import reverse
from allauth.account.models import EmailAddress
from django_mailman3.models import MailDomain
from postorius.tests.utils import ViewTestCase
......
......@@ -18,11 +18,12 @@
"""Tests for list header matches"""
from allauth.account.models import EmailAddress
from bs4 import BeautifulSoup
from django.contrib.auth.models import User
from django.urls import reverse
from allauth.account.models import EmailAddress
from bs4 import BeautifulSoup
from postorius.tests.utils import ViewTestCase
......
......@@ -18,11 +18,12 @@
from functools import partial
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.test import override_settings
from django.urls import reverse
from allauth.account.models import EmailAddress
from postorius.tests.utils import ViewTestCase
......
......@@ -16,15 +16,16 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.conf import settings
from django.contrib.auth.models import User
from django.urls import reverse
from allauth.account.models import EmailAddress
from django_mailman3.lib.mailman import get_mailman_client
from six.moves.urllib_parse import quote
from postorius.tests.utils import ViewTestCase
from postorius.forms import MemberModeration, UserPreferences
from postorius.tests.utils import ViewTestCase
class ListMembersOptionsTest(ViewTestCase):
......
......@@ -16,10 +16,11 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from allauth.account.models import EmailAddress
from postorius.tests.utils import ViewTestCase
......
......@@ -18,10 +18,11 @@
import time
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from allauth.account.models import EmailAddress
from postorius.tests.utils import ViewTestCase
......
......@@ -16,10 +16,11 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from allauth.account.models import EmailAddress
from postorius.tests.utils import ViewTestCase
......
......@@ -17,14 +17,15 @@
"""Tests for list settings"""
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from django.utils import six
from postorius.views.list import SETTINGS_FORMS
from allauth.account.models import EmailAddress
from postorius.models import List
from postorius.tests.utils import ViewTestCase
from postorius.views.list import SETTINGS_FORMS
class ListSettingsTest(ViewTestCase):
......
......@@ -16,12 +16,13 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from postorius.tests.utils import ViewTestCase
from allauth.account.models import EmailAddress
from postorius.forms import ListAnonymousSubscribe
from postorius.tests.utils import ViewTestCase
class ListSummaryPageTest(ViewTestCase):
......
......@@ -18,13 +18,14 @@
#
from __future__ import absolute_import, unicode_literals
import mock
from django.test import RequestFactory, TestCase
from django.urls import reverse
from django.test import TestCase, RequestFactory
from postorius.models import MailmanApiError
import mock
from mailmanclient import MailmanConnectionError
from postorius.models import MailmanApiError
class TestMiddleware(TestCase):
......
......@@ -18,20 +18,20 @@
#
from allauth.account.models import EmailAddress
from django.core.exceptions import PermissionDenied
from django.contrib.auth.models import User
from django.contrib.auth.models import AnonymousUser, User
from django.contrib.sites.models import Site
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.test import RequestFactory
from django.urls import reverse
from django.http import HttpResponse
from django.views.generic import TemplateView
from django.contrib.auth.models import AnonymousUser
from allauth.account.models import EmailAddress
from django_mailman3.models import MailDomain
from postorius.tests.utils import ViewTestCase
from postorius.auth.mixins import (
ListOwnerMixin, ListModeratorMixin, DomainOwnerMixin)
DomainOwnerMixin, ListModeratorMixin, ListOwnerMixin)
from postorius.tests.utils import ViewTestCase
class TestAuthenticationMixins(ViewTestCase):
......
......@@ -16,15 +16,16 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from mock import patch, MagicMock
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.utils.six.moves.urllib.error import HTTPError
from django.test import override_settings
from django.utils.six.moves.urllib.error import HTTPError
from allauth.account.models import EmailAddress
from mock import MagicMock, patch
from postorius.tests.utils import ViewTestCase
from postorius.models import (
MailmanApiError, MailmanListManager, MailmanUserManager)
from postorius.tests.utils import ViewTestCase
class ModelTest(ViewTestCase):
......
......@@ -16,16 +16,16 @@
# You should have received a copy of the GNU General Public License along with
# Postorius. If not, see <http://www.gnu.org/licenses/>.
#
import time
import json
import time
from email import message_from_bytes, message_from_file
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from email import message_from_file, message_from_bytes
from postorius.tests.utils import ViewTestCase
from postorius.views.rest import parse, get_attachments
from postorius.tests.utils import get_test_file, reverse
from allauth.account.models import EmailAddress
from postorius.tests.utils import ViewTestCase, get_test_file, reverse
from postorius.views.rest import get_attachments, parse
class TestRestViews(ViewTestCase):
......
......@@ -16,9 +16,10 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from allauth.account.models import EmailAddress
from mock import patch
from postorius.tests.utils import ViewTestCase
......
......@@ -17,10 +17,11 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
#
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from allauth.account.models import EmailAddress
from postorius.tests.utils import ViewTestCase
......
......@@ -19,15 +19,16 @@
import urllib
from allauth.account.models import EmailAddress
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.conf import settings
from django.urls import reverse
from allauth.account.models import EmailAddress
from django_mailman3.models import MailDomain
from postorius.models import TEMPLATES_LIST, EmailTemplate
from postorius.tests.utils import ViewTestCase
from postorius.models import EmailTemplate, TEMPLATES_LIST
class DomainTemplateViewTest(ViewTestCase):
......
......@@ -16,16 +16,15 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.urls import reverse
from django.test.utils import override_settings
# Temporarily disabled with test_rpeferences_none
# from mock import patch
from django.urls import reverse
from allauth.account.models import EmailAddress
from postorius.models import MailmanUser, Mailman404Error
from postorius.forms import ChangeSubscriptionForm, UserPreferences
from postorius.models import Mailman404Error, MailmanUser
from postorius.tests.utils import ViewTestCase
from postorius.forms import UserPreferences, ChangeSubscriptionForm
class MailmanUserTest(ViewTestCase):
......
......@@ -16,18 +16,18 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from allauth.account.models import EmailAddress
from django.contrib.auth.models import AnonymousUser, User
from django.core.exceptions import PermissionDenied
from django.test.client import RequestFactory
from django.test import TestCase
from django.test.client import RequestFactory
from allauth.account.models import EmailAddress
from mailmanclient import Client
from mock import patch
from postorius.auth.decorators import (list_owner_required,
list_moderator_required,
superuser_required)
from postorius.auth.decorators import (
list_moderator_required, list_owner_required, superuser_required)
from postorius.tests.utils import create_mock_list
from mailmanclient import Client
@list_owner_required
......
......@@ -17,8 +17,8 @@
# Postorius. If not, see <http://www.gnu.org/licenses/>.
#
from django.test import TestCase