Edgewall Software

Ticket #4158 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] - Display DateTime values in Query Results correctly

Reported by: ilias@… Owned by: cboos
Priority: normal Milestone: 0.11
Component: report system Version: devel
Severity: minor Keywords: datetime
Cc:

Description

the patch enables the dispaly of 'time' and 'changetime' fields (if available), otherwise the behaviour remains the same:

patch

It is identical to the patch suggested by mgood within this thread

See line 140 of this patch

Attachments

Change History

follow-ups: ↓ 2 ↓ 6   Changed 2 years ago by cboos

  • keywords datetime added
  • owner changed from mgood to cboos
  • severity changed from normal to minor
  • milestone set to 0.11

Thanks, though it looks preferable to do that based on type of the column.

  • query_div.html

     
    4545            result.changed and ' changed' or ''}${ 
    4646            result.removed and ' removed' or ''}"> 
    4747            <py:for each="idx, header in enumerate(headers)" py:choose=""> 
    48               <td py:when="idx == 0" class="id"><a href="$result.href" title="View ticket">#$result.id</a></td> 
    49               <td py:otherwise="" class="$header.name" py:choose=""> 
    50                 <a py:when="header.name == 'summary'" href="$result.href" title="View ticket">$result.summary</a> 
    51                 <span py:otherwise="">${result[header.name]}</span> 
    52               </td> 
     48              <py:with vars="name = header.name; value = result[name]"> 
     49                <td py:when="idx == 0" class="id"><a href="$result.href" title="View ticket">#$result.id</a></td> 
     50                <td py:otherwise="" class="$name" py:choose=""> 
     51                  <a py:when="name == 'summary'" href="$result.href" title="View ticket">$value</a> 
     52                  <span py:when="isinstance(value, datetime)">${format_datetime(value)}</span> 
     53                  <span py:otherwise="">$value</span> 
     54                </td> 
     55              </py:with> 
    5356            </py:for> 
    5457          </tr> 

in reply to: ↑ 1   Changed 2 years ago by ilias@…

Replying to cboos:

Thanks, though it looks preferable to do that based on type of the column.

...which is not yet defined.

I've 'back-developed' my patches to not affect the ticket api (as suggested by mgood):

http://groups.google.com/group/trac-dev/msg/61c2134c408c1296

So, at this point the field type definition does not exist thus looking for 'datetime' would not work. The suggested patch does the work fine (until the fields api is refactored/extended).

  • templates/query_div.html

     
    4848              <td py:when="idx == 0" class="id"><a href="$result.href" title="View ticket">#$result.id</a></td> 
    4949              <td py:otherwise="" class="$header.name" py:choose=""> 
    5050                <a py:when="header.name == 'summary'" href="$result.href" title="View ticket">$result.summary</a> 
     51                <span py:when="header.name in ('time', 'changetime')">${format_datetime(result[header.name])}</span> 
    5152                <span py:otherwise="">${result[header.name]}</span> 
    5253              </td> 
    5354            </py:for> 

follow-up: ↓ 4   Changed 2 years ago by cboos

Note that I've checked directly the type of the value: isinstance(value, datetime)

in reply to: ↑ 3   Changed 2 years ago by ilias@…

Replying to cboos:

Note that I've checked directly the type of the value: isinstance(value, datetime)

Oh yes, I see (a little bit overworked).

This would be a more elegant generic solution.

Of course it should be prefered.

  Changed 2 years ago by ilias@…

I've applied the patch and it works fine on the server, so for me it fine if it goes in trunk this way.

in reply to: ↑ 1   Changed 2 years ago by cboos

  • status changed from new to closed
  • resolution set to fixed

Patch applied in r4292.

Add/Change #4158 ([PATCH] - Display DateTime values in Query Results correctly)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cboos. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.