mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 20:51:49 +02:00
Fix some styling thanks to Flake8.
This commit is contained in:
parent
eade8519cb
commit
3a9da9f28a
7 changed files with 15 additions and 9 deletions
|
@ -6,7 +6,6 @@ from wtforms.validators import Email, Required, ValidationError
|
||||||
from flask_babel import lazy_gettext as _
|
from flask_babel import lazy_gettext as _
|
||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
from wtforms.widgets import html_params
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from jinja2 import Markup
|
from jinja2 import Markup
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ class MemberForm(FlaskForm):
|
||||||
if (not form.edit and Person.query.filter(
|
if (not form.edit and Person.query.filter(
|
||||||
Person.name == field.data,
|
Person.name == field.data,
|
||||||
Person.project == form.project,
|
Person.project == form.project,
|
||||||
Person.activated == True).all()):
|
Person.activated == True).all()): # NOQA
|
||||||
raise ValidationError(_("This project already have this member"))
|
raise ValidationError(_("This project already have this member"))
|
||||||
|
|
||||||
def save(self, project, person):
|
def save(self, project, person):
|
||||||
|
|
|
@ -20,12 +20,13 @@ class GeneratePasswordHash(Command):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = create_app()
|
app = create_app()
|
||||||
migrate = Migrate(app, db)
|
Migrate(app, db)
|
||||||
|
|
||||||
manager = Manager(app)
|
manager = Manager(app)
|
||||||
manager.add_command('db', MigrateCommand)
|
manager.add_command('db', MigrateCommand)
|
||||||
manager.add_command('generate_password_hash', GeneratePasswordHash)
|
manager.add_command('generate_password_hash', GeneratePasswordHash)
|
||||||
manager.run()
|
manager.run()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -11,8 +11,10 @@ db = SQLAlchemy()
|
||||||
|
|
||||||
class Project(db.Model):
|
class Project(db.Model):
|
||||||
|
|
||||||
_to_serialize = ("id", "name", "password", "contact_email",
|
_to_serialize = (
|
||||||
"members", "active_members", "balance")
|
"id", "name", "password", "contact_email", "members", "active_members",
|
||||||
|
"balance"
|
||||||
|
)
|
||||||
|
|
||||||
id = db.Column(db.String(64), primary_key=True)
|
id = db.Column(db.String(64), primary_key=True)
|
||||||
|
|
||||||
|
@ -230,6 +232,7 @@ class Person(db.Model):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Person %s for project %s>" % (self.name, self.project.name)
|
return "<Person %s for project %s>" % (self.name, self.project.name)
|
||||||
|
|
||||||
|
|
||||||
# We need to manually define a join table for m2m relations
|
# We need to manually define a join table for m2m relations
|
||||||
billowers = db.Table(
|
billowers = db.Table(
|
||||||
'billowers',
|
'billowers',
|
||||||
|
|
|
@ -139,5 +139,6 @@ def main():
|
||||||
app = create_app()
|
app = create_app()
|
||||||
app.run(host="0.0.0.0", debug=True)
|
app.run(host="0.0.0.0", debug=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -1174,5 +1174,6 @@ class ServerTestCase(APITestCase):
|
||||||
req = self.client.get("/foo/")
|
req = self.client.get("/foo/")
|
||||||
self.assertStatus(200, req)
|
self.assertStatus(200, req)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import base64
|
import base64
|
||||||
import re
|
import re
|
||||||
import inspect
|
|
||||||
|
|
||||||
from io import BytesIO, StringIO
|
from io import BytesIO, StringIO
|
||||||
from jinja2 import filters
|
from jinja2 import filters
|
||||||
|
@ -118,7 +117,7 @@ def list_of_dicts2csv(dict_to_convert):
|
||||||
for dic in dict_to_convert:
|
for dic in dict_to_convert:
|
||||||
csv_data.append(
|
csv_data.append(
|
||||||
[dic[h].encode('utf8')
|
[dic[h].encode('utf8')
|
||||||
if isinstance(dic[h], unicode) else str(dic[h]).encode('utf8')
|
if isinstance(dic[h], unicode) else str(dic[h]).encode('utf8') # NOQA
|
||||||
for h in dict_to_convert[0].keys()])
|
for h in dict_to_convert[0].keys()])
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
csv_data = []
|
csv_data = []
|
||||||
|
@ -129,5 +128,6 @@ def list_of_dicts2csv(dict_to_convert):
|
||||||
csv_file = BytesIO(csv_file.getvalue().encode('utf-8'))
|
csv_file = BytesIO(csv_file.getvalue().encode('utf-8'))
|
||||||
return csv_file
|
return csv_file
|
||||||
|
|
||||||
|
|
||||||
# base64 encoding that works with both py2 and py3 and yield no warning
|
# base64 encoding that works with both py2 and py3 and yield no warning
|
||||||
base64_encode = base64.encodestring if six.PY2 else base64.encodebytes
|
base64_encode = base64.encodestring if six.PY2 else base64.encodebytes
|
||||||
|
|
|
@ -228,7 +228,8 @@ def remind_password():
|
||||||
|
|
||||||
# send the password reminder
|
# send the password reminder
|
||||||
password_reminder = "password_reminder.%s" % get_locale().language
|
password_reminder = "password_reminder.%s" % get_locale().language
|
||||||
current_app.mail.send(Message("password recovery",
|
current_app.mail.send(Message(
|
||||||
|
"password recovery",
|
||||||
body=render_template(password_reminder, project=project),
|
body=render_template(password_reminder, project=project),
|
||||||
recipients=[project.contact_email]))
|
recipients=[project.contact_email]))
|
||||||
flash(_("a mail has been sent to you with the password"))
|
flash(_("a mail has been sent to you with the password"))
|
||||||
|
@ -388,7 +389,7 @@ def reactivate(member_id):
|
||||||
def remove_member(member_id):
|
def remove_member(member_id):
|
||||||
member = g.project.remove_member(member_id)
|
member = g.project.remove_member(member_id)
|
||||||
if member:
|
if member:
|
||||||
if member.activated == False:
|
if not member.activated:
|
||||||
flash(_("User '%(name)s' has been deactivated. It will still "
|
flash(_("User '%(name)s' has been deactivated. It will still "
|
||||||
"appear in the users list until its balance "
|
"appear in the users list until its balance "
|
||||||
"becomes zero.", name=member.name))
|
"becomes zero.", name=member.name))
|
||||||
|
|
Loading…
Reference in a new issue