mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
Merge pull request #1812 from jeromelebleu/drop-python2
Remove Python 2 support
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
language: python
|
||||
python:
|
||||
- '2.7'
|
||||
- '3.5'
|
||||
- '3.6'
|
||||
- '3.7'
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ is used as a central point of communication between all components.
|
||||
Modoboa is developed with modularity in mind, expanding it is really
|
||||
easy. Actually, all current features are extensions.
|
||||
|
||||
It is written in Python and uses the `Django
|
||||
It is written in Python 3 and uses the `Django
|
||||
<https://www.djangoproject.com>`_, `jQuery <http://jquery.com>`_ and
|
||||
`Bootstrap <http://getbootstrap.com/>`_
|
||||
frameworks.
|
||||
@@ -68,4 +68,4 @@ The following external libraries are provided with Modoboa:
|
||||
.. |codecov| image:: http://codecov.io/github/modoboa/modoboa/coverage.svg?branch=master
|
||||
:target: http://codecov.io/github/modoboa/modoboa?branch=master
|
||||
.. |codacy| image:: https://api.codacy.com/project/badge/Grade/82fd10127ac3468899ca75f04e9862b6
|
||||
:target: https://www.codacy.com/app/modoboa/modoboa?utm_source=github.com&utm_medium=referral&utm_content=modoboa/modoboa&utm_campaign=Badge_Grade
|
||||
:target: https://www.codacy.com/app/modoboa/modoboa?utm_source=github.com&utm_medium=referral&utm_content=modoboa/modoboa&utm_campaign=Badge_Grade
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from modoboa.core.commands import handle_command_line
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ This is just one possible configuration.
|
||||
To use mod_wsgi daemon mode, add the two following directives just
|
||||
under ``WSGIScriptAlias``::
|
||||
|
||||
WSGIDaemonProcess example.com python-path=<modoboa_instance>:<virtualenv path>/lib/python2.7/site-packages
|
||||
WSGIDaemonProcess example.com python-path=<modoboa_instance>:<virtualenv path>/lib/python3.7/site-packages
|
||||
WSGIProcessGroup example.com
|
||||
|
||||
Replace values between ``<>`` with yours. If you don't use a
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Modoboa - Mail hosting made simple."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from pkg_resources import DistributionNotFound, get_distribution
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
default_app_config = "modoboa.admin.apps.AdminConfig"
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Admin API."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import http
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from rest_framework import filters, status, viewsets
|
||||
from rest_framework.decorators import detail_route, list_route
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import ParseError
|
||||
from rest_framework.permissions import DjangoModelPermissions, IsAuthenticated
|
||||
from rest_framework.response import Response
|
||||
@@ -86,7 +82,7 @@ class AccountViewSet(viewsets.ModelViewSet):
|
||||
queryset = queryset.filter(mailbox__domain__name=domain)
|
||||
return queryset
|
||||
|
||||
@detail_route(methods=["put"])
|
||||
@action(methods=["put"], detail=True)
|
||||
def password(self, request, pk=None):
|
||||
"""Change account password."""
|
||||
try:
|
||||
@@ -100,7 +96,7 @@ class AccountViewSet(viewsets.ModelViewSet):
|
||||
return Response(
|
||||
serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
@list_route()
|
||||
@action(detail=False)
|
||||
def exists(self, request):
|
||||
"""Check if account exists.
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Modoboa admin settings."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from django import forms
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""AppConfig for admin."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
from .app_settings import load_admin_settings
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Admin constants."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
DNSBL_PROVIDERS = [
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Fixtures factories.
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import factory
|
||||
|
||||
from modoboa.core.factories import PermissionFactory, UserFactory
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .account import (
|
||||
AccountForm, AccountFormGeneral, AccountFormMail, AccountPermissionsForm,
|
||||
AccountWizard
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Forms related to accounts management."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from collections import OrderedDict
|
||||
from functools import reduce
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Forms related to aliases management."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from django import forms
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Forms related to domains management."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from django import forms
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Forms related to forwards management."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
from django.core import validators
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Forms related to import operations."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Django signal handlers for admin."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db.models import signals
|
||||
from django.dispatch import receiver
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Internal library for admin."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import ipaddress
|
||||
import logging
|
||||
import random
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""A management command to apply mailbox operations."""
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Modoboa main management command."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from subcommand.base import SubcommandCommand
|
||||
|
||||
from .subcommands._export import ExportCommand
|
||||
|
||||
@@ -1,24 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Django management command to export admin objects."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
import csv
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import six
|
||||
from django.utils.encoding import smart_text
|
||||
|
||||
from modoboa.core.extensions import exts_pool
|
||||
from modoboa.core.models import User
|
||||
from .... import models
|
||||
|
||||
if six.PY2:
|
||||
from backports import csv
|
||||
else:
|
||||
import csv
|
||||
|
||||
|
||||
class ExportCommand(BaseCommand):
|
||||
"""Command class."""
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Django management command to import admin objects."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import csv
|
||||
import io
|
||||
import os
|
||||
|
||||
@@ -12,7 +9,6 @@ from chardet.universaldetector import UniversalDetector
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.db import transaction
|
||||
from django.utils import six
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from modoboa.core import models as core_models
|
||||
@@ -20,11 +16,6 @@ from modoboa.core.extensions import exts_pool
|
||||
from modoboa.lib.exceptions import Conflict
|
||||
from .... import signals
|
||||
|
||||
if six.PY2:
|
||||
from backports import csv
|
||||
else:
|
||||
import csv
|
||||
|
||||
|
||||
class ImportCommand(BaseCommand):
|
||||
"""Command class."""
|
||||
@@ -35,7 +26,7 @@ class ImportCommand(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
"""Add extra arguments to command."""
|
||||
parser.add_argument(
|
||||
"--sepchar", type=six.text_type, default=";",
|
||||
"--sepchar", type=str, default=";",
|
||||
help="Separator used in file.")
|
||||
parser.add_argument(
|
||||
"--continue-if-exists", action="store_true",
|
||||
@@ -45,7 +36,7 @@ class ImportCommand(BaseCommand):
|
||||
"--crypt-password", action="store_true",
|
||||
default=False, help="Encrypt provided passwords.")
|
||||
parser.add_argument(
|
||||
"files", type=six.text_type, nargs="+", help="CSV files to import.")
|
||||
"files", type=str, nargs="+", help="CSV files to import.")
|
||||
|
||||
def _import(self, filename, options, encoding="utf-8"):
|
||||
"""Import domains or identities."""
|
||||
@@ -121,10 +112,7 @@ class ImportCommand(BaseCommand):
|
||||
encoding=detector.result["encoding"]
|
||||
)
|
||||
except UnicodeDecodeError as exc:
|
||||
six.raise_from(
|
||||
CommandError(
|
||||
_("Unable to decode CSV file using %(encoding)s "
|
||||
"encoding") % detector.result
|
||||
),
|
||||
exc
|
||||
)
|
||||
raise CommandError(
|
||||
_("Unable to decode CSV file using %(encoding)s "
|
||||
"encoding") % detector.result
|
||||
) from exc
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Management command to create DKIM keys."""
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Management command to check defined domains."""
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import ipaddress
|
||||
|
||||
import gevent
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Management command to check and fix known problems."""
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.encoding import smart_str
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.9 on 2016-09-14 09:07
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.5 on 2016-10-26 08:03
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.5 on 2016-11-04 18:00
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.5 on 2016-11-04 18:15
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.12 on 2017-02-06 06:13
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-02-15 08:48
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-02-15 12:28
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-12-20 14:17
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.8 on 2018-01-12 15:58
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.8 on 2018-01-24 23:11
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.16 on 2018-10-17 14:28
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Admin models."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .alias import Alias, AliasRecipient
|
||||
from .base import AdminObject
|
||||
from .domain import Domain
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Models related to aliases management."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import hashlib
|
||||
import random
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Base admin models."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.contenttypes.fields import GenericRelation
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Models related to domains management."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
from reversion import revisions as reversion
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Models related to domain aliases management."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from reversion import revisions as reversion
|
||||
|
||||
from django.contrib.contenttypes.fields import GenericRelation
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Models related to mailboxes management."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import pwd
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""MX records storage."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
from django.db import models
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Map file definitions for postfix."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
||||
class DomainsMap(object):
|
||||
|
||||
"""Map to list all domains."""
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Admin serializers."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import password_validation
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Modoboa admin signals."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.dispatch
|
||||
|
||||
check_extra_account_form = django.dispatch.Signal(
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Admin extension tags."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from django import template
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from unittest import skipIf
|
||||
|
||||
from django.test import override_settings
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.urls import reverse
|
||||
|
||||
from modoboa.core.models import User
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Admin API related tests."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import copy
|
||||
import json
|
||||
from unittest import mock
|
||||
|
||||
import dns.resolver
|
||||
|
||||
@@ -20,13 +17,6 @@ from modoboa.lib.tests import ModoAPITestCase
|
||||
from . import utils
|
||||
from .. import factories, models
|
||||
|
||||
try:
|
||||
# mock is part of the Python (>= 3.3) standard library
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
# fall back to the mock backport
|
||||
import mock
|
||||
|
||||
|
||||
class DomainAPITestCase(ModoAPITestCase):
|
||||
"""Check API."""
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Domain related test cases."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from unittest import mock
|
||||
|
||||
import dns.resolver
|
||||
from testfixtures import compare
|
||||
@@ -23,13 +20,6 @@ from . import utils
|
||||
from .. import factories
|
||||
from ..models import Alias, Domain
|
||||
|
||||
try:
|
||||
# mock is part of the Python (>= 3.3) standard library
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
# fall back to the mock backport
|
||||
import mock
|
||||
|
||||
|
||||
class DomainTestCase(ModoTestCase):
|
||||
"""Test case for Domain."""
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.urls import reverse
|
||||
|
||||
from modoboa.lib.tests import ModoTestCase
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Export related test cases."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
|
||||
from six.moves import StringIO
|
||||
from io import StringIO
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.urls import reverse
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
from unittest import mock
|
||||
|
||||
import dns.resolver
|
||||
|
||||
@@ -18,13 +15,6 @@ from . import utils
|
||||
from .. import factories
|
||||
from ..models import Alias, Domain, DomainAlias
|
||||
|
||||
try:
|
||||
# mock is part of the Python (>= 3.3) standard library
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
# fall back to the mock backport
|
||||
import mock
|
||||
|
||||
|
||||
class ImportTestCase(ModoTestCase):
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Management command tests."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from unittest import mock
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.test import override_settings
|
||||
@@ -15,13 +12,6 @@ from django.urls import reverse
|
||||
from modoboa.lib.tests import ModoTestCase
|
||||
from .. import factories, models
|
||||
|
||||
try:
|
||||
# mock is part of the Python (>= 3.3) standard library
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
# fall back to the mock backport
|
||||
import mock
|
||||
|
||||
|
||||
@override_settings(
|
||||
DOVECOT_LOOKUP_PATH=["{}/dovecot".format(os.path.dirname(__file__))])
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Test map files generation."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""DNSBL related tests."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from unittest import mock
|
||||
|
||||
import dns.resolver
|
||||
from testfixtures import LogCapture
|
||||
@@ -18,13 +16,6 @@ from . import utils
|
||||
from .. import factories, models
|
||||
from ..lib import get_domain_mx_list
|
||||
|
||||
try:
|
||||
# mock is part of the Python (>= 3.3) standard library
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
# fall back to the mock backport
|
||||
import mock
|
||||
|
||||
|
||||
class MXTestCase(ModoTestCase):
|
||||
"""TestCase for DNSBL related features."""
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.urls import reverse
|
||||
|
||||
from modoboa.core.models import User
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Repair command tests"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core import management
|
||||
|
||||
from modoboa.lib.permissions import ObjectAccess, get_object_owner
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""User related tests."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.urls import reverse
|
||||
|
||||
from modoboa.core.models import User
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Test utilities."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import socket
|
||||
|
||||
from dns.name import Name
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Admin urls."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Admin API urls."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from rest_framework import routers
|
||||
|
||||
from . import api
|
||||
|
||||
router = routers.SimpleRouter()
|
||||
router.register(r"domains", api.DomainViewSet, base_name="domain")
|
||||
router.register(r"domains", api.DomainViewSet, basename="domain")
|
||||
router.register(
|
||||
r"domainaliases", api.DomainAliasViewSet, base_name="domain_alias")
|
||||
router.register(r"accounts", api.AccountViewSet, base_name="account")
|
||||
router.register(r"aliases", api.AliasViewSet, base_name="alias")
|
||||
r"domainaliases", api.DomainAliasViewSet, basename="domain_alias")
|
||||
router.register(r"accounts", api.AccountViewSet, basename="account")
|
||||
router.register(r"aliases", api.AliasViewSet, basename="alias")
|
||||
router.register(
|
||||
r"senderaddresses", api.SenderAddressViewSet, base_name="sender_address")
|
||||
r"senderaddresses", api.SenderAddressViewSet, basename="sender_address")
|
||||
|
||||
urlpatterns = router.urls
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Shortcuts."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .alias import AliasDetailView
|
||||
from .dns import DNSBLDomainDetailView, MXDomainDetailView
|
||||
from .domain import DomainDetailView
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Alias related views."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from reversion import revisions as reversion
|
||||
|
||||
from django.contrib.auth import mixins as auth_mixins
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""DNSBL related views."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.auth import mixins as auth_mixins
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views import generic
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Domain related views."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from reversion import revisions as reversion
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Export related views."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import csv
|
||||
from io import StringIO
|
||||
|
||||
from rfc6266 import build_header
|
||||
|
||||
@@ -12,17 +11,11 @@ from django.contrib.auth.decorators import (
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
from django.utils import six
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from ..forms import ExportDomainsForm, ExportIdentitiesForm
|
||||
from ..lib import get_domains, get_identities
|
||||
|
||||
if six.PY2:
|
||||
from backports import csv
|
||||
else:
|
||||
import csv
|
||||
|
||||
|
||||
def _export(content, filename):
|
||||
"""Export a csv file's content
|
||||
@@ -54,7 +47,7 @@ def export_identities(request):
|
||||
if request.method == "POST":
|
||||
form = ExportIdentitiesForm(request.POST)
|
||||
form.is_valid()
|
||||
fp = six.StringIO()
|
||||
fp = StringIO()
|
||||
csvwriter = csv.writer(fp, delimiter=form.cleaned_data["sepchar"])
|
||||
identities = get_identities(
|
||||
request.user, **request.session["identities_filters"])
|
||||
@@ -82,7 +75,7 @@ def export_domains(request):
|
||||
if request.method == "POST":
|
||||
form = ExportDomainsForm(request.POST)
|
||||
form.is_valid()
|
||||
fp = six.StringIO()
|
||||
fp = StringIO()
|
||||
csvwriter = csv.writer(fp, delimiter=form.cleaned_data["sepchar"])
|
||||
for dom in get_domains(request.user,
|
||||
**request.session["domains_filters"]):
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Identity related views."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from reversion import revisions as reversion
|
||||
|
||||
from django.contrib.auth import mixins as auth_mixins
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Import related views."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import csv
|
||||
import io
|
||||
|
||||
from reversion import revisions as reversion
|
||||
@@ -14,7 +11,6 @@ from django.contrib.auth.decorators import (
|
||||
from django.db import transaction
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
from django.utils import six
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
@@ -22,11 +18,6 @@ from modoboa.lib.exceptions import Conflict, ModoboaException
|
||||
from .. import signals
|
||||
from ..forms import ImportDataForm, ImportIdentitiesForm
|
||||
|
||||
if six.PY2:
|
||||
from backports import csv
|
||||
else:
|
||||
import csv
|
||||
|
||||
|
||||
@reversion.create_revision()
|
||||
def importdata(request, formclass=ImportDataForm):
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""SimpleUsers views."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from reversion import revisions as reversion
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""App config for core."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
default_app_config = "modoboa.core.apps.CoreConfig"
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import password_validation
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Core config for admin."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
from django.db.models import signals
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# Import these to force registration of checks
|
||||
from . import settings_checks # NOQA:F401
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.checks import Warning, register
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""A shortcut to deploy a fresh modoboa instance."""
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import codecs
|
||||
import getpass
|
||||
import os
|
||||
import shutil
|
||||
@@ -18,7 +13,6 @@ import django
|
||||
from django.core import management
|
||||
from django.template import Context, Template
|
||||
from django.utils.encoding import smart_str
|
||||
from django.utils.six.moves import input
|
||||
|
||||
from modoboa.core.commands import Command
|
||||
from modoboa.lib.api_client import ModoAPIClient
|
||||
@@ -250,7 +244,7 @@ class DeployCommand(Command):
|
||||
"extra_settings": extra_settings
|
||||
}
|
||||
)
|
||||
with codecs.open("%s/settings.py" % path, "w", "utf-8") as fp:
|
||||
with open("%s/settings.py" % path, "w") as fp:
|
||||
fp.write(tpl)
|
||||
shutil.copyfile(
|
||||
"%s/urls.py.tpl" % self._templates_dir, "%s/urls.py" % path
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
|
||||
from . import Command
|
||||
|
||||
@@ -9,8 +9,6 @@ For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/1.11/ref/settings/
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from logging.handlers import SysLogHandler
|
||||
import os
|
||||
{% if devmode %}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Core application constants."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
SIMPLEUSERS_ROLE = ("SimpleUsers", ugettext_lazy("Simple user"))
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Custom context processors."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from . import signals
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Development settings
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
BOWER_COMPONENTS_ROOT = os.path.join(
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Extension management."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls import include, url
|
||||
from django.utils.encoding import smart_str
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Factories for core application."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import factory
|
||||
|
||||
from django.contrib.auth.models import Group
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Core forms."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
from django.contrib.auth import (
|
||||
forms as auth_forms, get_user_model, password_validation
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Modoboa core signal handlers."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from reversion import revisions as reversion
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Inactive accounts cleanup tool."""
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from six.moves import input
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import timezone
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Management command to communicate with public API."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from modoboa.admin import models as admin_models
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Management command to generate/update postfix map files."""
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import copy
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""A management command to load Modoboa initial data:
|
||||
|
||||
* Create a default super admin if none exists
|
||||
@@ -7,8 +5,6 @@
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from django.contrib.auth.models import Group
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
A simple managemenent command to update the default site.
|
||||
|
||||
See `https://docs.djangoproject.com/en/dev/ref/contrib/sites/`_.
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user