Skip to content

Commit

Permalink
Add TestExecutionStatus to admin
Browse files Browse the repository at this point in the history
Refs kiwitcms#236

- Add `django-colorfield` to `requirements/base.txt`
- Add `colorfield` to `INSTALLED_APPS`
- Change `TestExecutionStatus::color` from `models.CharField` to
  `colorfield.ColorField`
- Add `Meta` subclass to `TestExecutionStatus`
- Update admin tests to assert that the admin view contains
  `Test execution statuses`
  • Loading branch information
asankov committed Dec 21, 2019
1 parent e8ef245 commit 3393b34
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions requirements/base.txt
Expand Up @@ -6,6 +6,7 @@ django-attachments==1.5
django-contrib-comments==1.9.2
django-modern-rpc==0.12.0
django-simple-history==2.8.0
django-colorfield==0.1.15
jira==2.0.0
Markdown==3.1.1
python-redmine==2.2.1
Expand Down
2 changes: 1 addition & 1 deletion tcms/core/tests/test_admin.py
Expand Up @@ -58,7 +58,7 @@ def test_admin_display(self):
self.assertContains(response, 'Test plans')

# for tcms.testruns
self.assertNotContains(response, 'Test execution status')
self.assertContains(response, 'Test execution statuses')
self.assertContains(response, 'Testruns')
self.assertContains(response, 'Test runs')

Expand Down
1 change: 1 addition & 0 deletions tcms/settings/common.py
Expand Up @@ -257,6 +257,7 @@
'django_comments',
'modernrpc',
'simple_history',
'colorfield',

'tcms.core',
# if you wish to disable Kiwi TCMS bug tracker
Expand Down
3 changes: 2 additions & 1 deletion tcms/testruns/admin.py
Expand Up @@ -5,7 +5,7 @@
from django.utils.translation import ugettext_lazy as _

from tcms.core.history import ReadOnlyHistoryAdmin
from tcms.testruns.models import TestRun
from tcms.testruns.models import TestRun, TestExecutionStatus


class TestRunAdmin(ReadOnlyHistoryAdmin):
Expand All @@ -30,3 +30,4 @@ def delete_view(self, request, object_id, extra_context=None):


admin.site.register(TestRun, TestRunAdmin)
admin.site.register(TestExecutionStatus)
7 changes: 6 additions & 1 deletion tcms/testruns/models.py
Expand Up @@ -8,6 +8,7 @@
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import override
from colorfield.fields import ColorField

from tcms.core.contrib.linkreference.models import LinkReference
from tcms.core.history import KiwiHistoricalRecords
Expand Down Expand Up @@ -235,11 +236,15 @@ def stats_executions_status(self, statuses=None):

class TestExecutionStatus(TCMSActionModel):

class Meta:
# used in the admin view
verbose_name_plural = "Test execution statuses"

id = models.AutoField(db_column='case_run_status_id', primary_key=True)
name = models.CharField(max_length=60, blank=True, unique=True)
weight = models.IntegerField(default=0)
icon = models.CharField(max_length=64)
color = models.CharField(max_length=8)
color = ColorField()

def __str__(self):
return self.name
Expand Down

0 comments on commit 3393b34

Please sign in to comment.