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:
parent
ee606275ad
commit
f74c93e3e7
|
@ -48,10 +48,10 @@ class Diff(object):
|
||||||
return sorted(set(self.old_data) | set(self.new_data), key=lambda x: x.lower())
|
return sorted(set(self.old_data) | set(self.new_data), key=lambda x: x.lower())
|
||||||
|
|
||||||
def old_value(self, field):
|
def old_value(self, field):
|
||||||
return self.old_data[field]
|
return self.old_data.get(field)
|
||||||
|
|
||||||
def new_value(self, field):
|
def new_value(self, field):
|
||||||
return self.new_data[field]
|
return self.new_data.get(field)
|
||||||
|
|
||||||
def values_differ(self, field):
|
def values_differ(self, field):
|
||||||
return self.new_value(field) != self.old_value(field)
|
return self.new_value(field) != self.old_value(field)
|
||||||
|
|
|
@ -28,6 +28,7 @@ from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import logging
|
||||||
|
|
||||||
import six
|
import six
|
||||||
from pip.download import PipSession
|
from pip.download import PipSession
|
||||||
|
@ -46,6 +47,9 @@ from tailbone.views import MasterView3 as MasterView
|
||||||
from tailbone.progress import SessionProgress, get_progress_session
|
from tailbone.progress import SessionProgress, get_progress_session
|
||||||
|
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class UpgradeView(MasterView):
|
class UpgradeView(MasterView):
|
||||||
"""
|
"""
|
||||||
Master view for all user events
|
Master view for all user events
|
||||||
|
@ -227,6 +231,7 @@ class UpgradeView(MasterView):
|
||||||
class_='showing')
|
class_='showing')
|
||||||
return showing + diff.render_html()
|
return showing + diff.render_html()
|
||||||
except:
|
except:
|
||||||
|
log.exception("failed to render package diff for upgrade: {}".format(upgrade))
|
||||||
return "(not available for this upgrade)"
|
return "(not available for this upgrade)"
|
||||||
|
|
||||||
def changelog_link(self, project, url):
|
def changelog_link(self, project, url):
|
||||||
|
@ -264,6 +269,8 @@ class UpgradeView(MasterView):
|
||||||
return field
|
return field
|
||||||
|
|
||||||
def render_diff_value(self, field, value):
|
def render_diff_value(self, field, value):
|
||||||
|
if value is None:
|
||||||
|
return ""
|
||||||
if value.startswith("u'") and value.endswith("'"):
|
if value.startswith("u'") and value.endswith("'"):
|
||||||
return value[2:1]
|
return value[2:1]
|
||||||
return value
|
return value
|
||||||
|
|
Loading…
Reference in a new issue