Skip to content

Commit

Permalink
Merge branch 'master' of github.com:metabrainz/metabrainz.org
Browse files Browse the repository at this point in the history
  • Loading branch information
mayhem committed Oct 21, 2024
2 parents 53d6076 + 9e09db4 commit 962984a
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 140 deletions.
36 changes: 34 additions & 2 deletions metabrainz/payments/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/')
Expand Down
10 changes: 5 additions & 5 deletions metabrainz/templates/index/team.html
Original file line number Diff line number Diff line change
Expand Up @@ -294,23 +294,23 @@ <h4>{{ _('<span class="name">David "drsaunde" Saunders</span> &mdash; MusicBrain

<div class="person">
<img
alt="CatCat's photo"
alt="MonkeyPython's photo"
class="pic"
src="{{ url_for('static', filename='img/team/catcat.jpg') }}"
/>
<div class="bio">
<h4>{{ _('<span class="name">Akira Holm</span> &mdash; MusicBrainz Instruments') }}</h4>
<p>
{{ _('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.') }}
</p>
<ul class="links">
<li><strong>IRC:</strong> ApeKattQuest</li>
<li><strong>MusicBrainz:</strong> <a href="https://musicbrainz.org/user/CatCat">CatCat</a></li>
<li><strong>ListenBrainz:</strong> <a href="https://listenbrainz.org/user/CatCat">CatCat</a></li>
<li><strong>IRC:</strong> ApeKattQuest, MonkeyPython (plus a whole lot of other Lupin III references)</li>
<li><strong>MusicBrainz:</strong> <a href="https://musicbrainz.org/user/ApeKattQuest, MonkeyPython">ApeKattQuest, MonkeyPython</a></li>
<li><strong>ListenBrainz:</strong> <a href="https://listenbrainz.org/user/ApeKattQuest, MonkeyPython">ApeKattQuest, MonkeyPython</a></li>
</ul>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion metabrainz/templates/payments/donate.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1 class="page-title">{{ _('Make a Donation') }}</h1>
<label for="input-amount" class="col-sm-offset-2 col-sm-3 control-label">{{ _('Amount') }}</label>
<div class="col-sm-4">
<div id="input-amount-fg">
{{ form.amount(id="input-amount", class="form-control", value="50.00") | safe }}
{{ form.amount(id="input-amount", class="form-control") | safe }}
<div id="currency-selector" class="btn-group" data-toggle="buttons">
{% for subfield in form.currency %}
<label class="btn btn-primary {{ 'active' if subfield.checked }}">
Expand Down
Loading

0 comments on commit 962984a

Please sign in to comment.