]>
git.ipfire.org Git - ipfire.org.git/blob - src/web/donate.py
9 class DonateHandler(base
.BaseHandler
):
12 # Makes sure that we call blacklist for everything
16 location
= self
.get_remote_location()
19 country
= location
.country
24 first_name
= self
.get_argument("first_name", None)
25 last_name
= self
.get_argument("last_name", None)
26 amount
= self
.get_argument_int("amount", None)
27 currency
= self
.get_argument("currency", None)
28 frequency
= self
.get_argument("frequency", None)
30 # Set default currency
31 if not currency
in ("EUR", "USD"):
34 # Default to USD for the US only
38 # Set default frequency
39 if not frequency
in ("one-time", "monthly"):
40 frequency
= "one-time"
42 self
.render("donate/donate.html", countries
=iso3166
.countries
,
43 country
=country
, first_name
=first_name
, last_name
=last_name
,
44 amount
=amount
, currency
=currency
, frequency
=frequency
)
46 @tornado.gen
.coroutine
48 amount
= self
.get_argument("amount")
49 currency
= self
.get_argument("currency", "EUR")
50 frequency
= self
.get_argument("frequency")
55 "currency" : currency
,
57 # Is this a recurring donation?
58 "recurring" : frequency
== "monthly",
61 "email" : self
.get_argument("email"),
62 "title" : self
.get_argument("title"),
63 "first_name" : self
.get_argument("first_name"),
64 "last_name" : self
.get_argument("last_name"),
65 "company_name" : self
.get_argument("company_name", None),
66 "street1" : self
.get_argument("street1"),
67 "street2" : self
.get_argument("street2", None),
68 "post_code" : self
.get_argument("post_code"),
69 "city" : self
.get_argument("city"),
70 "state" : self
.get_argument("state", None),
71 "country_code" : self
.get_argument("country_code"),
74 # Add URLs to redirect the user back
76 "success_url" : "https://%s/donate/thank-you" % self
.request
.host
,
77 "error_url" : "https://%s/donate/error" % self
.request
.host
,
78 "back_url" : "https://%s/donate?amount=%s¤cy=%s&frequency=%s" %
79 (self
.request
.host
, amount
, currency
, frequency
),
82 # Send request to Zeiterfassung
84 response
= yield self
.backend
.zeiterfassung
.send_request(
85 "/api/v1/donations/create/ipfire-project", **args
)
88 raise # XXX handle any problems when Zeiterfassung is unreachable
90 # Redirect the user to the payment page
91 redirect_url
= response
.get("redirect_url")
93 raise tornado
.web
.HTTPError(500, "Did not receive a redirect URL")
95 self
.redirect(redirect_url
)
98 class ThankYouHandler(base
.BaseHandler
):
100 self
.render("donate/thank-you.html")
103 class ErrorHandler(base
.BaseHandler
):
105 self
.render("donate/error.html")