1. Peter Suter
  2. trac-1942

Source

trac-1942 / ct-restrict-owner-fix.patch

# HG changeset patch
# Parent e44f51de5a9ef32c96ed814c182eec8b0e54b251
Restore list type lost in previous changeset(s) and add `user_time` for
custom (i18n aware) date/time formatting and parsing available after [10571].

diff --git a/trac/ticket/query.py b/trac/ticket/query.py
--- a/trac/ticket/query.py
+++ b/trac/ticket/query.py
@@ -1067,7 +1067,7 @@
                 add_warning(req, error)
 
         context = web_context(req, 'query')
-        owner_field = query.fields.by_name('owner', None)
+        owner_field = [query.fields.by_name('owner', None)]
         if owner_field:
             TicketSystem(self.env).eventually_restrict_owner(owner_field[0])
         data = query.template_data(context, tickets, orig_list, orig_time, req)
diff --git a/trac/ticket/web_ui.py b/trac/ticket/web_ui.py
--- a/trac/ticket/web_ui.py
+++ b/trac/ticket/web_ui.py
@@ -37,9 +37,10 @@
 from trac.ticket.notification import TicketNotifyEmail
 from trac.timeline.api import ITimelineEventProvider
 from trac.util import as_bool, as_int, get_reporter_id
-from trac.util.datefmt import format_datetime, format_date, format_datetime, from_utimestamp, \
-                              get_date_format_hint, get_datetime_format_hint, \
-                              pretty_timedelta, parse_date, to_utimestamp, utc
+from trac.util.datefmt import format_datetime, format_date, format_datetime, \
+                              from_utimestamp, get_date_format_hint, \
+                              get_datetime_format_hint, pretty_timedelta, \
+                              parse_date, to_utimestamp, user_time, utc
 from trac.util.text import exception_to_unicode, obfuscate_email_address, \
                            shorten_line, to_unicode
 from trac.util.presentation import separated
@@ -705,7 +706,7 @@
             fields.pop('checkbox_' + each, None)    # See Ticket.populate()
         for field, value in fields.iteritems():
             if field in ticket.time_fields:
-                fields[field] = parse_date(value, req.tz, 'datetime') \
+                fields[field] = user_time(req, parse_date, value) \
                                 if value else None
         ticket.populate(fields)
         # special case for updating the Cc: field
@@ -1684,11 +1685,9 @@
         if format == 'age' and relative:
             return pretty_timedelta(value) if value else ''
         elif format == 'date':
-            return format_date(value, '%Y-%m-%d', tzinfo=req.tz) \
-                   if value else ''
+            return user_time(req, format_date, value) if value else ''
         else:
-            return format_datetime(value, '%Y-%m-%d %H:%M:%S', tzinfo=req.tz) \
-                   if value else ''
+            return user_time(req, format_datetime, value) if value else ''
 
     def grouped_changelog_entries(self, ticket, db=None, when=None):
         """Iterate on changelog entries, consolidating related changes