Edgewall Software
Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#9581 closed enhancement (fixed)

Documentation page for TracIni should list or have reference to allowed values for default_timezone

Reported by: ryano@… Owned by: Ryan J Ollos <ryano@…>
Priority: high Milestone: 1.0
Component: general Version: 0.12dev
Severity: normal Keywords: bitesized, patch
Cc:
Release Notes:

admin: the default timezone and default language can be set in the "Basic Settings" panel

API Changes:

Description

I had a bit of a difficult time figuring out what are the valid values for the default_timezone option in the [trac] section of trac.ini. It seems like the allowed values should be documented at TracIni#trac-section, or an external reference pointed to.

Another option might be to add it to Basic Settings section of the WebAdmin panel and allow a drop down list of allowed values.

Attachments (5)

BasicSettings.png (16.6 KB) - added by Ryan J Ollos <ryano@…> 4 years ago.
t9581-r10056.patch (3.0 KB) - added by Ryan J Ollos <ryano@…> 4 years ago.
PrefsPanelText2.png (22.9 KB) - added by Ryan J Ollos <ryano@…> 4 years ago.
PrefsPanelText1.png (22.1 KB) - added by Ryan J Ollos <ryano@…> 4 years ago.
9581-default-tz-lang-r10162.patch (7.6 KB) - added by rblank 4 years ago.
Configure default timezone and language in admin panel.

Download all attachments as: .zip

Change History (22)

comment:1 follow-up: Changed 4 years ago by rblank

  • Keywords bitesized added
  • Milestone set to unscheduled

Except for the "GMT +xx:xx" zones, the names are defined in pytz, so we can't just list them in the documentation. We could list the GMT+offset zones, and provide a link to the pytz documentation.

Then again, an entry in the "Basic Settings" sounds nice, too, and we already have the necessary code in the user preferences, so it shouldn't be too difficult.

comment:2 in reply to: ↑ 1 Changed 4 years ago by Ryan Ollos <ryano@…>

Replying to rblank:

Except for the "GMT +xx:xx" zones, the names are defined in pytz, so we can't just list them in the documentation. We could list the GMT+offset zones, and provide a link to the pytz documentation.

I searched around but couldn't find a list of names in the pytz documentation. There is described a way to generate them, which could be pointed to in the Trac docs, or perhaps there is some way to use this pytz function to generate output for the Trac docs.

Then again, an entry in the "Basic Settings" sounds nice, too, and we already have the necessary code in the user preferences, so it shouldn't be too difficult.

I'll have a first cut at a patch for this ready by this evening.

Changed 4 years ago by Ryan J Ollos <ryano@…>

comment:3 Changed 4 years ago by Ryan J Ollos <ryano@…>

Is default_timezone a property of some object, like project_name can be accessed in self.env.project_name? I've spent some time looking at localtz in trac.utils.datefmt, and also calling self.config.get('trac', 'default_timezone') within render_admin_panel. It doesn't seem to be behaving well, so I thinking I'm doing this wrong.

I added the select list to the Basic Settings panel at the following position:

comment:4 follow-up: Changed 4 years ago by rblank

The default_timezone option is defined in RequestDispatcher. You can get and set the value via this property, or go through self.config if it's easier. What do you mean with "doesn't seem to be behaving well"? Don't hesitate to post a patch (even incomplete).

The place where you put the selector looks fine.

comment:5 in reply to: ↑ 4 Changed 4 years ago by Ryan J Ollos <ryano@…>

Replying to rblank:

What do you mean with "doesn't seem to be behaving well"? Don't hesitate to post a patch (even incomplete).

I'm struggling a bit with passing data between the template and render_admin_panel. I'll spend a little bit of time with it tomorrow morning, and then post what I have so far (and also spend some time testing your revised patch in #9582 at that time). Thanks!

comment:6 Changed 4 years ago by Ryan J Ollos <ryano@…>

Here is my first cut at a patch. The main question I have is over the use of pytz objects vs strings. Since all_timezones is a list of strings, I've coded it so that the template does a string comparison and returns a string. However, default_timezone is a pytz object. It seemed safer to pass the string value to get_timezone since it seems to handle the error checking.

I looked at the code in prefs_datetime.html, but did things a bit differently. It seems like the following code is overly complicated. For example, I'm not sure why settings.session.get('tz') would be called from the template rather than passing a value for session_tzname from PreferencesModule.render_preference_panel.

<div class="field" py:with="session_tzname = settings.session.get('tz');
                            selected_tz = timezone(session_tzname) or utc">
  <label>Time zone:
  <select name="tz">
    <option value="None">Default time zone</option>
    <option py:for="tzname in timezones" value="${tzname}"
            selected="${session_tzname != None and
                        session_tzname.startswith('Etc/') and
                        selected_tz == timezone(tzname) or
                        session_tzname == tzname or None}">${tzname}</option>
  </select></label>

Changed 4 years ago by Ryan J Ollos <ryano@…>

Changed 4 years ago by Ryan J Ollos <ryano@…>

Changed 4 years ago by Ryan J Ollos <ryano@…>

comment:7 Changed 4 years ago by Ryan J Ollos <ryano@…>

I also think there may be a small problem with the Preferences: Date & Time panel. If I leave the Default time zone selected in the listbox and repeatedly hit Save, the text below the listbox toggles between:


The difference is the third line of text.

comment:8 follow-up: Changed 4 years ago by rblank

  • Milestone changed from unscheduled to 0.13
  • Owner set to rblank

Looks good at first sight. One comment, though: placing the content of <textarea> fields on a new line is intentional, as it fixes an issue with IE (I can't find the relevant ticket ATM, but I'm sure Christian will chime in). Please don't change those.

comment:9 in reply to: ↑ 8 Changed 4 years ago by cboos

Replying to rblank:

placing the content of <textarea> fields on a new line is intentional, as it fixes an issue with IE

Right, see #7657 and especially r3496 for a discussion of the problem.

comment:10 Changed 4 years ago by rblank

  • Priority changed from normal to high

comment:11 Changed 4 years ago by cboos

  • Keywords needfixup added

Changed 4 years ago by rblank

Configure default timezone and language in admin panel.

comment:12 Changed 4 years ago by rblank

9581-default-tz-lang-r10162.patch is a reworked version of your patch, and (while I was at it) also adds a select box for the default language. Testing welcome.

About comment:7, I can't reproduce that with current trunk, but it may have been fixed in [10160]. If this is still happening for you, please provide the value of [trac] default_timezone on your system, as well as your version of pytz (if installed).

comment:13 Changed 4 years ago by rblank

  • Keywords patch added; needfixup removed

comment:14 Changed 4 years ago by rblank

  • Resolution set to fixed
  • Status changed from new to closed

Patch applied in [10178]. Thanks Ryan for your excellent patch!

comment:15 Changed 4 years ago by rblank

  • Owner changed from rblank to Ryan J Ollos <ryano@…>

comment:16 Changed 4 years ago by Ryan Ollos <ryano@…>

Thanks for revising and applying the patch! Normally I'd be able to help test it out in the few days you made available, but have been exceptionally busy lately. On to the next ticket soon I hope …

comment:17 Changed 4 years ago by cboos

  • Release Notes modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos <ryano@…>.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos <ryano@…> to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.