mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 18:50:01 +00:00
AutoPEP8 (after elasticsearch merge)
This commit is contained in:
parent
9ac56ba3d7
commit
4e9409fb30
|
@ -162,7 +162,8 @@ def home(rss):
|
||||||
if not max_search_results:
|
if not max_search_results:
|
||||||
max_search_results = DEFAULT_MAX_SEARCH_RESULT
|
max_search_results = DEFAULT_MAX_SEARCH_RESULT
|
||||||
|
|
||||||
max_page = min(query_args['page'], int(math.ceil(max_search_results / float(per_page)))) # Only allow up to (max_search_results / page) pages
|
# Only allow up to (max_search_results / page) pages
|
||||||
|
max_page = min(query_args['page'], int(math.ceil(max_search_results / float(per_page))))
|
||||||
|
|
||||||
query_args['page'] = max_page
|
query_args['page'] = max_page
|
||||||
query_args['max_search_results'] = max_search_results
|
query_args['max_search_results'] = max_search_results
|
||||||
|
@ -253,7 +254,8 @@ def view_user(user_name):
|
||||||
if not max_search_results:
|
if not max_search_results:
|
||||||
max_search_results = DEFAULT_MAX_SEARCH_RESULT
|
max_search_results = DEFAULT_MAX_SEARCH_RESULT
|
||||||
|
|
||||||
max_page = min(query_args['page'], int(math.ceil(max_search_results / float(per_page)))) # Only allow up to (max_search_results / page) pages
|
# Only allow up to (max_search_results / page) pages
|
||||||
|
max_page = min(query_args['page'], int(math.ceil(max_search_results / float(per_page))))
|
||||||
|
|
||||||
query_args['page'] = max_page
|
query_args['page'] = max_page
|
||||||
query_args['max_search_results'] = max_search_results
|
query_args['max_search_results'] = max_search_results
|
||||||
|
@ -293,6 +295,7 @@ def view_user(user_name):
|
||||||
def _jinja2_filter_rfc822(date, fmt=None):
|
def _jinja2_filter_rfc822(date, fmt=None):
|
||||||
return formatdate(float(date.strftime('%s')))
|
return formatdate(float(date.strftime('%s')))
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter('rfc822_es')
|
@app.template_filter('rfc822_es')
|
||||||
def _jinja2_filter_rfc822(datestr, fmt=None):
|
def _jinja2_filter_rfc822(datestr, fmt=None):
|
||||||
return formatdate(float(datetime.strptime(datestr, '%Y-%m-%dT%H:%M:%S').strftime('%s')))
|
return formatdate(float(datetime.strptime(datestr, '%Y-%m-%dT%H:%M:%S').strftime('%s')))
|
||||||
|
|
|
@ -167,8 +167,8 @@ def search_elastic(term='', user=None, sort='id', order='desc',
|
||||||
s = s[0:per_page]
|
s = s[0:per_page]
|
||||||
else:
|
else:
|
||||||
max_page = min(page, int(math.ceil(max_search_results / float(per_page))))
|
max_page = min(page, int(math.ceil(max_search_results / float(per_page))))
|
||||||
from_idx = (max_page-1)*per_page
|
from_idx = (max_page - 1) * per_page
|
||||||
to_idx = min(max_search_results, max_page*per_page)
|
to_idx = min(max_search_results, max_page * per_page)
|
||||||
s = s[from_idx:to_idx]
|
s = s[from_idx:to_idx]
|
||||||
|
|
||||||
highlight = app.config.get('ENABLE_ELASTIC_SEARCH_HIGHLIGHT')
|
highlight = app.config.get('ENABLE_ELASTIC_SEARCH_HIGHLIGHT')
|
||||||
|
@ -267,10 +267,12 @@ def search_db(term='', user=None, sort='id', order='desc', category='0_0',
|
||||||
|
|
||||||
if not admin:
|
if not admin:
|
||||||
# Hide all DELETED torrents if regular user
|
# Hide all DELETED torrents if regular user
|
||||||
query = query.filter(models.Torrent.flags.op('&')(int(models.TorrentFlags.DELETED)).is_(False))
|
query = query.filter(models.Torrent.flags.op('&')(
|
||||||
|
int(models.TorrentFlags.DELETED)).is_(False))
|
||||||
# If logged in user is not the same as the user being viewed, show only torrents that aren't hidden or anonymous
|
# If logged in user is not the same as the user being viewed, show only torrents that aren't hidden or anonymous
|
||||||
# If logged in user is the same as the user being viewed, show all torrents including hidden and anonymous ones
|
# If logged in user is the same as the user being viewed, show all torrents including hidden and anonymous ones
|
||||||
# On RSS pages in user view, show only torrents that aren't hidden or anonymous no matter what
|
# On RSS pages in user view, show only torrents that aren't hidden or
|
||||||
|
# anonymous no matter what
|
||||||
if not same_user or rss:
|
if not same_user or rss:
|
||||||
query = query.filter(models.Torrent.flags.op('&')(int(models.TorrentFlags.HIDDEN |
|
query = query.filter(models.Torrent.flags.op('&')(int(models.TorrentFlags.HIDDEN |
|
||||||
models.TorrentFlags.ANONYMOUS)).is_(False))
|
models.TorrentFlags.ANONYMOUS)).is_(False))
|
||||||
|
@ -278,7 +280,8 @@ def search_db(term='', user=None, sort='id', order='desc', category='0_0',
|
||||||
else:
|
else:
|
||||||
if not admin:
|
if not admin:
|
||||||
# Hide all DELETED torrents if regular user
|
# Hide all DELETED torrents if regular user
|
||||||
query = query.filter(models.Torrent.flags.op('&')(int(models.TorrentFlags.DELETED)).is_(False))
|
query = query.filter(models.Torrent.flags.op('&')(
|
||||||
|
int(models.TorrentFlags.DELETED)).is_(False))
|
||||||
# If logged in, show all torrents that aren't hidden unless they belong to you
|
# If logged in, show all torrents that aren't hidden unless they belong to you
|
||||||
# On RSS pages, show all public torrents and nothing more.
|
# On RSS pages, show all public torrents and nothing more.
|
||||||
if logged_in_user and not rss:
|
if logged_in_user and not rss:
|
||||||
|
@ -286,7 +289,8 @@ def search_db(term='', user=None, sort='id', order='desc', category='0_0',
|
||||||
(models.Torrent.uploader_id == logged_in_user.id))
|
(models.Torrent.uploader_id == logged_in_user.id))
|
||||||
# Otherwise, show all torrents that aren't hidden
|
# Otherwise, show all torrents that aren't hidden
|
||||||
else:
|
else:
|
||||||
query = query.filter(models.Torrent.flags.op('&')(int(models.TorrentFlags.HIDDEN)).is_(False))
|
query = query.filter(models.Torrent.flags.op('&')(
|
||||||
|
int(models.TorrentFlags.HIDDEN)).is_(False))
|
||||||
|
|
||||||
if main_category:
|
if main_category:
|
||||||
query = query.filter(models.Torrent.main_category_id == main_cat_id)
|
query = query.filter(models.Torrent.main_category_id == main_cat_id)
|
||||||
|
@ -295,7 +299,8 @@ def search_db(term='', user=None, sort='id', order='desc', category='0_0',
|
||||||
(models.Torrent.sub_category_id == sub_cat_id))
|
(models.Torrent.sub_category_id == sub_cat_id))
|
||||||
|
|
||||||
if filter_tuple:
|
if filter_tuple:
|
||||||
query = query.filter(models.Torrent.flags.op('&')(int(filter_tuple[0])).is_(filter_tuple[1]))
|
query = query.filter(models.Torrent.flags.op('&')(
|
||||||
|
int(filter_tuple[0])).is_(filter_tuple[1]))
|
||||||
|
|
||||||
if term:
|
if term:
|
||||||
for item in shlex.split(term, posix=False):
|
for item in shlex.split(term, posix=False):
|
||||||
|
|
|
@ -54,6 +54,7 @@ def get_trackers(torrent):
|
||||||
|
|
||||||
return list(trackers)
|
return list(trackers)
|
||||||
|
|
||||||
|
|
||||||
def get_trackers_magnet():
|
def get_trackers_magnet():
|
||||||
trackers = OrderedSet()
|
trackers = OrderedSet()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue