Change order of snatched provider images to chronological on History layout compact and add ordinal indicators in the tooltips.

Change code clean up, pep8.
This commit is contained in:
JackDandy 2015-03-31 01:07:24 +01:00
parent 86443c21ca
commit b85f81b441
3 changed files with 217 additions and 174 deletions

View file

@ -121,6 +121,7 @@
* Fix correctly display show runtime when available on the displayShow page
* Fix correctly initialise IMDb id loaded from db
* Fix loading shows from the DB that have NULL IMDb id
* Change order of snatched provider images to chronological on History layout compact and add ordinal indicators in the tooltips
### 0.7.2 (2015-03-10 17:05:00 UTC)

View file

@ -1988,6 +1988,33 @@ h2.day, h2.network{
top:0
}
/* =======================================================================
history.tmpl
========================================================================== */
#historyTable td,
#historyTable td.provider span{
text-align:center
}
#historyTable td.provider img{
margin-right:3px
}
#historyTable td img,
#historyTable td span{
vertical-align:middle
}
#historyTable td img.help,
#historyTable td span.help{
cursor:help
}
#historyTable td.tvShow{
text-align:left
}
/* =======================================================================
cache.tmpl
========================================================================== */

View file

@ -7,13 +7,13 @@
#from sickbeard import sbdatetime
#from sickbeard.providers import generic
#from sickbeard.common import *
#set global $title="History"
#set global $header="History"
#set global $sbPath=".."
#set global $topmenu="history"#
#set global $title = 'History'
#set global $header = 'History'
#set global $sbPath = '..'
#set global $topmenu = 'history'
#set $layout = $sickbeard.HISTORY_LAYOUT
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_top.tmpl")
#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_top.tmpl')
<style type="text/css">
.sort_data {display:none}
@ -23,93 +23,93 @@
<!--
\$.tablesorter.addParser({
id: 'cDate',
is: function(s) {
return false;
},
format: function(s) {
return s;
},
type: 'numeric'
id: 'cDate',
is: function(s) {
return false;
},
format: function(s) {
return s;
},
type: 'numeric'
});
\$(document).ready(function()
{
\$("#historyTable:has(tbody tr)").tablesorter({
widgets: ['zebra', 'filter'],
sortList: [[0,1]],
textExtraction: {
#if ( $layout == 'detailed'):
0: function(node) { return \$(node).find("span").text().toLowerCase(); },
4: function(node) { return \$(node).find("span").text().toLowerCase(); }
#else
0: function(node) { return \$(node).find("span").text().toLowerCase(); },
1: function(node) { return \$(node).find("span").text().toLowerCase(); },
2: function(node) { return \$(node).attr("provider").toLowerCase(); },
5: function(node) { return \$(node).attr("quality").toLowerCase(); }
#end if
},
headers: {
#if ( $layout == 'detailed'):
0: { sorter: 'cDate' },
4: { sorter: 'quality' }
#else
0: { sorter: 'cDate' },
4: { sorter: false },
5: { sorter: 'quality' }
#end if
}
});
\$('#limit').change(function(){
url = '$sbRoot/history/?limit='+\$(this).val()
window.location.href = url
});
\$(document).ready(function()
{
\$('#historyTable:has(tbody tr)').tablesorter({
widgets: ['zebra', 'filter'],
sortList: [[0, 1]],
textExtraction: {
0: function(node) { return \$(node).find('span').text().toLowerCase(); },
#if ('detailed' == $layout)
4: function(node) { return \$(node).find('span').text().toLowerCase(); }
#else
1: function(node) { return \$(node).find('span').text().toLowerCase(); },
2: function(node) { return \$(node).attr('provider').toLowerCase(); },
5: function(node) { return \$(node).attr('quality').toLowerCase(); }
#end if
},
headers: {
0: { sorter: 'cDate' },
#if ('detailed' == $layout)
4: { sorter: 'quality' }
#else
4: { sorter: false },
5: { sorter: 'quality' }
#end if
}
#set $fuzzydate = 'airdate'
#if $sickbeard.FUZZY_DATING:
fuzzyMoment({
containerClass : '.${fuzzydate}',
dateHasTime : true,
dateFormat : '${sickbeard.DATE_PRESET}',
timeFormat : '${sickbeard.TIME_PRESET_W_SECONDS}',
trimZero : #if $sickbeard.TRIM_ZERO then "true" else "false"#,
dtGlue : ', ',
});
#end if
});
\$('#limit').change(function(){
url = '$sbRoot/history/?limit=' + \$(this).val()
window.location.href = url
});
#set $fuzzydate = 'airdate'
#if $sickbeard.FUZZY_DATING
fuzzyMoment({
containerClass : '.${fuzzydate}',
dateHasTime : true,
dateFormat : '${sickbeard.DATE_PRESET}',
timeFormat : '${sickbeard.TIME_PRESET_W_SECONDS}',
trimZero : #echo ('false', 'true')[$sickbeard.TRIM_ZERO]#,
dtGlue : ', '
});
#end if
});
//-->
</script>
#if $varExists('header')
<h1 class="header">$header</h1>
#else
<h1 class="title">$title</h1>
#if $varExists('header')
<h1 class="header">$header</h1>
#else
<h1 class="title">$title</h1>
#end if
<div class="h2footer pull-right"><b>Limit:</b>
<select name="limit" id="limit" class="form-control form-control-inline input-sm">
<option value="100" #if $limit == "100" then "selected=\"selected\"" else ""#>100</option>
<option value="250" #if $limit == "250" then "selected=\"selected\"" else ""#>250</option>
<option value="500" #if $limit == "500" then "selected=\"selected\"" else ""#>500</option>
<option value="0" #if $limit == "0" then "selected=\"selected\"" else ""#>All</option>
</select>
#set $html_selected = ' selected="selected"'
<span> Layout:
<select name="HistoryLayout" class="form-control form-control-inline input-sm" onchange="location = this.options[this.selectedIndex].value;">
<option value="$sbRoot/setHistoryLayout/?layout=compact" #if $sickbeard.HISTORY_LAYOUT == "compact" then "selected=\"selected\"" else ""#>Compact</option>
<option value="$sbRoot/setHistoryLayout/?layout=detailed" #if $sickbeard.HISTORY_LAYOUT == "detailed" then "selected=\"selected\"" else ""#>Detailed</option>
<div class="h2footer pull-right">Limit:
<select name="limit" id="limit" class="form-control form-control-inline input-sm">
<option value="100"#echo ('', $html_selected)['100' == $limit]#>100</option>
<option value="250"#echo ('', $html_selected)['250' == $limit]#>250</option>
<option value="500"#echo ('', $html_selected)['500' == $limit]#>500</option>
<option value="0"#echo ('', $html_selected)['0' == $limit]#>All</option>
</select>
</span>
</div>
<br>
#if $layout == "detailed"
<table id="historyTable" class="sickbeardTable tablesorter" cellspacing="1" border="0" cellpadding="0">
<span style="margin-left:5px">Layout:
<select name="HistoryLayout" class="form-control form-control-inline input-sm" onchange="location = this.options[this.selectedIndex].value">
<option value="$sbRoot/setHistoryLayout/?layout=compact"#echo ('', $html_selected)['compact' == $sickbeard.HISTORY_LAYOUT]#>Compact</option>
<option value="$sbRoot/setHistoryLayout/?layout=detailed"#echo ('', $html_selected)['detailed' == $sickbeard.HISTORY_LAYOUT]#>Detailed</option>
</select>
</span>
</div>
<br>
<table id="historyTable" class="sickbeardTable tablesorter $layout" cellspacing="1" border="0" cellpadding="0">
#if 'detailed' == $layout
<thead>
<tr>
<th class="nowrap">Time</th>
<th>Episode</th>
<th width="35%">Episode</th>
<th>Action</th>
<th>Provider</th>
<th>Quality</th>
@ -121,127 +121,142 @@
<th class="nowrap" colspan="5">&nbsp;</th>
</tr>
</tfoot>
<tbody>
#for $hItem in $historyResults:
#set $curStatus, $curQuality = $Quality.splitCompositeStatus(int($hItem["action"]))
#for $hItem in $historyResults
#set $curStatus, $curQuality = $Quality.splitCompositeStatus(int($hItem['action']))
<tr>
#set $curdatetime = $datetime.datetime.strptime(str($hItem["date"]), $history.dateFormat)
<td align="center"><div class="${fuzzydate}">$sbdatetime.sbdatetime.sbfdatetime($curdatetime, show_seconds=True)</div><span class="sort_data">$time.mktime($curdatetime.timetuple())</span></td>
<td class="tvShow" width="35%"><a href="$sbRoot/home/displayShow?show=$hItem["showid"]#season-$hItem["season"]">$hItem["show_name"] - <%="S%02i" % int(hItem["season"])+"E%02i" % int(hItem["episode"]) %>#if "proper" in $hItem["resource"].lower or "repack" in $hItem["resource"].lower then ' <span class="quality Proper">Proper</span>' else ""#</a></td>
<td align="center" #if $curStatus == SUBTITLED then 'class="subtitles_column"' else ''#>
#if $curStatus == SUBTITLED:
<img width="16" height="11" style="vertical-align:middle;" src="$sbRoot/images/flags/<%= hItem["resource"][len(hItem["resource"])-6:len(hItem["resource"])-4]+'.png'%>">
#end if
<span style="cursor: help; vertical-align:middle;" title="$os.path.basename($hItem["resource"])">$statusStrings[$curStatus]</span>
#set $curdatetime = $datetime.datetime.strptime(str($hItem['date']), $history.dateFormat)
<td><div class="${fuzzydate}">$sbdatetime.sbdatetime.sbfdatetime($curdatetime, show_seconds=True)</div><span class="sort_data">$time.mktime($curdatetime.timetuple())</span></td>
<td class="tvShow"><a href="$sbRoot/home/displayShow?show=$hItem['showid']#season-$hItem['season']">$hItem['show_name'] - <%= 'S%02i' % int(hItem['season']) + 'E%02i' % int(hItem['episode']) %>#if 'proper' in $hItem['resource'].lower or 'repack' in $hItem['resource'].lower then ' <span class="quality Proper">Proper</span>' else ''#</a></td>
<td#echo ('', ' class="subtitles_column"')[$curStatus == SUBTITLED]#>
#if SUBTITLED == $curStatus
<img width="16" height="11" src="$sbRoot/images/flags/<%= hItem["resource"][len(hItem["resource"])-6:len(hItem["resource"])-4] + '.png' %>">
#end if
<span class="help" title="$os.path.basename($hItem["resource"])">$statusStrings[$curStatus]</span>
</td>
<td align="center">
#if $curStatus == DOWNLOADED:
#if $hItem["provider"] != "-1":
<span style="vertical-align:middle;"><i>$hItem["provider"]</i></span>
#end if
#else
#if $hItem["provider"] > 0
#if $curStatus in [SNATCHED, FAILED]:
#set $provider = $providers.getProviderClass($generic.GenericProvider.makeID($hItem["provider"]))
#if $provider != None:
<img src="$sbRoot/images/providers/<%=provider.imageName()%>" width="16" height="16" style="vertical-align:middle;" /> <span style="vertical-align:middle;">$provider.name</span>
#else:
<img src="$sbRoot/images/providers/missing.png" width="16" height="16" style="vertical-align:middle;" title="missing provider"/> <span style="vertical-align:middle;">Missing Provider</span>
#end if
#else:
<img src="$sbRoot/images/subtitles/<%=hItem["provider"]+'.png' %>" width="16" height="16" style="vertical-align:middle;" /> <span style="vertical-align:middle;"><%=hItem["provider"].capitalize()%></span>
#end if
#end if
#end if
<td class="provider">
#if DOWNLOADED == $curStatus
#if '-1' != $hItem['provider']
<span><i>$hItem['provider']</i></span>
#end if
#else
#if 0 < $hItem['provider']
#if $curStatus in [SNATCHED, FAILED]
#set $provider = $providers.getProviderClass($generic.GenericProvider.makeID($hItem['provider']))
#if None is not $provider
<img src="$sbRoot/images/providers/<%= provider.imageName() %>" width="16" height="16" /><span>$provider.name</span>
#else
<img src="$sbRoot/images/providers/missing.png" width="16" height="16" title="missing provider" /><span>Missing Provider</span>
#end if
#else
<img src="$sbRoot/images/subtitles/<%= hItem['provider']+'.png' %>" width="16" height="16" /><span><%= hItem['provider'].capitalize() %></span>
#end if
#end if
#end if
</td>
<span style="display: none;">$curQuality</span>
<td align="center"><span class="quality $Quality.qualityStrings[$curQuality].replace("720p","HD720p").replace("1080p","HD1080p").replace("RawHD TV", "RawHD").replace("HD TV", "HD720p")">$Quality.qualityStrings[$curQuality]</span></td>
<td><span style="display:none">$curQuality</span><span class="quality $Quality.qualityStrings[$curQuality].replace('720p', 'HD720p').replace('1080p', 'HD1080p').replace('RawHD TV', 'RawHD').replace('HD TV', 'HD720p')">$Quality.qualityStrings[$curQuality]</span></td>
</tr>
#end for
</tbody>
</table>
#end for
#else:
<table id="historyTable" class="sickbeardTable tablesorter" cellspacing="1" border="0" cellpadding="0">
#else
<thead>
<tr>
<th class="nowrap">Time</th>
<th>Episode</th>
<th width="#echo '3%s%%' % ('5', '0')[sickbeard.USE_SUBTITLES]#">Episode</th>
<th>Snatched</th>
<th>Downloaded</th>
#if sickbeard.USE_SUBTITLES
#if sickbeard.USE_SUBTITLES
<th>Subtitled</th>
#end if
<th>Quality</th>
#end if
<th width="14%">Quality</th>
</tr>
</thead>
<tfoot>
<tr>
<th class="nowrap" colspan="6">&nbsp;</th>
</tr>
</tfoot>
<tbody>
#for $hItem in $compactResults:
#for $hItem in $compactResults
#set $curdatetime = $datetime.datetime.strptime(str($hItem['actions'][0]['time']), $history.dateFormat)
#set $prov_list = []
#set $down_list = []
#set $order = 1
#set $ordinal_indicators = {'1':'st', '2':'nd', '3':'rd'}
#for $action in reversed($hItem['actions'])
#set $curStatus, $curQuality = $Quality.splitCompositeStatus(int($action['action']))
#set $basename = $os.path.basename($action['resource'])
#if $curStatus in [SNATCHED, FAILED]
#set $provider = $providers.getProviderClass($generic.GenericProvider.makeID($action['provider']))
#if None is not $provider
#set $prov_list += ['<img class="help" src="%s/images/providers/%s" width="16" height="16" alt="%s" title="%s%s.. %s: %s" />'\
% ($sbRoot, $provider.imageName(), $provider.name, $order,
'th' if str($order)[-1] not in $ordinal_indicators else $ordinal_indicators[str($order)[-1]],
$provider.name, $basename)]
#set $order += 1
#else
#set $prov_list += ['<img src="%s/images/providers/missing.png" width="16" height="16" alt="missing provider" title="missing provider" />'\
% $sbRoot]
#end if
#end if
#if DOWNLOADED == $curStatus
#set $match = $re.search('\-(\w+)\.\w{3}\Z', $basename)
#set $non_scene_note = ''
#if not $match
## This fallback is for when idiots add a space and word to a release group. The space is converted
## to '\' which makes the regex parsing the scene group name fail, therefore we arrive here.
## A better solution would be to find where such data is parsed and saved to the db and perhaps
## fix at that point. But, in the meantime...
#set $non_scene_resource = re.sub(r'(\-\w+)([\\]\w+)?(\.\w{3})\Z', r'\1\3', $action['resource'])
#if $non_scene_resource
#set $non_scene_note = ' (Non scene name: %s)' % $action['resource'].partition('-')[-1]
#set $basename = $os.path.basename($non_scene_resource)
#set $match = $re.search('\-(\w+)\.\w{3}\Z', $basename)
#end if
#end if
#if $match
#if $match.group(1).upper() in ('X264', '720P')
#set $match = $re.search('(\w+)\-.*\-' + $match.group(1) + '\.\w{3}\Z', $os.path.basename($hItem['resource']), re.I)
#end if
#if $match
#set $down_list += ['<span class="help" title="%s%s"><i>%s</i></span>'\
% ($basename, $non_scene_note, $match.group(1).upper())]
#end if
#end if
#end if
#end for
<tr>
#set $curdatetime = $datetime.datetime.strptime(str($hItem["actions"][0]["time"]), $history.dateFormat)
<td align="center"><div class="${fuzzydate}">$sbdatetime.sbdatetime.sbfdatetime($curdatetime, show_seconds=True)</div><span class="sort_data">$time.mktime($curdatetime.timetuple())</span></td>
<td class="tvShow" width="25%">
<span><a href="$sbRoot/home/displayShow?show=$hItem["show_id"]#season-$hItem["season"]">$hItem["show_name"] - <%="S%02i" % int(hItem["season"])+"E%02i" % int(hItem["episode"]) %>#if "proper" in $hItem["resource"].lower or "repack" in $hItem["resource"].lower then ' <span class="quality Proper">Proper</span>' else ""#</a></span>
<td><div class="${fuzzydate}">$sbdatetime.sbdatetime.sbfdatetime($curdatetime, show_seconds=True)</div><span class="sort_data">$time.mktime($curdatetime.timetuple())</span></td>
<td class="tvShow">
<span><a href="$sbRoot/home/displayShow?show=$hItem['show_id']#season-$hItem['season']">$hItem['show_name'] - <%= 'S%02i' % int(hItem['season']) + 'E%02i' % int(hItem['episode']) %>#if 'proper' in $hItem['resource'].lower or 'repack' in $hItem['resource'].lower then ' <span class="quality Proper">Proper</span>' else ''#</a></span>
</td>
<td align="center" provider="<%=str(sorted(hItem["actions"])[0]["provider"])%>">
#for $action in sorted($hItem["actions"]):
#set $curStatus, $curQuality = $Quality.splitCompositeStatus(int($action["action"]))
#if $curStatus in [SNATCHED, FAILED]:
#set $provider = $providers.getProviderClass($generic.GenericProvider.makeID($action["provider"]))
#if $provider != None:
<img src="$sbRoot/images/providers/<%=provider.imageName()%>" width="16" height="16" style="vertical-align:middle;" alt="$provider.name" style="cursor: help;" title="$provider.name: $os.path.basename($action["resource"])"/>
#else:
<img src="$sbRoot/images/providers/missing.png" width="16" height="16" style="vertical-align:middle;" alt="missing provider" title="missing provider"/>
#end if
#end if
#end for
</td>
<td align="center">
#for $action in sorted($hItem["actions"]):
#set $curStatus, $curQuality = $Quality.splitCompositeStatus(int($action["action"]))
#if $curStatus == DOWNLOADED:
#set $match = $re.search("\-(\w+)\.\w{3}\Z", $os.path.basename($action["resource"]))
#if $match
#if $match.group(1).upper() in ("X264", "720P"):
#set $match = $re.search("(\w+)\-.*\-"+$match.group(1)+"\.\w{3}\Z", $os.path.basename($hItem["resource"]), re.IGNORECASE)
#if $match
<span style="cursor: help;" title="$os.path.basename($action["resource"])"><i>$match.group(1).upper()</i></span>
#end if
#else:
<span style="cursor: help;" title="$os.path.basename($action["resource"])"><i>$match.group(1).upper()</i></span>
#end if
#end if
#end if
#end for
<td class="provider" provider="<%= str(sorted(hItem['actions'])[0]['provider']) %>">
#echo ''.join($prov_list)#
</td>
#if sickbeard.USE_SUBTITLES:
<td align="center">
#for $action in sorted($hItem["actions"]):
#set $curStatus, $curQuality = $Quality.splitCompositeStatus(int($action["action"]))
#if $curStatus == SUBTITLED:
<img src="$sbRoot/images/subtitles/<%=action["provider"]+'.png' %>" width="16" height="16" style="vertical-align:middle;" alt="$action["provider"]" title="<%=action["provider"].capitalize()%>: $os.path.basename($action["resource"])"/>
<span style="vertical-align:middle;"> / </span>
<img width="16" height="11" style="vertical-align:middle;" src="$sbRoot/images/flags/<%= action["resource"][len(action["resource"])-6:len(action["resource"])-4]+'.png'%>" style="vertical-align: middle !important;">
&nbsp;
#end if
#end for
<td>
#echo ' '.join($down_list)#
</td>
#end if
<td align="center" width="14%" quality="$curQuality"><span class="quality $Quality.qualityStrings[$curQuality].replace("720p","HD720p").replace("1080p","HD1080p").replace("RawHD TV", "RawHD").replace("HD TV", "HD720p")">$Quality.qualityStrings[$curQuality]</span></td>
#if sickbeard.USE_SUBTITLES
<td>
#for $action in reversed($hItem['actions'])
#set $curStatus, $curQuality = $Quality.splitCompositeStatus(int($action['action']))
#if SUBTITLED == $curStatus
<img src="$sbRoot/images/subtitles/<%= action['provider'] + '.png' %>" width="16" height="16" alt="$action['provider']" title="<%= action['provider'].capitalize() %>:$os.path.basename($action['resource'])" />
<span> / </span>
<img width="16" height="11" src="$sbRoot/images/flags/<%= action['resource'][len(action['resource'])-6:len(action['resource'])-4] + '.png' %>" style="vertical-align:middle !important">
&nbsp;
#end if
#end for
</td>
#end if
<td quality="$curQuality"><span class="quality $Quality.qualityStrings[$curQuality].replace('720p', 'HD720p').replace('1080p', 'HD1080p').replace('RawHD TV', 'RawHD').replace('HD TV', 'HD720p')">$Quality.qualityStrings[$curQuality]</span></td>
</tr>
#end for
</tbody>
</table>
#end for
#end if
#include $os.path.join($sickbeard.PROG_DIR,"gui/slick/interfaces/default/inc_bottom.tmpl")
</tbody>
</table>
#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl')