Skip to content

Commit ad1af82

Browse files
author
Nicolas Harraudeau
committed
tags: PEP8 code style improvements
Signed-off-by: Nicolas Harraudeau <[email protected]>
1 parent cd412ea commit ad1af82

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

invenio/modules/tags/views.py

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,43 +25,47 @@
2525
"""
2626

2727
# Flask
28-
from werkzeug import LocalProxy
29-
from flask import render_template, request, flash, redirect, url_for, \
30-
jsonify, Blueprint
31-
from invenio.base.i18n import _
32-
from invenio.base.decorators import wash_arguments, templated
28+
from flask import Blueprint, flash, jsonify, redirect, \
29+
render_template, request, url_for
30+
31+
from flask_breadcrumbs import default_breadcrumb_root, register_breadcrumb
32+
3333
from flask_login import current_user, login_required
34-
from invenio.base.globals import cfg
3534

36-
# External imports
35+
from flask_menu import register_menu
36+
37+
from invenio.base.decorators import templated, wash_arguments
38+
from invenio.base.globals import cfg
39+
from invenio.base.i18n import _
40+
from invenio.ext.sqlalchemy import db
3741
from invenio.modules.accounts.models import User
3842
from invenio.modules.records.models import Record as Bibrec
3943
from invenio.modules.search.models import Collection
4044
from invenio.modules.search.views.search import response_formated_records
41-
from flask_menu import register_menu
42-
from flask_breadcrumbs import default_breadcrumb_root, register_breadcrumb
43-
from invenio.ext.sqlalchemy import db
4445

45-
# Internal imports
46-
from .models import \
47-
WtgTAG, \
48-
WtgTAGRecord, \
49-
wash_tag
46+
from werkzeug import LocalProxy
5047

48+
# Internal imports
5149
# Forms
5250
from .forms import \
53-
CreateTagForm, \
5451
AttachTagForm, \
52+
CreateTagForm, \
5553
DetachTagForm, \
5654
EditTagForm, \
5755
TagAnnotationForm, \
5856
validate_tag_exists, \
5957
validate_user_owns_tag, \
6058
validators
6159

60+
from .models import \
61+
WtgTAG, \
62+
WtgTAGRecord, \
63+
wash_tag
64+
6265
# Uset settings
63-
user_settings = LocalProxy(lambda:
64-
current_user['settings'].get('webtag', cfg['CFG_WEBTAG_DEFAULT_USER_SETTINGS']))
66+
user_settings = LocalProxy(
67+
68+
lambda: current_user['settings'].get('webtag', cfg['CFG_WEBTAG_DEFAULT_USER_SETTINGS']))
6569

6670
blueprint = Blueprint('webtag', __name__, url_prefix='/yourtags',
6771
template_folder='templates', static_folder='static')
@@ -100,8 +104,8 @@ def display_cloud():
100104

101105
for tag in tags:
102106
size = min_size + \
103-
float(max_size - min_size) * \
104-
float(tag.record_count - min_count) / difference
107+
float(max_size - min_size) * \
108+
float(tag.record_count - min_count) / difference
105109

106110
tag.css_size = str(size*100)
107111

@@ -113,7 +117,7 @@ def display_cloud():
113117
@login_required
114118
@templated('tags/display_list.html')
115119
@wash_arguments({'sort_by': (unicode, 'name'),
116-
'order': (unicode, '')})
120+
'order': (unicode, '')})
117121
@register_breadcrumb(blueprint, '.list', _('Display as List'))
118122
def display_list(sort_by, order):
119123
""" List of user's private/group/public tags """
@@ -161,8 +165,8 @@ def tag_details(id_tag):
161165
return redirect(url_for('.display_cloud'))
162166

163167
return response_formated_records([bibrec.id for bibrec in tag.records],
164-
Collection.query.get(1),
165-
'hb')
168+
Collection.query.get(1),
169+
'hb')
166170

167171

168172
@blueprint.route('/tag/<int:id_tag>/edit', methods=['GET', 'POST'])
@@ -241,10 +245,8 @@ def record_tags(id_bibrec):
241245
from .template_context_functions.tfn_webtag_record_tags \
242246
import template_context_function
243247

244-
from invenio.ext.template import render_template_to_string
245-
246248
return dict(
247-
tag_list = template_context_function(id_bibrec, current_user.get_id()))
249+
tag_list=template_context_function(id_bibrec, current_user.get_id()))
248250

249251

250252
@blueprint.route('/tokenize/<int:id_bibrec>', methods=['GET', 'POST'])
@@ -315,7 +317,7 @@ def editor(id_bibrec):
315317
# invenio_templated cannot be used,
316318
# because this view is requested using AJAX
317319
return render_template('tags/record_editor.html', id_bibrec=id_bibrec,
318-
record_tags=tags_json)
320+
record_tags=tags_json)
319321

320322

321323
#Temporary solution to call validators, we need a better one
@@ -460,8 +462,8 @@ def detach():
460462

461463
if form.validate():
462464
association = db.session.query(WtgTAGRecord)\
463-
.filter_by(id_tag = form.data['id_tag'],
464-
id_bibrec = form.data['id_bibrec']).first()
465+
.filter_by(id_tag=form.data['id_tag'],
466+
id_bibrec=form.data['id_bibrec']).first()
465467
if association:
466468
db.session.delete(association)
467469
db.session.commit()

0 commit comments

Comments
 (0)