Merge pull request #160 from nyaadevs/pep8-fixes

Fix lint errors
This commit is contained in:
katnyaa 2017-05-22 14:13:47 +00:00 committed by GitHub
commit 34031126ed
4 changed files with 10 additions and 8 deletions

View File

@ -107,7 +107,7 @@ def api_upload(upload_request, user):
return flask.make_response(flask.jsonify( return flask.make_response(flask.jsonify(
{'Failure': ['No torrent file was attached.']}), 400) {'Failure': ['No torrent file was attached.']}), 400)
form = forms.UploadForm(CombinedMultiDict((torrent_file, form_info)), meta={'csrf':False}) form = forms.UploadForm(CombinedMultiDict((torrent_file, form_info)), meta={'csrf': False})
form.category.choices = _create_upload_category_choices() form.category.choices = _create_upload_category_choices()
if upload_request.method == 'POST' and form.validate(): if upload_request.method == 'POST' and form.validate():
@ -138,7 +138,7 @@ UPLOAD_API_FORM_KEYMAP = {
} }
UPLOAD_API_FORM_KEYMAP_REVERSE = {v: k for k, v in UPLOAD_API_FORM_KEYMAP.items()} UPLOAD_API_FORM_KEYMAP_REVERSE = {v: k for k, v in UPLOAD_API_FORM_KEYMAP.items()}
UPLOAD_API_DEFAULTS = { UPLOAD_API_DEFAULTS = {
'name' : '', 'name': '',
'category': '', 'category': '',
'anonymous': False, 'anonymous': False,
'hidden': False, 'hidden': False,
@ -169,7 +169,7 @@ def v2_api_upload():
mapped_dict[mapped_key] = request_data.get(key, default) mapped_dict[mapped_key] = request_data.get(key, default)
# Flask-WTF (very helpfully!!) automatically grabs the request form, so force a None formdata # Flask-WTF (very helpfully!!) automatically grabs the request form, so force a None formdata
upload_form = forms.UploadForm(None, data=mapped_dict, meta={'csrf':False}) upload_form = forms.UploadForm(None, data=mapped_dict, meta={'csrf': False})
upload_form.category.choices = _create_upload_category_choices() upload_form.category.choices = _create_upload_category_choices()
if upload_form.validate(): if upload_form.validate():
@ -193,7 +193,7 @@ def v2_api_upload():
# #################################### TEMPORARY #################################### # #################################### TEMPORARY ####################################
from orderedset import OrderedSet from orderedset import OrderedSet # noqa: E402
@api_blueprint.route('/ghetto_import', methods=['POST']) @api_blueprint.route('/ghetto_import', methods=['POST'])

View File

@ -73,7 +73,7 @@ def handle_torrent_upload(upload_form, uploading_user=None, fromAPI=False):
# Copy trusted status from user if possible # Copy trusted status from user if possible
can_mark_trusted = uploading_user and uploading_user.is_trusted can_mark_trusted = uploading_user and uploading_user.is_trusted
# To do, automatically mark trusted if user is trusted unless user specifies otherwise # To do, automatically mark trusted if user is trusted unless user specifies otherwise
torrent.trusted = upload_form.is_trusted.data if can_mark_trusted else False torrent.trusted = upload_form.is_trusted.data if can_mark_trusted else False
# Set category ids # Set category ids
torrent.main_category_id, torrent.sub_category_id = \ torrent.main_category_id, torrent.sub_category_id = \

View File

@ -166,7 +166,6 @@ class EditForm(FlaskForm):
class UploadForm(FlaskForm): class UploadForm(FlaskForm):
torrent_file = FileField('Torrent file', [ torrent_file = FileField('Torrent file', [
FileRequired() FileRequired()
]) ])

View File

@ -215,7 +215,9 @@ def home(rss):
query_results = search_elastic(**query_args) query_results = search_elastic(**query_args)
if render_as_rss: if render_as_rss:
return render_rss('"{}"'.format(search_term), query_results, use_elastic=True, magnet_links=use_magnet_links) return render_rss(
'"{}"'.format(search_term), query_results,
use_elastic=True, magnet_links=use_magnet_links)
else: else:
rss_query_string = _generate_query_string( rss_query_string = _generate_query_string(
search_term, category, quality_filter, user_name) search_term, category, quality_filter, user_name)
@ -637,7 +639,8 @@ def edit_torrent(torrent_id):
db.session.commit() db.session.commit()
flask.flash(flask.Markup( flask.flash(flask.Markup(
'Torrent has been successfully edited! Changes might take a few minutes to show up.'), 'info') 'Torrent has been successfully edited! Changes might take a few minutes to show up.'),
'info')
return flask.redirect(flask.url_for('view_torrent', torrent_id=torrent.id)) return flask.redirect(flask.url_for('view_torrent', torrent_id=torrent.id))
else: else: