Fix some bugs for rendering upgrade package diffs

in particular, when a new package gets installed and there is no "old"
version for it
This commit is contained in:
Lance Edgar 2017-08-20 13:03:30 -05:00
parent ee606275ad
commit f74c93e3e7
2 changed files with 9 additions and 2 deletions

View file

@ -48,10 +48,10 @@ class Diff(object):
return sorted(set(self.old_data) | set(self.new_data), key=lambda x: x.lower())
def old_value(self, field):
return self.old_data[field]
return self.old_data.get(field)
def new_value(self, field):
return self.new_data[field]
return self.new_data.get(field)
def values_differ(self, field):
return self.new_value(field) != self.old_value(field)

View file

@ -28,6 +28,7 @@ from __future__ import unicode_literals, absolute_import
import os
import re
import logging
import six
from pip.download import PipSession
@ -46,6 +47,9 @@ from tailbone.views import MasterView3 as MasterView
from tailbone.progress import SessionProgress, get_progress_session
log = logging.getLogger(__name__)
class UpgradeView(MasterView):
"""
Master view for all user events
@ -227,6 +231,7 @@ class UpgradeView(MasterView):
class_='showing')
return showing + diff.render_html()
except:
log.exception("failed to render package diff for upgrade: {}".format(upgrade))
return "(not available for this upgrade)"
def changelog_link(self, project, url):
@ -264,6 +269,8 @@ class UpgradeView(MasterView):
return field
def render_diff_value(self, field, value):
if value is None:
return ""
if value.startswith("u'") and value.endswith("'"):
return value[2:1]
return value