]> git.ipfire.org Git - ipfire.org.git/commitdiff
donation: Add list of countries
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jul 2018 10:25:33 +0000 (11:25 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jul 2018 10:25:33 +0000 (11:25 +0100)
And select the right one based on GeoIP location

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/donate.html
src/web/handlers.py

index 45307bb64957bb9406a0303297cb10efaec17721..9caa667e9551780070e89aadf6b590c5f9ccba10 100644 (file)
                                                                                                                <div class="form-group">
                                                                                                                        <select class="form-control" required>
                                                                                                                                <option value="">- {{ _("Country") }} -</option>
-                                                                                                                               <option>2</option>
-                                                                                                                               <option>3</option>
-                                                                                                                               <option>4</option>
-                                                                                                                               <option>5</option>
+
+                                                                                                                               {% for c in countries %}
+                                                                                                                                       <option value="{{ c.alpha2 }}" {% if country == c.alpha2 %}selected{% end %}>{{ c.name }}</option>
+                                                                                                                               {% end %}
                                                                                                                        </select>
                                                                                                                </div>
                                                                                                        </div>
index cc710d2bdea2df3bc3479f364f23ea0f4a6c2dbf..15f3b3eab7b9e51169b90f5ddb87a7a14e54ab18 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 #import httplib
+import iso3166
 #import logging
 #import markdown2
 import operator
@@ -93,7 +94,14 @@ class GeoIPHandler(BaseHandler):
 
 class DonateHandler(BaseHandler):
        def get(self):
-               self.render("donate.html")
+               location = self.get_remote_location()
+
+               if location:
+                       country = location.country
+               else:
+                       country = None
+
+               self.render("donate.html", countries=iso3166.countries, country=country)
 
        @tornado.gen.coroutine
        def post(self):