Make form and signature list use two-letter country codes (#336)

make form and signature list use two-letter country codes

Co-authored-by: max.mehl <max.mehl@fsfe.org>
lektura
Max Mehl 2020-04-22 13:31:18 +02:00
parent 238c0b1898
commit dc6157f5db
3 changed files with 16 additions and 15 deletions

View File

@ -10,7 +10,7 @@
"include_vars": { "include_vars": {
"name": "Test Docker", "name": "Test Docker",
"confirm": "jonas@example.com", "confirm": "jonas@example.com",
"country": "Testland", "country": "DE",
"zip": "64632", "zip": "64632",
"comment": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "comment": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
"permissionPriv": "yes", "permissionPriv": "yes",
@ -31,7 +31,7 @@
"include_vars": { "include_vars": {
"name": "Test Testson", "name": "Test Testson",
"confirm": "jonas@example.com", "confirm": "jonas@example.com",
"country": "Sweden", "country": "SE",
"zip": "64632", "zip": "64632",
"comment": "Hey Max! Lets see if this works.", "comment": "Hey Max! Lets see if this works.",
"permissionPriv": "yes", "permissionPriv": "yes",
@ -52,7 +52,7 @@
"include_vars": { "include_vars": {
"name": "Test Testson 2", "name": "Test Testson 2",
"confirm": "jonas@example.com", "confirm": "jonas@example.com",
"country": "Sweden", "country": "ABCDE",
"zip": "64632", "zip": "64632",
"comment": "Hey Max! Lets see if this works, AGAIN!", "comment": "Hey Max! Lets see if this works, AGAIN!",
"permissionPriv": "yes", "permissionPriv": "yes",
@ -95,7 +95,7 @@
"include_vars": { "include_vars": {
"name": "Test Testson 2", "name": "Test Testson 2",
"confirm": "jonas@example.com", "confirm": "jonas@example.com",
"country": "Sweden", "country": "AF",
"zip": "64632", "zip": "64632",
"comment": "Hey Max! Lets see if this works, AGAIN! With timestamp.", "comment": "Hey Max! Lets see if this works, AGAIN! With timestamp.",
"permissionPriv": "yes", "permissionPriv": "yes",
@ -117,7 +117,7 @@
"include_vars": { "include_vars": {
"name": "Max1", "name": "Max1",
"confirm": "mail@example.org", "confirm": "mail@example.org",
"country": "Belgium", "country": "BE",
"zip": "12345", "zip": "12345",
"comment": "", "comment": "",
"permissionPriv": "yes", "permissionPriv": "yes",
@ -139,7 +139,7 @@
"include_vars": { "include_vars": {
"name": "Max3", "name": "Max3",
"confirm": "tech+blah@example.org", "confirm": "tech+blah@example.org",
"country": "Netherlands", "country": "NL",
"zip": "66816", "zip": "66816",
"comment": "mail with + and not appear in list", "comment": "mail with + and not appear in list",
"permissionPriv": "yes", "permissionPriv": "yes",
@ -160,7 +160,7 @@
"include_vars": { "include_vars": {
"name": "Max2", "name": "Max2",
"confirm": "mail@example.org", "confirm": "mail@example.org",
"country": "Bulgaria", "country": "BG",
"zip": "68168", "zip": "68168",
"comment": "This is the same email as Max1", "comment": "This is the same email as Max1",
"permissionPriv": "yes", "permissionPriv": "yes",
@ -182,7 +182,7 @@
"include_vars": { "include_vars": {
"name": "Fan", "name": "Fan",
"confirm": "tech@example.org", "confirm": "tech@example.org",
"country": "Czech Republic", "country": "CZ",
"zip": "26168", "zip": "26168",
"comment": "Yeah", "comment": "Yeah",
"permissionPriv": "yes", "permissionPriv": "yes",
@ -203,7 +203,7 @@
"include_vars": { "include_vars": {
"name": "Test2", "name": "Test2",
"confirm": "tech+2@example.org", "confirm": "tech+2@example.org",
"country": "Portugal", "country": "PT",
"zip": "6168", "zip": "6168",
"comment": "Test again", "comment": "Test again",
"permissionPriv": "yes", "permissionPriv": "yes",
@ -224,7 +224,7 @@
"include_vars": { "include_vars": {
"name": "HIDDEN", "name": "HIDDEN",
"confirm": "tech@example.org", "confirm": "tech@example.org",
"country": "Luxembourg", "country": "LU",
"zip": "51684168", "zip": "51684168",
"comment": "Crazy <3 \"\" symbols ' // %$ \\", "comment": "Crazy <3 \"\" symbols ' // %$ \\",
"permissionPriv": "yes", "permissionPriv": "yes",

View File

@ -12,7 +12,7 @@
<option value="">{{ i18n "action_form_country" }}</option> <option value="">{{ i18n "action_form_country" }}</option>
{{ $json := getJSON "data/countries/countries.json" }} {{ $json := getJSON "data/countries/countries.json" }}
{{ range sort $json "name" "asc" }} {{ range sort $json "name" "asc" }}
<option value="{{ .name }}">{{ .name }}</option> <option value="{{ .genc2a }}">{{ .name }}</option>
{{ end }} {{ end }}
</select> </select>
</label> </label>

View File

@ -8,13 +8,14 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{ $json := getJSON "data/signatures/signatures.json" }} {{ $signatures := getJSON "data/signatures/signatures.json" }}
{{ $json := where $json "include_vars.permissionPub" "yes" }} {{ $signatures := where $signatures "include_vars.permissionPub" "yes" }}
{{ $countries := getJSON "data/countries/countries.json" }}
{{ range sort $json "timestamp" "desc" }} {{ range sort $signatures "timestamp" "desc" }}
<tr> <tr>
<td>{{ .include_vars.name }}</td> <td>{{ .include_vars.name }}</td>
<td>{{ .include_vars.country }}</td> <td>{{ (index (where $countries "genc2a" .include_vars.country) 0).name | default .include_vars.country}}</td> <!-- finds the two-letter code in countries.json (first match), and prints the full name -->
<td>{{ .include_vars.comment }}</td> <td>{{ .include_vars.comment }}</td>
</tr> </tr>
{{ end }} {{ end }}