From 951ebf146ab0acb913abb13b6e2d939a28930cfb Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Fri, 18 May 2018 13:51:17 -0400 Subject: [PATCH] remove unused project field --- awx/api/serializers.py | 6 +--- ...emove_project_scm_delete_on_next_update.py | 19 ++++++++++ awx/main/models/projects.py | 35 ------------------- 3 files changed, 20 insertions(+), 40 deletions(-) create mode 100644 awx/main/migrations/0052_v340_remove_project_scm_delete_on_next_update.py diff --git a/awx/api/serializers.py b/awx/api/serializers.py index b86c4c5e4a..aaf28acb46 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1311,16 +1311,12 @@ class ProjectSerializer(UnifiedJobTemplateSerializer, ProjectOptionsSerializer): 'admin', 'update', {'copy': 'organization.project_admin'} ] - scm_delete_on_next_update = serializers.BooleanField( - read_only=True, - help_text=_('This field has been deprecated and will be removed in a future release')) class Meta: model = Project - fields = ('*', 'organization', 'scm_delete_on_next_update', 'scm_update_on_launch', + fields = ('*', 'organization', 'scm_update_on_launch', 'scm_update_cache_timeout', 'scm_revision', 'custom_virtualenv',) + \ ('last_update_failed', 'last_updated') # Backwards compatibility - read_only_fields = ('scm_delete_on_next_update',) def get_related(self, obj): res = super(ProjectSerializer, self).get_related(obj) diff --git a/awx/main/migrations/0052_v340_remove_project_scm_delete_on_next_update.py b/awx/main/migrations/0052_v340_remove_project_scm_delete_on_next_update.py new file mode 100644 index 0000000000..2179c21a3b --- /dev/null +++ b/awx/main/migrations/0052_v340_remove_project_scm_delete_on_next_update.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.11 on 2018-05-18 17:49 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0051_v340_job_slicing'), + ] + + operations = [ + migrations.RemoveField( + model_name='project', + name='scm_delete_on_next_update', + ), + ] diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index 3c283e2fd2..f39b949f61 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -254,10 +254,6 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEn on_delete=models.CASCADE, related_name='projects', ) - scm_delete_on_next_update = models.BooleanField( - default=False, - editable=False, - ) scm_update_on_launch = models.BooleanField( default=False, help_text=_('Update the project when a job is launched that uses the project.'), @@ -331,13 +327,6 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEn # if it hasn't been specified, then we're just doing a normal save. update_fields = kwargs.get('update_fields', []) skip_update = bool(kwargs.pop('skip_update', False)) - # Check if scm_type or scm_url changes. - if self.pk: - project_before = self.__class__.objects.get(pk=self.pk) - if project_before.scm_type != self.scm_type or project_before.scm_url != self.scm_url: - self.scm_delete_on_next_update = True - if 'scm_delete_on_next_update' not in update_fields: - update_fields.append('scm_delete_on_next_update') # Create auto-generated local path if project uses SCM. if self.pk and self.scm_type and not self.local_path.startswith('_'): slug_name = slugify(six.text_type(self.name)).replace(u'-', u'_') @@ -397,19 +386,6 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEn def _can_update(self): return bool(self.scm_type) - def _update_unified_job_kwargs(self, create_kwargs, kwargs): - ''' - :param create_kwargs: key-worded arguments to be updated and later used for creating unified job. - :type create_kwargs: dict - :param kwargs: request parameters used to override unified job template fields with runtime values. - :type kwargs: dict - :return: modified create_kwargs. - :rtype: dict - ''' - if self.scm_delete_on_next_update: - create_kwargs['scm_delete_on_update'] = True - return create_kwargs - def create_project_update(self, **kwargs): return self.create_unified_job(**kwargs) @@ -549,17 +525,6 @@ class ProjectUpdate(UnifiedJob, ProjectOptions, JobNotificationMixin, TaskManage def get_ui_url(self): return urlparse.urljoin(settings.TOWER_URL_BASE, "/#/jobs/project/{}".format(self.pk)) - def _update_parent_instance(self): - parent_instance = self._get_parent_instance() - if parent_instance and self.job_type == 'check': - update_fields = self._update_parent_instance_no_save(parent_instance) - if self.status in ('successful', 'failed', 'error', 'canceled'): - if not self.failed and parent_instance.scm_delete_on_next_update: - parent_instance.scm_delete_on_next_update = False - if 'scm_delete_on_next_update' not in update_fields: - update_fields.append('scm_delete_on_next_update') - parent_instance.save(update_fields=update_fields) - def cancel(self, job_explanation=None, is_chain=False): res = super(ProjectUpdate, self).cancel(job_explanation=job_explanation, is_chain=is_chain) if res and self.launch_type != 'sync':