start working on accepting tx and subscription info

main
lza_menace 3 years ago
parent 3ecdec68aa
commit 543736704b

@ -7,3 +7,8 @@ from wtforms.validators import DataRequired
class UserAuth(FlaskForm): class UserAuth(FlaskForm):
username = StringField('Username:', validators=[DataRequired()], render_kw={"placeholder": "Username", "class": "form-control", "type": "text"}) username = StringField('Username:', validators=[DataRequired()], render_kw={"placeholder": "Username", "class": "form-control", "type": "text"})
password = StringField('Password:', validators=[DataRequired()], render_kw={"placeholder": "Password", "class": "form-control", "type": "password"}) password = StringField('Password:', validators=[DataRequired()], render_kw={"placeholder": "Password", "class": "form-control", "type": "password"})
class ConfirmSubscription(FlaskForm):
tx_id = StringField('TX ID:', validators=[DataRequired()], render_kw={"placeholder": "TX ID", "class": "form-control", "type": "text"})
tx_key = StringField('TX Key:', validators=[DataRequired()], render_kw={"placeholder": "TX Key", "class": "form-control", "type": "text"})
wallet_address = StringField('XMR Address:', validators=[DataRequired()], render_kw={"placeholder": "XMR Address", "class": "form-control", "type": "text"})

@ -1,5 +1,6 @@
from quart import Blueprint, render_template, flash, redirect, url_for from quart import Blueprint, render_template, flash, redirect, url_for
from xmrbackers.forms import ConfirmSubscription
from xmrbackers.models import User, CreatorProfile, TextPost, SubscriptionMeta from xmrbackers.models import User, CreatorProfile, TextPost, SubscriptionMeta
@ -42,10 +43,22 @@ async def subscription(username):
subscription_meta = SubscriptionMeta.select().where( subscription_meta = SubscriptionMeta.select().where(
SubscriptionMeta.creator == creator SubscriptionMeta.creator == creator
).order_by(SubscriptionMeta.create_date.desc()).first() ).order_by(SubscriptionMeta.create_date.desc()).first()
form = ConfirmSubscription()
return await render_template( return await render_template(
'creator/subscription.html', 'creator/subscription.html',
subscription_meta=subscription_meta subscription_meta=subscription_meta,
form=form
) )
else: else:
await flash('That creator does not exist.') await flash('That creator does not exist.')
return redirect(url_for('meta.index')) return redirect(url_for('meta.index'))
@bp.route('/subscription/<int:creator_id>/confirm', methods=['POST'])
async def confirm_subscription(creator_id):
form = ConfirmSubscription()
if form.validate_on_submit():
return redirect(url_for('meta.index'))
else:
await flash('Unable to accept form POST.')
return redirect(url_for('meta.index'))

@ -15,6 +15,24 @@
<p>XMR: {{ subscription_meta.atomic_xmr | from_atomic }}</p> <p>XMR: {{ subscription_meta.atomic_xmr | from_atomic }}</p>
<p>Address: {{ subscription_meta.wallet_address }}</p> <p>Address: {{ subscription_meta.wallet_address }}</p>
<p>Hours: {{ subscription_meta.number_hours }}</p> <p>Hours: {{ subscription_meta.number_hours }}</p>
<form method="POST" action="{{ url_for('creator.confirm_subscription', creator_id=subscription_meta.creator.id) }}">
{% for f in form %}
{% if f.name == 'csrf_token' %}
{{ f }}
{% else %}
<div class="form-group">
{{ f.label }}
{{ f }}
</div>
{% endif %}
{% endfor %}
<ul>
{% for field, errors in form.errors.items() %}
<li>{{ form[field].label }}: {{ ', '.join(errors) }}</li>
{% endfor %}
</ul>
<input type="submit" value="Confirm" class="btn btn-link btn-outline btn-xl">
</form>
{% endif %} {% endif %}
{% include 'includes/footer.html' %} {% include 'includes/footer.html' %}

Loading…
Cancel
Save