From c5492cf4ed6656c0ac7a4b4a1096d91a27a4cdf4 Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 4 Mar 2020 16:58:42 -0700 Subject: [PATCH] Minor updates to Financials and donation goal Just a couple relatively minor updates to the financial stuff: * Removed the "is_approximate" column on the table and just added a more general note about most of the amounts being approximate. It was more annoying to worry about than meaningful. * Some style/layout/wording tweaks to the donation goal to try to make it a little more obvious that this is a long-term sustainability goal. --- ...f_financials_drop_is_approximate_column.py | 33 +++++++++++++++++++ tildes/scss/modules/_donation.scss | 11 ++++++- tildes/tildes/models/financials.py | 3 +- tildes/tildes/templates/financials.jinja2 | 11 +++---- tildes/tildes/templates/home.jinja2 | 14 ++++---- 5 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 tildes/alembic/versions/fe91222503ef_financials_drop_is_approximate_column.py diff --git a/tildes/alembic/versions/fe91222503ef_financials_drop_is_approximate_column.py b/tildes/alembic/versions/fe91222503ef_financials_drop_is_approximate_column.py new file mode 100644 index 0000000..90c90cd --- /dev/null +++ b/tildes/alembic/versions/fe91222503ef_financials_drop_is_approximate_column.py @@ -0,0 +1,33 @@ +"""Financials: Drop is_approximate column + +Revision ID: fe91222503ef +Revises: 84dc19f6e876 +Create Date: 2020-03-04 22:38:15.528403 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "fe91222503ef" +down_revision = "84dc19f6e876" +branch_labels = None +depends_on = None + + +def upgrade(): + op.drop_column("financials", "is_approximate") + + +def downgrade(): + op.add_column( + "financials", + sa.Column( + "is_approximate", + sa.BOOLEAN(), + server_default=sa.text("false"), + autoincrement=False, + nullable=False, + ), + ) diff --git a/tildes/scss/modules/_donation.scss b/tildes/scss/modules/_donation.scss index e864310..826c87a 100644 --- a/tildes/scss/modules/_donation.scss +++ b/tildes/scss/modules/_donation.scss @@ -12,11 +12,20 @@ border-color: inherit; font-size: 0.6rem; + line-height: 1.3; text-align: center; header { font-weight: bold; } + + a { + text-decoration: underline; + + &:hover { + text-decoration: none; + } + } } .donation-goal-meter { @@ -28,7 +37,7 @@ display: flex; align-items: center; width: 100%; - margin: 0.2rem 0; + margin-top: 0.2rem; } .donation-goal-percentage { diff --git a/tildes/tildes/models/financials.py b/tildes/tildes/models/financials.py index 027188b..7847ad7 100644 --- a/tildes/tildes/models/financials.py +++ b/tildes/tildes/models/financials.py @@ -6,7 +6,7 @@ from decimal import Decimal from psycopg2.extras import DateRange -from sqlalchemy import Boolean, Column, Index, Integer, Numeric, Text +from sqlalchemy import Column, Index, Integer, Numeric, Text from sqlalchemy.dialects.postgresql import DATERANGE, ENUM from tildes.enums import FinancialEntryType @@ -23,7 +23,6 @@ class Financials(DatabaseModel): description: str = Column(Text) amount: Decimal = Column(Numeric(scale=2), nullable=False) date_range: DateRange = Column(DATERANGE, nullable=False) - is_approximate: bool = Column(Boolean, nullable=False, server_default="false") # Add a GiST index on the date_range column for range operators __table_args__ = ( diff --git a/tildes/tildes/templates/financials.jinja2 b/tildes/tildes/templates/financials.jinja2 index b0a488e..4615d4d 100644 --- a/tildes/tildes/templates/financials.jinja2 +++ b/tildes/tildes/templates/financials.jinja2 @@ -30,11 +30,13 @@

{{ current_time.strftime("%B %Y") }} expenses and income

+Note: Most amounts are approximate, due to currency conversion, incomplete data, or uncertain fees. + {% for entry in entries["expense"] %} - {{ entry_table_row(entry.description, entry.amount, entry.is_approximate) }} + {{ entry_table_row(entry.description, entry.amount) }} {% endfor %} {{ entry_table_row("{} total expenses".format(current_time.strftime("%B %Y")), entries["expense"]|sum(attribute="amount"), is_summary=True) }} @@ -44,20 +46,17 @@ {% for entry in entries["income"] %} - {{ entry_table_row(entry.description, entry.amount, entry.is_approximate) }} + {{ entry_table_row(entry.description, entry.amount) }} {% endfor %} {{ entry_table_row("{} total income (so far)".format(current_time.strftime("%B %Y")), entries["income"]|sum(attribute="amount"), is_summary=True) }}
Expenses
Income
- -* Approximate, due to currency conversion, incomplete data, or uncertain fees. {% endblock %} -{% macro entry_table_row(description, amount, is_approximate=False, is_summary=False) %} +{% macro entry_table_row(description, amount, is_summary=False) %} {{ description }} - {% if is_approximate %}*{% endif %} {{ format_money(amount) }} diff --git a/tildes/tildes/templates/home.jinja2 b/tildes/tildes/templates/home.jinja2 index 77fa1c9..84b0411 100644 --- a/tildes/tildes/templates/home.jinja2 +++ b/tildes/tildes/templates/home.jinja2 @@ -94,7 +94,8 @@ {% macro donation_goal(financial_data, current_time) %}
-
{{ current_time.strftime("%B %Y") }} donation goal
+
Tildes's progress to sustainability
+
{{ financial_data["goal_percentage"] }}%
-

- Tildes is a non-profit site with no ads or investors, funded entirely by donations.
- Please donate to support its continued development! (more details) -

+

{{ current_time.strftime("%B %Y") }} donations

+ +

Tildes is a non-profit site with no ads or investors, funded entirely by donations.

+ +

Please donate to support its continued development! (more details)

{% endmacro %}