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 import request
|
||||
|
||||
from wtforms.widgets import html_params
|
||||
from datetime import datetime
|
||||
from jinja2 import Markup
|
||||
|
||||
|
@ -155,7 +154,7 @@ class MemberForm(FlaskForm):
|
|||
if (not form.edit and Person.query.filter(
|
||||
Person.name == field.data,
|
||||
Person.project == form.project,
|
||||
Person.activated == True).all()):
|
||||
Person.activated == True).all()): # NOQA
|
||||
raise ValidationError(_("This project already have this member"))
|
||||
|
||||
def save(self, project, person):
|
||||
|
|
|
@ -20,12 +20,13 @@ class GeneratePasswordHash(Command):
|
|||
|
||||
def main():
|
||||
app = create_app()
|
||||
migrate = Migrate(app, db)
|
||||
Migrate(app, db)
|
||||
|
||||
manager = Manager(app)
|
||||
manager.add_command('db', MigrateCommand)
|
||||
manager.add_command('generate_password_hash', GeneratePasswordHash)
|
||||
manager.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -11,8 +11,10 @@ db = SQLAlchemy()
|
|||
|
||||
class Project(db.Model):
|
||||
|
||||
_to_serialize = ("id", "name", "password", "contact_email",
|
||||
"members", "active_members", "balance")
|
||||
_to_serialize = (
|
||||
"id", "name", "password", "contact_email", "members", "active_members",
|
||||
"balance"
|
||||
)
|
||||
|
||||
id = db.Column(db.String(64), primary_key=True)
|
||||
|
||||
|
@ -230,6 +232,7 @@ class Person(db.Model):
|
|||
def __repr__(self):
|
||||
return "<Person %s for project %s>" % (self.name, self.project.name)
|
||||
|
||||
|
||||
# We need to manually define a join table for m2m relations
|
||||
billowers = db.Table(
|
||||
'billowers',
|
||||
|
|
|
@ -139,5 +139,6 @@ def main():
|
|||
app = create_app()
|
||||
app.run(host="0.0.0.0", debug=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1174,5 +1174,6 @@ class ServerTestCase(APITestCase):
|
|||
req = self.client.get("/foo/")
|
||||
self.assertStatus(200, req)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import base64
|
||||
import re
|
||||
import inspect
|
||||
|
||||
from io import BytesIO, StringIO
|
||||
from jinja2 import filters
|
||||
|
@ -118,7 +117,7 @@ def list_of_dicts2csv(dict_to_convert):
|
|||
for dic in dict_to_convert:
|
||||
csv_data.append(
|
||||
[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()])
|
||||
except (KeyError, IndexError):
|
||||
csv_data = []
|
||||
|
@ -129,5 +128,6 @@ def list_of_dicts2csv(dict_to_convert):
|
|||
csv_file = BytesIO(csv_file.getvalue().encode('utf-8'))
|
||||
return csv_file
|
||||
|
||||
|
||||
# base64 encoding that works with both py2 and py3 and yield no warning
|
||||
base64_encode = base64.encodestring if six.PY2 else base64.encodebytes
|
||||
|
|
|
@ -228,7 +228,8 @@ def remind_password():
|
|||
|
||||
# send the password reminder
|
||||
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),
|
||||
recipients=[project.contact_email]))
|
||||
flash(_("a mail has been sent to you with the password"))
|
||||
|
@ -388,7 +389,7 @@ def reactivate(member_id):
|
|||
def remove_member(member_id):
|
||||
member = g.project.remove_member(member_id)
|
||||
if member:
|
||||
if member.activated == False:
|
||||
if not member.activated:
|
||||
flash(_("User '%(name)s' has been deactivated. It will still "
|
||||
"appear in the users list until its balance "
|
||||
"becomes zero.", name=member.name))
|
||||
|
|
Loading…
Reference in a new issue