mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
pep8 <3 and '*' imports removal
This commit is contained in:
parent
fddf60a662
commit
6a50e7318b
1 changed files with 34 additions and 20 deletions
|
@ -1,9 +1,11 @@
|
||||||
from flaskext.wtf import *
|
from flaskext.wtf import DateField, DecimalField, Email, Form, PasswordField, \
|
||||||
|
Required, SelectField, SelectMultipleField, SubmitField, TextAreaField, \
|
||||||
|
TextField, ValidationError
|
||||||
from flaskext.babel import lazy_gettext as _
|
from flaskext.babel import lazy_gettext as _
|
||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
from wtforms.widgets import html_params
|
from wtforms.widgets import html_params
|
||||||
from models import Project, Person, Bill, db
|
from models import Project, Person
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from jinja2 import Markup
|
from jinja2 import Markup
|
||||||
from utils import slugify
|
from utils import slugify
|
||||||
|
@ -18,14 +20,16 @@ def select_multi_checkbox(field, ul_class='', **kwargs):
|
||||||
js_function = u'toggle();'
|
js_function = u'toggle();'
|
||||||
options = dict(kwargs, id=choice_id, onclick=js_function)
|
options = dict(kwargs, id=choice_id, onclick=js_function)
|
||||||
label = _("Select All/None")
|
label = _("Select All/None")
|
||||||
html.append(u'<li><label for="%s">%s<span>%s</span></label></li>' % (choice_id, '<input %s /> ' % html_params(**options), label))
|
html.append(u'<li><label for="%s">%s<span>%s</span></label></li>'
|
||||||
|
% (choice_id, '<input %s /> ' % html_params(**options), label))
|
||||||
|
|
||||||
for value, label, checked in field.iter_choices():
|
for value, label, checked in field.iter_choices():
|
||||||
choice_id = u'%s-%s' % (field_id, value)
|
choice_id = u'%s-%s' % (field_id, value)
|
||||||
options = dict(kwargs, name=field.name, value=value, id=choice_id)
|
options = dict(kwargs, name=field.name, value=value, id=choice_id)
|
||||||
if checked:
|
if checked:
|
||||||
options['checked'] = 'checked'
|
options['checked'] = 'checked'
|
||||||
html.append(u'<li><label for="%s">%s<span>%s</span></label></li>' % (choice_id, '<input %s /> ' % html_params(**options), label))
|
html.append(u'<li><label for="%s">%s<span>%s</span></label></li>'
|
||||||
|
% (choice_id, '<input %s /> ' % html_params(**options), label))
|
||||||
html.append(u'</ul>')
|
html.append(u'</ul>')
|
||||||
return u''.join(html)
|
return u''.join(html)
|
||||||
|
|
||||||
|
@ -38,13 +42,15 @@ def get_billform_for(project, set_default=True, **kwargs):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
form = BillForm(**kwargs)
|
form = BillForm(**kwargs)
|
||||||
form.payed_for.choices = form.payer.choices = [(m.id, m.name) for m in project.active_members]
|
form.payed_for.choices = form.payer.choices = [(m.id, m.name)
|
||||||
|
for m in project.active_members]
|
||||||
form.payed_for.default = [m.id for m in project.active_members]
|
form.payed_for.default = [m.id for m in project.active_members]
|
||||||
|
|
||||||
if set_default and request.method == "GET":
|
if set_default and request.method == "GET":
|
||||||
form.set_default()
|
form.set_default()
|
||||||
return form
|
return form
|
||||||
|
|
||||||
|
|
||||||
class CommaDecimalField(DecimalField):
|
class CommaDecimalField(DecimalField):
|
||||||
"""A class to deal with comma in Decimal Field"""
|
"""A class to deal with comma in Decimal Field"""
|
||||||
def process_formdata(self, value):
|
def process_formdata(self, value):
|
||||||
|
@ -85,7 +91,12 @@ class ProjectForm(EditProjectForm):
|
||||||
def validate_id(form, field):
|
def validate_id(form, field):
|
||||||
form.id.data = slugify(field.data)
|
form.id.data = slugify(field.data)
|
||||||
if Project.query.get(form.id.data):
|
if Project.query.get(form.id.data):
|
||||||
raise ValidationError(Markup(_("The project identifier is used to log in and for the URL of the project. We tried to generate an identifier for you but a project with this identifier already exists. Please create a new identifier you will be able to remember.")))
|
raise ValidationError(Markup(_("The project identifier is used "
|
||||||
|
"to log in and for the URL of the project. "
|
||||||
|
"We tried to generate an identifier for you but a project "
|
||||||
|
"with this identifier already exists. "
|
||||||
|
"Please create a new identifier "
|
||||||
|
"that you will be able to remember.")))
|
||||||
|
|
||||||
|
|
||||||
class AuthenticationForm(Form):
|
class AuthenticationForm(Form):
|
||||||
|
@ -118,7 +129,8 @@ class BillForm(Form):
|
||||||
bill.amount = self.amount.data
|
bill.amount = self.amount.data
|
||||||
bill.what = self.what.data
|
bill.what = self.what.data
|
||||||
bill.date = self.date.data
|
bill.date = self.date.data
|
||||||
bill.owers = [Person.query.get(ower, project) for ower in self.payed_for.data]
|
bill.owers = [Person.query.get(ower, project)
|
||||||
|
for ower in self.payed_for.data]
|
||||||
|
|
||||||
return bill
|
return bill
|
||||||
|
|
||||||
|
@ -141,7 +153,8 @@ class BillForm(Form):
|
||||||
|
|
||||||
class MemberForm(Form):
|
class MemberForm(Form):
|
||||||
|
|
||||||
name = TextField(_("Name"), validators=[Required()], default=_("Type user name here"))
|
name = TextField(_("Name"), validators=[Required()],
|
||||||
|
default=_("Type user name here"))
|
||||||
submit = SubmitField(_("Add"))
|
submit = SubmitField(_("Add"))
|
||||||
|
|
||||||
def __init__(self, project, *args, **kwargs):
|
def __init__(self, project, *args, **kwargs):
|
||||||
|
@ -163,6 +176,7 @@ class MemberForm(Form):
|
||||||
|
|
||||||
return person
|
return person
|
||||||
|
|
||||||
|
|
||||||
class InviteForm(Form):
|
class InviteForm(Form):
|
||||||
emails = TextAreaField(_("People to notify"))
|
emails = TextAreaField(_("People to notify"))
|
||||||
submit = SubmitField(_("Send invites"))
|
submit = SubmitField(_("Send invites"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue