# HG changeset patch # User Brian Neal # Date 1246471031 0 # Node ID c0d3b09c9b95e5cf2944772ab02ad4fa45857672 # Parent 9fb8e804652b8b7feb9f08ed216f2fa61514c030 #18 - Add time zone field to user profile. diff -r 9fb8e804652b -r c0d3b09c9b95 gpp/bio/forms.py --- a/gpp/bio/forms.py Sun Jun 28 18:54:29 2009 +0000 +++ b/gpp/bio/forms.py Wed Jul 01 17:57:11 2009 +0000 @@ -30,6 +30,7 @@ location = forms.CharField(required=False, widget=forms.TextInput(attrs={'size' : 64 })) occupation = forms.CharField(required=False, widget=forms.TextInput(attrs={'size' : 64 })) interests = forms.CharField(required=False, widget=forms.TextInput(attrs={'size' : 64 })) + time_zone = forms.CharField(required=False, widget=forms.HiddenInput()) class Meta: model = UserProfile @@ -42,7 +43,7 @@ } js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ settings.GPP_THIRD_PARTY_JS['jquery-ui'] + \ - ('js/bio.js', ) + ('js/bio.js', 'js/timezone.js') def get_image(file): diff -r 9fb8e804652b -r c0d3b09c9b95 gpp/bio/models.py --- a/gpp/bio/models.py Sun Jun 28 18:54:29 2009 +0000 +++ b/gpp/bio/models.py Wed Jul 01 17:57:11 2009 +0000 @@ -34,6 +34,8 @@ signature = models.TextField(blank=True) signature_html = models.TextField(blank=True) avatar = models.ImageField(upload_to=avatar_file_path, blank=True) + time_zone = models.CharField(max_length=64, blank=True, + default='US/Pacific') def __unicode__(self): return self.user.username diff -r 9fb8e804652b -r c0d3b09c9b95 gpp/gcalendar/forms.py --- a/gpp/gcalendar/forms.py Sun Jun 28 18:54:29 2009 +0000 +++ b/gpp/gcalendar/forms.py Wed Jul 01 17:57:11 2009 +0000 @@ -87,7 +87,7 @@ } js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ settings.GPP_THIRD_PARTY_JS['jquery-ui'] + \ - ('js/gcalendar.js', ) + ('js/timezone.js', 'js/gcalendar.js', ) def __init__(self, *args, **kwargs): initial = kwargs.get('initial', {}) diff -r 9fb8e804652b -r c0d3b09c9b95 gpp/templates/bio/edit_profile.html --- a/gpp/templates/bio/edit_profile.html Sun Jun 28 18:54:29 2009 +0000 +++ b/gpp/templates/bio/edit_profile.html Wed Jul 01 17:57:11 2009 +0000 @@ -24,6 +24,9 @@ Edit Elsewhere Links {% elsewhere_links user %} + + Time Zone: +   diff -r 9fb8e804652b -r c0d3b09c9b95 gpp/templates/bio/view_profile.html --- a/gpp/templates/bio/view_profile.html Sun Jun 28 18:54:29 2009 +0000 +++ b/gpp/templates/bio/view_profile.html Wed Jul 01 17:57:11 2009 +0000 @@ -37,6 +37,7 @@ Signature{{ profile.signature_html|safe }} {% endif %} Elsewhere{% elsewhere_links subject %} + Time Zone{{ profile.time_zone }} {% if this_is_me %} diff -r 9fb8e804652b -r c0d3b09c9b95 media/js/gcalendar.js --- a/media/js/gcalendar.js Sun Jun 28 18:54:29 2009 +0000 +++ b/media/js/gcalendar.js Wed Jul 01 17:57:11 2009 +0000 @@ -1,19 +1,3 @@ -var gcalTzInfo = { - areas: ['Africa', 'America', 'Antarctica', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'US'], - locations: [['Abidjan', 'Accra', 'Addis Ababa', 'Algiers', 'Asmara', 'Bamako', 'Bangui', 'Banjul', 'Bissau', 'Blantyre', 'Brazzaville', 'Bujumbura', 'Cairo', 'Casablanca', 'Ceuta', 'Conakry', 'Dakar', 'Dar es Salaam', 'Djibouti', 'Douala', 'El Aaiun', 'Freetown', 'Gaborone', 'Harare', 'Johannesburg', 'Kampala', 'Khartoum', 'Kigali', 'Kinshasa', 'Lagos', 'Libreville', 'Lome', 'Luanda', 'Lubumbashi', 'Lusaka', 'Malabo', 'Maputo', 'Maseru', 'Mbabane', 'Mogadishu', 'Monrovia', 'Nairobi', 'Ndjamena', 'Niamey', 'Nouakchott', 'Ouagadougou', 'Porto-Novo', 'Sao Tome', 'Tripoli', 'Tunis', 'Windhoek'], -['Adak', 'Anchorage', 'Anguilla', 'Antigua', 'Araguaina', 'Argentina/Buenos Aires', 'Argentina/Catamarca', 'Argentina/Cordoba', 'Argentina/Jujuy', 'Argentina/La Rioja', 'Argentina/Mendoza', 'Argentina/Rio Gallegos', 'Argentina/Salta', 'Argentina/San Juan', 'Argentina/San Luis', 'Argentina/Tucuman', 'Argentina/Ushuaia', 'Aruba', 'Asuncion', 'Atikokan', 'Bahia', 'Barbados', 'Belem', 'Belize', 'Blanc-Sablon', 'Boa Vista', 'Bogota', 'Boise', 'Cambridge Bay', 'Campo Grande', 'Cancun', 'Caracas', 'Cayenne', 'Cayman', 'Chicago', 'Chihuahua', 'Costa Rica', 'Cuiaba', 'Curacao', 'Danmarkshavn', 'Dawson', 'Dawson Creek', 'Denver', 'Detroit', 'Dominica', 'Edmonton', 'Eirunepe', 'El Salvador', 'Fortaleza', 'Glace Bay', 'Godthab', 'Goose Bay', 'Grand Turk', 'Grenada', 'Guadeloupe', 'Guatemala', 'Guayaquil', 'Guyana', 'Halifax', 'Havana', 'Hermosillo', 'Indiana/Indianapolis', 'Indiana/Knox', 'Indiana/Marengo', 'Indiana/Petersburg', 'Indiana/Tell City', 'Indiana/Vevay', 'Indiana/Vincennes', 'Indiana/Winamac', 'Inuvik', 'Iqaluit', 'Jamaica', 'Juneau', 'Kentucky/Louisville', 'Kentucky/Monticello', 'La Paz', 'Lima', 'Los Angeles', 'Maceio', 'Managua', 'Manaus', 'Martinique', 'Mazatlan', 'Menominee', 'Merida', 'Mexico City', 'Miquelon', 'Moncton', 'Monterrey', 'Montevideo', 'Montreal', 'Montserrat', 'Nassau', 'New York', 'Nipigon', 'Nome', 'Noronha', 'North Dakota/Center', 'North Dakota/New Salem', 'Panama', 'Pangnirtung', 'Paramaribo', 'Phoenix', 'Port of Spain', 'Port-au-Prince', 'Porto Velho', 'Puerto Rico', 'Rainy River', 'Rankin Inlet', 'Recife', 'Regina', 'Resolute', 'Rio Branco', 'Santarem', 'Santiago', 'Santo Domingo', 'Sao Paulo', 'Scoresbysund', 'St Johns', 'St Kitts', 'St Lucia', 'St Thomas', 'St Vincent', 'Swift Current', 'Tegucigalpa', 'Thule', 'Thunder Bay', 'Tijuana', 'Toronto', 'Tortola', 'Vancouver', 'Whitehorse', 'Winnipeg', 'Yakutat', 'Yellowknife'], -['Casey', 'Davis', 'DumontDUrville', 'Mawson', 'McMurdo', 'Palmer', 'Rothera', 'Syowa', 'Vostok'], -['Aden', 'Almaty', 'Amman', 'Anadyr', 'Aqtau', 'Aqtobe', 'Ashgabat', 'Baghdad', 'Bahrain', 'Baku', 'Bangkok', 'Beirut', 'Bishkek', 'Brunei', 'Choibalsan', 'Chongqing', 'Colombo', 'Damascus', 'Dhaka', 'Dili', 'Dubai', 'Dushanbe', 'Gaza', 'Harbin', 'Ho Chi Minh', 'Hong Kong', 'Hovd', 'Irkutsk', 'Jakarta', 'Jayapura', 'Jerusalem', 'Kabul', 'Kamchatka', 'Karachi', 'Kashgar', 'Kathmandu', 'Kolkata', 'Krasnoyarsk', 'Kuala Lumpur', 'Kuching', 'Kuwait', 'Macau', 'Magadan', 'Makassar', 'Manila', 'Muscat', 'Nicosia', 'Novosibirsk', 'Omsk', 'Oral', 'Phnom Penh', 'Pontianak', 'Pyongyang', 'Qatar', 'Qyzylorda', 'Rangoon', 'Riyadh', 'Sakhalin', 'Samarkand', 'Seoul', 'Shanghai', 'Singapore', 'Taipei', 'Tashkent', 'Tbilisi', 'Tehran', 'Thimphu', 'Tokyo', 'Ulaanbaatar', 'Urumqi', 'Vientiane', 'Vladivostok', 'Yakutsk', 'Yekaterinburg', 'Yerevan'], -['Azores', 'Bermuda', 'Canary', 'Cape Verde', 'Faroe', 'Madeira', 'Reykjavik', 'South Georgia', 'St Helena', 'Stanley'], -['Adelaide', 'Brisbane', 'Broken Hill', 'Currie', 'Darwin', 'Eucla', 'Hobart', 'Lindeman', 'Lord Howe', 'Melbourne', 'Perth', 'Sydney'], -['Amsterdam', 'Andorra', 'Athens', 'Belgrade', 'Berlin', 'Brussels', 'Bucharest', 'Budapest', 'Chisinau', 'Copenhagen', 'Dublin', 'Gibraltar', 'Helsinki', 'Istanbul', 'Kaliningrad', 'Kiev', 'Lisbon', 'London', 'Luxembourg', 'Madrid', 'Malta', 'Minsk', 'Monaco', 'Moscow', 'Oslo', 'Paris', 'Prague', 'Riga', 'Rome', 'Samara', 'Simferopol', 'Sofia', 'Stockholm', 'Tallinn', 'Tirane', 'Uzhgorod', 'Vaduz', 'Vienna', 'Vilnius', 'Volgograd', 'Warsaw', 'Zaporozhye', 'Zurich'], -['Antananarivo', 'Chagos', 'Christmas', 'Cocos', 'Comoro', 'Kerguelen', 'Mahe', 'Maldives', 'Mauritius', 'Mayotte', 'Reunion'], -['Apia', 'Auckland', 'Chatham', 'Easter', 'Efate', 'Enderbury', 'Fakaofo', 'Fiji', 'Funafuti', 'Galapagos', 'Gambier', 'Guadalcanal', 'Guam', 'Honolulu', 'Johnston', 'Kiritimati', 'Kosrae', 'Kwajalein', 'Majuro', 'Marquesas', 'Midway', 'Nauru', 'Niue', 'Norfolk', 'Noumea', 'Pago Pago', 'Palau', 'Pitcairn', 'Ponape', 'Port Moresby', 'Rarotonga', 'Saipan', 'Tahiti', 'Tarawa', 'Tongatapu', 'Truk', 'Wake', 'Wallis'], -['Alaska', 'Arizona', 'Central', 'Eastern', 'Hawaii', 'Mountain', 'Pacific']], - default_area: 9, - default_location: 6 -}; - $(document).ready(function() { $('#id_description').markItUp(mySettings); $('#id_start_date').datepicker({constrainInput: true, @@ -45,67 +29,4 @@ $('#id_end_time').toggle(); $('#id_tz_stuff').toggle(); }); - - var tz_area = $('#id_tz_area')[0]; - var tz_loc = $('#id_tz_location')[0]; - tz_area.options.length = 0; - for (var i = 0; i < gcalTzInfo.areas.length; ++i) - { - tz_area.options[i] = new Option(gcalTzInfo.areas[i]); - } - - var event_tz = $('#id_time_zone').val(); - if (event_tz == '') - { - tz_area.options.selectedIndex = gcalTzInfo.default_area; - } - else - { - var area_match = event_tz.match(/^(\w+)\/.*$/); - if (area_match != null) - { - var i = gcalTzInfo.areas.indexOf(area_match[1]); - tz_area.options.selectedIndex = (i != -1) ? i : gcalTzInfo.default_area; - } - else - { - tz_area.options.selectedIndex = gcalTzInfo.default_area; - } - } - - $('#id_tz_area').change(function () { - tz_loc.options.length = 0; - var area = tz_area.options.selectedIndex; - for (var i = 0; i < gcalTzInfo.locations[area].length; ++i) - { - tz_loc.options[i] = new Option(gcalTzInfo.locations[area][i]); - } - }).change(); - - if (event_tz == '') - { - tz_loc.options.selectedIndex = gcalTzInfo.default_location; - } - else - { - var loc_match = event_tz.match(/^[^\/]+\/(.*)$/); - if (loc_match != null) - { - var loc = loc_match[1].replace(/_/g, ' '); - var i = gcalTzInfo.locations[tz_area.options.selectedIndex].indexOf(loc); - tz_loc.options.selectedIndex = (i != -1) ? i : gcalTzInfo.default_location; - } - else - { - tz_loc.options.selectedIndex = gcalTzInfo.default_location; - } - } - - $('#id_gcal_event_form').submit(function () { - var area = $('#id_tz_area').val(); - var loc = $('#id_tz_location').val(); - var tz = area + '/' + loc.replace(/ /g, '_'); - $('#id_time_zone').val(tz); - return true; - }); }); diff -r 9fb8e804652b -r c0d3b09c9b95 media/js/timezone.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/media/js/timezone.js Wed Jul 01 17:57:11 2009 +0000 @@ -0,0 +1,81 @@ +var gcalTzInfo = { + areas: ['Africa', 'America', 'Antarctica', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'US'], + locations: [['Abidjan', 'Accra', 'Addis Ababa', 'Algiers', 'Asmara', 'Bamako', 'Bangui', 'Banjul', 'Bissau', 'Blantyre', 'Brazzaville', 'Bujumbura', 'Cairo', 'Casablanca', 'Ceuta', 'Conakry', 'Dakar', 'Dar es Salaam', 'Djibouti', 'Douala', 'El Aaiun', 'Freetown', 'Gaborone', 'Harare', 'Johannesburg', 'Kampala', 'Khartoum', 'Kigali', 'Kinshasa', 'Lagos', 'Libreville', 'Lome', 'Luanda', 'Lubumbashi', 'Lusaka', 'Malabo', 'Maputo', 'Maseru', 'Mbabane', 'Mogadishu', 'Monrovia', 'Nairobi', 'Ndjamena', 'Niamey', 'Nouakchott', 'Ouagadougou', 'Porto-Novo', 'Sao Tome', 'Tripoli', 'Tunis', 'Windhoek'], +['Adak', 'Anchorage', 'Anguilla', 'Antigua', 'Araguaina', 'Argentina/Buenos Aires', 'Argentina/Catamarca', 'Argentina/Cordoba', 'Argentina/Jujuy', 'Argentina/La Rioja', 'Argentina/Mendoza', 'Argentina/Rio Gallegos', 'Argentina/Salta', 'Argentina/San Juan', 'Argentina/San Luis', 'Argentina/Tucuman', 'Argentina/Ushuaia', 'Aruba', 'Asuncion', 'Atikokan', 'Bahia', 'Barbados', 'Belem', 'Belize', 'Blanc-Sablon', 'Boa Vista', 'Bogota', 'Boise', 'Cambridge Bay', 'Campo Grande', 'Cancun', 'Caracas', 'Cayenne', 'Cayman', 'Chicago', 'Chihuahua', 'Costa Rica', 'Cuiaba', 'Curacao', 'Danmarkshavn', 'Dawson', 'Dawson Creek', 'Denver', 'Detroit', 'Dominica', 'Edmonton', 'Eirunepe', 'El Salvador', 'Fortaleza', 'Glace Bay', 'Godthab', 'Goose Bay', 'Grand Turk', 'Grenada', 'Guadeloupe', 'Guatemala', 'Guayaquil', 'Guyana', 'Halifax', 'Havana', 'Hermosillo', 'Indiana/Indianapolis', 'Indiana/Knox', 'Indiana/Marengo', 'Indiana/Petersburg', 'Indiana/Tell City', 'Indiana/Vevay', 'Indiana/Vincennes', 'Indiana/Winamac', 'Inuvik', 'Iqaluit', 'Jamaica', 'Juneau', 'Kentucky/Louisville', 'Kentucky/Monticello', 'La Paz', 'Lima', 'Los Angeles', 'Maceio', 'Managua', 'Manaus', 'Martinique', 'Mazatlan', 'Menominee', 'Merida', 'Mexico City', 'Miquelon', 'Moncton', 'Monterrey', 'Montevideo', 'Montreal', 'Montserrat', 'Nassau', 'New York', 'Nipigon', 'Nome', 'Noronha', 'North Dakota/Center', 'North Dakota/New Salem', 'Panama', 'Pangnirtung', 'Paramaribo', 'Phoenix', 'Port of Spain', 'Port-au-Prince', 'Porto Velho', 'Puerto Rico', 'Rainy River', 'Rankin Inlet', 'Recife', 'Regina', 'Resolute', 'Rio Branco', 'Santarem', 'Santiago', 'Santo Domingo', 'Sao Paulo', 'Scoresbysund', 'St Johns', 'St Kitts', 'St Lucia', 'St Thomas', 'St Vincent', 'Swift Current', 'Tegucigalpa', 'Thule', 'Thunder Bay', 'Tijuana', 'Toronto', 'Tortola', 'Vancouver', 'Whitehorse', 'Winnipeg', 'Yakutat', 'Yellowknife'], +['Casey', 'Davis', 'DumontDUrville', 'Mawson', 'McMurdo', 'Palmer', 'Rothera', 'Syowa', 'Vostok'], +['Aden', 'Almaty', 'Amman', 'Anadyr', 'Aqtau', 'Aqtobe', 'Ashgabat', 'Baghdad', 'Bahrain', 'Baku', 'Bangkok', 'Beirut', 'Bishkek', 'Brunei', 'Choibalsan', 'Chongqing', 'Colombo', 'Damascus', 'Dhaka', 'Dili', 'Dubai', 'Dushanbe', 'Gaza', 'Harbin', 'Ho Chi Minh', 'Hong Kong', 'Hovd', 'Irkutsk', 'Jakarta', 'Jayapura', 'Jerusalem', 'Kabul', 'Kamchatka', 'Karachi', 'Kashgar', 'Kathmandu', 'Kolkata', 'Krasnoyarsk', 'Kuala Lumpur', 'Kuching', 'Kuwait', 'Macau', 'Magadan', 'Makassar', 'Manila', 'Muscat', 'Nicosia', 'Novosibirsk', 'Omsk', 'Oral', 'Phnom Penh', 'Pontianak', 'Pyongyang', 'Qatar', 'Qyzylorda', 'Rangoon', 'Riyadh', 'Sakhalin', 'Samarkand', 'Seoul', 'Shanghai', 'Singapore', 'Taipei', 'Tashkent', 'Tbilisi', 'Tehran', 'Thimphu', 'Tokyo', 'Ulaanbaatar', 'Urumqi', 'Vientiane', 'Vladivostok', 'Yakutsk', 'Yekaterinburg', 'Yerevan'], +['Azores', 'Bermuda', 'Canary', 'Cape Verde', 'Faroe', 'Madeira', 'Reykjavik', 'South Georgia', 'St Helena', 'Stanley'], +['Adelaide', 'Brisbane', 'Broken Hill', 'Currie', 'Darwin', 'Eucla', 'Hobart', 'Lindeman', 'Lord Howe', 'Melbourne', 'Perth', 'Sydney'], +['Amsterdam', 'Andorra', 'Athens', 'Belgrade', 'Berlin', 'Brussels', 'Bucharest', 'Budapest', 'Chisinau', 'Copenhagen', 'Dublin', 'Gibraltar', 'Helsinki', 'Istanbul', 'Kaliningrad', 'Kiev', 'Lisbon', 'London', 'Luxembourg', 'Madrid', 'Malta', 'Minsk', 'Monaco', 'Moscow', 'Oslo', 'Paris', 'Prague', 'Riga', 'Rome', 'Samara', 'Simferopol', 'Sofia', 'Stockholm', 'Tallinn', 'Tirane', 'Uzhgorod', 'Vaduz', 'Vienna', 'Vilnius', 'Volgograd', 'Warsaw', 'Zaporozhye', 'Zurich'], +['Antananarivo', 'Chagos', 'Christmas', 'Cocos', 'Comoro', 'Kerguelen', 'Mahe', 'Maldives', 'Mauritius', 'Mayotte', 'Reunion'], +['Apia', 'Auckland', 'Chatham', 'Easter', 'Efate', 'Enderbury', 'Fakaofo', 'Fiji', 'Funafuti', 'Galapagos', 'Gambier', 'Guadalcanal', 'Guam', 'Honolulu', 'Johnston', 'Kiritimati', 'Kosrae', 'Kwajalein', 'Majuro', 'Marquesas', 'Midway', 'Nauru', 'Niue', 'Norfolk', 'Noumea', 'Pago Pago', 'Palau', 'Pitcairn', 'Ponape', 'Port Moresby', 'Rarotonga', 'Saipan', 'Tahiti', 'Tarawa', 'Tongatapu', 'Truk', 'Wake', 'Wallis'], +['Alaska', 'Arizona', 'Central', 'Eastern', 'Hawaii', 'Mountain', 'Pacific']], + default_area: 9, + default_location: 6 +}; + +$(document).ready(function() { + var $tz_area = $('#id_tz_area'); + var $tz_loc = $('#id_tz_location'); + var tz_area = $tz_area[0]; + var tz_loc = $tz_loc[0]; + tz_area.options.length = 0; + for (var i = 0; i < gcalTzInfo.areas.length; ++i) + { + tz_area.options[i] = new Option(gcalTzInfo.areas[i]); + } + var tz = $('#id_time_zone').val(); + if (tz == '') + { + tz_area.options.selectedIndex = gcalTzInfo.default_area; + } + else + { + var area_match = tz.match(/^(\w+)\/.*$/); + if (area_match != null) + { + var i = gcalTzInfo.areas.indexOf(area_match[1]); + tz_area.options.selectedIndex = (i != -1) ? i : gcalTzInfo.default_area; + } + else + { + tz_area.options.selectedIndex = gcalTzInfo.default_area; + } + } + + $tz_area.change(function () { + tz_loc.options.length = 0; + var area = tz_area.options.selectedIndex; + for (var i = 0; i < gcalTzInfo.locations[area].length; ++i) + { + tz_loc.options[i] = new Option(gcalTzInfo.locations[area][i]); + } + }).change(); + + if (tz == '') + { + tz_loc.options.selectedIndex = gcalTzInfo.default_location; + } + else + { + var loc_match = tz.match(/^[^\/]+\/(.*)$/); + if (loc_match != null) + { + var loc = loc_match[1].replace(/_/g, ' '); + var i = gcalTzInfo.locations[tz_area.options.selectedIndex].indexOf(loc); + tz_loc.options.selectedIndex = (i != -1) ? i : gcalTzInfo.default_location; + } + else + { + tz_loc.options.selectedIndex = gcalTzInfo.default_location; + } + } + + $tz_area.parents('form').submit(function () { + var area = $tz_area.val(); + var loc = $tz_loc.val(); + var tz = area + '/' + loc.replace(/ /g, '_'); + $('#id_time_zone').val(tz); + return true; + }); +});