Skip to content

Commit

Permalink
Merge pull request #153 from modoboa/django-42
Browse files Browse the repository at this point in the history
Update to django 4.2
  • Loading branch information
tonioo authored Jun 12, 2023
2 parents 4fddaf3 + 2495793 commit 57cd8d2
Show file tree
Hide file tree
Showing 20 changed files with 162 additions and 160 deletions.
47 changes: 24 additions & 23 deletions .github/workflows/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -40,7 +40,7 @@ jobs:
strategy:
matrix:
database: ['postgres', 'mysql']
python-version: [3.7, 3.8, 3.9]
python-version: [3.8, 3.9, '3.10']
fail-fast: false

steps:
Expand All @@ -56,20 +56,25 @@ jobs:
#pip install -e git+https://github.com/modoboa/modoboa.git#egg=modoboa
pip install -r requirements.txt
pip install -r test-requirements.txt
cd ..
git clone https://github.com/modoboa/modoboa.git
cd modoboa
python setup.py develop
cd ../modoboa-amavis
python setup.py develop
- name: Install postgres requirements
if: ${{ matrix.database == 'postgres' }}
run: |
pip install 'psycopg2-binary>=2.8,<2.9'
pip install 'psycopg[binary]>=3.1'
pip install coverage
echo "DB=postgres" >> $GITHUB_ENV
- name: Install mysql requirements
if: ${{ matrix.database == 'mysql' }}
run: |
pip install 'mysqlclient<2.0.4'
pip install 'mysqlclient<2.1.2'
echo "DB=mysql" >> $GITHUB_ENV
- name: Test with pytest
if: ${{ matrix.python-version != '3.9' || matrix.database != 'postgres' }}
if: ${{ matrix.python-version != '3.10' || matrix.database != 'postgres' }}
run: |
cd test_project
python3 manage.py test modoboa_amavis
Expand All @@ -82,10 +87,12 @@ jobs:
MYSQL_USER: root

- name: Test with pytest and coverage
if: ${{ matrix.python-version == '3.9' && matrix.database == 'postgres' }}
if: ${{ matrix.python-version == '3.10' && matrix.database == 'postgres' }}
run: |
cd test_project
coverage run --source ../modoboa_amavis manage.py test modoboa_amavis
coverage xml
coverage report
env:
# use localhost for the host here because we are running the job on the VM.
# If we were running the job on in a container this would be postgres
Expand All @@ -94,44 +101,38 @@ jobs:
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }} # get randomly assigned published port
MYSQL_USER: root
- name: Upload coverage result
if: ${{ matrix.python-version == '3.9' }}
uses: actions/upload-artifact@v2
if: ${{ matrix.python-version == '3.10' && matrix.database == 'postgres' }}
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: test_project/.coverage
path: test_project/coverage.xml

coverage:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install codecov
- name: Download coverage results
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: coverage-results
- name: Report coverage
run: |
coverage report
codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml

release:
if: github.event_name != 'pull_request'
needs: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
- name: Build packages
run: |
sudo apt-get install librrd-dev rrdtool libssl-dev gettext
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
.eggs

# C extensions
*.so
Expand Down
2 changes: 1 addition & 1 deletion modoboa_amavis/checks/settings_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf import settings
from django.core.checks import Warning, register
from django.db import connections
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

W001 = Warning(
_("AMAVIS_DEFAULT_DATABASE_ENCODING does not match the character "
Expand Down
2 changes: 1 addition & 1 deletion modoboa_amavis/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import collections

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

MESSAGE_TYPES = collections.OrderedDict((
("C", _("Clean")),
Expand Down
88 changes: 44 additions & 44 deletions modoboa_amavis/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from django import forms
from django.utils.translation import ugettext as _, ugettext_lazy
from django.utils.translation import gettext as _, gettext_lazy

from modoboa.lib import form_utils
from modoboa.parameters import forms as param_forms, tools as param_tools
Expand Down Expand Up @@ -100,144 +100,144 @@ class ParametersForm(param_forms.AdminParametersForm):
app = "modoboa_amavis"

amavis_settings_sep = form_utils.SeparatorField(
label=ugettext_lazy("Amavis settings"))
label=gettext_lazy("Amavis settings"))

localpart_is_case_sensitive = form_utils.YesNoField(
label=ugettext_lazy("Localpart is case sensitive"),
label=gettext_lazy("Localpart is case sensitive"),
initial=False,
help_text=ugettext_lazy("Value should match amavisd.conf variable %s"
help_text=gettext_lazy("Value should match amavisd.conf variable %s"
% "$localpart_is_case_sensitive")
)

recipient_delimiter = forms.CharField(
label=ugettext_lazy("Recipient delimiter"),
label=gettext_lazy("Recipient delimiter"),
initial="",
help_text=ugettext_lazy("Value should match amavisd.conf variable %s"
help_text=gettext_lazy("Value should match amavisd.conf variable %s"
% "$recipient_delimiter"),
widget=forms.TextInput(attrs={"class": "form-control"}),
required=False
)

qsettings_sep = form_utils.SeparatorField(
label=ugettext_lazy("Quarantine settings"))
label=gettext_lazy("Quarantine settings"))

max_messages_age = forms.IntegerField(
label=ugettext_lazy("Maximum message age"),
label=gettext_lazy("Maximum message age"),
initial=14,
help_text=ugettext_lazy(
help_text=gettext_lazy(
"Quarantine messages maximum age (in days) before deletion"
)
)

sep1 = form_utils.SeparatorField(label=ugettext_lazy("Messages releasing"))
sep1 = form_utils.SeparatorField(label=gettext_lazy("Messages releasing"))

released_msgs_cleanup = form_utils.YesNoField(
label=ugettext_lazy("Remove released messages"),
label=gettext_lazy("Remove released messages"),
initial=False,
help_text=ugettext_lazy(
help_text=gettext_lazy(
"Remove messages marked as released while cleaning up "
"the database"
)
)

am_pdp_mode = forms.ChoiceField(
label=ugettext_lazy("Amavis connection mode"),
label=gettext_lazy("Amavis connection mode"),
choices=[("inet", "inet"), ("unix", "unix")],
initial="unix",
help_text=ugettext_lazy("Mode used to access the PDP server"),
help_text=gettext_lazy("Mode used to access the PDP server"),
widget=form_utils.HorizontalRadioSelect()
)

am_pdp_host = forms.CharField(
label=ugettext_lazy("PDP server address"),
label=gettext_lazy("PDP server address"),
initial="localhost",
help_text=ugettext_lazy("PDP server address (if inet mode)"),
help_text=gettext_lazy("PDP server address (if inet mode)"),
widget=forms.TextInput(attrs={"class": "form-control"})
)

am_pdp_port = forms.IntegerField(
label=ugettext_lazy("PDP server port"),
label=gettext_lazy("PDP server port"),
initial=9998,
help_text=ugettext_lazy("PDP server port (if inet mode)")
help_text=gettext_lazy("PDP server port (if inet mode)")
)

am_pdp_socket = forms.CharField(
label=ugettext_lazy("PDP server socket"),
label=gettext_lazy("PDP server socket"),
initial="/var/amavis/amavisd.sock",
help_text=ugettext_lazy("Path to the PDP server socket (if unix mode)")
help_text=gettext_lazy("Path to the PDP server socket (if unix mode)")
)

user_can_release = form_utils.YesNoField(
label=ugettext_lazy("Allow direct release"),
label=gettext_lazy("Allow direct release"),
initial=False,
help_text=ugettext_lazy(
help_text=gettext_lazy(
"Allow users to directly release their messages")
)

self_service = form_utils.YesNoField(
label=ugettext_lazy("Enable self-service mode"),
label=gettext_lazy("Enable self-service mode"),
initial=False,
help_text=ugettext_lazy("Activate the 'self-service' mode")
help_text=gettext_lazy("Activate the 'self-service' mode")
)

notifications_sender = forms.EmailField(
label=ugettext_lazy("Notifications sender"),
label=gettext_lazy("Notifications sender"),
initial="notification@modoboa.org",
help_text=ugettext_lazy(
help_text=gettext_lazy(
"The e-mail address used to send notitications")
)

lsep = form_utils.SeparatorField(label=ugettext_lazy("Manual learning"))
lsep = form_utils.SeparatorField(label=gettext_lazy("Manual learning"))

manual_learning = form_utils.YesNoField(
label=ugettext_lazy("Enable manual learning"),
label=gettext_lazy("Enable manual learning"),
initial=True,
help_text=ugettext_lazy(
help_text=gettext_lazy(
"Allow super administrators to manually train Spamassassin"
)
)

sa_is_local = form_utils.YesNoField(
label=ugettext_lazy("Is Spamassassin local?"),
label=gettext_lazy("Is Spamassassin local?"),
initial=True,
help_text=ugettext_lazy(
help_text=gettext_lazy(
"Tell if Spamassassin is running on the same server than modoboa"
)
)

default_user = forms.CharField(
label=ugettext_lazy("Default user"),
label=gettext_lazy("Default user"),
initial="amavis",
help_text=ugettext_lazy(
help_text=gettext_lazy(
"Name of the user owning the default bayesian database"
)
)

spamd_address = forms.CharField(
label=ugettext_lazy("Spamd address"),
label=gettext_lazy("Spamd address"),
initial="127.0.0.1",
help_text=ugettext_lazy("The IP address where spamd can be reached")
help_text=gettext_lazy("The IP address where spamd can be reached")
)

spamd_port = forms.IntegerField(
label=ugettext_lazy("Spamd port"),
label=gettext_lazy("Spamd port"),
initial=783,
help_text=ugettext_lazy("The TCP port spamd is listening on")
help_text=gettext_lazy("The TCP port spamd is listening on")
)

domain_level_learning = form_utils.YesNoField(
label=ugettext_lazy("Enable per-domain manual learning"),
label=gettext_lazy("Enable per-domain manual learning"),
initial=False,
help_text=ugettext_lazy(
help_text=gettext_lazy(
"Allow domain administrators to train Spamassassin "
"(within dedicated per-domain databases)"
)
)

user_level_learning = form_utils.YesNoField(
label=ugettext_lazy("Enable per-user manual learning"),
label=gettext_lazy("Enable per-user manual learning"),
initial=False,
help_text=ugettext_lazy(
help_text=gettext_lazy(
"Allow simple users to personally train Spamassassin "
"(within a dedicated database)"
)
Expand All @@ -262,11 +262,11 @@ class UserSettings(param_forms.UserParametersForm):

app = "modoboa_amavis"

dsep = form_utils.SeparatorField(label=ugettext_lazy("Display"))
dsep = form_utils.SeparatorField(label=gettext_lazy("Display"))

messages_per_page = forms.IntegerField(
initial=40,
label=ugettext_lazy("Number of displayed emails per page"),
help_text=ugettext_lazy(
label=gettext_lazy("Number of displayed emails per page"),
help_text=gettext_lazy(
"Set the maximum number of messages displayed in a page")
)
2 changes: 1 addition & 1 deletion modoboa_amavis/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.dispatch import receiver
from django.template import Context, Template
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from modoboa.admin import models as admin_models, signals as admin_signals
from modoboa.core import signals as core_signals
Expand Down
Loading

0 comments on commit 57cd8d2

Please sign in to comment.