datetime: Show timezone properly when it not in expected list

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2017-04-30 10:03:51 +05:30 committed by James Valleroy
parent 6f14f20ef1
commit 520347cc1b
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -44,8 +44,11 @@ This will set the system-wide time zone.'))
time_zone_options = [(zone, zone)
for zone in self.get_time_zones()]
# Show not-set option only when time zone is not set
if self.initial.get('time_zone') == 'none':
current_time_zone = self.initial.get('time_zone')
if current_time_zone == 'none':
time_zone_options.insert(0, ('none', _('-- no time zone set --')))
elif (current_time_zone, current_time_zone) not in time_zone_options:
time_zone_options.insert(0, (current_time_zone, current_time_zone))
self.fields['time_zone'].choices = time_zone_options