From 0e6f34d0eed263351d12f79cfc17cbd911f34af2 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Mon, 6 May 2019 02:29:59 -0400 Subject: [PATCH] Add deprecation warning to convertdb Signed-off-by: Roberto Rosario --- HISTORY.rst | 1 + docs/releases/3.2.rst | 1 + mayan/apps/common/literals.py | 3 +++ mayan/apps/common/management/commands/convertdb.py | 12 ++++++++++++ mayan/apps/common/warnings.py | 6 ++++++ 5 files changed, 23 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index a9e7ff83a2..cce85e3ddd 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -240,6 +240,7 @@ * Remove MultipleInstanceActionMixin. * Backport MultipleObjectMixin improvements. * Remove ObjectListPermissionFilterMixin. +* Add deprecation warning to convertdb 3.1.11 (2019-04-XX) =================== diff --git a/docs/releases/3.2.rst b/docs/releases/3.2.rst index 37740c5dc7..b31f380e46 100644 --- a/docs/releases/3.2.rst +++ b/docs/releases/3.2.rst @@ -273,6 +273,7 @@ Other changes * Remove MultipleInstanceActionMixin. * Backport MultipleObjectMixin improvements. * Remove ObjectListPermissionFilterMixin. +* Add deprecation warning to convertdb Removals -------- diff --git a/mayan/apps/common/literals.py b/mayan/apps/common/literals.py index 651eb871de..acebfa08d2 100644 --- a/mayan/apps/common/literals.py +++ b/mayan/apps/common/literals.py @@ -6,6 +6,9 @@ DEFAULT_COMMON_HOME_VIEW = 'common:home' DELETE_STALE_UPLOADS_INTERVAL = 60 * 10 # 10 minutes DJANGO_SQLITE_BACKEND = 'django.db.backends.sqlite3' +MESSAGE_DEPRECATION_WARNING = _( + 'This feature has been deprecated and will be removed in a future version.' +) MESSAGE_SQLITE_WARNING = _( 'Your database backend is set to use SQLite. SQLite should only be used ' 'for development and testing, not for production.' diff --git a/mayan/apps/common/management/commands/convertdb.py b/mayan/apps/common/management/commands/convertdb.py index 8327fae9a6..30bc2d0e67 100644 --- a/mayan/apps/common/management/commands/convertdb.py +++ b/mayan/apps/common/management/commands/convertdb.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import errno import os +import warnings from pathlib2 import Path @@ -14,6 +15,9 @@ from django.utils.translation import ugettext_lazy as _ from mayan.apps.documents.models import DocumentType from mayan.apps.storage.utils import fs_cleanup +from ...literals import MESSAGE_DEPRECATION_WARNING +from ...warnings import DeprecationWarning + CONVERTDB_FOLDER = 'convertdb' CONVERTDB_OUTPUT_FILENAME = 'migrate.json' @@ -21,6 +25,14 @@ CONVERTDB_OUTPUT_FILENAME = 'migrate.json' class Command(management.BaseCommand): help = 'Convert from a database backend to another one.' + def __init__(self, *args, **kwargs): + warnings.warn( + category=DeprecationWarning, + message=force_text(MESSAGE_DEPRECATION_WARNING) + ) + + super(Command, self).__init__(*args, **kwargs) + def add_arguments(self, parser): parser.add_argument( 'args', metavar='app_label[.ModelName]', nargs='*', diff --git a/mayan/apps/common/warnings.py b/mayan/apps/common/warnings.py index 24929d58db..e7c3a68d3d 100644 --- a/mayan/apps/common/warnings.py +++ b/mayan/apps/common/warnings.py @@ -7,6 +7,12 @@ class DatabaseWarning(UserWarning): """ +class DeprecationWarning(UserWarning): + """ + Warning when a feature or interface has been deprecated + """ + + class InterfaceWarning(UserWarning): """ Warning when using obsolete internal interfaces