diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index d00b5fe4..0be12f02 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -1,8 +1,8 @@ from flask_wtf.form import FlaskForm from wtforms.fields.core import SelectField, SelectMultipleField -from wtforms.fields.html5 import DateField, DecimalField +from wtforms.fields.html5 import DateField, DecimalField, URLField from wtforms.fields.simple import PasswordField, SubmitField, TextAreaField, StringField -from wtforms.validators import Email, DataRequired, ValidationError, EqualTo, NumberRange +from wtforms.validators import Email, DataRequired, ValidationError, EqualTo, NumberRange, Optional from flask_babel import lazy_gettext as _ from flask import request from werkzeug.security import generate_password_hash @@ -139,6 +139,7 @@ class BillForm(FlaskForm): what = StringField(_("What?"), validators=[DataRequired()]) payer = SelectField(_("Payer"), validators=[DataRequired()], coerce=int) amount = CalculatorStringField(_("Amount paid"), validators=[DataRequired()]) + document = URLField(_("Document"), validators=[Optional()], description="A link to your bill.") payed_for = SelectMultipleField(_("For whom?"), validators=[DataRequired()], coerce=int) submit = SubmitField(_("Submit")) @@ -149,6 +150,7 @@ class BillForm(FlaskForm): bill.amount = self.amount.data bill.what = self.what.data bill.date = self.date.data + bill.document = self.document.data bill.owers = [Person.query.get(ower, project) for ower in self.payed_for.data] @@ -159,6 +161,7 @@ class BillForm(FlaskForm): self.amount.data = bill.amount self.what.data = bill.what self.date.data = bill.date + self.document.data = bill.document self.payed_for.data = [int(ower.id) for ower in bill.owers] def set_default(self): diff --git a/ihatemoney/migrations/versions/df95884d26ae_.py b/ihatemoney/migrations/versions/df95884d26ae_.py new file mode 100644 index 00000000..b668f14e --- /dev/null +++ b/ihatemoney/migrations/versions/df95884d26ae_.py @@ -0,0 +1,26 @@ +"""empty message + +Revision ID: df95884d26ae +Revises: a67119aa3ee5 +Create Date: 2019-09-15 23:17:29.721176 + +""" + +# revision identifiers, used by Alembic. +revision = 'df95884d26ae' +down_revision = 'a67119aa3ee5' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('bill', sa.Column('document', sa.UnicodeText(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('bill', 'document') + # ### end Alembic commands ### diff --git a/ihatemoney/models.py b/ihatemoney/models.py index 3e908fa8..caadfdbe 100644 --- a/ihatemoney/models.py +++ b/ihatemoney/models.py @@ -358,12 +358,13 @@ class Bill(db.Model): date = db.Column(db.Date, default=datetime.now) creation_date = db.Column(db.Date, default=datetime.now) what = db.Column(db.UnicodeText) + document = db.Column(db.UnicodeText) archive = db.Column(db.Integer, db.ForeignKey("archive.id")) @property def _to_serialize(self): - return { + dict = { "id": self.id, "payer_id": self.payer_id, "owers": self.owers, @@ -372,6 +373,9 @@ class Bill(db.Model): "creation_date": self.creation_date, "what": self.what, } + if self.document: + dict["document"] = self.document + return dict def pay_each(self): """Compute what each share has to pay""" diff --git a/ihatemoney/static/css/main.css b/ihatemoney/static/css/main.css index acc95a1a..2e27f2cb 100644 --- a/ihatemoney/static/css/main.css +++ b/ihatemoney/static/css/main.css @@ -290,7 +290,8 @@ footer .footer-left { } .bill-actions > .delete, -.bill-actions > .edit { +.bill-actions > .edit, +.bill-actions > .see { font-size: 0px; display: block; width: 16px; @@ -308,6 +309,10 @@ footer .footer-left { background: url("../images/edit.png") no-repeat right; } +.bill-actions > .see { + background: url("../images/see.png") no-repeat right; +} + #bill_table { margin-top: 30px; } diff --git a/ihatemoney/static/images/see.png b/ihatemoney/static/images/see.png new file mode 100644 index 00000000..edcaf635 Binary files /dev/null and b/ihatemoney/static/images/see.png differ diff --git a/ihatemoney/templates/forms.html b/ihatemoney/templates/forms.html index a64e2055..6aa07074 100644 --- a/ihatemoney/templates/forms.html +++ b/ihatemoney/templates/forms.html @@ -95,6 +95,7 @@ {{ input(form.what, inline=True) }} {{ input(form.payer, inline=True, class="form-control custom-select") }} {{ input(form.amount, inline=True) }} + {{ input(form.document, inline=True) }}