Browse Source

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.
merge-requests/110/head
Deimos 5 years ago
parent
commit
c5492cf4ed
  1. 33
      tildes/alembic/versions/fe91222503ef_financials_drop_is_approximate_column.py
  2. 11
      tildes/scss/modules/_donation.scss
  3. 3
      tildes/tildes/models/financials.py
  4. 11
      tildes/tildes/templates/financials.jinja2
  5. 14
      tildes/tildes/templates/home.jinja2

33
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,
),
)

11
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 {

3
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__ = (

11
tildes/tildes/templates/financials.jinja2

@ -30,11 +30,13 @@
<h2>{{ current_time.strftime("%B %Y") }} expenses and income</h2>
<small>Note: Most amounts are approximate, due to currency conversion, incomplete data, or uncertain fees.</small>
<table class="table table-financials">
<tr><th colspan="2">Expenses</th></tr>
{% 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 @@
<tr><th colspan="2">Income</th></tr>
{% 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) }}
</table>
<small>* Approximate, due to currency conversion, incomplete data, or uncertain fees.</small>
{% endblock %}
{% macro entry_table_row(description, amount, is_approximate=False, is_summary=False) %}
{% macro entry_table_row(description, amount, is_summary=False) %}
<tr{{ ' class="tr-summary"'|safe if is_summary }}>
<td>{{ description }}</td>
<td class="td-money">
{% if is_approximate %}*{% endif %}
{{ format_money(amount) }}
</td>
</tr>

14
tildes/tildes/templates/home.jinja2

@ -94,7 +94,8 @@
{% macro donation_goal(financial_data, current_time) %}
<div class="donation-goal">
<header>{{ current_time.strftime("%B %Y") }} donation goal</header>
<header>Tildes's progress to sustainability</header>
<div class="donation-goal-progress">
<meter
{% if financial_data["goal_percentage"] <= 100 %}
@ -110,14 +111,15 @@
max="{{ financial_data["income"] }}"
value="{{ financial_data["goal"] }}"
{% endif %}
title="${{ financial_data["income"] }} / ${{ financial_data["goal"] }} (USD)"
title="${{ financial_data["income"] }} of ${{ financial_data["goal"] }} goal (USD)"
></meter>
<span class="donation-goal-percentage">{{ financial_data["goal_percentage"] }}%</span>
</div>
<p>
Tildes is a non-profit site with no ads or investors, funded entirely by donations.<br>
<a href="https://docs.tildes.net/donate">Please donate</a> to support its continued development! <a href="/financials">(more details)</a>
</p>
<p class="text-secondary">{{ current_time.strftime("%B %Y") }} donations</p>
<p>Tildes is a non-profit site with no ads or investors, funded entirely by donations.</p>
<p><a href="https://docs.tildes.net/donate">Please donate</a> to support its continued development! (<a href="/financials">more details</a>)</p>
</div>
{% endmacro %}
Loading…
Cancel
Save