src/web/base.py \
src/web/blog.py \
src/web/boot.py \
+ src/web/donate.py \
src/web/download.py \
src/web/fireinfo.py \
src/web/handlers.py \
templates_DATA = \
src/templates/base.html \
- src/templates/donate.html \
src/templates/error.html \
src/templates/index.html
templates_blog_modulesdir = $(templates_blogdir)/modules
+templates_donate_DATA = \
+ src/templates/donate/donate.html \
+ src/templates/donate/error.html \
+ src/templates/donate/thank-you.html
+
+templates_donatedir = $(templatesdir)/donate
+
templates_download_DATA = \
src/templates/download/release.html
-{% extends "base.html" %}
+{% extends "../base.html" %}
{% block title %}{{ _("Donate") }}{% end block %}
--- /dev/null
+{% extends "../error.html" %}
+
+{% block title %}{{ _("Oops!") }}{% end block %}
+
+{% block message %}{{ _("Error") }}{% end block %}
+
+{% block main %}
+ <p>
+ {{ _("Unfortunately we were not able to process your donation.") }}
+ {{ _("Please try again later.") }}
+ </p>
+{% end block %}
--- /dev/null
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Thank You!") }}{% end block %}
+
+{% block container %}
+ <section>
+ <div class="container">
+ <div class="row">
+ <div class="col col-lg-6">
+ <h1 class="display-2">{{ _("Thank You") }}</h1>
+
+ <p>
+ {{ _("Thank you very much for your donation to the IPFire Project.") }}
+ </p>
+ </div>
+ </div>
+ </div>
+ </section>
+{% end block %}
<div class="container">
<div class="row justify-content-center mt-5">
<div class="col col-md-5">
- <h5 class="mb-0">{{ _("Error %s") % status_code }}</h5>
+ <h5 class="mb-0">{% block message %}{{ _("Error %s") % status_code }}{% end block %}</h5>
<h1>{{ _("oops, something went wrong") }}</h1>
+
+ {% block main %}{% end block %}
</div>
</div>
</div>
from . import auth
from . import blog
from . import boot
+from . import donate
from . import download
from . import fireinfo
from . import iuse
(r"/download/([0-9a-z\-\.]+)", download.ReleaseHandler),
# Donate
- (r"/donate", DonateHandler),
+ (r"/donate", donate.DonateHandler),
+ (r"/donate/thank-you", donate.ThankYouHandler),
+ (r"/donate/error", donate.ErrorHandler),
(r"/donation", tornado.web.RedirectHandler, { "url" : "/donate" }),
# Newsletter
--- /dev/null
+#!/usr/bin/python3
+
+import iso3166
+import tornado.gen
+import tornado.web
+
+from . import base
+
+class DonateHandler(base.BaseHandler):
+ def get(self):
+ location = self.get_remote_location()
+
+ if location:
+ country = location.country
+ else:
+ country = None
+
+ # Get defaults
+ amount = self.get_argument_int("amount", None)
+ currency = self.get_argument("currency", None)
+ frequency = self.get_argument("frequency", None)
+
+ # Set default currency
+ if not currency in ("EUR", "USD"):
+ currency = "EUR"
+
+ # Default to USD for the US only
+ if country == "US":
+ currency = "USD"
+
+ # Set default frequency
+ if not frequency in ("one-time", "monthly"):
+ frequency = "one-time"
+
+ self.render("donate.html", countries=iso3166.countries,
+ country=country, amount=amount, currency=currency, frequency=frequency)
+
+ @tornado.gen.coroutine
+ def post(self):
+ amount = self.get_argument("amount")
+ currency = self.get_argument("currency", "EUR")
+ frequency = self.get_argument("frequency")
+
+ # Get form inputs
+ args = {
+ "amount" : amount,
+ "currency" : currency,
+
+ # Is this a recurring donation?
+ "recurring" : frequency == "monthly",
+
+ # Address
+ "email" : self.get_argument("email"),
+ "title" : self.get_argument("title"),
+ "first_name" : self.get_argument("first_name"),
+ "last_name" : self.get_argument("last_name"),
+ "company_name" : self.get_argument("company_name", None),
+ "street1" : self.get_argument("street1"),
+ "street2" : self.get_argument("street2", None),
+ "post_code" : self.get_argument("post_code"),
+ "city" : self.get_argument("city"),
+ "state" : self.get_argument("state", None),
+ "country_code" : self.get_argument("country_code"),
+ }
+
+ # Add URLs to redirect the user back
+ args.update({
+ "success_url" : "https://%s/donate/thank-you" % self.request.host,
+ "error_url" : "https://%s/donate/error" % self.request.host,
+ "back_url" : "https://%s/donate?amount=%s¤cy=%s&frequency=%s" %
+ (self.request.host, amount, currency, frequency),
+ })
+
+ # Send request to Zeiterfassung
+ try:
+ response = yield self.backend.zeiterfassung.send_request(
+ "/api/v1/donations/create/ipfire-project", **args)
+
+ except Exception:
+ raise # XXX handle any problems when Zeiterfassung is unreachable
+
+ # Redirect the user to the payment page
+ redirect_url = response.get("redirect_url")
+ if not redirect_url:
+ raise tornado.web.HTTPError(500, "Did not receive a redirect URL")
+
+ self.redirect(redirect_url)
+
+
+class ThankYouHandler(base.BaseHandler):
+ def get(self):
+ self.render("donate/thank-you.html")
+
+
+class ErrorHandler(base.BaseHandler):
+ def get(self):
+ self.render("donate/error.html")
-#!/usr/bin/python
-
-import iso3166
-import tornado.gen
-import tornado.httputil
-import tornado.web
+#!/usr/bin/python3
from . import base
self.redirect("https://blog.ipfire.org/authors/%s" % user, permanent=True)
-class DonateHandler(base.BaseHandler):
- def get(self):
- location = self.get_remote_location()
-
- if location:
- country = location.country
- else:
- country = None
-
- # Get defaults
- amount = self.get_argument_int("amount", None)
- currency = self.get_argument("currency", None)
- frequency = self.get_argument("frequency", None)
-
- # Set default currency
- if not currency in ("EUR", "USD"):
- currency = "EUR"
-
- # Default to USD for the US only
- if country == "US":
- currency = "USD"
-
- # Set default frequency
- if not frequency in ("one-time", "monthly"):
- frequency = "one-time"
-
- self.render("donate.html", countries=iso3166.countries,
- country=country, amount=amount, currency=currency, frequency=frequency)
-
- @tornado.gen.coroutine
- def post(self):
- amount = self.get_argument("amount")
- currency = self.get_argument("currency", "EUR")
- frequency = self.get_argument("frequency")
-
- # Get form inputs
- args = {
- "amount" : amount,
- "currency" : currency,
-
- # Is this a recurring donation?
- "recurring" : frequency == "monthly",
-
- # Address
- "email" : self.get_argument("email"),
- "title" : self.get_argument("title"),
- "first_name" : self.get_argument("first_name"),
- "last_name" : self.get_argument("last_name"),
- "company_name" : self.get_argument("company_name", None),
- "street1" : self.get_argument("street1"),
- "street2" : self.get_argument("street2", None),
- "post_code" : self.get_argument("post_code"),
- "city" : self.get_argument("city"),
- "state" : self.get_argument("state", None),
- "country_code" : self.get_argument("country_code"),
- }
-
- # Add URLs to redirect the user back
- args.update({
- "success_url" : "https://%s/donate/thank-you" % self.request.host,
- "error_url" : "https://%s/donate/error" % self.request.host,
- "back_url" : "https://%s/donate?amount=%s¤cy=%s&frequency=%s" %
- (self.request.host, amount, currency, frequency),
- })
-
- # Send request to Zeiterfassung
- try:
- response = yield self.backend.zeiterfassung.send_request(
- "/api/v1/donations/create/ipfire-project", **args)
-
- except Exception:
- raise # XXX handle any problems when Zeiterfassung is unreachable
-
- # Redirect the user to the payment page
- redirect_url = response.get("redirect_url")
- if not redirect_url:
- raise tornado.web.HTTPError(500, "Did not receive a redirect URL")
-
- self.redirect(redirect_url)
-
-
class StaticHandler(base.BaseHandler):
def initialize(self, template):
self._template = template