From 94b283d0e93930aad8d817a15e0ad5b355a74d5b Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 6 Sep 2015 16:31:31 -0400 Subject: [PATCH] Flesh out user donations panel a bit --- fosspay/blueprints/html.py | 2 +- fosspay/objects.py | 5 ++++- templates/panel.html | 30 ++++++++++++++++++++++++++++ templates/post-donation-message.html | 2 +- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/fosspay/blueprints/html.py b/fosspay/blueprints/html.py index 293a002..c7e4fcc 100644 --- a/fosspay/blueprints/html.py +++ b/fosspay/blueprints/html.py @@ -204,4 +204,4 @@ def reset_password(token): def panel(): return render_template("panel.html", one_times=lambda u: [d for d in u.donations if d.type == DonationType.one_time], - recurring=lambda u: next(d for d in u.donations if d.type == DonationType.recurring)) + recurring=lambda u: [d for d in u.donations if d.type == DonationType.monthly and d.active]) diff --git a/fosspay/objects.py b/fosspay/objects.py index 504727d..5e70c04 100644 --- a/fosspay/objects.py +++ b/fosspay/objects.py @@ -59,17 +59,20 @@ class Donation(Base): type = Column(ChoiceType(DonationType, impl=String())) amount = Column(Integer, nullable=False) created = Column(DateTime, nullable=False) - emailed_about = Column(Boolean, nullable=False) + updated = Column(DateTime, nullable=False) comment = Column(String(512)) + active = Column(Boolean) def __init__(self, user, type, amount, project=None, comment=None): self.user = user self.type = type self.amount = amount self.created = datetime.now() + self.updated = datetime.now() self.emailed_about = False self.project = project self.comment = comment + self.active = True def __repr__(self): return "".format( diff --git a/templates/panel.html b/templates/panel.html index af7af5f..ff9c6ae 100644 --- a/templates/panel.html +++ b/templates/panel.html @@ -10,6 +10,35 @@
+ {% if any(recurring(user)) %} +

Monthly Donations

+ + + + + + + + + + + {% for donation in recurring(user) %} + + + + + + + {% endfor %} + +
DateAmountProject
+
+ +
+
{{ donation.created.strftime("%Y-%m-%d") }}${{ "{:.2f}".format(donation.amount / 100) }}{{ donation.project.name if donation.project else "Not specified" }}
+ {% endif %} + {% if any(one_times(user)) %} +

One-time Donations

@@ -28,5 +57,6 @@ {% endfor %}
+ {% endif %}
{% endblock %} diff --git a/templates/post-donation-message.html b/templates/post-donation-message.html index 229f4f6..ff98cdb 100644 --- a/templates/post-donation-message.html +++ b/templates/post-donation-message.html @@ -1,2 +1,2 @@

Thanks!

-

You'll get an email when your money is going to be put to work.

+

Have a great day!