mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* deprecate old commands
* add changelog fragment
* fix django version in docs
* fix wording on the deprecations
* Update changelogs/fragments/5400-django-manage-deprecations.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* update chglog fragment
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 7857d0669e
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
9ed0603072
commit
da8a11b8d8
2 changed files with 65 additions and 17 deletions
3
changelogs/fragments/5400-django-manage-deprecations.yml
Normal file
3
changelogs/fragments/5400-django-manage-deprecations.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
deprecated_features:
|
||||||
|
- django_manage - support for the commands ``cleanup``, ``syncdb`` and ``validate`` that have been deprecated in Django long time ago will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5400).
|
||||||
|
- django_manage - support for Django releases older than 4.1 has been deprecated and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5400).
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (c) 2022, Alexei Znamensky <russoz@gmail.com>
|
||||||
# Copyright (c) 2013, Scott Anderson <scottanderson42@gmail.com>
|
# Copyright (c) 2013, Scott Anderson <scottanderson42@gmail.com>
|
||||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
@ -12,24 +13,36 @@ __metaclass__ = type
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: django_manage
|
module: django_manage
|
||||||
short_description: Manages a Django application.
|
short_description: Manages a Django application
|
||||||
description:
|
description:
|
||||||
- Manages a Django application using the C(manage.py) application frontend to C(django-admin). With the
|
- Manages a Django application using the C(manage.py) application frontend to C(django-admin). With the
|
||||||
C(virtualenv) parameter, all management commands will be executed by the given C(virtualenv) installation.
|
I(virtualenv) parameter, all management commands will be executed by the given C(virtualenv) installation.
|
||||||
options:
|
options:
|
||||||
command:
|
command:
|
||||||
description:
|
description:
|
||||||
- The name of the Django management command to run. Built in commands are C(cleanup), C(collectstatic),
|
- The name of the Django management command to run. The commands listed below are built in this module and have some basic parameter validation.
|
||||||
C(flush), C(loaddata), C(migrate), C(syncdb), C(test), and C(validate).
|
- >
|
||||||
- Other commands can be entered, but will fail if they're unknown to Django. Other commands that may
|
C(cleanup) - clean up old data from the database (deprecated in Django 1.5). This parameter will be
|
||||||
|
removed in community.general 9.0.0. Use C(clearsessions) instead.
|
||||||
|
- C(collectstatic) - Collects the static files into C(STATIC_ROOT).
|
||||||
|
- C(createcachetable) - Creates the cache tables for use with the database cache backend.
|
||||||
|
- C(flush) - Removes all data from the database.
|
||||||
|
- C(loaddata) - Searches for and loads the contents of the named I(fixtures) into the database.
|
||||||
|
- C(migrate) - Synchronizes the database state with models and migrations.
|
||||||
|
- >
|
||||||
|
C(syncdb) - Synchronizes the database state with models and migrations (deprecated in Django 1.7).
|
||||||
|
This parameter will be removed in community.general 9.0.0. Use C(migrate) instead.
|
||||||
|
- C(test) - Runs tests for all installed apps.
|
||||||
|
- >
|
||||||
|
C(validate) - Validates all installed models (deprecated in Django 1.7). This parameter will be
|
||||||
|
removed in community.general 9.0.0. Use C(check) instead.
|
||||||
|
- Other commands can be entered, but will fail if they are unknown to Django. Other commands that may
|
||||||
prompt for user input should be run with the C(--noinput) flag.
|
prompt for user input should be run with the C(--noinput) flag.
|
||||||
- The module will perform some basic parameter validation (when applicable) to the commands C(cleanup),
|
|
||||||
C(collectstatic), C(createcachetable), C(flush), C(loaddata), C(migrate), C(syncdb), C(test), and C(validate).
|
|
||||||
type: str
|
type: str
|
||||||
required: true
|
required: true
|
||||||
project_path:
|
project_path:
|
||||||
description:
|
description:
|
||||||
- The path to the root of the Django application where B(manage.py) lives.
|
- The path to the root of the Django application where C(manage.py) lives.
|
||||||
type: path
|
type: path
|
||||||
required: true
|
required: true
|
||||||
aliases: [app_path, chdir]
|
aliases: [app_path, chdir]
|
||||||
|
@ -42,12 +55,13 @@ options:
|
||||||
description:
|
description:
|
||||||
- A directory to add to the Python path. Typically used to include the settings module if it is located
|
- A directory to add to the Python path. Typically used to include the settings module if it is located
|
||||||
external to the application directory.
|
external to the application directory.
|
||||||
|
- This would be equivalent to adding I(pythonpath)'s value to the C(PYTHONPATH) environment variable.
|
||||||
type: path
|
type: path
|
||||||
required: false
|
required: false
|
||||||
aliases: [python_path]
|
aliases: [python_path]
|
||||||
virtualenv:
|
virtualenv:
|
||||||
description:
|
description:
|
||||||
- An optional path to a I(virtualenv) installation to use while running the manage application.
|
- An optional path to a C(virtualenv) installation to use while running the manage application.
|
||||||
type: path
|
type: path
|
||||||
aliases: [virtual_env]
|
aliases: [virtual_env]
|
||||||
apps:
|
apps:
|
||||||
|
@ -87,29 +101,33 @@ options:
|
||||||
required: false
|
required: false
|
||||||
skip:
|
skip:
|
||||||
description:
|
description:
|
||||||
- Will skip over out-of-order missing migrations, you can only use this parameter with C(migrate) command.
|
- Will skip over out-of-order missing migrations, you can only use this parameter with C(migrate) command.
|
||||||
required: false
|
required: false
|
||||||
type: bool
|
type: bool
|
||||||
merge:
|
merge:
|
||||||
description:
|
description:
|
||||||
- Will run out-of-order or missing migrations as they are not rollback migrations, you can only use this
|
- Will run out-of-order or missing migrations as they are not rollback migrations, you can only use this
|
||||||
parameter with C(migrate) command.
|
parameter with C(migrate) command.
|
||||||
required: false
|
required: false
|
||||||
type: bool
|
type: bool
|
||||||
link:
|
link:
|
||||||
description:
|
description:
|
||||||
- Will create links to the files instead of copying them, you can only use this parameter with
|
- Will create links to the files instead of copying them, you can only use this parameter with
|
||||||
C(collectstatic) command.
|
C(collectstatic) command.
|
||||||
required: false
|
required: false
|
||||||
type: bool
|
type: bool
|
||||||
testrunner:
|
testrunner:
|
||||||
description:
|
description:
|
||||||
- "From the Django docs: Controls the test runner class that is used to execute tests."
|
- Controls the test runner class that is used to execute tests.
|
||||||
- This parameter is passed as-is to C(manage.py).
|
- This parameter is passed as-is to C(manage.py).
|
||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
aliases: [test_runner]
|
aliases: [test_runner]
|
||||||
notes:
|
notes:
|
||||||
|
- >
|
||||||
|
B(ATTENTION - DEPRECATION): Support for Django releases older than 4.1 will be removed in
|
||||||
|
community.general version 9.0.0 (estimated to be released in May 2024).
|
||||||
|
Please notice that Django 4.1 requires Python 3.8 or greater.
|
||||||
- C(virtualenv) (U(http://www.virtualenv.org)) must be installed on the remote host if the I(virtualenv) parameter
|
- C(virtualenv) (U(http://www.virtualenv.org)) must be installed on the remote host if the I(virtualenv) parameter
|
||||||
is specified.
|
is specified.
|
||||||
- This module will create a virtualenv if the I(virtualenv) parameter is specified and a virtual environment does not already
|
- This module will create a virtualenv if the I(virtualenv) parameter is specified and a virtual environment does not already
|
||||||
|
@ -121,8 +139,20 @@ notes:
|
||||||
- To be able to use the C(collectstatic) command, you must have enabled staticfiles in your settings.
|
- To be able to use the C(collectstatic) command, you must have enabled staticfiles in your settings.
|
||||||
- Your C(manage.py) application must be executable (rwxr-xr-x), and must have a valid shebang,
|
- Your C(manage.py) application must be executable (rwxr-xr-x), and must have a valid shebang,
|
||||||
i.e. C(#!/usr/bin/env python), for invoking the appropriate Python interpreter.
|
i.e. C(#!/usr/bin/env python), for invoking the appropriate Python interpreter.
|
||||||
|
seealso:
|
||||||
|
- name: django-admin and manage.py Reference
|
||||||
|
description: Reference for C(django-admin) or C(manage.py) commands.
|
||||||
|
link: https://docs.djangoproject.com/en/4.1/ref/django-admin/
|
||||||
|
- name: Django Download page
|
||||||
|
description: The page showing how to get Django and the timeline of supported releases.
|
||||||
|
link: https://www.djangoproject.com/download/
|
||||||
|
- name: What Python version can I use with Django?
|
||||||
|
description: From the Django FAQ, the response to Python requirements for the framework.
|
||||||
|
link: https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django
|
||||||
requirements: [ "virtualenv", "django" ]
|
requirements: [ "virtualenv", "django" ]
|
||||||
author: "Scott Anderson (@tastychutney)"
|
author:
|
||||||
|
- Alexei Znamensky (@russoz)
|
||||||
|
- Scott Anderson (@tastychutney)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -280,6 +310,21 @@ def main():
|
||||||
project_path = module.params['project_path']
|
project_path = module.params['project_path']
|
||||||
virtualenv = module.params['virtualenv']
|
virtualenv = module.params['virtualenv']
|
||||||
|
|
||||||
|
try:
|
||||||
|
_deprecation = dict(
|
||||||
|
cleanup="clearsessions",
|
||||||
|
syncdb="migrate",
|
||||||
|
validate="check",
|
||||||
|
)
|
||||||
|
module.deprecate(
|
||||||
|
'The command {0} has been deprecated as it is no longer supported in recent Django versions.'
|
||||||
|
'Please use the command {1} instead that provide similar capability.'.format(command_bin, _deprecation[command_bin]),
|
||||||
|
version='9.0.0',
|
||||||
|
collection_name='community.general'
|
||||||
|
)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
for param in specific_params:
|
for param in specific_params:
|
||||||
value = module.params[param]
|
value = module.params[param]
|
||||||
if value and param not in command_allowed_param_map[command_bin]:
|
if value and param not in command_allowed_param_map[command_bin]:
|
||||||
|
|
Loading…
Reference in a new issue