Skip to content

Commit

Permalink
fix flask-wtf and beautifulsoup warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Feb 5, 2018
1 parent a13a691 commit 5820eea
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions sopy/admin/forms.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from flask_wtf import Form
from flask_wtf import FlaskForm
from wtforms.validators import ValidationError, InputRequired
from sopy import db
from sopy.auth.models import User
from sopy.ext.forms import StripStringField


class UserListForm(Form):
class UserListForm(FlaskForm):
user_ids = StripStringField('User IDs', validators=[InputRequired()])

def validate_user_ids(self, field):
Expand Down
4 changes: 2 additions & 2 deletions sopy/auth/forms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from flask_wtf import Form
from flask_wtf import FlaskForm
from wtforms.validators import InputRequired
from sopy.auth.models import User
from sopy.ext.forms import StripStringField


class LoginForm(Form):
class LoginForm(FlaskForm):
user_id = StripStringField('User ID', validators=[InputRequired()])

def validate_user_id(self, field):
Expand Down
4 changes: 2 additions & 2 deletions sopy/canon/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import request
from flask_wtf import Form
from flask_wtf import FlaskForm
from wtforms import Form as BaseForm
from wtforms.fields import TextAreaField
from wtforms.fields.core import BooleanField
Expand All @@ -12,7 +12,7 @@
from sopy.tags.models import Tag


class CanonItemForm(Form):
class CanonItemForm(FlaskForm):
title = StripStringField(validators=[InputRequired()])
excerpt = TextAreaField()
body = TextAreaField()
Expand Down
4 changes: 2 additions & 2 deletions sopy/canon/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import redirect, render_template
from flask_wtf import Form
from flask_wtf import FlaskForm
from sopy import db
from sopy.auth.login import group_required, current_user, login_required, require_group, has_group
from sopy.canon import bp
Expand Down Expand Up @@ -53,7 +53,7 @@ def update(id=None):
@group_required('editor')
def delete(id):
item = CanonItem.query.get_or_404(id)
form = Form()
form = FlaskForm()

if form.validate_on_submit():
db.session.delete(item)
Expand Down
4 changes: 2 additions & 2 deletions sopy/salad/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from flask_wtf import Form
from flask_wtf import FlaskForm
from wtforms.validators import InputRequired
from sopy.ext.forms import StripStringField


class SaladForm(Form):
class SaladForm(FlaskForm):
term = StripStringField(validators=[InputRequired()])
definition = StripStringField(validators=[InputRequired()])
4 changes: 2 additions & 2 deletions sopy/salad/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import request, render_template
from flask_wtf import Form
from flask_wtf import FlaskForm
from sopy import db
from sopy.auth.login import group_required, current_user
from sopy.ext.views import redirect_for
Expand Down Expand Up @@ -58,7 +58,7 @@ def move(id, down=False):
@group_required('Dark Council')
def delete(id):
item = Salad.query.get_or_404(id)
form = Form()
form = FlaskForm()

if form.validate_on_submit():
item.delete()
Expand Down
4 changes: 2 additions & 2 deletions sopy/spoiler/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flask_wtf import Form
from flask_wtf import FlaskForm
from wtforms import TextAreaField
from wtforms.validators import InputRequired

class SpoilerForm(Form):
class SpoilerForm(FlaskForm):
message = TextAreaField(validators=[InputRequired()])
6 changes: 3 additions & 3 deletions sopy/transcript/forms.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from datetime import datetime
from flask_wtf import Form
from flask_wtf import FlaskForm
from requests import RequestException
from wtforms.fields import StringField, DateTimeField, TextAreaField, IntegerField
from wtforms.validators import Optional, InputRequired
from sopy.transcript.parser import get_range


class CreateTranscriptForm(Form):
class CreateTranscriptForm(FlaskForm):
title = StringField(validators=[InputRequired()])
ts = DateTimeField('When', format='%Y-%m-%d %H:%M', validators=[Optional()])
body = TextAreaField('Description')
Expand Down Expand Up @@ -56,7 +56,7 @@ def populate_obj(self, obj):
obj.ts = self.messages[0].ts


class UpdateTranscriptForm(Form):
class UpdateTranscriptForm(FlaskForm):
title = StringField(validators=[InputRequired()])
ts = DateTimeField('When', format='%Y-%m-%d %H:%M', validators=[Optional()])
body = TextAreaField('Description')
Expand Down
8 changes: 4 additions & 4 deletions sopy/transcript/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def previous_page(current):
# get and parse the new page
r = requests.get(base_url.format(element['href']))
r.raise_for_status()
return BeautifulSoup(r.content)
return BeautifulSoup(r.content, 'lxml')


def next_page(current):
Expand Down Expand Up @@ -74,7 +74,7 @@ def next_page(current):
# get and parse the new page
r = requests.get(base_url.format(element['href']))
r.raise_for_status()
return BeautifulSoup(r.content)
return BeautifulSoup(r.content, 'lxml')


def page_date(page):
Expand All @@ -101,11 +101,11 @@ def get_range(start_id, end_id):
# need to check that the range is in the same room, so fetch start and end pages
r = requests.get(permalink_url.format(start_id))
r.raise_for_status()
page = BeautifulSoup(r.content)
page = BeautifulSoup(r.content, 'lxml')
room_href = page.find('div', id='sidebar-content').find('span', class_='room-name').a['href']
r = requests.get(permalink_url.format(end_id))
r.raise_for_status()
end_page = BeautifulSoup(r.content)
end_page = BeautifulSoup(r.content, 'lxml')

if room_href != end_page.find('div', id='sidebar-content').find('span', class_='room-name').a['href']:
raise ValueError('Start and end are in different rooms.')
Expand Down
4 changes: 2 additions & 2 deletions sopy/transcript/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import render_template, redirect
from flask_wtf import Form
from flask_wtf import FlaskForm
from sopy import db
from sopy.auth.login import group_required
from sopy.ext.views import redirect_for
Expand Down Expand Up @@ -45,7 +45,7 @@ def update(id=None):
@group_required('Dark Council')
def delete(id):
item = Transcript.query.get_or_404(id)
form = Form()
form = FlaskForm()

if form.validate_on_submit():
db.session.delete(item)
Expand Down
4 changes: 2 additions & 2 deletions sopy/wiki/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask_wtf import Form
from flask_wtf import FlaskForm
import re
from markupsafe import Markup
from wtforms.fields import TextAreaField, BooleanField
Expand All @@ -7,7 +7,7 @@
from sopy.wiki.models import WikiPage


class WikiPageForm(Form):
class WikiPageForm(FlaskForm):
title = StripStringField(validators=[DataRequired()])
body = TextAreaField()

Expand Down
6 changes: 3 additions & 3 deletions sopy/wiki/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import redirect, render_template, request, session, url_for
from flask_wtf import Form
from flask import redirect, render_template, request, session
from flask_wtf import FlaskForm
from sopy import db
from sopy.auth.login import group_required, current_user, login_required, require_group, has_group
from sopy.ext.views import redirect_for
Expand Down Expand Up @@ -72,7 +72,7 @@ def update(title=None):
@group_required('editor')
def delete(title):
page = WikiPage.query.filter(WikiPage.title == title).first_or_404()
form = Form()
form = FlaskForm()

if form.validate_on_submit():
db.session.delete(page)
Expand Down

0 comments on commit 5820eea

Please sign in to comment.