diff --git a/metabrainz/payments/views.py b/metabrainz/payments/views.py index bdc9f15c..b8105807 100644 --- a/metabrainz/payments/views.py +++ b/metabrainz/payments/views.py @@ -1,9 +1,13 @@ from __future__ import division + +from decimal import Decimal, InvalidOperation + from flask import Blueprint, request, render_template, url_for, redirect, current_app, jsonify from flask_babel import gettext +from flask_login import current_user from werkzeug.datastructures import MultiDict -from metabrainz.payments import SUPPORTED_CURRENCIES +from metabrainz.payments import SUPPORTED_CURRENCIES, Currency from metabrainz.model.payment import Payment from metabrainz.payments.forms import DonationForm, PaymentForm from metabrainz import flash @@ -20,7 +24,35 @@ @payments_bp.route('/donate') def donate(): """Regular donation page.""" - return render_template('payments/donate.html', form=DonationForm()) + form = DonationForm() + + if editor := request.args.get('editor'): + form.editor.data = editor + else: + if current_user is not None and not current_user.is_anonymous: + form.editor.data = current_user.musicbrainz_id + + amount = None + if _amount := request.args.get('amount'): + try: + value = Decimal(_amount) + if value >= 0: + amount = value + except (ValueError, TypeError, InvalidOperation): + pass + + if amount is None: + amount = Decimal(50) + form.amount.data = amount + + _currency = request.args.get('currency', 'usd') + if _currency.lower() == 'eur': + currency = 'eur' + else: + currency = 'usd' + form.currency.data = currency + + return render_template('payments/donate.html', form=form) @payments_bp.route('/payment/') diff --git a/metabrainz/templates/index/team.html b/metabrainz/templates/index/team.html index ebb0201e..e1740636 100644 --- a/metabrainz/templates/index/team.html +++ b/metabrainz/templates/index/team.html @@ -294,23 +294,23 @@

{{ _('David "drsaunde" Saunders — MusicBrain
CatCat's photo

{{ _('Akira Holm — MusicBrainz Instruments') }}

- {{ _('CatQuest, the Endeavouring Cat! (CatCat, for short) has been a MusicBrainz editor since 2004, and + {{ _('ApeKattQuest or MonkeyPython has been a MusicBrainz editor since 2004, and is in charge of adding and improving the musical instruments in MusicBrainz (the very unseriously-named, yet quite important "Instrument Inserter" position). When not looking all over the internet (and the library!) for instrument data, his other hobbies include playing games, listening to all sorts of different music, Lupin III, colouring, and collecting all sorts of things, from stickers and stamps to bottlecaps.') }}

diff --git a/metabrainz/templates/payments/donate.html b/metabrainz/templates/payments/donate.html index a15675d8..feae52b8 100644 --- a/metabrainz/templates/payments/donate.html +++ b/metabrainz/templates/payments/donate.html @@ -39,7 +39,7 @@

{{ _('Make a Donation') }}

- {{ form.amount(id="input-amount", class="form-control", value="50.00") | safe }} + {{ form.amount(id="input-amount", class="form-control") | safe }}
{% for subfield in form.currency %}