[Trac-tickets] [The Trac Project] #1791: [PATCH] Allow WikiFormatting in custom ticket fields of type textarea, and labels of any custom field.

The Trac Project noreply at edgewall.com
Thu Jul 14 15:45:30 CDT 2005


#1791: [PATCH] Allow WikiFormatting in custom ticket fields of type textarea, and
labels of any custom field.
---------------------------+------------------------------------------------
       Id:  1791           |      Status:  new                     
Component:  ticket system  |    Modified:  Thu Jul 14 15:45:30 2005
 Severity:  enhancement    |   Milestone:                          
 Priority:  normal         |     Version:  devel                   
    Owner:  jonas          |    Reporter:  anthony.vito at gmail.com  
---------------------------+------------------------------------------------
 This patch builds on the patch provided in #925 and resolves the issue
 addressed in #1392 against the trunk. WikiFormatting of all custom field
 labels is allowed, and textarea fields can use as much WikiFormatting as
 they would like. Quite a bit of functionality for 7 lines of code ;) Of
 course I haven't tested this throughly. Since the preview for tickets is
 now done at the top with the full ticket display, you even get a preview
 of everything! This patch is against [1970] the trunk as of [[Timestamp]]

 {{{
 Index: trac/ticket/api.py
 ===================================================================
 --- trac/ticket/api.py  (revision 1970)
 +++ trac/ticket/api.py  (working copy)
 @@ -25,6 +25,8 @@
  from trac.core import *
  from trac.perm import IPermissionRequestor
  from trac.wiki import IWikiSyntaxProvider
 +from trac.wiki import wiki_to_html
 +from trac.wiki import wiki_to_oneliner

  class MyLinkResolver(Component):
      """
 @@ -121,7 +123,8 @@
                  'name': name,
                  'type': self.config.get('ticket-custom', name),
                  'order': int(self.config.get('ticket-custom', name +
 '.order', '0')),
 -                'label': self.config.get('ticket-custom', name +
 '.label', ''),
 +                'label': wiki_to_oneliner(self.config.get('ticket-
 custom', name + '.label', ''),
 +                                          self.env,
 self.env.get_db_cnx()),
                  'value': self.config.get('ticket-custom', name +
 '.value', '')
              }
              if field['type'] == 'select' or field['type'] == 'radio':
 Index: trac/ticket/web_ui.py
 ===================================================================
 --- trac/ticket/web_ui.py       (revision 1970)
 +++ trac/ticket/web_ui.py       (working copy)
 @@ -348,6 +348,8 @@
              if name in ('summary', 'reporter', 'description', 'type',
 'status',
                          'resolution', 'owner'):
                  field['skip'] = True
 +            else:
 +                field['formatted'] =
 wiki_to_html(ticket.values.get(name), self.env, req, db)
              req.hdf['ticket.fields.' + name] = field

          req.hdf['ticket.reporter_id'] = util.escape(reporter_id)
 Index: templates/ticket.cs
 ===================================================================
 --- templates/ticket.cs (revision 1970)
 +++ templates/ticket.cs (working copy)
 @@ -64,7 +64,7 @@
      if:fullrow && idx % 2 ?><th></th><td></td></tr><tr><?cs /if ?>
      <th id="h_<?cs var:name(field) ?>"><?cs var:field.label ?>:</th>
      <td<?cs if:fullrow ?> colspan="3"<?cs /if ?> headers="h_<?cs
 -      var:name(field) ?>"><?cs var:ticket[name(field)] ?></td><?cs
 +      var:name(field) ?>"><?cs var:field.formatted ?></td><?cs
      if:idx % 2 ?></tr><tr><?cs
      elif:idx == num_fields - 1 ?><th></th><td></td><?cs
      /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs

 }}}

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/1791>
The Trac Project <>


More information about the Trac-Tickets mailing list