mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-29 01:42:37 +02:00
Merge pull request #192 from JocelynDelalande/jd-remove-warnings
Warnings hunt !
This commit is contained in:
commit
49615acb1d
8 changed files with 29 additions and 22 deletions
|
@ -29,7 +29,7 @@ def check_project(*args, **kwargs):
|
||||||
class ProjectHandler(object):
|
class ProjectHandler(object):
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
form = ProjectForm(csrf_enabled=False)
|
form = ProjectForm(meta={'csrf': False})
|
||||||
if form.validate():
|
if form.validate():
|
||||||
project = form.save()
|
project = form.save()
|
||||||
db.session.add(project)
|
db.session.add(project)
|
||||||
|
@ -49,7 +49,7 @@ class ProjectHandler(object):
|
||||||
|
|
||||||
@need_auth(check_project, "project")
|
@need_auth(check_project, "project")
|
||||||
def update(self, project):
|
def update(self, project):
|
||||||
form = EditProjectForm(csrf_enabled=False)
|
form = EditProjectForm(meta={'csrf': False})
|
||||||
if form.validate():
|
if form.validate():
|
||||||
form.update(project)
|
form.update(project)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -69,7 +69,7 @@ class MemberHandler(object):
|
||||||
return 200, project.members
|
return 200, project.members
|
||||||
|
|
||||||
def add(self, project):
|
def add(self, project):
|
||||||
form = MemberForm(project, csrf_enabled=False)
|
form = MemberForm(project, meta={'csrf': False})
|
||||||
if form.validate():
|
if form.validate():
|
||||||
member = Person()
|
member = Person()
|
||||||
form.save(project, member)
|
form.save(project, member)
|
||||||
|
@ -78,7 +78,7 @@ class MemberHandler(object):
|
||||||
return 400, form.errors
|
return 400, form.errors
|
||||||
|
|
||||||
def update(self, project, member_id):
|
def update(self, project, member_id):
|
||||||
form = MemberForm(project, csrf_enabled=False)
|
form = MemberForm(project, meta={'csrf': False})
|
||||||
if form.validate():
|
if form.validate():
|
||||||
member = Person.query.get(member_id, project)
|
member = Person.query.get(member_id, project)
|
||||||
form.save(project, member)
|
form.save(project, member)
|
||||||
|
@ -104,7 +104,7 @@ class BillHandler(object):
|
||||||
return project.get_bills().all()
|
return project.get_bills().all()
|
||||||
|
|
||||||
def add(self, project):
|
def add(self, project):
|
||||||
form = get_billform_for(project, True, csrf_enabled=False)
|
form = get_billform_for(project, True, meta={'csrf': False})
|
||||||
if form.validate():
|
if form.validate():
|
||||||
bill = Bill()
|
bill = Bill()
|
||||||
form.save(bill, project)
|
form.save(bill, project)
|
||||||
|
@ -114,7 +114,7 @@ class BillHandler(object):
|
||||||
return 400, form.errors
|
return 400, form.errors
|
||||||
|
|
||||||
def update(self, project, bill_id):
|
def update(self, project, bill_id):
|
||||||
form = get_billform_for(project, True, csrf_enabled=False)
|
form = get_billform_for(project, True, meta={'csrf': False})
|
||||||
if form.validate():
|
if form.validate():
|
||||||
bill = Bill.query.get(project, bill_id)
|
bill = Bill.query.get(project, bill_id)
|
||||||
form.save(bill, project)
|
form.save(bill, project)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///budget.db'
|
SQLALCHEMY_DATABASE_URI = 'sqlite:///budget.db'
|
||||||
SQLACHEMY_ECHO = DEBUG
|
SQLACHEMY_ECHO = DEBUG
|
||||||
|
# Will likely become the default value in flask-sqlalchemy >=3 ; could be removed
|
||||||
|
# then:
|
||||||
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
|
|
||||||
SECRET_KEY = "tralala"
|
SECRET_KEY = "tralala"
|
||||||
|
|
||||||
MAIL_DEFAULT_SENDER = ("Budget manager", "budget@notmyidea.org")
|
MAIL_DEFAULT_SENDER = ("Budget manager", "budget@notmyidea.org")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from flask_wtf.form import FlaskForm
|
from flask_wtf.form import FlaskForm
|
||||||
from wtforms.fields.core import SelectField, SelectMultipleField
|
from wtforms.fields.core import SelectField, SelectMultipleField
|
||||||
from wtforms.fields.html5 import DateField, DecimalField
|
from wtforms.fields.html5 import DateField, DecimalField
|
||||||
from wtforms.fields.simple import PasswordField, SubmitField, TextAreaField, TextField
|
from wtforms.fields.simple import PasswordField, SubmitField, TextAreaField, StringField
|
||||||
from wtforms.validators import Email, Required, ValidationError
|
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
|
||||||
|
@ -38,9 +38,9 @@ class CommaDecimalField(DecimalField):
|
||||||
|
|
||||||
|
|
||||||
class EditProjectForm(FlaskForm):
|
class EditProjectForm(FlaskForm):
|
||||||
name = TextField(_("Project name"), validators=[Required()])
|
name = StringField(_("Project name"), validators=[Required()])
|
||||||
password = TextField(_("Private code"), validators=[Required()])
|
password = StringField(_("Private code"), validators=[Required()])
|
||||||
contact_email = TextField(_("Email"), validators=[Required(), Email()])
|
contact_email = StringField(_("Email"), validators=[Required(), Email()])
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
"""Create a new project with the information given by this form.
|
"""Create a new project with the information given by this form.
|
||||||
|
@ -62,7 +62,7 @@ class EditProjectForm(FlaskForm):
|
||||||
|
|
||||||
|
|
||||||
class ProjectForm(EditProjectForm):
|
class ProjectForm(EditProjectForm):
|
||||||
id = TextField(_("Project identifier"), validators=[Required()])
|
id = StringField(_("Project identifier"), validators=[Required()])
|
||||||
password = PasswordField(_("Private code"), validators=[Required()])
|
password = PasswordField(_("Private code"), validators=[Required()])
|
||||||
submit = SubmitField(_("Create the project"))
|
submit = SubmitField(_("Create the project"))
|
||||||
|
|
||||||
|
@ -78,13 +78,13 @@ class ProjectForm(EditProjectForm):
|
||||||
|
|
||||||
|
|
||||||
class AuthenticationForm(FlaskForm):
|
class AuthenticationForm(FlaskForm):
|
||||||
id = TextField(_("Project identifier"), validators=[Required()])
|
id = StringField(_("Project identifier"), validators=[Required()])
|
||||||
password = PasswordField(_("Private code"), validators=[Required()])
|
password = PasswordField(_("Private code"), validators=[Required()])
|
||||||
submit = SubmitField(_("Get in"))
|
submit = SubmitField(_("Get in"))
|
||||||
|
|
||||||
|
|
||||||
class PasswordReminder(FlaskForm):
|
class PasswordReminder(FlaskForm):
|
||||||
id = TextField(_("Project identifier"), validators=[Required()])
|
id = StringField(_("Project identifier"), validators=[Required()])
|
||||||
submit = SubmitField(_("Send me the code by email"))
|
submit = SubmitField(_("Send me the code by email"))
|
||||||
|
|
||||||
def validate_id(form, field):
|
def validate_id(form, field):
|
||||||
|
@ -94,7 +94,7 @@ class PasswordReminder(FlaskForm):
|
||||||
|
|
||||||
class BillForm(FlaskForm):
|
class BillForm(FlaskForm):
|
||||||
date = DateField(_("Date"), validators=[Required()], default=datetime.now)
|
date = DateField(_("Date"), validators=[Required()], default=datetime.now)
|
||||||
what = TextField(_("What?"), validators=[Required()])
|
what = StringField(_("What?"), validators=[Required()])
|
||||||
payer = SelectField(_("Payer"), validators=[Required()], coerce=int)
|
payer = SelectField(_("Payer"), validators=[Required()], coerce=int)
|
||||||
amount = CommaDecimalField(_("Amount paid"), validators=[Required()])
|
amount = CommaDecimalField(_("Amount paid"), validators=[Required()])
|
||||||
payed_for = SelectMultipleField(_("For whom?"),
|
payed_for = SelectMultipleField(_("For whom?"),
|
||||||
|
@ -129,7 +129,7 @@ class BillForm(FlaskForm):
|
||||||
|
|
||||||
class MemberForm(FlaskForm):
|
class MemberForm(FlaskForm):
|
||||||
|
|
||||||
name = TextField(_("Name"), validators=[Required()])
|
name = StringField(_("Name"), validators=[Required()])
|
||||||
weight = CommaDecimalField(_("Weight"), default=1)
|
weight = CommaDecimalField(_("Weight"), default=1)
|
||||||
submit = SubmitField(_("Add"))
|
submit = SubmitField(_("Add"))
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from flask.ext.script import Manager
|
from flask_script import Manager
|
||||||
from flask.ext.migrate import Migrate, MigrateCommand
|
from flask_migrate import Migrate, MigrateCommand
|
||||||
|
|
||||||
from run import app
|
from run import app
|
||||||
from models import db
|
from models import db
|
||||||
|
|
|
@ -5,7 +5,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import unittest # NOQA
|
import unittest # NOQA
|
||||||
|
|
||||||
import base64
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
@ -17,6 +16,7 @@ from flask import session
|
||||||
|
|
||||||
import run
|
import run
|
||||||
import models
|
import models
|
||||||
|
import utils
|
||||||
|
|
||||||
|
|
||||||
class TestCase(unittest.TestCase):
|
class TestCase(unittest.TestCase):
|
||||||
|
@ -759,7 +759,7 @@ class APITestCase(TestCase):
|
||||||
|
|
||||||
def get_auth(self, username, password=None):
|
def get_auth(self, username, password=None):
|
||||||
password = password or username
|
password = password or username
|
||||||
base64string = base64.encodestring(
|
base64string = utils.base64_encode(
|
||||||
('%s:%s' % (username, password)).encode('utf-8')).decode('utf-8').replace('\n', '')
|
('%s:%s' % (username, password)).encode('utf-8')).decode('utf-8').replace('\n', '')
|
||||||
return {"Authorization": "Basic %s" % base64string}
|
return {"Authorization": "Basic %s" % base64string}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import base64
|
||||||
import re
|
import re
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
|
@ -120,3 +121,6 @@ def list_of_dicts2csv(dict_to_convert):
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
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_encode = base64.encodestring if six.PY2 else base64.encodebytes
|
||||||
|
|
|
@ -16,5 +16,4 @@ pygments_style = 'sphinx'
|
||||||
sys.path.append(os.path.abspath('_themes'))
|
sys.path.append(os.path.abspath('_themes'))
|
||||||
html_theme_path = ['_themes']
|
html_theme_path = ['_themes']
|
||||||
html_theme = 'pelican'
|
html_theme = 'pelican'
|
||||||
html_static_path = ['_static']
|
|
||||||
html_theme_options = { 'nosidebar': True }
|
html_theme_options = { 'nosidebar': True }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
flask>=0.11
|
flask>=0.11
|
||||||
flask-wtf>=0.13
|
flask-wtf>=0.14
|
||||||
flask-sqlalchemy
|
flask-sqlalchemy>=2.2,<3.0
|
||||||
flask-mail>=0.8
|
flask-mail>=0.8
|
||||||
Flask-Migrate>=1.8.0
|
Flask-Migrate>=1.8.0
|
||||||
flask-babel
|
flask-babel
|
||||||
|
|
Loading…
Reference in a new issue