1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Merge branch 'flask0.9' of github.com:aavenel/ihatemoney

This commit is contained in:
A.Avenel 2013-02-19 15:36:37 +01:00
commit b410e48851
10 changed files with 35 additions and 29 deletions

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from flask import Blueprint, request
from flask_rest import RESTResource, need_auth
from flask.ext.rest import RESTResource, need_auth
from models import db, Project, Person, Bill
from forms import (ProjectForm, EditProjectForm, MemberForm,

View file

@ -1,7 +1,7 @@
from flaskext.wtf import DateField, DecimalField, Email, Form, PasswordField, \
from flask.ext.wtf import DateField, DecimalField, Email, Form, PasswordField, \
Required, SelectField, SelectMultipleField, SubmitField, TextAreaField, \
TextField, ValidationError
from flaskext.babel import lazy_gettext as _
from flask.ext.babel import lazy_gettext as _
from flask import request
from wtforms.widgets import html_params
@ -19,16 +19,14 @@ def select_multi_checkbox(field, ul_class='', **kwargs):
choice_id = u'toggleField'
js_function = u'toggle();'
options = dict(kwargs, id=choice_id, onclick=js_function)
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'<p><a id="selectall" onclick="selectall()">%s</a> | <a id="selectnone" onclick="selectnone()">%s</a></p>'% (_("Select all"), _("Select none")))
for value, label, checked in field.iter_choices():
choice_id = u'%s-%s' % (field_id, value)
options = dict(kwargs, name=field.name, value=value, id=choice_id)
if checked:
options['checked'] = 'checked'
html.append(u'<li><label for="%s">%s<span>%s</span></label></li>'
html.append(u'<p><label for="%s">%s<span>%s</span></label></p>'
% (choice_id, '<input %s /> ' % html_params(**options), label))
html.append(u'</ul>')
return u''.join(html)
@ -189,6 +187,6 @@ class InviteForm(Form):
class CreateArchiveForm(Form):
start_date = DateField(_("Start date"), validators=[Required(), ])
end_date = DateField(_("End date"), validators=[Required(), ])
name = TextField(_("Name for this archive (optional)"))
name = TextField(_("Name for this archive (optional)"), validators=[])
start_date = DateField(_("Start date"), validators=[Required()])
end_date = DateField(_("End date"), validators=[Required()], default=datetime.now)

View file

@ -1,7 +1,7 @@
from collections import defaultdict
from datetime import datetime
from flask_sqlalchemy import SQLAlchemy, BaseQuery
from flask.ext.sqlalchemy import SQLAlchemy, BaseQuery
from flask import g
from sqlalchemy import orm

View file

@ -1,4 +1,4 @@
flask
flask>=0.9
flask-wtf
flask-sqlalchemy
flask-mail

View file

@ -1,5 +1,5 @@
from flask import Flask, g, request, session
from flaskext.babel import Babel
from flask.ext.babel import Babel
from raven.contrib.flask import Sentry
from web import main, db, mail

View file

@ -189,6 +189,10 @@ tr.payer_line .balance-name{
position: absolute;
}
.modal-body {
max-height:455px;
}
/* Fluid Offsets for Boostrap */
.row-fluid > [class*="span"]:not([class*="offset"]):first-child{margin-left:0;}

View file

@ -1,17 +1,18 @@
// Add a script to select all or non of the checkboxes in the add_bill form
function toggle()
// Add scripts to select all or non of the checkboxes in the add_bill form
function selectall()
{
var els = document.getElementsByName('payed_for');
for(var i =0;i<els.length;i++)
{
if(document.getElementById('toggleField').checked)
{
els[i].checked=true;
}
else
{
els[i].checked=false;
}
els[i].checked=true;
}
}
function selectnone()
{
var els = document.getElementsByName('payed_for');
for(var i =0;i<els.length;i++)
{
els[i].checked=false;
}
}

View file

@ -108,6 +108,7 @@
<fieldset>
<legend>{{ _("Create an archive") }}</legend>
{{ form.hidden_tag() }}
{{ input(form.name) }}
{{ input(form.start_date) }}
{{ input(form.end_date) }}
</fieldset>

View file

@ -22,9 +22,11 @@ class TestCase(unittest.TestCase):
run.app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///memory"
run.app.config['CSRF_ENABLED'] = False # simplify the tests
self.app = run.app.test_client()
models.db.init_app(run.app)
run.mail.init_app(run.app)
try:
models.db.init_app(run.app)
run.mail.init_app(run.app)
except:
pass
models.db.app = run.app
models.db.create_all()

View file

@ -11,8 +11,8 @@ and `add_project_id` for a quick overview)
from flask import Blueprint, current_app, flash, g, redirect, \
render_template, request, session, url_for
from flaskext.mail import Mail, Message
from flaskext.babel import get_locale, gettext as _
from flask.ext.mail import Mail, Message
from flask.ext.babel import get_locale, gettext as _
from smtplib import SMTPRecipientsRefused
import werkzeug
@ -390,7 +390,7 @@ def settle_bill():
return render_template("settle_bill.html", bills=bills)
@main.route("/<project_id>/archives/create")
@main.route("/<project_id>/archives/create", methods=["GET", "POST"])
def create_archive():
form = CreateArchiveForm()
if request.method == "POST":