Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CharField.choices for Build.status_code #7166

Merged
merged 3 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion readthedocs/builds/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,9 @@
SEMVER_VERSIONS: SEMVER_VERSIONS_REGEX,
}

BUILD_STATUS_CODE_DUPLICATED_BUILD = 0
BUILD_STATUS_CODE_NORMAL = 'normal'
BUILD_STATUS_CODE_DUPLICATED = 'duplicated'
BUILD_STATUS_CODE_CHOICES = (
(BUILD_STATUS_CODE_NORMAL, 'Normal'),
(BUILD_STATUS_CODE_DUPLICATED, 'Duplicated'),
)
18 changes: 18 additions & 0 deletions readthedocs/builds/migrations/0024_status_code_choices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.12 on 2020-06-08 17:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('builds', '0023_add_status_code'),
]

operations = [
migrations.AlterField(
model_name='build',
name='status_code',
field=models.CharField(blank=True, choices=[('normal', 'Normal'), ('duplicated', 'Duplicated')], default=None, max_length=32, null=True, verbose_name='Status code'),
),
]
10 changes: 9 additions & 1 deletion readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
BUILD_STATE_FINISHED,
BUILD_STATE_TRIGGERED,
BUILD_TYPES,
BUILD_STATUS_CODE_CHOICES,
EXTERNAL,
GENERIC_EXTERNAL_VERSION_NAME,
GITHUB_EXTERNAL_VERSION_NAME,
Expand Down Expand Up @@ -615,7 +616,14 @@ class Build(models.Model):
choices=BUILD_STATE,
default='finished',
)
status_code = models.BooleanField(_('Status code'), null=True, default=None, blank=True)
status_code = models.CharField(
humitos marked this conversation as resolved.
Show resolved Hide resolved
_('Status code'),
choices=BUILD_STATUS_CODE_CHOICES,
max_length=32,
null=True,
default=None,
blank=True,
)
date = models.DateTimeField(_('Date'), auto_now_add=True)
success = models.BooleanField(_('Success'), default=True)

Expand Down
4 changes: 2 additions & 2 deletions readthedocs/doc_builder/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Exceptions raised when building documentation."""

from django.utils.translation import ugettext_noop
from readthedocs.builds.constants import BUILD_STATUS_CODE_DUPLICATED_BUILD
from readthedocs.builds.constants import BUILD_STATUS_CODE_DUPLICATED


class BuildEnvironmentException(Exception):
Expand Down Expand Up @@ -61,7 +61,7 @@ class BuildMaxConcurrencyError(BuildEnvironmentError):
class DuplicatedBuildError(BuildEnvironmentError):
message = ugettext_noop('Duplicated build.')
exit_code = 1
status_code = BUILD_STATUS_CODE_DUPLICATED_BUILD
status_code = BUILD_STATUS_CODE_DUPLICATED


class BuildEnvironmentWarning(BuildEnvironmentException):
Expand Down