Skip to content

Commit

Permalink
Delete unused TestEnvironment{,Category,Element,Map,Property} models
Browse files Browse the repository at this point in the history
these are not used and duplicated by the existing TCMSEnv{Group,Property,Value}
models

    - Delete model TestEnvironment
    - Delete model TestEnvironmentCategory
    - Delete model TestEnvironmentElement
    - Delete model TestEnvironmentMap
    - Delete model TestEnvironmentProperty
  • Loading branch information
atodorov committed Jan 26, 2018
1 parent d83c7f1 commit 9031d02
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 197 deletions.
7 changes: 1 addition & 6 deletions tcms/core/ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def info(request):

class Objects(object):
__all__ = [
'builds', 'categories', 'components', 'envs', 'env_groups',
'builds', 'categories', 'components', 'env_groups',
'env_properties', 'env_values', 'tags', 'users', 'versions'
]

Expand Down Expand Up @@ -101,11 +101,6 @@ def components(self):

return Component.objects.filter(product__id=self.product_id)

def envs(self):
from tcms.management.models import TestEnvironment

return TestEnvironment.objects.filter(product__id=self.product_id)

def env_groups(self):
from tcms.management.models import TCMSEnvGroup

Expand Down
67 changes: 67 additions & 0 deletions tcms/management/migrations/0005_remove_testenvironment_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Generated by Django 2.0.1 on 2018-01-26 12:51
# Removes movels which are not used anywhere and are
# somewhat duplicated by TCMSEnv{Group,Property,Value} models
# which are in active use

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('management', '0004_update_tcmsenvvalue_ordering'),
]

operations = [
migrations.RemoveField(
model_name='testenvironment',
name='product',
),
migrations.AlterIndexTogether(
name='testenvironmentcategory',
index_together=set(),
),
migrations.RemoveField(
model_name='testenvironmentcategory',
name='product',
),
migrations.RemoveField(
model_name='testenvironmentelement',
name='env_category',
),
migrations.RemoveField(
model_name='testenvironmentelement',
name='parent',
),
migrations.RemoveField(
model_name='testenvironmentmap',
name='element',
),
migrations.RemoveField(
model_name='testenvironmentmap',
name='environment',
),
migrations.RemoveField(
model_name='testenvironmentmap',
name='property',
),
migrations.RemoveField(
model_name='testenvironmentproperty',
name='element',
),
migrations.DeleteModel(
name='TestEnvironment',
),
migrations.DeleteModel(
name='TestEnvironmentCategory',
),
migrations.DeleteModel(
name='TestEnvironmentElement',
),
migrations.DeleteModel(
name='TestEnvironmentMap',
),
migrations.DeleteModel(
name='TestEnvironmentProperty',
),
]
83 changes: 0 additions & 83 deletions tcms/management/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,87 +275,8 @@ def get_case_runs_passed_percent(self):
else:
return None

# Test environments zone


class TestEnvironment(TCMSActionModel):
environment_id = models.AutoField(
max_length=10,
primary_key=True
)
product = models.ForeignKey(Product, related_name='environments', on_delete=models.CASCADE)
name = models.CharField(max_length=255, blank=True)
is_active = models.BooleanField(db_column="isactive", default=True)

class Meta:
db_table = u'test_environments'

def __str__(self):
return self.name

def as_choice(self):
return (self.environment_id, self.name)


class TestEnvironmentCategory(models.Model):
env_category_id = models.AutoField(primary_key=True)
product = models.ForeignKey(Product, related_name='environment_categories',
on_delete=models.CASCADE)
name = models.CharField(unique=True, max_length=255, blank=True)

class Meta:
db_table = u'test_environment_category'
index_together = (('env_category_id', 'product'), ('product', 'name'))

def __str__(self):
return self.name


class TestEnvironmentElement(models.Model):
element_id = models.AutoField(max_length=10, primary_key=True)
env_category = models.ForeignKey(TestEnvironmentCategory, on_delete=models.CASCADE)
name = models.CharField(unique=True, max_length=255, blank=True)
parent = models.ForeignKey('self', null=True, related_name='parent_set',
on_delete=models.CASCADE)
is_private = models.BooleanField(db_column='isprivate', default=False)

class Meta:
db_table = u'test_environment_element'

def __str__(self):
return self.name


class TestEnvironmentProperty(models.Model):
property_id = models.IntegerField(primary_key=True)
element = models.ForeignKey(TestEnvironmentElement, on_delete=models.CASCADE)
name = models.CharField(unique=True, max_length=255, blank=True)
valid_express = models.TextField(db_column='validexp', blank=True)

class Meta:
db_table = u'test_environment_property'

def __str__(self):
return self.name


class TestEnvironmentMap(models.Model):
environment = models.ForeignKey(TestEnvironment, on_delete=models.CASCADE)
property = models.ForeignKey(TestEnvironmentProperty, on_delete=models.CASCADE)
element = models.ForeignKey(TestEnvironmentElement, on_delete=models.CASCADE)
value_selected = models.TextField(blank=True)

