Added new checker runs for all active drafts with yang modules to the yang link data migration, in order to make sure to have module information available.
- Legacy-Id: 14277
This commit is contained in:
parent
370a0e3d94
commit
b6f0fbd52d
67
ietf/submit/migrations/0023_create_draft_yang_links.py
Normal file
67
ietf/submit/migrations/0023_create_draft_yang_links.py
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.8 on 2017-11-01 14:00
|
||||||
|
from __future__ import unicode_literals, print_function
|
||||||
|
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
import debug # pyflakes:ignore
|
||||||
|
|
||||||
|
from ietf.submit.checkers import DraftYangChecker
|
||||||
|
|
||||||
|
def get_file_name(draft):
|
||||||
|
return os.path.join(settings.INTERNET_DRAFT_PATH, '%s-%s.txt'%(draft.name, draft.rev))
|
||||||
|
|
||||||
|
def forwards(apps, schema_editor):
|
||||||
|
Document = apps.get_model('doc', 'Document')
|
||||||
|
SubmissionCheck = apps.get_model('submit', 'SubmissionCheck')
|
||||||
|
checker = DraftYangChecker()
|
||||||
|
|
||||||
|
for draft in tqdm(Document.objects.filter(type_id='draft', states__slug='active', submission__checks__checker='yang validation').distinct()):
|
||||||
|
submission = draft.submission_set.filter(rev=draft.rev).order_by('-id').first()
|
||||||
|
if submission:
|
||||||
|
prev_check = submission.checks.filter(checker=checker.name).order_by('-id').first()
|
||||||
|
if prev_check and prev_check.message:
|
||||||
|
result = checker.check_file_txt(get_file_name(draft))
|
||||||
|
passed, message, errors, warnings, items = result
|
||||||
|
items = json.loads(json.dumps(items))
|
||||||
|
items['draft'] = draft.name
|
||||||
|
items['rev'] = draft.rev
|
||||||
|
check = SubmissionCheck.objects.create(submission=submission, checker=checker.name, passed=passed,
|
||||||
|
message=message, errors=errors, warnings=warnings, items=items,
|
||||||
|
symbol=checker.symbol)
|
||||||
|
if 'code' in check.items and check.items['code']:
|
||||||
|
code = check.items['code']
|
||||||
|
if 'yang' in code:
|
||||||
|
modules = code['yang']
|
||||||
|
# Yang impact analysis URL
|
||||||
|
draft.documenturl_set.filter(tag_id='yang-impact-analysis').delete()
|
||||||
|
f = settings.SUBMIT_YANG_CATALOG_MODULEARG
|
||||||
|
moduleargs = '&'.join([ f.format(module=m) for m in modules])
|
||||||
|
url = settings.SUBMIT_YANG_CATALOG_IMPACT_URL.format(moduleargs=moduleargs, draft=draft.name)
|
||||||
|
desc = settings.SUBMIT_YANG_CATALOG_IMPACT_DESC.format(modules=','.join(modules), draft=draft.name)
|
||||||
|
draft.documenturl_set.create(url=url, tag_id='yang-impact-analysis', desc=desc)
|
||||||
|
# Yang module metadata URLs
|
||||||
|
old_urls = draft.documenturl_set.filter(tag_id='yang-module-metadata')
|
||||||
|
old_urls.delete()
|
||||||
|
for module in modules:
|
||||||
|
url = settings.SUBMIT_YANG_CATALOG_MODULE_URL.format(module=module)
|
||||||
|
desc = settings.SUBMIT_YANG_CATALOG_MODULE_DESC.format(module=module)
|
||||||
|
draft.documenturl_set.create(url=url, tag_id='yang-module-metadata', desc=desc)
|
||||||
|
|
||||||
|
def backwards(apps, schema_editor):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('submit', '0022_submission_check_json_upgrade'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(forwards, backwards),
|
||||||
|
]
|
Loading…
Reference in a new issue