class History(WebRoot): def __init__(self, *args, **kwargs): super(History, self).__init__(*args, **kwargs) self.history = HistoryTool() def index(self): """ Render the history page. [Converted to VueRouter] """ t = PageTemplate(rh=self, filename='index.mako') return t.render() def clearHistory(self): # @TODO: Replace this with DELETE /api/v2/history self.history.clear() ui.notifications.message('History cleared') return self.redirect('/history/') def trimHistory(self): # @TODO: Replace this with DELETE /api/v2/history?gt={days} # gt and lt would be greater than and less than x days old self.history.trim() ui.notifications.message('Removed history entries older than 30 days') return self.redirect('/history/')
class History(WebRoot): def __init__(self, *args, **kwargs): super(History, self).__init__(*args, **kwargs) self.history = HistoryTool() def index(self, limit=None): if limit is None: if app.HISTORY_LIMIT: limit = int(app.HISTORY_LIMIT) else: limit = 100 else: limit = try_int(limit, 100) app.HISTORY_LIMIT = limit app.instance.save_config() history = self.history.get(limit) t = PageTemplate(rh=self, filename='history.mako') submenu = [ {'title': 'Clear History', 'path': 'history/clearHistory', 'icon': 'ui-icon ui-icon-trash', 'class': 'clearhistory', 'confirm': True}, {'title': 'Trim History', 'path': 'history/trimHistory', 'icon': 'menu-icon-cut', 'class': 'trimhistory', 'confirm': True}, ] return t.render(historyResults=history.detailed, compactResults=history.compact, limit=limit, submenu=submenu[::-1], title='History', header='History', topmenu='history', controller='history', action='index') def clearHistory(self): # @TODO: Replace this with DELETE /api/v2/history self.history.clear() ui.notifications.message('History cleared') return self.redirect('/history/') def trimHistory(self): # @TODO: Replace this with DELETE /api/v2/history?gt={days} # gt and lt would be greater than and less than x days old self.history.trim() ui.notifications.message('Removed history entries older than 30 days') return self.redirect('/history/')
class History(WebRoot): def __init__(self, *args, **kwargs): super(History, self).__init__(*args, **kwargs) self.history = HistoryTool() def index(self, limit=None): if limit is None: if app.HISTORY_LIMIT: limit = int(app.HISTORY_LIMIT) else: limit = 100 else: limit = try_int(limit, 100) app.HISTORY_LIMIT = limit app.instance.save_config() history = self.history.get(limit) t = PageTemplate(rh=self, filename='history.mako') submenu = [ {'title': 'Clear History', 'path': 'history/clearHistory', 'icon': 'ui-icon ui-icon-trash', 'class': 'clearhistory', 'confirm': True}, {'title': 'Trim History', 'path': 'history/trimHistory', 'icon': 'menu-icon-cut', 'class': 'trimhistory', 'confirm': True}, ] return t.render(historyResults=history.detailed, compactResults=history.compact, limit=limit, submenu=submenu[::-1], controller='history', action='index') def clearHistory(self): # @TODO: Replace this with DELETE /api/v2/history self.history.clear() ui.notifications.message('History cleared') return self.redirect('/history/') def trimHistory(self): # @TODO: Replace this with DELETE /api/v2/history?gt={days} # gt and lt would be greater than and less than x days old self.history.trim() ui.notifications.message('Removed history entries older than 30 days') return self.redirect('/history/')
def test_get_actions(self): test_cases = { None: [], '': [], 'wrong': [], 'downloaded': Quality.DOWNLOADED, 'Downloaded': Quality.DOWNLOADED, 'snatched': Quality.SNATCHED, 'Snatched': Quality.SNATCHED, } unicode_test_cases = { u'': [], u'wrong': [], u'downloaded': Quality.DOWNLOADED, u'Downloaded': Quality.DOWNLOADED, u'snatched': Quality.SNATCHED, u'Snatched': Quality.SNATCHED, } for tests in test_cases, unicode_test_cases: for (action, result) in iteritems(tests): self.assertEqual(History._get_actions(action), result) # pylint: disable=protected-access
def __init__(self, *args, **kwargs): super(History, self).__init__(*args, **kwargs) self.history = HistoryTool()