Browse Source

PEP8 fixes

sh4nks 11 years ago
parent
commit
d8ce86271d
3 changed files with 22 additions and 14 deletions
  1. 12 8
      flaskbb/forum/forms.py
  2. 1 1
      flaskbb/forum/models.py
  3. 9 5
      flaskbb/forum/views.py

+ 12 - 8
flaskbb/forum/forms.py

@@ -12,7 +12,7 @@ from flask.ext.wtf import Form
 from wtforms import TextAreaField, TextField, SelectMultipleField
 from wtforms import TextAreaField, TextField, SelectMultipleField
 from wtforms.validators import Required, Optional, Length
 from wtforms.validators import Required, Optional, Length
 
 
-from flaskbb.forum.models import Topic, Post, Report, Forum, Category
+from flaskbb.forum.models import Topic, Post, Report, Forum
 from flaskbb.user.models import User
 from flaskbb.user.models import User
 
 
 
 
@@ -58,7 +58,9 @@ class ReportForm(Form):
 
 
 
 
 class UserSearchForm(Form):
 class UserSearchForm(Form):
-    search_query = TextField("Search", validators=[Optional(), Length(min=3, max=50)])
+    search_query = TextField("Search", validators=[
+        Optional(), Length(min=3, max=50)
+    ])
 
 
     def get_results(self):
     def get_results(self):
         query = self.search_query.data
         query = self.search_query.data
@@ -66,13 +68,16 @@ class UserSearchForm(Form):
 
 
 
 
 class SearchPageForm(Form):
 class SearchPageForm(Form):
-    search_query = TextField("Criteria", validators=[Required(), Length(min=3, max=50)])
-    search_types = SelectMultipleField("Content", validators=[Required()], choices=[
-        ('post', 'Post'), ('topic', 'Topic'), ('forum', 'Forum'), ('user', 'Users')])
+    search_query = TextField("Criteria", validators=[
+        Required(), Length(min=3, max=50)])
+
+    search_types = SelectMultipleField("Content", validators=[
+        Required()], choices=[('post', 'Post'), ('topic', 'Topic'),
+                              ('forum', 'Forum'), ('user', 'Users')])
 
 
     def get_results(self):
     def get_results(self):
-        # Because the DB is not yet initialized when this form is loaded, the query objects cannot be instantiated
-        # in the class itself
+        # Because the DB is not yet initialized when this form is loaded,
+        # the query objects cannot be instantiated in the class itself
         search_actions = {
         search_actions = {
             'post': Post.query.whoosh_search,
             'post': Post.query.whoosh_search,
             'topic': Topic.query.whoosh_search,
             'topic': Topic.query.whoosh_search,
@@ -89,4 +94,3 @@ class SearchPageForm(Form):
                 results[type] = search_actions[type](query)
                 results[type] = search_actions[type](query)
 
 
         return results
         return results
-

+ 1 - 1
flaskbb/forum/models.py

@@ -458,7 +458,7 @@ class Topic(db.Model):
         return self
         return self
 
 
     def tracker_needs_update(self, forumsread, topicsread):
     def tracker_needs_update(self, forumsread, topicsread):
-        """Returns True if the tracker needs an update.
+        """Returns True if the topicsread tracker needs an update.
         Also, if the ``TRACKER_LENGTH`` is configured, it will just recognize
         Also, if the ``TRACKER_LENGTH`` is configured, it will just recognize
         topics that are newer than the ``TRACKER_LENGTH`` (in days) as unread.
         topics that are newer than the ``TRACKER_LENGTH`` (in days) as unread.
 
 

+ 9 - 5
flaskbb/forum/views.py

@@ -494,12 +494,15 @@ def memberlist():
     search_form = UserSearchForm()
     search_form = UserSearchForm()
 
 
     if search_form.validate():
     if search_form.validate():
-        users = search_form.get_results().paginate(page, current_app.config['USERS_PER_PAGE'], False)
-        return render_template("forum/memberlist.html", users=users, search_form=search_form)
+        users = search_form.get_results().\
+            paginate(page, current_app.config['USERS_PER_PAGE'], False)
+        return render_template("forum/memberlist.html", users=users,
+                               search_form=search_form)
     else:
     else:
-        users = User.query. \
+        users = User.query.\
             paginate(page, current_app.config['USERS_PER_PAGE'], False)
             paginate(page, current_app.config['USERS_PER_PAGE'], False)
-        return render_template("forum/memberlist.html", users=users, search_form=search_form)
+        return render_template("forum/memberlist.html", users=users,
+                               search_form=search_form)
 
 
 
 
 @forum.route("/topictracker")
 @forum.route("/topictracker")
@@ -540,6 +543,7 @@ def search():
 
 
     if form.validate_on_submit():
     if form.validate_on_submit():
         result = form.get_results()
         result = form.get_results()
-        return render_template('forum/search_result.html', form=form, result=result)
+        return render_template('forum/search_result.html', form=form,
+                               result=result)
 
 
     return render_template('forum/search_form.html', form=form)
     return render_template('forum/search_form.html', form=form)