Make default amount and type configurable

master
Drew DeVault 9 years ago
parent fb45e17b65
commit 3bcb966efc
  1. 6
      config.ini.example
  2. 1
      fosspay/app.py
  3. 4
      scripts/index.js
  4. 24
      templates/index.html

@ -26,3 +26,9 @@ connection-string=postgresql://postgres@localhost/fosspay
# Click here first: https://dashboard.stripe.com/account/bitcoin/enable # Click here first: https://dashboard.stripe.com/account/bitcoin/enable
enable-bitcoin=no enable-bitcoin=no
# Pick between 5, 10, 20, or 50
default-amount=10
# Pick between "monthly" and "once"
default-type=monthly

@ -72,5 +72,6 @@ def inject():
'file_link': file_link, 'file_link': file_link,
'user': current_user, 'user': current_user,
'_cfg': _cfg, '_cfg': _cfg,
'_cfgi': _cfgi,
'debug': app.debug 'debug': app.debug
} }

@ -1,7 +1,7 @@
(function() { (function() {
var donation = { var donation = {
type: "monthly", type: window.default_type,
amount: 1000, // cents amount: window.default_amount * 100, // cents
project: null, project: null,
comment: null comment: null
}; };

@ -5,6 +5,8 @@ window.stripe_key = "{{ _cfg("stripe-publish") }}";
window.avatar = "{{ avatar }}"; window.avatar = "{{ avatar }}";
window.your_name = "{{ _cfg("your-name") }}"; window.your_name = "{{ _cfg("your-name") }}";
window.bitcoin = "{{ _cfg("enable-bitcoin") }}" === "yes"; window.bitcoin = "{{ _cfg("enable-bitcoin") }}" === "yes";
window.default_amount = {{ _cfg("default-amount") }};
window.default_type = "{{ _cfg("default-type") }}";
</script> </script>
<script src="//checkout.stripe.com/checkout.js"></script> <script src="//checkout.stripe.com/checkout.js"></script>
<script src="static/index.js"></script> <script src="static/index.js"></script>
@ -49,16 +51,24 @@ window.bitcoin = "{{ _cfg("enable-bitcoin") }}" === "yes";
<div class="col-md-8 col-md-offset-2"> <div class="col-md-8 col-md-offset-2">
<div class="btn-group btn-group-justified amounts" role="group" aria-label="..."> <div class="btn-group btn-group-justified amounts" role="group" aria-label="...">
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button data-amount="5" type="button" class="btn btn-default">$5</button> <button data-amount="5" type="button"
class="btn btn-default {{"active" if _cfgi("default-amount") == 5 else ""}}">
$5</button>
</div> </div>
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button data-amount="10" type="button" class="btn btn-default active">$10</button> <button data-amount="10" type="button"
class="btn btn-default {{"active" if _cfgi("default-amount") == 10 else ""}}">
$10</button>
</div> </div>
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button data-amount="20" type="button" class="btn btn-default">$20</button> <button data-amount="20" type="button"
class="btn btn-default {{"active" if _cfgi("default-amount") == 20 else ""}}">
$20</button>
</div> </div>
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button data-amount="50" type="button" class="btn btn-default">$50</button> <button data-amount="50" type="button"
class="btn btn-default {{"active" if _cfgi("default-amount") == 50 else ""}}">
$50</button>
</div> </div>
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button data-amount="custom" type="button" class="btn btn-default">Custom</button> <button data-amount="custom" type="button" class="btn btn-default">Custom</button>
@ -87,11 +97,13 @@ window.bitcoin = "{{ _cfg("enable-bitcoin") }}" === "yes";
<div class="btn-group btn-group-justified frequencies" role="group" aria-label="..."> <div class="btn-group btn-group-justified frequencies" role="group" aria-label="...">
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button data-frequency="once" type="button" <button data-frequency="once" type="button"
class="btn btn-default">Once</button> class="btn btn-default {{"active" if _cfg("default-type")=="once" else ""}}">
Once</button>
</div> </div>
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button data-frequency="monthly" type="button" <button data-frequency="monthly" type="button"
class="btn btn-default active">Monthly</button> class="btn btn-default {{"active" if _cfg("default-type")=="monthly" else ""}}">
Monthly</button>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save