We have to upgrade django-reversion to 1.8 due to upgrading Django, but unfortunately in that same version the author has removed the type field on Version model, without a particularly good explanation as to why. This is really annoying as we were using it to provide a reasonable audit including for deletes. I suspect we'll need to move away from django-reversion and do our own thing in future, but for now at least allow the layer index to keep working.
Signed-off-by: Paul Eggleton <paul.eggle...@linux.intel.com> --- layerindex/views.py | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/layerindex/views.py b/layerindex/views.py index d9480c9..1f42039 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -630,29 +630,30 @@ def annotate_revision(sender, **kwargs): for ver, inst in zip(versions, instances): currentVersion = ver.field_dict modelmeta = ver.content_type.model_class()._meta - if ver.type == reversion.models.VERSION_DELETE: - changelist.append("Deleted %s: %s" % (modelmeta.verbose_name.lower(), ver.object_repr)) + #FIXME modern django-reversion dropped the type field (argh!) + #if ver.type == reversion.models.VERSION_DELETE: + # changelist.append("Deleted %s: %s" % (modelmeta.verbose_name.lower(), ver.object_repr)) + #else: + pastver = reversion.get_for_object(inst) + if pastver:# and ver.type != reversion.models.VERSION_ADD: + pastVersion = pastver[0].field_dict + changes = set(currentVersion.items()) - set(pastVersion.items()) + changedVars = [var[0] for var in changes] + fieldchanges = [] + for field in changedVars: + if field not in ignorefields: + modelfield = modelmeta.get_field(field) + newvalue = currentVersion[field] + if modelfield.choices: + for v in modelfield.choices: + if v[0] == newvalue: + newvalue = v[1] + break + fieldchanges.append("%s to '%s'" % (modelfield.verbose_name.lower(), newvalue)) + if fieldchanges: + changelist.append("Changed %s %s %s" % (modelmeta.verbose_name.lower(), ver.object_repr, ", ".join(fieldchanges))) else: - pastver = reversion.get_for_object(inst) - if pastver and ver.type != reversion.models.VERSION_ADD: - pastVersion = pastver[0].field_dict - changes = set(currentVersion.items()) - set(pastVersion.items()) - changedVars = [var[0] for var in changes] - fieldchanges = [] - for field in changedVars: - if field not in ignorefields: - modelfield = modelmeta.get_field(field) - newvalue = currentVersion[field] - if modelfield.choices: - for v in modelfield.choices: - if v[0] == newvalue: - newvalue = v[1] - break - fieldchanges.append("%s to '%s'" % (modelfield.verbose_name.lower(), newvalue)) - if fieldchanges: - changelist.append("Changed %s %s %s" % (modelmeta.verbose_name.lower(), ver.object_repr, ", ".join(fieldchanges))) - else: - changelist.append("Added %s: %s" % (modelmeta.verbose_name.lower(), ver.object_repr)) + changelist.append("Added %s: %s" % (modelmeta.verbose_name.lower(), ver.object_repr)) comment = '\n'.join(changelist) if not comment: comment = 'No changes' -- 2.5.5 -- _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto