summaryrefslogtreecommitdiff
path: root/postgresqleu/util/backendlookups.py
diff options
context:
space:
mode:
authorMagnus Hagander2019-03-28 14:37:53 +0000
committerMagnus Hagander2019-03-28 14:37:53 +0000
commitafbbf702078dd3e7e98cd04523093f0d68188051 (patch)
tree226cf2defed24f98c434a2b1b14a02a19506358a /postgresqleu/util/backendlookups.py
parentd053129df7e8f628e7ea6711830cd5ae0342f000 (diff)
Make country optional and show most common countries
With country mandatory we see people picking something from the top of the list, probably just because it's easy or because they don't want to share their country. To deal with the first, modify the country selection so that it first shows the most common countries used for this conference, and only later the full list of countries. The initial list of countries under "common countries" can be specified at the conference configuration, and will then gradually be replaced with the actual countries of the attendees. To deal with the second, make the country field optional.
Diffstat (limited to 'postgresqleu/util/backendlookups.py')
-rw-r--r--postgresqleu/util/backendlookups.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/postgresqleu/util/backendlookups.py b/postgresqleu/util/backendlookups.py
index 4392b3c8..136cbbfa 100644
--- a/postgresqleu/util/backendlookups.py
+++ b/postgresqleu/util/backendlookups.py
@@ -59,3 +59,25 @@ class GeneralAccountLookup(LookupBase):
Q(username__icontains=query) | Q(first_name__icontains=query) | Q(last_name__icontains=query)
)[:30]
]
+
+
+class CountryLookup(LookupBase):
+ @property
+ def url(self):
+ return '/events/admin/lookups/country/'
+
+ @property
+ def label_from_instance(self):
+ return lambda x: x.printable_name
+
+ @classmethod
+ def get_values(self, query):
+ return [
+ {
+ 'id': c.iso,
+ 'value': c.printable_name,
+ }
+ for c in Country.objects.filter(
+ Q(printable_name__icontains=query) | Q(iso__icontains=query)
+ )[:30]
+ ]