]>
git.ipfire.org Git - ipfire.org.git/blob - src/web/donate.py
8 class DonateHandler(base
.BaseHandler
):
10 location
= self
.get_remote_location()
13 country
= location
.country
18 first_name
= self
.get_argument("first_name", None)
19 last_name
= self
.get_argument("last_name", None)
20 amount
= self
.get_argument_float("amount", None)
21 currency
= self
.get_argument("currency", None)
22 frequency
= self
.get_argument("frequency", None)
24 # Set default currency
25 if not currency
in ("EUR", "USD"):
28 # Default to USD for the US only
32 # Set default frequency
33 if not frequency
in ("one-time", "monthly"):
34 frequency
= "one-time"
36 self
.render("donate/donate.html", countries
=iso3166
.countries
,
37 country
=country
, first_name
=first_name
, last_name
=last_name
,
38 amount
=amount
, currency
=currency
, frequency
=frequency
)
40 @base.ratelimit(minutes
=24*60, requests
=5)
42 amount
= self
.get_argument("amount")
43 currency
= self
.get_argument("currency", "EUR")
44 frequency
= self
.get_argument("frequency")
49 "currency" : currency
,
51 # Is this a recurring donation?
52 "recurring" : frequency
== "monthly",
55 "email" : self
.get_argument("email"),
56 "title" : self
.get_argument("title"),
57 "first_name" : self
.get_argument("first_name"),
58 "last_name" : self
.get_argument("last_name"),
59 "company_name" : self
.get_argument("company_name", None),
60 "street1" : self
.get_argument("street1"),
61 "street2" : self
.get_argument("street2", None),
62 "post_code" : self
.get_argument("post_code"),
63 "city" : self
.get_argument("city"),
64 "state" : self
.get_argument("state", None),
65 "country_code" : self
.get_argument("country_code"),
68 # Add URLs to redirect the user back
70 "success_url" : "https://%s/donate/thank-you" % self
.request
.host
,
71 "error_url" : "https://%s/donate/error" % self
.request
.host
,
72 "back_url" : "https://%s/donate?amount=%s¤cy=%s&frequency=%s" %
73 (self
.request
.host
, amount
, currency
, frequency
),
76 # Send request to Zeiterfassung
78 response
= await self
.backend
.zeiterfassung
.send_request(
79 "/api/v1/donations/create/ipfire-project", **args
)
82 raise # XXX handle any problems when Zeiterfassung is unreachable
84 # Redirect the user to the payment page
85 redirect_url
= response
.get("redirect_url")
87 raise tornado
.web
.HTTPError(500, "Did not receive a redirect URL")
89 self
.redirect(redirect_url
)
92 class ThankYouHandler(base
.BaseHandler
):
94 self
.render("donate/thank-you.html")
97 class ErrorHandler(base
.BaseHandler
):
99 self
.render("donate/error.html")