Skip to content

Commit

Permalink
Issue dropdown generate cover from pages 1 or 2
Browse files Browse the repository at this point in the history
  • Loading branch information
philborman committed Sep 20, 2018
1 parent 382511e commit 59db4d3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 58 deletions.
3 changes: 2 additions & 1 deletion data/interfaces/bookstrap/issues.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ <h1>${title}</h1>
<select name="action" id="action" class="form-control input-sm">
<option value="Remove" selected>Remove</option>
<option value="Delete">Delete</option>
<option value="NewCover">New Cover</option>
<option value="reCover1">Cover Page 1</option>
<option value="reCover2">Cover Page 2</option>
</select>
<button type="submit" class=" btn btn-m btn-primary" onclick="validateForm()">Go</button>
%if lazylibrarian.CONFIG['TOGGLES'] == True:
Expand Down
112 changes: 55 additions & 57 deletions lazylibrarian/webServe.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,13 +956,13 @@ def config(self):
for mag in magazines:
title = mag['Title']
regex = mag['Regex']
if regex is None:
if not regex:
regex = ""
reject = mag['Reject']
if reject is None:
if not reject:
reject = ""
datetype = mag['DateType']
if datetype is None:
if not datetype:
datetype = ""
coverpage = check_int(mag['CoverPage'], 1)
mags_list.append({
Expand Down Expand Up @@ -1212,7 +1212,7 @@ def configUpdate(self, **kwargs):
@cherrypy.expose
def search(self, name):
self.label_thread('SEARCH')
if name is None or not name:
if not name:
raise cherrypy.HTTPRedirect("home")

myDB = database.DBConnection()
Expand Down Expand Up @@ -3289,59 +3289,57 @@ def markIssues(self, action=None, **args):
title = ''
args.pop('book_table_length', None)

for item in args:
issue = myDB.match('SELECT IssueFile,Title,IssueDate from issues WHERE IssueID=?', (item,))
if issue:
title = issue['Title']
if action == 'NewCover':
cmd = 'select coverpage from magazines where Title=?'
res = myDB.match(cmd, (title,))
if res:
createMagCover(issue['IssueFile'], refresh=True, pagenum=check_int(res['coverpage'], 1))
if action == "Delete":
result = self.deleteIssue(issue['IssueFile'])
if result:
logger.info('Issue %s of %s deleted from disc' % (issue['IssueDate'], issue['Title']))
if action == "Remove" or action == "Delete":
myDB.action('DELETE from issues WHERE IssueID=?', (item,))
logger.info('Issue %s of %s removed from database' % (issue['IssueDate'], issue['Title']))
# Set magazine_issuedate to issuedate of most recent issue we have
# Set latestcover to most recent issue cover
# Set magazine_lastacquired to acquired date of most recent issue we have
# Set magazine_added to acquired date of earliest issue we have
cmd = 'select IssueDate,IssueAcquired,IssueFile from issues where title=?'
cmd += ' order by IssueDate '
newest = myDB.match(cmd + 'DESC', (title,))
oldest = myDB.match(cmd + 'ASC', (title,))
controlValueDict = {'Title': title}
if newest and oldest:
old_acquired = ''
new_acquired = ''
cover = ''
issuefile = newest['IssueFile']
if os.path.exists(issuefile):
cover = os.path.splitext(issuefile)[0] + '.jpg'
mtime = os.path.getmtime(issuefile)
new_acquired = datetime.date.isoformat(datetime.date.fromtimestamp(mtime))
issuefile = oldest['IssueFile']
if os.path.exists(issuefile):
mtime = os.path.getmtime(issuefile)
old_acquired = datetime.date.isoformat(datetime.date.fromtimestamp(mtime))

newValueDict = {
'IssueDate': newest['IssueDate'],
'LatestCover': cover,
'LastAcquired': new_acquired,
'MagazineAdded': old_acquired
}
else:
newValueDict = {
'IssueDate': '',
'LastAcquired': '',
'LatestCover': '',
'MagazineAdded': ''
}
myDB.upsert("magazines", newValueDict, controlValueDict)
if action:
for item in args:
issue = myDB.match('SELECT IssueFile,Title,IssueDate from issues WHERE IssueID=?', (item,))
if issue:
title = issue['Title']
if 'reCover' in action:
createMagCover(issue['IssueFile'], refresh=True, pagenum=check_int(action[-1], 1))
if action == "Delete":
result = self.deleteIssue(issue['IssueFile'])
if result:
logger.info('Issue %s of %s deleted from disc' % (issue['IssueDate'], issue['Title']))
if action == "Remove" or action == "Delete":
myDB.action('DELETE from issues WHERE IssueID=?', (item,))
logger.info('Issue %s of %s removed from database' % (issue['IssueDate'], issue['Title']))
# Set magazine_issuedate to issuedate of most recent issue we have
# Set latestcover to most recent issue cover
# Set magazine_lastacquired to acquired date of most recent issue we have
# Set magazine_added to acquired date of earliest issue we have
cmd = 'select IssueDate,IssueAcquired,IssueFile from issues where title=?'
cmd += ' order by IssueDate '
newest = myDB.match(cmd + 'DESC', (title,))
oldest = myDB.match(cmd + 'ASC', (title,))
controlValueDict = {'Title': title}
if newest and oldest:
old_acquired = ''
new_acquired = ''
cover = ''
issuefile = newest['IssueFile']
if os.path.exists(issuefile):
cover = os.path.splitext(issuefile)[0] + '.jpg'
mtime = os.path.getmtime(issuefile)
new_acquired = datetime.date.isoformat(datetime.date.fromtimestamp(mtime))
issuefile = oldest['IssueFile']
if os.path.exists(issuefile):
mtime = os.path.getmtime(issuefile)
old_acquired = datetime.date.isoformat(datetime.date.fromtimestamp(mtime))

newValueDict = {
'IssueDate': newest['IssueDate'],
'LatestCover': cover,
'LastAcquired': new_acquired,
'MagazineAdded': old_acquired
}
else:
newValueDict = {
'IssueDate': '',
'LastAcquired': '',
'LatestCover': '',
'MagazineAdded': ''
}
myDB.upsert("magazines", newValueDict, controlValueDict)
if title:
raise cherrypy.HTTPRedirect("issuePage?title=%s" % quote_plus(title))
else:
Expand Down

0 comments on commit 59db4d3

Please sign in to comment.