diff --git a/pandora/item/models.py b/pandora/item/models.py
index 0b414fecb..001118045 100644
--- a/pandora/item/models.py
+++ b/pandora/item/models.py
@@ -256,6 +256,18 @@ class Item(models.Model):
self.external_data = data
self.save()
+ def expand_connections(self):
+ c = self.get('connections')
+ connections = {}
+ if c:
+ for t in c:
+ connections[t] = [{'item': l.itemId, 'title': l.get('title')}
+ for l in Item.objects.filter(itemId__in=c[t])]
+ connections[t].sort(key=lambda a: c[t].index(a['item']))
+ if not connections[t]:
+ del connections[t]
+ return connections
+
def __unicode__(self):
year = self.get('year')
if year:
@@ -441,6 +453,9 @@ class Item(models.Model):
if 'cast' in i and isinstance(i['cast'][0], list):
i['cast'] = map(lambda x: {'actor': x[0], 'character': x[1]}, i['cast'])
+ if 'connections' in i:
+ i['connections'] = self.expand_connections()
+
if not keys or 'posterRatio' in keys:
i['posterRatio'] = self.poster_width / self.poster_height
diff --git a/static/js/pandora/ui/infoView.js b/static/js/pandora/ui/infoView.js
index 4b935d5cb..b6f5f0cf2 100644
--- a/static/js/pandora/ui/infoView.js
+++ b/static/js/pandora/ui/infoView.js
@@ -304,7 +304,7 @@ pandora.ui.infoView = function(data) {
'Spoofs', 'Spoofed in'
].forEach(function(key) {
data.connections[key] && html.push(
- formatKey(key) + formatValue(data.connections[key])
+ formatKey(key) + formatConnections(data.connections[key])
);
});
$div.html(html.join('; '));
@@ -352,6 +352,12 @@ pandora.ui.infoView = function(data) {
return '' + str + '';
}
+ function formatConnections(connections) {
+ return connections.map(function(c) {
+ return '' + c.title + '';
+ }).join(', ');
+ }
+
function formatValue(value, key) {
return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ?