mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-06 05:34:46 +02:00

Make layerupdate collection slightly more reliable and make it easier to see when updates have actually been captured: * Split layerbranch into separate layer and branch fields, since there may not be a layerbranch in existence but we might want to log an error relating to the branch and layer. * Show all layerupdates on the update detail page, not just those with log messages * Record before and after revisions and show these in the update detail and layerupdate detail (with links) * Record return code of update_layer process * Highlight layer updates with a non-zero return code, errors or warnings in the output on the update detail page * Show duration on the layerupdate detail page Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Generated by Django 1.11.12 on 2018-08-13 23:05
|
|
from __future__ import unicode_literals
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
def set_branch_layer(apps, schema_editor):
|
|
LayerUpdate = apps.get_model('layerindex', 'LayerUpdate')
|
|
for layerupdate in LayerUpdate.objects.all():
|
|
layerupdate.branch = layerupdate.layerbranch.branch
|
|
layerupdate.layer = layerupdate.layerbranch.layer
|
|
layerupdate.save()
|
|
|
|
def set_layerbranch(apps, schema_editor):
|
|
LayerUpdate = apps.get_model('layerindex', 'LayerUpdate')
|
|
LayerBranch = apps.get_model('layerindex', 'LayerBranch')
|
|
to_delete = []
|
|
for layerupdate in LayerUpdate.objects.all():
|
|
layerbranch = LayerBranch.objects.filter(layeritem=layerupdate.layer, branch=layerupdate.branch).first()
|
|
if layerbranch:
|
|
layerupdate.layerbranch = layerbranch
|
|
layerupdate.save()
|
|
else:
|
|
# The whole point of splitting layerbranch -> layer,branch was to
|
|
# be able to have records with no corresponding LayerBranch, so we
|
|
# now have to delete any that don't when reversing
|
|
to_delete.append(layerupdate.id)
|
|
for luid in to_delete:
|
|
LayerUpdate.objects.filter(id=luid).delete()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('layerindex', '0021_layerupdate_add_layer_branch'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(set_branch_layer, reverse_code=set_layerbranch),
|
|
]
|