Added migrations for the submit check display work.
- Legacy-Id: 10998
This commit is contained in:
parent
4b0b7e0c58
commit
6b7faf3926
21
ietf/submit/migrations/0007_submission_draft.py
Normal file
21
ietf/submit/migrations/0007_submission_draft.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('doc', '0012_auto_20160207_0537'),
|
||||||
|
('submit', '0006_remove_submission_idnits_message'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='submission',
|
||||||
|
name='draft',
|
||||||
|
field=models.ForeignKey(null=True, blank=True, to='doc.Document'),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,31 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
def populate_submission_draft(apps, schema_editor):
|
||||||
|
Submission = apps.get_model('submit', 'Submission')
|
||||||
|
Document = apps.get_model('doc', 'Document')
|
||||||
|
print("")
|
||||||
|
for submission in Submission.objects.filter(state_id='posted'):
|
||||||
|
if submission.draft == None:
|
||||||
|
try:
|
||||||
|
draft = Document.objects.get(name=submission.name)
|
||||||
|
except Document.DoesNotExist:
|
||||||
|
print( "Failed to find %s-%s" % (submission.name, submission.rev))
|
||||||
|
continue
|
||||||
|
submission.draft = draft
|
||||||
|
submission.save()
|
||||||
|
|
||||||
|
def backward(apps, schema_editor):
|
||||||
|
pass # nothing to do
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('submit', '0007_submission_draft'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(populate_submission_draft, backward)
|
||||||
|
]
|
20
ietf/submit/migrations/0009_submissioncheck_symbol.py
Normal file
20
ietf/submit/migrations/0009_submissioncheck_symbol.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('submit', '0008_data_for_submission_draft_field'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='submissioncheck',
|
||||||
|
name='symbol',
|
||||||
|
field=models.CharField(default=b'', max_length=64),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,32 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
from ietf.submit.checkers import DraftIdnitsChecker, DraftYangChecker
|
||||||
|
|
||||||
|
def set_submission_check_symbol(apps, schema_editor):
|
||||||
|
SubmissionCheck = apps.get_model('submit','SubmissionCheck')
|
||||||
|
for s in SubmissionCheck.objects.all():
|
||||||
|
if not s.symbol:
|
||||||
|
if s.checker == "idnits check":
|
||||||
|
s.symbol = DraftIdnitsChecker.symbol
|
||||||
|
if s.checker == 'yang validation':
|
||||||
|
s.symbol = DraftYangChecker.symbol
|
||||||
|
s.save()
|
||||||
|
|
||||||
|
def backward(apps, schema_editor):
|
||||||
|
SubmissionCheck = apps.get_model('submit','SubmissionCheck')
|
||||||
|
for s in SubmissionCheck.objects.all():
|
||||||
|
if s.symbol != "":
|
||||||
|
s.symbol = ""
|
||||||
|
s.save()
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('submit', '0009_submissioncheck_symbol'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(set_submission_check_symbol, backward)
|
||||||
|
]
|
Loading…
Reference in a new issue