Roundup Tracker - Issues

Message7202

Author rouilj
Recipients ced, rouilj
Date 2021-04-18.21:53:07
Message-id <1618782788.14.0.90081790955.issue2551128@roundup.psfhosted.org>
In-reply-to
Hi Cedric:

Thanks for the patch I created  test and applied it in
rev 6380:d76291836523.

You might want to consider using a select box for setting the
timezone.

This tal uses a couple of utility functions utils.UsingPytz and 
utils.GetCommonTZ to provide a text entry box if not using Pytz
or to provide a select input with a list of all recognized
timezones.

    <tal:block tal:condition="python:(context.is_edit_ok() or
                              context.timezone) and
                              not utils.UsingPytz()">
      <input name="timezone" metal:use-macro="normal_input">
    </tal:block>
    <tal:subif condition="python:utils.UsingPytz()">
      <tal:span tal:condition="python: not context.is_edit_ok()"
                tal:content="context/timezone"></tal:span>
      <select tal:condition="python:context.is_edit_ok()"
              id="timezone" name="timezone">
        <option value="0">- no selection -</option>
        <tal:block tal:repeat="tz python:utils.GetCommonTz()">
          <option tal:attributes="value tz; selected python:tz == 
context.timezone"
                  tal:content="tz"></option>
        </tal:block>
      </select>
    </tal:subif>

and the helper functions:

def using_pytz():
    try:
        import pytz
        return True
    except:
        return False

def get_common_tz():
    if using_pytz():
        import pytz
        return pytz.common_timezones


instance.registerUtil('UsingPytz', using_pytz)
instance.registerUtil('GetCommonTz', get_common_tz)

You can see it in context at:

  https://rouilj.dynamic-dns.net/fossil/roundup_sysadmin/file?
name=extensions/time.py&ci=tip

and

   https://rouilj.dynamic-dns.net/fossil/roundup_sysadmin/file?
ci=tip&name=html/user.item.html&txt=1&ln=119-144
History
Date User Action Args
2021-04-18 21:53:08rouiljsetmessageid: <1618782788.14.0.90081790955.issue2551128@roundup.psfhosted.org>
2021-04-18 21:53:08rouiljsetrecipients: + rouilj, ced
2021-04-18 21:53:08rouiljlinkissue2551128 messages
2021-04-18 21:53:07rouiljcreate