mylar/data/interfaces/default/index.html

165 lines
7.5 KiB
HTML

<%inherit file="base.html"/>
<%!
from mylar import helpers, db
import datetime
%>
<%def name="body()">
<div class="table_wrapper">
<table class="display" id="artist_table">
<thead>
<tr>
<th id="publisher">Publisher</th>
<th id="name">Comic</th>
<th id="year">Year</th>
<th id="issue">Last Issue</th>
<th id="published">Published</th>
<th id="have">Have</th>
<th id="status">Status</th>
<th id="status">Active</th>
</tr>
</thead>
<tbody>
%for comic in comics:
<%
myDB = db.DBConnection()
issue = myDB.select("SELECT * FROM issues WHERE ComicID=?", [comic['ComicID']])
wantedc = myDB.action("SELECT COUNT(*) as count FROM issues WHERE ComicID=? AND Status='Wanted'", [comic['ComicID']]).fetchone()
if annuals_on:
anwantedc = myDB.action("SELECT COUNT(*) as count FROM annuals WHERE ComicID=? AND Status='Wanted'", [comic['ComicID']]).fetchone()
annual = myDB.action("SELECT COUNT(*) as count FROM annuals WHERE ComicID=?", [comic['ComicID']]).fetchone()
else:
anwantedc = 0
annual = 0
archedc = myDB.action("SELECT COUNT(*) as count FROM issues WHERE ComicID=? AND Status='Archived'", [comic['ComicID']]).fetchone()
if annuals_on:
annualcount = annual[0]
if not annualcount:
annualcount = 0
anns = anwantedc[0]
else:
annualcount = 0
anns = 0
totaltracks = comic['Total'] + annualcount
havetracks = comic['Have']
wants = wantedc[0]
arcs = archedc[0]
if not havetracks:
havetracks = 0
if not wants:
wants = 0
if not anns:
anns = 0
if not arcs:
arcs = 0
try:
wantpercent = (wants*100.0)/totaltracks
if wantpercent > 100:
wantpercent = 100
except (ZeroDivisionError, TypeError):
wantpercent = 0
wants = '?'
try:
percent = (havetracks*100.0)/totaltracks
if percent > 100:
percent = 100
except (ZeroDivisionError, TypeError):
percent = 0
totaltracks = '?'
if comic['Status'] == 'Paused':
grade = 'X'
elif comic['Status'] == 'Loading':
grade = 'L'
elif comic['Status'] == 'Error':
grade = 'X'
else:
grade = 'A'
%>
<tr class="grade${grade}">
<td id="publisher">${comic['ComicPublisher']}</td>
<td id="name"><span title="${comic['ComicSortName']}"></span><a href="comicDetails?ComicID=${comic['ComicID']}">${comic['ComicName']}</a></td>
<td id="year"><span title="${comic['ComicYear']}"></span>${comic['ComicYear']}</td>
<td id="issue"><span title="${comic['LatestIssue']}"></span># ${comic['LatestIssue']}</td>
<td id="published">${comic['LatestDate']}</td>
<td id="have"><span title="${percent}"></span><div class="progress-container"><div style="background-color:#a3e532; height:14px; width:${percent}%"><div class="havetracks">${havetracks}/${totaltracks}</div></div></div></td>
<td id="status">
%if comic['ComicPublished'] is None or comic['ComicPublished'] == '':
Unknown
%elif comic['ForceContinuing'] == 1:
Continuing
%elif 'present' in comic['ComicPublished'].lower() or ( helpers.today()[:4] in comic['LatestDate']):
<%
latestdate = comic['LatestDate']
c_date = datetime.date(int(latestdate[:4]),int(latestdate[5:7]),1)
n_date = datetime.date.today()
recentchk = (n_date - c_date).days
if recentchk < 55:
recentstatus = 'Continuing'
else:
recentstatus = 'Ended'
%>
${recentstatus}
%else:
Ended
%endif
</td>
<td id="active" align="center">
%if comic['Status'] == "Active":
<img src="/interfaces/default/images/checkmark.png" alt="Y" width="16" height="16" />
%else:
<img src="/interfaces/default/images/cross.png" alt="N" width="16" height="16" />
%endif
</td>
</tr>
%endfor
</tbody>
</table>
</div>
</%def>
<%def name="headIncludes()">
<link rel="stylesheet" href="interfaces/default/css/data_table.css">
</%def>
<%def name="javascriptIncludes()">
<script src="js/libs/jquery.dataTables.min.js"></script>
<script>
function initThisPage() {
$('#artist_table').dataTable(
{
"bDestroy": true,
"aoColumnDefs": [
{ 'bSortable': false, 'aTargets': [ 5 ] }
],
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, 'All' ]],
"oLanguage": {
"sLengthMenu":"Show _MENU_ results per page",
"sEmptyTable": "No results",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ results",
"sInfoEmpty":"Showing 0 to 0 of 0 results",
"sInfoFiltered":"(filtered from _MAX_ total results)",
"sSearch" : ""},
"bStateSave": true,
"iDisplayLength": 25,
"sPaginationType": "full_numbers",
"aaSorting": []
});
resetFilters("comic");
}
$(document).ready(function(){
initThisPage();
});
$(window).load(function(){
initFancybox();
});
</script>
</%def>