diff --git a/doc/upgrade.rst b/doc/upgrade.rst index 1a0675db5..bec3a4c56 100644 --- a/doc/upgrade.rst +++ b/doc/upgrade.rst @@ -144,6 +144,17 @@ Version 2.3.0 new migrations **AFTER** the following instructions. If you don't, you'll get into trouble... +Pre update +---------- + +Before your start upgrading modoboa, run the following commands from +your virtual environment: + +.. sourcecode:: bash + + > python manage.py modo repair + > python manage.py rename_app modoboa_postfix_autoreply postfix_autoreply + Required changes to :file:`settings.py` --------------------------------------- @@ -301,16 +312,6 @@ SORBS DNS bl.spameatingmonkey.net=127.0.0.2*2 bl.spamcop.net=127.0.0.2 - -Post update ------------ - -After upgrading modoboa, run the following commands from your virtual environment: - -.. sourcecode:: bash - - > python manage.py rename_app modoboa_postfix_autoreply postfix_autoreply - Version 2.2.3 ============= diff --git a/modoboa/admin/management/commands/subcommands/_repair.py b/modoboa/admin/management/commands/subcommands/_repair.py index 5a921d6ce..27a5f2cf6 100644 --- a/modoboa/admin/management/commands/subcommands/_repair.py +++ b/modoboa/admin/management/commands/subcommands/_repair.py @@ -4,6 +4,9 @@ from django.conf import settings from django.core.management.base import BaseCommand from django.utils.encoding import smart_str +from django.contrib.auth.models import Permission +from django.contrib.contenttypes.models import ContentType + from modoboa.admin import models from modoboa.core.models import User from modoboa.lib.permissions import get_object_owner, grant_access_to_object @@ -89,6 +92,15 @@ def sometimes_mailbox_have_no_alias(**options): ) +@known_problem +def postfix_autoreply_old_contenttypes(**options): + """Sometime old postfix autoreply contenttypes might be present.""" + for ct in ContentType.objects.filter(app_label="postfix_autoreply"): + result = Permission.objects.filter(content_type=ct).delete() + ct.delete() + log(f"Removed content type {ct.name} and {result[0]} associated permssions") + + class Repair(BaseCommand): """Command class."""