diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..34f9181f Binary files /dev/null and b/.DS_Store differ diff --git a/ihatemoney/.DS_Store b/ihatemoney/.DS_Store new file mode 100644 index 00000000..d5c892a0 Binary files /dev/null and b/ihatemoney/.DS_Store differ diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index eb1bf2b9..39a299db 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -21,8 +21,7 @@ from jinja2 import Markup import email_validator from ihatemoney.models import Project, Person -from ihatemoney.utils import slugify, eval_arithmetic_expression - +from ihatemoney.utils import slugify, eval_arithmetic_expression,CurrencyConverter def strip_filter(string): try: @@ -87,6 +86,10 @@ class EditProjectForm(FlaskForm): name = StringField(_("Project name"), validators=[DataRequired()]) password = StringField(_("Private code"), validators=[DataRequired()]) contact_email = StringField(_("Email"), validators=[DataRequired(), Email()]) + currency_helper = CurrencyConverter() + default_currency = SelectField( + _("Default Currency"), choices=currency_helper.get_currencies(), validators=[DataRequired()] + ) def save(self): """Create a new project with the information given by this form. @@ -98,6 +101,7 @@ class EditProjectForm(FlaskForm): id=self.id.data, password=generate_password_hash(self.password.data), contact_email=self.contact_email.data, + default_currency=self.default_currency.data ) return project @@ -106,6 +110,7 @@ class EditProjectForm(FlaskForm): project.name = self.name.data project.password = generate_password_hash(self.password.data) project.contact_email = self.contact_email.data + project.default_currency = self.default_currency.data return project diff --git a/ihatemoney/migrations/versions/5cdb4f2e52c9_add_default_currency.py b/ihatemoney/migrations/versions/5cdb4f2e52c9_add_default_currency.py index 77a7517c..e037daa0 100644 --- a/ihatemoney/migrations/versions/5cdb4f2e52c9_add_default_currency.py +++ b/ihatemoney/migrations/versions/5cdb4f2e52c9_add_default_currency.py @@ -7,15 +7,17 @@ Create Date: 2019-12-06 15:46:03.416256 """ # revision identifiers, used by Alembic. -revision = '5cdb4f2e52c9' -down_revision = 'e782dd493cdc' +revision = "5cdb4f2e52c9" +down_revision = "e782dd493cdc" from alembic import op import sqlalchemy as sa def upgrade(): - op.add_column("project", sa.Column("default_currency", sa.String(length=3), nullable=True)) + op.add_column( + "project", sa.Column("default_currency", sa.String(length=3), nullable=True) + ) def downgrade(): diff --git a/ihatemoney/migrations/versions/e782dd493cdc_add_original_currency_and_amount.py b/ihatemoney/migrations/versions/e782dd493cdc_add_original_currency_and_amount.py index 0b17e902..64ae16cd 100644 --- a/ihatemoney/migrations/versions/e782dd493cdc_add_original_currency_and_amount.py +++ b/ihatemoney/migrations/versions/e782dd493cdc_add_original_currency_and_amount.py @@ -7,15 +7,17 @@ Create Date: 2019-12-06 15:12:46.116711 """ # revision identifiers, used by Alembic. -revision = 'e782dd493cdc' -down_revision = '6c6fb2b7f229' +revision = "e782dd493cdc" +down_revision = "6c6fb2b7f229" from alembic import op import sqlalchemy as sa def upgrade(): - op.add_column("bill", sa.Column("original_currency", sa.String(length=3), nullable=True)) + op.add_column( + "bill", sa.Column("original_currency", sa.String(length=3), nullable=True) + ) op.add_column("bill", sa.Column("original_amount", sa.Float(), nullable=True)) diff --git a/ihatemoney/models.py b/ihatemoney/models.py index 0f4c19de..5cbc974d 100644 --- a/ihatemoney/models.py +++ b/ihatemoney/models.py @@ -379,6 +379,7 @@ class Bill(db.Model): "external_link": self.external_link, "original_currency": self.original_currency, "original_amount": self.original_amount, + } def pay_each(self): diff --git a/ihatemoney/templates/forms.html b/ihatemoney/templates/forms.html index 61127ce7..af3c0357 100644 --- a/ihatemoney/templates/forms.html +++ b/ihatemoney/templates/forms.html @@ -65,6 +65,7 @@ {{ input(form.name) }} {{ input(form.password) }} {{ input(form.contact_email) }} + {{ input(form.default_currency) }} {% if not home %} {{ submit(form.submit, home=True) }} {% endif %} @@ -78,6 +79,7 @@ {{ input(form.name) }} {{ input(form.password) }} {{ input(form.contact_email) }} + {{ input(form.default_currency) }}