From 445d8920505b6ba79bc06a0f757a8e02cb828ab3 Mon Sep 17 00:00:00 2001 From: Rick Elrod Date: Mon, 31 Jul 2023 10:05:27 -0500 Subject: [PATCH] Drop unused django-taggit dependency (#14241) This drops the django-taggit dependency and drops the relevant fields from old migrations. Signed-off-by: Rick Elrod --- awx/main/migrations/0001_initial.py | 74 ------------------- .../migrations/0002_squashed_v300_release.py | 15 ---- awx/main/migrations/0006_v320_release.py | 11 --- .../0067_v350_credential_plugins.py | 8 -- .../migrations/0124_execution_environments.py | 8 -- .../migrations/0186_drop_django_taggit.py | 27 +++++++ awx/main/models/base.py | 5 -- awx/main/registrar.py | 4 - awx/settings/defaults.py | 1 - licenses/django-taggit.txt | 27 ------- requirements/requirements.in | 1 - requirements/requirements.txt | 3 - tools/docker-compose/README.md | 2 +- 13 files changed, 28 insertions(+), 158 deletions(-) create mode 100644 awx/main/migrations/0186_drop_django_taggit.py delete mode 100644 licenses/django-taggit.txt diff --git a/awx/main/migrations/0001_initial.py b/awx/main/migrations/0001_initial.py index cb9de8ec87c1..c9d7a2ad15a9 100644 --- a/awx/main/migrations/0001_initial.py +++ b/awx/main/migrations/0001_initial.py @@ -9,13 +9,11 @@ import django.utils.timezone import django.db.models.deletion from django.conf import settings -import taggit.managers import awx.main.fields class Migration(migrations.Migration): dependencies = [ - ('taggit', '0002_auto_20150616_2121'), ('contenttypes', '0002_remove_content_type_name'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] @@ -184,12 +182,6 @@ class Migration(migrations.Migration): null=True, ), ), - ( - 'tags', - taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), ], options={ 'ordering': ('kind', 'name'), @@ -529,12 +521,6 @@ class Migration(migrations.Migration): null=True, ), ), - ( - 'tags', - taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), ('users', models.ManyToManyField(related_name='organizations', to=settings.AUTH_USER_MODEL, blank=True)), ], options={ @@ -589,12 +575,6 @@ class Migration(migrations.Migration): null=True, ), ), - ( - 'tags', - taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), ], ), migrations.CreateModel( @@ -644,12 +624,6 @@ class Migration(migrations.Migration): null=True, ), ), - ( - 'tags', - taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), ], options={ 'ordering': ['-next_run'], @@ -687,12 +661,6 @@ class Migration(migrations.Migration): ), ), ('organization', models.ForeignKey(related_name='teams', on_delete=django.db.models.deletion.SET_NULL, to='main.Organization', null=True)), - ( - 'tags', - taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), ('users', models.ManyToManyField(related_name='teams', to=settings.AUTH_USER_MODEL, blank=True)), ], options={ @@ -1267,13 +1235,6 @@ class Migration(migrations.Migration): null=True, ), ), - migrations.AddField( - model_name='unifiedjobtemplate', - name='tags', - field=taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), migrations.AddField( model_name='unifiedjob', name='created_by', @@ -1319,13 +1280,6 @@ class Migration(migrations.Migration): name='schedule', field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, default=None, editable=False, to='main.Schedule', null=True), ), - migrations.AddField( - model_name='unifiedjob', - name='tags', - field=taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), migrations.AddField( model_name='unifiedjob', name='unified_job_template', @@ -1370,13 +1324,6 @@ class Migration(migrations.Migration): help_text='Organization containing this inventory.', ), ), - migrations.AddField( - model_name='inventory', - name='tags', - field=taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), migrations.AddField( model_name='host', name='inventory', @@ -1407,13 +1354,6 @@ class Migration(migrations.Migration): null=True, ), ), - migrations.AddField( - model_name='host', - name='tags', - field=taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), migrations.AddField( model_name='group', name='hosts', @@ -1441,13 +1381,6 @@ class Migration(migrations.Migration): name='parents', field=models.ManyToManyField(related_name='children', to='main.Group', blank=True), ), - migrations.AddField( - model_name='group', - name='tags', - field=taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), migrations.AddField( model_name='custominventoryscript', name='organization', @@ -1459,13 +1392,6 @@ class Migration(migrations.Migration): null=True, ), ), - migrations.AddField( - model_name='custominventoryscript', - name='tags', - field=taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), migrations.AddField( model_name='credential', name='team', diff --git a/awx/main/migrations/0002_squashed_v300_release.py b/awx/main/migrations/0002_squashed_v300_release.py index 8093de717554..413869d88d53 100644 --- a/awx/main/migrations/0002_squashed_v300_release.py +++ b/awx/main/migrations/0002_squashed_v300_release.py @@ -12,8 +12,6 @@ from django.conf import settings from django.utils.timezone import now -import taggit.managers - def create_system_job_templates(apps, schema_editor): """ @@ -125,7 +123,6 @@ class Migration(migrations.Migration): ] dependencies = [ - ('taggit', '0002_auto_20150616_2121'), ('contenttypes', '0002_remove_content_type_name'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('main', '0001_initial'), @@ -256,12 +253,6 @@ class Migration(migrations.Migration): 'organization', models.ForeignKey(related_name='notification_templates', on_delete=django.db.models.deletion.SET_NULL, to='main.Organization', null=True), ), - ( - 'tags', - taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), ], ), migrations.AddField( @@ -721,12 +712,6 @@ class Migration(migrations.Migration): help_text='Organization this label belongs to.', ), ), - ( - 'tags', - taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), ], options={ 'ordering': ('organization', 'name'), diff --git a/awx/main/migrations/0006_v320_release.py b/awx/main/migrations/0006_v320_release.py index 68034e75cedf..f1dd01d70852 100644 --- a/awx/main/migrations/0006_v320_release.py +++ b/awx/main/migrations/0006_v320_release.py @@ -5,7 +5,6 @@ # Django from django.db import connection, migrations, models, OperationalError, ProgrammingError from django.conf import settings -import taggit.managers # AWX import awx.main.fields @@ -317,10 +316,6 @@ class Migration(migrations.Migration): model_name='permission', name='project', ), - migrations.RemoveField( - model_name='permission', - name='tags', - ), migrations.RemoveField( model_name='permission', name='team', @@ -510,12 +505,6 @@ class Migration(migrations.Migration): null=True, ), ), - ( - 'tags', - taggit.managers.TaggableManager( - to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags' - ), - ), ], options={ 'ordering': ('kind', 'name'), diff --git a/awx/main/migrations/0067_v350_credential_plugins.py b/awx/main/migrations/0067_v350_credential_plugins.py index 482b4ce22076..abe1ad391c45 100644 --- a/awx/main/migrations/0067_v350_credential_plugins.py +++ b/awx/main/migrations/0067_v350_credential_plugins.py @@ -4,7 +4,6 @@ from django.conf import settings from django.db import migrations, models import django.db.models.deletion -import taggit.managers # AWX import awx.main.fields @@ -20,7 +19,6 @@ def setup_tower_managed_defaults(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('taggit', '0002_auto_20150616_2121'), ('main', '0066_v350_inventorysource_custom_virtualenv'), ] @@ -60,12 +58,6 @@ class Migration(migrations.Migration): 'source_credential', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='target_input_sources', to='main.Credential'), ), - ( - 'tags', - taggit.managers.TaggableManager( - blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags' - ), - ), ( 'target_credential', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='input_sources', to='main.Credential'), diff --git a/awx/main/migrations/0124_execution_environments.py b/awx/main/migrations/0124_execution_environments.py index 67a6e314640d..0030bc1ad045 100644 --- a/awx/main/migrations/0124_execution_environments.py +++ b/awx/main/migrations/0124_execution_environments.py @@ -4,12 +4,10 @@ from django.db import migrations, models import django.db.models.deletion import django.db.models.expressions -import taggit.managers class Migration(migrations.Migration): dependencies = [ - ('taggit', '0003_taggeditem_add_unique_index'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('main', '0123_drop_hg_support'), ] @@ -69,12 +67,6 @@ class Migration(migrations.Migration): to='main.Organization', ), ), - ( - 'tags', - taggit.managers.TaggableManager( - blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags' - ), - ), ], options={ 'ordering': (django.db.models.expressions.OrderBy(django.db.models.expressions.F('organization_id'), nulls_first=True), 'image'), diff --git a/awx/main/migrations/0186_drop_django_taggit.py b/awx/main/migrations/0186_drop_django_taggit.py new file mode 100644 index 000000000000..c9c767b74c1b --- /dev/null +++ b/awx/main/migrations/0186_drop_django_taggit.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + + +def delete_taggit_contenttypes(apps, schema_editor): + ContentType = apps.get_model('contenttypes', 'ContentType') + ContentType.objects.filter(app_label='taggit').delete() + + +def delete_taggit_migration_records(apps, schema_editor): + recorder = migrations.recorder.MigrationRecorder(connection=schema_editor.connection) + recorder.migration_qs.filter(app='taggit').delete() + + +class Migration(migrations.Migration): + dependencies = [ + ('main', '0185_move_JSONBlob_to_JSONField'), + ] + + operations = [ + migrations.RunSQL("DROP TABLE IF EXISTS taggit_tag CASCADE;"), + migrations.RunSQL("DROP TABLE IF EXISTS taggit_taggeditem CASCADE;"), + migrations.RunPython(delete_taggit_contenttypes), + migrations.RunPython(delete_taggit_migration_records), + ] diff --git a/awx/main/models/base.py b/awx/main/models/base.py index 571f37ccb9f7..0ef5b244f2e8 100644 --- a/awx/main/models/base.py +++ b/awx/main/models/base.py @@ -7,9 +7,6 @@ from django.utils.translation import gettext_lazy as _ from django.utils.timezone import now -# Django-Taggit -from taggit.managers import TaggableManager - # Django-CRUM from crum import get_current_user @@ -301,8 +298,6 @@ class Meta: on_delete=models.SET_NULL, ) - tags = TaggableManager(blank=True) - def __init__(self, *args, **kwargs): r = super(PrimordialModel, self).__init__(*args, **kwargs) if self.pk: diff --git a/awx/main/registrar.py b/awx/main/registrar.py index d13f5b685726..31133f936bca 100644 --- a/awx/main/registrar.py +++ b/awx/main/registrar.py @@ -3,8 +3,6 @@ from django.db.models.signals import pre_save, post_save, pre_delete, m2m_changed -from taggit.managers import TaggableManager - class ActivityStreamRegistrar(object): def __init__(self): @@ -21,8 +19,6 @@ def connect(self, model): pre_delete.connect(activity_stream_delete, sender=model, dispatch_uid=str(self.__class__) + str(model) + "_delete") for m2mfield in model._meta.many_to_many: - if isinstance(m2mfield, TaggableManager): - continue # Special case for taggit app try: m2m_attr = getattr(model, m2mfield.name) m2m_changed.connect( diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index a7287fb515fd..5baf978d44d0 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -327,7 +327,6 @@ 'rest_framework', 'django_extensions', 'polymorphic', - 'taggit', 'social_django', 'django_guid', 'corsheaders', diff --git a/licenses/django-taggit.txt b/licenses/django-taggit.txt deleted file mode 100644 index d2b01574181d..000000000000 --- a/licenses/django-taggit.txt +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) Alex Gaynor and individual contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of django-taggit nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/requirements/requirements.in b/requirements/requirements.in index 90d4363b401a..d447556c077b 100644 --- a/requirements/requirements.in +++ b/requirements/requirements.in @@ -23,7 +23,6 @@ django-polymorphic django-pglocks django-solo django-split-settings==1.0.0 # We hit a strange issue where the release process errored when upgrading past 1.0.0 see UPGRADE BLOCKERS -django-taggit djangorestframework djangorestframework-yaml filelock diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 40b1490dd4b5..15e4c444a289 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -117,7 +117,6 @@ django==4.2.3 # django-oauth-toolkit # django-polymorphic # django-solo - # django-taggit # djangorestframework django-auth-ldap==4.1.0 # via -r /awx_devel/requirements/requirements.in @@ -140,8 +139,6 @@ django-solo==2.0.0 # via -r /awx_devel/requirements/requirements.in django-split-settings==1.0.0 # via -r /awx_devel/requirements/requirements.in -django-taggit==3.1.0 - # via -r /awx_devel/requirements/requirements.in djangorestframework==3.14.0 # via -r /awx_devel/requirements/requirements.in djangorestframework-yaml==2.0.0 diff --git a/tools/docker-compose/README.md b/tools/docker-compose/README.md index 7634059fd614..fdca69fe42ae 100644 --- a/tools/docker-compose/README.md +++ b/tools/docker-compose/README.md @@ -175,7 +175,7 @@ The first time you start the environment, database migrations need to run in ord ```bash awx_1 | Operations to perform: awx_1 | Synchronize unmigrated apps: solo, api, staticfiles, debug_toolbar, messages, channels, django_extensions, ui, rest_framework, polymorphic -awx_1 | Apply all migrations: sso, taggit, sessions, sites, kombu_transport_django, social_auth, contenttypes, auth, conf, main +awx_1 | Apply all migrations: sso, sessions, sites, kombu_transport_django, social_auth, contenttypes, auth, conf, main awx_1 | Synchronizing apps without migrations: awx_1 | Creating tables... awx_1 | Running deferred SQL...