From c54c37b10e4a32351f22812ec7a4f8b971143645 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 15 Nov 2021 23:01:58 -0800 Subject: [PATCH] setup donation page and begging --- wowstash/blueprints/meta/routes.py | 8 +++--- wowstash/blueprints/wallet/routes.py | 21 ++++++++++++++- wowstash/models.py | 16 ++++++++++++ wowstash/templates/meta/donate.html | 33 ++++++++++++++++++++++++ wowstash/templates/wallet/dashboard.html | 3 ++- 5 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 wowstash/templates/meta/donate.html diff --git a/wowstash/blueprints/meta/routes.py b/wowstash/blueprints/meta/routes.py index 530caec..52d0f31 100644 --- a/wowstash/blueprints/meta/routes.py +++ b/wowstash/blueprints/meta/routes.py @@ -36,8 +36,6 @@ def health(): 'docker': Docker().client.ping() }), 200) -# @app.errorhandler(404) -# def not_found(error): -# return make_response(jsonify({ -# 'error': 'Page not found' -# }), 404) +@meta_bp.route('/donate') +def donate(): + return render_template('meta/donate.html') diff --git a/wowstash/blueprints/wallet/routes.py b/wowstash/blueprints/wallet/routes.py index 1496897..8fb88bb 100644 --- a/wowstash/blueprints/wallet/routes.py +++ b/wowstash/blueprints/wallet/routes.py @@ -15,7 +15,7 @@ from wowstash.library.jsonrpc import Wallet, daemon, to_atomic from wowstash.library.cache import cache from wowstash.forms import Send, Delete, Restore from wowstash.factory import db -from wowstash.models import User +from wowstash.models import User, DonatePrompt from wowstash import config @@ -70,6 +70,25 @@ def dashboard(): sleep(1.5) return redirect(url_for('wallet.loading')) + # Redirect to donate page if user isnt prompted for a bit + dp = DonatePrompt.query.filter( + DonatePrompt.user == current_user.id + ).order_by( + DonatePrompt.date.desc() + ).first() + if not dp: + d = DonatePrompt(user=current_user.id) + db.session.add(d) + db.session.commit() + return redirect(url_for('meta.donate')) + + # If havent seen donate page in some time, show again + if dp.hours_elapsed() > 168: + d = DonatePrompt(user=current_user.id) + db.session.add(d) + db.session.commit() + return redirect(url_for('meta.donate')) + address = wallet.get_address() transfers = wallet.get_transfers() for type in transfers: diff --git a/wowstash/models.py b/wowstash/models.py index ec39bbc..e56c293 100644 --- a/wowstash/models.py +++ b/wowstash/models.py @@ -89,3 +89,19 @@ class PasswordReset(db.Model): def __repr__(self): return self.id + + +class DonatePrompt(db.Model): + __tablename__ = 'donate_prompts' + + id = db.Column(db.Integer, primary_key=True) + user = db.Column(db.Integer, db.ForeignKey(User.id)) + date = db.Column(db.DateTime, server_default=func.now()) + + def hours_elapsed(self): + now = datetime.utcnow() + diff = now - self.date + return diff.total_seconds() / 60 / 60 + + def __repr__(self): + return str(f'donate-prompt-{self.id}') diff --git a/wowstash/templates/meta/donate.html b/wowstash/templates/meta/donate.html new file mode 100644 index 0000000..948aae8 --- /dev/null +++ b/wowstash/templates/meta/donate.html @@ -0,0 +1,33 @@ + + + + {% include 'head.html' %} + + + + {% include 'navbar.html' %} + +
+
+
+
+
+

Donate

+

Hey, this service is provided to you for free, please consider donating some WOW since I both donate my time and money keeping the service alive and paying for hosting.

+

lza_menace: Wo59kvcHiDd48sstysDqGgBAN1fECLKALKw2bPUJhS4UjX9wj2SK4e4GH6HvrBmot6cBrWNE1T65UR6a5SLbzh882c1SXEhiK

+ Ok, take me to my wallet +

+ Nah, fuck you menace. +
+
+
+
+
+ + {% include 'footer.html' %} + + {% include 'scripts.html' %} + + + + diff --git a/wowstash/templates/wallet/dashboard.html b/wowstash/templates/wallet/dashboard.html index 28aafa4..db17c86 100644 --- a/wowstash/templates/wallet/dashboard.html +++ b/wowstash/templates/wallet/dashboard.html @@ -117,7 +117,7 @@ {{ send_form.csrf_token }}
{{ send_form.address.label }} - {{ send_form.address }} +
{{ send_form.amount.label }} @@ -130,6 +130,7 @@ + Donation Info