Repository: google/personfinder

Issue:
Should have admin UI to set timezone of a repository
We have config for timezone (time_zone_offset and time_zone_abbreviation), but it looks we have no UI for them.


Discussion:

Resolving patch:
diff --git a/app/admin.py b/app/admin.py
--- a/app/admin.py
+++ b/app/admin.py
@@ -78,6 +78,7 @@ def post(self):
                     # These settings are all entered in JSON. It can be either:
                     # - JSON object e.g., {"k1": "v1", "k2": "v2"}
                     # - JSON boolean literal i.e., true or false
+                    # - JSON number literal e.g., 1, 2, 3
                     json_config_names=[
                         'allow_believed_dead_via_ui',
                         'family_name_first',
@@ -97,6 +98,7 @@ def post(self):
                         'show_profile_entry',
                         'start_page_custom_htmls',
                         'test_mode',
+                        'time_zone_offset',
                         'use_alternate_names',
                         'use_family_name',
                         'use_postal_code',
@@ -109,6 +111,7 @@ def post(self):
                         'deactivation_message_html',
                         'keywords',
                         'launch_status',
+                        'time_zone_abbreviation',
                     ],
                     # Update updated_date if any of the following settings are
                     # changed.
diff --git a/app/admin_create_repo.py b/app/admin_create_repo.py
--- a/app/admin_create_repo.py
+++ b/app/admin_create_repo.py
@@ -63,5 +63,7 @@ def post(self):
             test_mode=False,
             force_https=False,
             zero_rating_mode=False,
+            time_zone_offset=0,
+            time_zone_abbreviation='UTC',
         )
         self.redirect('/admin', new_repo)
diff --git a/app/setup_pf.py b/app/setup_pf.py
--- a/app/setup_pf.py
+++ b/app/setup_pf.py
@@ -118,6 +118,8 @@ def setup_configs():
         results_page_custom_htmls={'en': '', 'fr': ''},
         view_page_custom_htmls={'en': '', 'fr': ''},
         seek_query_form_custom_htmls={'en': '', 'fr': ''},
+        time_zone_offset=0,
+        time_zone_abbreviation='UTC',
         published_date=get_timestamp(datetime(2010, 1, 12)),
         updated_date=get_timestamp(datetime(2010, 1, 12)),
     )
@@ -185,6 +187,8 @@ def setup_configs():
         results_page_custom_htmls={'en': '', 'fr': ''},
         view_page_custom_htmls={'en': '', 'fr': ''},
         seek_query_form_custom_htmls={'en': '', 'fr': ''},
+        time_zone_offset=0,
+        time_zone_abbreviation='UTC',
         published_date=get_timestamp(datetime(2010, 8, 6)),
         updated_date=get_timestamp(datetime(2010, 8, 6)),
     )


Test patch:
diff --git a/tests/scrape.py b/tests/scrape.py
--- a/tests/scrape.py
+++ b/tests/scrape.py
@@ -660,8 +660,15 @@ def get_form_params(form):
     for input in form.cssselect('input'):
         if input.get('name') and input.get('disabled') is None:
             type = input.get('type', 'text').lower()
-            if type in ['text', 'password', 'hidden'] or (
-               type in ['checkbox', 'radio'] and input.get('checked') is not None):
+            if type in ['checkbox', 'radio']:
+                add_value = input.get('checked') is not None
+            elif type in ['file', 'submit', 'image', 'reset', 'button']:
+                add_value = False
+            else:
+                # Ordinary input fields such as 'text' or 'hidden'. Note that
+                # there are many types in this category in HTML5 like 'number'.
+                add_value = True
+            if add_value:
                 params[input.get('name')] = input.get('value', '')
     for select in form.cssselect('select'):
         if select.get('disabled') is None:
diff --git a/tests/server_test_cases/config_tests.py b/tests/server_test_cases/config_tests.py
--- a/tests/server_test_cases/config_tests.py
+++ b/tests/server_test_cases/config_tests.py
@@ -376,6 +376,7 @@ def test_custom_messages(self):
                 '{"en": "<b>English</b> footer message",'
                 ' "fr": "<b>French</b> footer message"}',
         )
+        assert self.s.status == 200
 
         cfg = config.Configuration('haiti')
         assert cfg.start_page_custom_htmls == \