Skip to content

Commit

Permalink
Fix invalid CourseUpdate.status model field definition
Browse files Browse the repository at this point in the history
The model field definition used the UpdateStatus enum incorrectly.
The status choices were strings that started with "UpdateStatus.",
e.g., "UpdateStatus.PENDING". The prefix "UpdateStatus" is not
supposed to be saved to the database. It even breaches the max_length
constraint of the CharField, but since SQLite ignores max_length,
this does not cause issues when testing on SQLite.
  • Loading branch information
markkuriekkinen committed Feb 6, 2022
1 parent 44ab3a0 commit 2566888
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion builder/migrations/0003_auto_20210622_0829.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='courseupdate',
name='status',
field=models.CharField(choices=[(builder.models.UpdateStatus('PENDING'), 'PENDING'), (builder.models.UpdateStatus('RUNNING'), 'RUNNING'), (builder.models.UpdateStatus('SUCCESS'), 'SUCCESS'), (builder.models.UpdateStatus('FAILED'), 'FAILED'), (builder.models.UpdateStatus('SKIPPED'), 'SKIPPED')], default=builder.models.UpdateStatus('PENDING'), max_length=10),
field=models.CharField(choices=[('PENDING', 'PENDING'), ('RUNNING', 'RUNNING'), ('SUCCESS', 'SUCCESS'), ('FAILED', 'FAILED'), ('SKIPPED', 'SKIPPED')], default='PENDING', max_length=10),
),
]
18 changes: 18 additions & 0 deletions builder/migrations/0014_auto_20220127_1707.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.26 on 2022-01-27 17:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('builder', '0013_course_webhook_secret'),
]

operations = [
migrations.AlterField(
model_name='courseupdate',
name='status',
field=models.CharField(choices=[('PENDING', 'PENDING'), ('RUNNING', 'RUNNING'), ('SUCCESS', 'SUCCESS'), ('FAILED', 'FAILED'), ('SKIPPED', 'SKIPPED')], default='PENDING', max_length=10),
),
]
2 changes: 1 addition & 1 deletion builder/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CourseUpdate(models.Model):
request_ip = models.CharField(max_length=40)
request_time = models.DateTimeField(auto_now_add=True)
updated_time = models.DateTimeField(default=None, null=True, blank=True)
status = models.CharField(max_length=10, default=UpdateStatus.PENDING, choices=[(tag, tag.value) for tag in UpdateStatus])
status = models.CharField(max_length=10, default=UpdateStatus.PENDING.value, choices=[(tag.value, tag.value) for tag in UpdateStatus])
log = models.TextField(default=None, null=True, blank=True)

class Meta:
Expand Down

0 comments on commit 2566888

Please sign in to comment.