class Meta:
db_table = u'test_environment_map'
# FIXME: is unique_together against environment and property necessary?

def __str__(self):
return self.value_selected


# Test tag zone


class TestTag(TCMSActionModel):
id = models.AutoField(db_column='tag_id', max_length=10, primary_key=True)
name = models.CharField(db_column='tag_name', max_length=255)
Expand All @@ -376,10 +297,6 @@ def get_or_create_many_by_name(cls, names):
tags.append(new_tag)
return tags

# ============================
# New TCMS Environments models
# ============================


class TCMSEnvGroup(TCMSActionModel):
name = models.CharField(unique=True, max_length=255)
Expand Down
1 change: 0 additions & 1 deletion tcms/static/js/createrun.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Nitrate.CreateRunPage = {
They may not be blank.
*/
bind_build_selector_to_product(false);
// bind_env_selector_to_product(false);
bind_version_selector_to_product(false);

/*
Expand Down
61 changes: 0 additions & 61 deletions tcms/static/js/tcms_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,63 +449,6 @@ function getBuildsByProductId(allow_blank, product_field, build_field, is_active
});
}

function getEnvsByProductId(allow_blank, product_field) {
if (!product_field) {
var product_field = jQ('#id_product')[0];
}

product_id = jQ(product_field).val();
var args = false;
if (jQ('#value_sub_module').length) {
if (jQ('#value_sub_module').val() === 'new_run') {
args = 'is_active';
}
}

if(product_id === '') {
jQ('#id_env_id').html('<option value="">---------</option>');
return true;
}

var success = function(t) {
returnobj = jQ.parseJSON(t.responseText);

debug_output('Get environments succeed get ready to replace the select widget inner html');

set_up_choices(
jQ('#id_env_id')[0],
returnobj.map(function(o) {
return [o.pk, o.fields.name];
}),
allow_blank
);

if (document.title === "Create new test run") {
if (jQ('#id_env_id').html() === '') {
window.alert('You should create new enviroment first before create new run');
}
}
};

var failure = function(jqXHR, textStatus, errorThrown) {
if (jqXHR.readyState != 0 && errorThrown != "") {
alert("Update builds and envs failed");
}
};

var url = Nitrate.http.URLConf.reverse({ name: 'get_product_info' });
new Ajax.Request(url, {
method:'get',
parameters:{
info_type: 'envs',
product_id: product_id,
args: args,
},
requestHeaders: {Accept: 'application/json'},
onSuccess: success,
onFailure: failure
});
}

function getVersionsByProductId(allow_blank, product_field, version_field) {
var product_field = jQ('#id_product')[0];
Expand Down Expand Up @@ -704,10 +647,6 @@ function bind_build_selector_to_product(allow_blank, product_field, build_field,
}
}

function bind_env_selector_to_product(allow_blank) {
jQ('#id_product_id').bind('change', function() { getEnvsByProductId(allow_blank); });
getEnvsByProductId(allow_blank);
}

function bind_version_selector_to_product(allow_blank, load, product_field, version_field) {
var product_field = checkProductField(product_field);
Expand Down
46 changes: 0 additions & 46 deletions tcms/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,52 +115,6 @@ class Meta:
product = factory.SubFactory(ProductFactory)


class TestEnvironmentFactory(DjangoModelFactory):

class Meta:
model = 'management.TestEnvironment'

name = factory.Sequence(lambda n: 'Environment %d' % n)
product = factory.SubFactory(ProductFactory)


class TestEnvironmentCategoryFactory(DjangoModelFactory):

class Meta:
model = 'management.TestEnvironmentCategory'

name = factory.Sequence(lambda n: 'Environment Category %d' % n)
product = factory.SubFactory(ProductFactory)


class TestEnvironmentElementFactory(DjangoModelFactory):

class Meta:
model = 'management.TestEnvironmentElement'

name = factory.Sequence(lambda n: 'Environment Element %d' % n)
env_category = factory.SubFactory(TestEnvironmentCategoryFactory)


class TestEnvironmentPropertyFactory(DjangoModelFactory):

class Meta:
model = 'management.TestEnvironmentProperty'

name = factory.Sequence(lambda n: 'Environment Property %d' % n)
element = factory.SubFactory(TestEnvironmentElementFactory)


class TestEnvironmentMapFactory(DjangoModelFactory):

class Meta:
model = 'management.TestEnvironmentMap'

environment = factory.SubFactory(TestEnvironmentFactory)
property = factory.SubFactory(TestEnvironmentPropertyFactory)
element = factory.SubFactory(TestEnvironmentElementFactory)


class TestTagFactory(DjangoModelFactory):

class Meta:
Expand Down

0 comments on commit 9031d02

Please sign in to comment.