]>
git.ipfire.org Git - ipfire.org.git/blob - src/web/donate.py
9 class DonateHandler(base
.BaseHandler
):
11 location
= self
.get_remote_location()
14 country
= location
.country
19 amount
= self
.get_argument_int("amount", None)
20 currency
= self
.get_argument("currency", None)
21 frequency
= self
.get_argument("frequency", None)
23 # Set default currency
24 if not currency
in ("EUR", "USD"):
27 # Default to USD for the US only
31 # Set default frequency
32 if not frequency
in ("one-time", "monthly"):
33 frequency
= "one-time"
35 self
.render("donate.html", countries
=iso3166
.countries
,
36 country
=country
, amount
=amount
, currency
=currency
, frequency
=frequency
)
38 @tornado.gen
.coroutine
40 amount
= self
.get_argument("amount")
41 currency
= self
.get_argument("currency", "EUR")
42 frequency
= self
.get_argument("frequency")
47 "currency" : currency
,
49 # Is this a recurring donation?
50 "recurring" : frequency
== "monthly",
53 "email" : self
.get_argument("email"),
54 "title" : self
.get_argument("title"),
55 "first_name" : self
.get_argument("first_name"),
56 "last_name" : self
.get_argument("last_name"),
57 "company_name" : self
.get_argument("company_name", None),
58 "street1" : self
.get_argument("street1"),
59 "street2" : self
.get_argument("street2", None),
60 "post_code" : self
.get_argument("post_code"),
61 "city" : self
.get_argument("city"),
62 "state" : self
.get_argument("state", None),
63 "country_code" : self
.get_argument("country_code"),
66 # Add URLs to redirect the user back
68 "success_url" : "https://%s/donate/thank-you" % self
.request
.host
,
69 "error_url" : "https://%s/donate/error" % self
.request
.host
,
70 "back_url" : "https://%s/donate?amount=%s¤cy=%s&frequency=%s" %
71 (self
.request
.host
, amount
, currency
, frequency
),
74 # Send request to Zeiterfassung
76 response
= yield self
.backend
.zeiterfassung
.send_request(
77 "/api/v1/donations/create/ipfire-project", **args
)
80 raise # XXX handle any problems when Zeiterfassung is unreachable
82 # Redirect the user to the payment page
83 redirect_url
= response
.get("redirect_url")
85 raise tornado
.web
.HTTPError(500, "Did not receive a redirect URL")
87 self
.redirect(redirect_url
)
90 class ThankYouHandler(base
.BaseHandler
):
92 self
.render("donate/thank-you.html")
95 class ErrorHandler(base
.BaseHandler
):
97 self
.render("donate/error.html")