Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timezone setting along with menu of choices at project creation #139

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"pkg_name": "{{ cookiecutter.project_slug.replace('-', '_') }}",
"first_app_name": "core",
"site_domain": "{{ cookiecutter.project_slug }}.test",
"include_example_code": ["yes", "no"]
"include_example_code": ["yes", "no"],
"timezone": ["America/New_York", "Etc/GMT+12", "Etc/GMT+11", "Pacific/Midway", "Pacific/Niue", "Pacific/Pago_Pago", "Etc/GMT+10", "Pacific/Honolulu", "Pacific/Johnston", "Pacific/Rarotonga", "Pacific/Tahiti", "America/Anchorage", "America/Juneau", "America/Nome", "America/Sitka", "America/Yakutat", "America/Santa_Isabel", "America/Dawson", "America/Los_Angeles", "America/Tijuana", "America/Vancouver", "America/Whitehorse", "America/Dawson", "America/Los_Angeles", "America/Tijuana", "America/Vancouver", "America/Whitehorse", "PST8PDT", "America/Creston", "America/Dawson_Creek", "America/Hermosillo", "America/Phoenix", "Etc/GMT+7", "America/Chihuahua", "America/Mazatlan", "America/Boise", "America/Cambridge_Bay", "America/Denver", "America/Edmonton", "America/Inuvik", "America/Ojinaga", "America/Yellowknife", "MST7MDT", "America/Belize", "America/Costa_Rica", "America/El_Salvador", "America/Guatemala", "America/Managua", "America/Tegucigalpa", "Etc/GMT+6", "Pacific/Galapagos", "America/Chicago", "America/Indiana/Knox", "America/Indiana/Tell_City", "America/Matamoros", "America/Menominee", "America/North_Dakota/Beulah", "America/North_Dakota/Center", "America/North_Dakota/New_Salem", "America/Rainy_River", "America/Rankin_Inlet", "America/Resolute", "America/Winnipeg", "CST6CDT", "America/Bahia_Banderas", "America/Cancun", "America/Merida", "America/Mexico_City", "America/Monterrey", "America/Regina", "America/Swift_Current", "America/Bogota", "America/Cayman", "America/Coral_Harbour", "America/Eirunepe", "America/Guayaquil", "America/Jamaica", "America/Lima", "America/Panama", "America/Rio_Branco", "Etc/GMT+5", "America/Detroit", "America/Havana", "America/Indiana/Petersburg", "America/Indiana/Vincennes", "America/Indiana/Winamac", "America/Iqaluit", "America/Kentucky/Monticello", "America/Louisville", "America/Montreal", "America/Nassau", "America/Nipigon", "America/Pangnirtung", "America/Port-au-Prince", "America/Thunder_Bay", "America/Toronto", "EST5EDT", "America/Indiana/Marengo", "America/Indiana/Vevay", "America/Indianapolis", "America/Caracas", "America/Asuncion", "America/Glace_Bay", "America/Goose_Bay", "America/Halifax", "America/Moncton", "America/Thule", "Atlantic/Bermuda", "America/Campo_Grande", "America/Cuiaba", "America/Anguilla", "America/Antigua", "America/Aruba", "America/Barbados", "America/Blanc-Sablon", "America/Boa_Vista", "America/Curacao", "America/Dominica", "America/Grand_Turk", "America/Grenada", "America/Guadeloupe", "America/Guyana", "America/Kralendijk", "America/La_Paz", "America/Lower_Princes", "America/Manaus", "America/Marigot", "America/Martinique", "America/Montserrat", "America/Port_of_Spain", "America/Porto_Velho", "America/Puerto_Rico", "America/Santo_Domingo", "America/St_Barthelemy", "America/St_Kitts", "America/St_Lucia", "America/St_Thomas", "America/St_Vincent", "America/Tortola", "Etc/GMT+4", "America/Santiago", "Antarctica/Palmer", "America/St_Johns", "America/Sao_Paulo", "America/Argentina/La_Rioja", "America/Argentina/Rio_Gallegos", "America/Argentina/Salta", "America/Argentina/San_Juan", "America/Argentina/San_Luis", "America/Argentina/Tucuman", "America/Argentina/Ushuaia", "America/Buenos_Aires", "America/Catamarca", "America/Cordoba", "America/Jujuy", "America/Mendoza", "America/Araguaina", "America/Belem", "America/Cayenne", "America/Fortaleza", "America/Maceio", "America/Paramaribo", "America/Recife", "America/Santarem", "Antarctica/Rothera", "Atlantic/Stanley", "Etc/GMT+3", "America/Godthab", "America/Montevideo", "America/Bahia", "America/Noronha", "Atlantic/South_Georgia", "Etc/GMT+2", "America/Scoresbysund", "Atlantic/Azores", "Atlantic/Cape_Verde", "Etc/GMT+1", "Africa/Casablanca", "Africa/El_Aaiun", "America/Danmarkshavn", "Etc/GMT", "Europe/Isle_of_Man", "Europe/Guernsey", "Europe/Jersey", "Europe/London", "Europe/Isle_of_Man", "Europe/Guernsey", "Europe/Jersey", "Europe/London", "Atlantic/Canary", "Atlantic/Faeroe", "Atlantic/Madeira", "Europe/Dublin", "Europe/Lisbon", "Africa/Abidjan", "Africa/Accra", "Africa/Bamako", "Africa/Banjul", "Africa/Bissau", "Africa/Conakry", "Africa/Dakar", "Africa/Freetown", "Africa/Lome", "Africa/Monrovia", "Africa/Nouakchott", "Africa/Ouagadougou", "Africa/Sao_Tome", "Atlantic/Reykjavik", "Atlantic/St_Helena", "Arctic/Longyearbyen", "Europe/Amsterdam", "Europe/Andorra", "Europe/Berlin", "Europe/Busingen", "Europe/Gibraltar", "Europe/Luxembourg", "Europe/Malta", "Europe/Monaco", "Europe/Oslo", "Europe/Rome", "Europe/San_Marino", "Europe/Stockholm", "Europe/Vaduz", "Europe/Vatican", "Europe/Vienna", "Europe/Zurich", "Europe/Belgrade", "Europe/Bratislava", "Europe/Budapest", "Europe/Ljubljana", "Europe/Podgorica", "Europe/Prague", "Europe/Tirane", "Africa/Ceuta", "Europe/Brussels", "Europe/Copenhagen", "Europe/Madrid", "Europe/Paris", "Europe/Sarajevo", "Europe/Skopje", "Europe/Warsaw", "Europe/Zagreb", "Africa/Algiers", "Africa/Bangui", "Africa/Brazzaville", "Africa/Douala", "Africa/Kinshasa", "Africa/Lagos", "Africa/Libreville", "Africa/Luanda", "Africa/Malabo", "Africa/Ndjamena", "Africa/Niamey", "Africa/Porto-Novo", "Africa/Tunis", "Etc/GMT-1", "Africa/Windhoek", "Asia/Nicosia", "Europe/Athens", "Europe/Bucharest", "Europe/Chisinau", "Asia/Beirut", "Africa/Cairo", "Asia/Damascus", "Asia/Nicosia", "Europe/Athens", "Europe/Bucharest", "Europe/Chisinau", "Europe/Helsinki", "Europe/Kiev", "Europe/Mariehamn", "Europe/Nicosia", "Europe/Riga", "Europe/Sofia", "Europe/Tallinn", "Europe/Uzhgorod", "Europe/Vilnius", "Europe/Zaporozhye", "Africa/Blantyre", "Africa/Bujumbura", "Africa/Gaborone", "Africa/Harare", "Africa/Johannesburg", "Africa/Kigali", "Africa/Lubumbashi", "Africa/Lusaka", "Africa/Maputo", "Africa/Maseru", "Africa/Mbabane", "Etc/GMT-2", "Europe/Helsinki", "Europe/Kiev", "Europe/Mariehamn", "Europe/Riga", "Europe/Sofia", "Europe/Tallinn", "Europe/Uzhgorod", "Europe/Vilnius", "Europe/Zaporozhye", "Europe/Istanbul", "Asia/Jerusalem", "Africa/Tripoli", "Asia/Amman", "Asia/Baghdad", "Europe/Kaliningrad", "Asia/Aden", "Asia/Bahrain", "Asia/Kuwait", "Asia/Qatar", "Asia/Riyadh", "Africa/Addis_Ababa", "Africa/Asmera", "Africa/Dar_es_Salaam", "Africa/Djibouti", "Africa/Juba", "Africa/Kampala", "Africa/Khartoum", "Africa/Mogadishu", "Africa/Nairobi", "Antarctica/Syowa", "Etc/GMT-3", "Indian/Antananarivo", "Indian/Comoro", "Indian/Mayotte", "Europe/Kirov", "Europe/Moscow", "Europe/Simferopol", "Europe/Volgograd", "Europe/Minsk", "Europe/Astrakhan", "Europe/Samara", "Europe/Ulyanovsk", "Asia/Tehran", "Asia/Dubai", "Asia/Muscat", "Etc/GMT-4", "Asia/Baku", "Indian/Mahe", "Indian/Mauritius", "Indian/Reunion", "Asia/Tbilisi", "Asia/Yerevan", "Asia/Kabul", "Antarctica/Mawson", "Asia/Aqtau", "Asia/Aqtobe", "Asia/Ashgabat", "Asia/Dushanbe", "Asia/Oral", "Asia/Samarkand", "Asia/Tashkent", "Etc/GMT-5", "Indian/Kerguelen", "Indian/Maldives", "Asia/Yekaterinburg", "Asia/Karachi", "Asia/Kolkata", "Asia/Colombo", "Asia/Kathmandu", "Antarctica/Vostok", "Asia/Almaty", "Asia/Bishkek", "Asia/Qyzylorda", "Asia/Urumqi", "Etc/GMT-6", "Indian/Chagos", "Asia/Dhaka", "Asia/Thimphu", "Asia/Rangoon", "Indian/Cocos", "Antarctica/Davis", "Asia/Bangkok", "Asia/Hovd", "Asia/Jakarta", "Asia/Phnom_Penh", "Asia/Pontianak", "Asia/Saigon", "Asia/Vientiane", "Etc/GMT-7", "Indian/Christmas", "Asia/Novokuznetsk", "Asia/Novosibirsk", "Asia/Omsk", "Asia/Hong_Kong", "Asia/Macau", "Asia/Shanghai", "Asia/Krasnoyarsk", "Asia/Brunei", "Asia/Kuala_Lumpur", "Asia/Kuching", "Asia/Makassar", "Asia/Manila", "Asia/Singapore", "Etc/GMT-8", "Antarctica/Casey", "Australia/Perth", "Asia/Taipei", "Asia/Choibalsan", "Asia/Ulaanbaatar", "Asia/Irkutsk", "Asia/Dili", "Asia/Jayapura", "Asia/Tokyo", "Etc/GMT-9", "Pacific/Palau", "Asia/Pyongyang", "Asia/Seoul", "Australia/Adelaide", "Australia/Broken_Hill", "Australia/Darwin", "Australia/Brisbane", "Australia/Lindeman", "Australia/Melbourne", "Australia/Sydney", "Antarctica/DumontDUrville", "Etc/GMT-10", "Pacific/Guam", "Pacific/Port_Moresby", "Pacific/Saipan", "Pacific/Truk", "Australia/Currie", "Australia/Hobart", "Asia/Chita", "Asia/Khandyga", "Asia/Yakutsk", "Antarctica/Macquarie", "Etc/GMT-11", "Pacific/Efate", "Pacific/Guadalcanal", "Pacific/Kosrae", "Pacific/Noumea", "Pacific/Ponape", "Asia/Sakhalin", "Asia/Ust-Nera", "Asia/Vladivostok", "Antarctica/McMurdo", "Pacific/Auckland", "Etc/GMT-12", "Pacific/Funafuti", "Pacific/Kwajalein", "Pacific/Majuro", "Pacific/Nauru", "Pacific/Tarawa", "Pacific/Wake", "Pacific/Wallis", "Pacific/Fiji", "Asia/Anadyr", "Asia/Kamchatka", "Asia/Magadan", "Asia/Srednekolymsk", "Asia/Kamchatka", "Etc/GMT-13", "Pacific/Enderbury", "Pacific/Fakaofo", "Pacific/Tongatapu", "Pacific/Apia"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class {{ cookiecutter.pkg_name.split('_')|map('capitalize')|join('') }}Mixin(Con

BASE_DIR = Path(__file__).resolve(strict=True).parent.parent

USE_TZ = True
waxlamp marked this conversation as resolved.
Show resolved Hide resolved
TIME_ZONE = '{{ cookiecutter.timezone }}'
Copy link
Collaborator

@brianhelba brianhelba Mar 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is set explicitly upstream: https://github.com/girder/django-composed-configuration/blob/e65bdc513d74ead19035a837079dad6df5ddf48c/composed_configuration/_django.py#L83

At a minimum, if we agree that "America/New_York" is a better default than "UTC", we can just change that upstream.

Furthermore, I agree that timezone may be a common thing which individual projects want to override. As a less disruptive change, which would not require a new cookiecutter option, we could just turn this line into a code comment, which would inform downstreams that they could trivially override the TIME_ZONE for their local project. The benefit is that it would defer this choice (which is not absolutely essential to starting up a working project) to a later point in the lifecycle, while still providing a hopefully-obvious pointer to one of the first settings which developers may actually want to override.

While we're on the subject, we should perhaps think of other settings that it's highly likely developers want to override, and put pointers to them in here too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a short term action item, should I just close this PR and open a one-line-change PR in django-composed-configuration?

As a longer term thing, how do I learn about the relationship between this cookiecutter repo and django-composed-configuration? Is there documentation, or can I just bug you on Slack about it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repo produces a working Django / Girder 4 project. To do that, this repo makes some opinionated choices about the dependencies it uses (including Celery, Django Allauth, etc.)

One of the dependencies is django-composed-configuration, which provides an extensible set of sensible default Django-settings.

Once a project is started, downstreams are free to abandon any or all of default dependencies and it's perfectly possible to "eject" django-composed-configuration by replacing it with a local static list of Django-settings. The advantage to using / keeping django-composed-configuration is that as "best practices" around many Django-settings evolves, downstream projects can get the updates for free, without having to manage hundreds of settings (most of which they aren't opinionated about) explicitly.


As a meta-note about documentation, I think it makes sense to update django-composed-configuration docs to better explain the rationale and value it provides. However, it is ultimately just one library amongst many, and unfortunately, it's probably necessary for developers to have a superficial understanding of almost all the Girder 4 / cookiecutter dependencies and their value proposition in order to successfully further build out a full project.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a short term action item, should I just close this PR and open a one-line-change PR in django-composed-configuration?

I think that even if this PR just added a code comment showing how TIME_ZONE could be overridden, it would be a nice net improvement to the cookiecutter.

The bonus would be if someone could figure out a short list of the most immediate settings which projects would want to override.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I converted the offered setting into an example of how to override, and I'll open a PR to change the default timezone in the other project.

I don't have very much insight into what other settings ought to go here, but I'd like to conclude this work and get it off my plate, so maybe instead we can just open an issue asking for discussion on other settings that should be demo'ed in this fashion.


@staticmethod
def before_binding(configuration: ComposedConfiguration) -> None:
# Install local apps first, to ensure any overridden resources are found first
Expand Down