Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

#4158 closed defect (fixed)

[PATCH] - Display DateTime values in Query Results correctly

Reported by: ilias@… Owned by: Christian Boos
Priority: normal Milestone: 0.11
Component: report system Version: devel
Severity: minor Keywords: datetime
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

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 (0)

Change History (6)

comment:1 by Christian Boos, 16 years ago

Keywords: datetime added
Milestone: 0.11
Owner: changed from Matthew Good to Christian Boos
Severity: normalminor

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 comment:2 by ilias@…, 16 years ago

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>

comment:3 by Christian Boos, 16 years ago

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

in reply to:  3 comment:4 by ilias@…, 16 years ago

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.

comment:5 by ilias@…, 16 years ago

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 comment:6 by Christian Boos, 16 years ago

Resolution: fixed
Status: newclosed

Patch applied in r4292.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.