From 495f3b63a185b203f09abbd13aa80240e0c0ce27 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 9 May 2016 21:12:25 -0400 Subject: [PATCH] Add a helper to Country; should go upstream prolly --- gratipay/models/country.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gratipay/models/country.py b/gratipay/models/country.py index 6b6dc5e668..646a8861e7 100644 --- a/gratipay/models/country.py +++ b/gratipay/models/country.py @@ -16,3 +16,7 @@ class Country(Model): """ typname = 'countries' + + @classmethod + def from_code2(cls, code2): + return cls.db.one("SELECT countries.*::countries FROM countries WHERE code2=%s", (code2,))