Edgewall Software

Ticket #925: patch-customlabelwiki-r1049.diff

File patch-customlabelwiki-r1049.diff, 4.8 KB (added by pkou <pkou at ua.fm>, 4 years ago)

Patch for the changes

  • trac/Milestone.py

     
    208208            cursor.execute("SELECT DISTINCT owner AS name FROM ticket " 
    209209                           "ORDER BY owner") 
    210210        elif by not in Ticket.std_fields: 
    211             fields = get_custom_fields(self.env) 
     211            fields = get_custom_fields(self.req.hdf, self.env, self.db) 
    212212            field = [f for f in fields if f['name'] == by] 
    213213            if not field: 
    214214                return [] 
     
    308308 
    309309        available_groups = [ 'component', 'version', 'severity', 'priority', 
    310310                             'owner' ] 
    311         available_groups += [f['name'] for f in get_custom_fields(self.env) 
     311        available_groups += [f['name'] for f in get_custom_fields(self.req.hdf, self.env, self.db) 
    312312                             if f['type'] == 'select' or f['type'] == 'radio'] 
    313313        add_to_hdf(available_groups, self.req.hdf, 
    314314                   'milestone.stats.available_groups') 
  • trac/Query.py

     
    2525import perm 
    2626import util 
    2727from Module import Module 
    28 from Ticket import get_custom_fields, insert_custom_fields, Ticket 
     28from Ticket import get_custom_fields, Ticket 
    2929 
    3030 
    3131class QueryModule(Module): 
     
    3333 
    3434    def get_constraints(self): 
    3535        constraints = {} 
    36         custom_fields = [f['name'] for f in get_custom_fields(self.env)] 
     36        custom_fields = [f['name'] for f in get_custom_fields(self.req.hdf, self.env, self.db)] 
    3737        constrained_fields = [k for k in self.args.keys() 
    3838                              if k in Ticket.std_fields or k in custom_fields] 
    3939        for field in constrained_fields: 
     
    127127        add_options('severity', constraints, 'query.options.', cursor, 
    128128                    "SELECT name FROM enum WHERE type='severity' ORDER BY value") 
    129129 
    130         custom_fields = get_custom_fields(self.env) 
     130        custom_fields = get_custom_fields(self.req.hdf, self.env, self.db) 
    131131        for custom in custom_fields: 
    132132            if custom['type'] == 'select' or custom['type'] == 'radio': 
    133133                check = constraints.has_key(custom['name']) 
     
    167167 
    168168        sql = [] 
    169169        sql.append("SELECT " + ", ".join(headers)) 
    170         custom_fields = [f['name'] for f in get_custom_fields(self.env)] 
     170        custom_fields = [f['name'] for f in get_custom_fields(self.req.hdf, self.env, self.db)] 
    171171        for k in [k for k in constraints.keys() if k in custom_fields]: 
    172172            sql.append(", %s.value AS %s" % (k, k)) 
    173173        sql.append(" FROM ticket") 
  • trac/Ticket.py

     
    2828import perm 
    2929import util 
    3030from Module import Module 
    31 from WikiFormatter import wiki_to_html 
     31from WikiFormatter import wiki_to_html, wiki_to_oneliner 
    3232from Notify import TicketNotifyEmail 
    3333 
    3434__all__ = ['Ticket', 'NewticketModule', 'TicketModule'] 
     
    207207        else: 
    208208            return 0 
    209209 
    210 def get_custom_fields(env): 
     210def get_custom_fields(hdf, env, db): 
    211211    cfg = env.get_config_items('ticket-custom') 
    212212    if not cfg: 
    213213        return [] 
     
    223223            'name': name, 
    224224            'type': items[name], 
    225225            'order': items.get(name + '.order', '0'), 
    226             'label': items.get(name + '.label', ''), 
     226            'label': wiki_to_oneliner(items.get(name + '.label', ''), hdf, env, db), 
    227227            'value': items.get(name + '.value', '') 
    228228        } 
    229229        if field['type'] == 'select' or field['type'] == 'radio': 
     
    237237    return fields 
    238238 
    239239 
    240 def insert_custom_fields(env, hdf, vals = {}): 
    241     fields = get_custom_fields(env) 
     240def insert_custom_fields(hdf, env, db, vals = {}): 
     241    fields = get_custom_fields(hdf, env, db) 
    242242    i = 0 
    243243    for f in fields: 
    244244        name = f['name'] 
     
    328328        util.sql_to_hdf(self.db, 'SELECT name FROM version ORDER BY name', 
    329329                        self.req.hdf, 'newticket.versions') 
    330330 
    331         insert_custom_fields(self.env, self.req.hdf, ticket) 
     331        insert_custom_fields(self.req.hdf, self.env, self.db, ticket) 
    332332 
    333333 
    334334class TicketModule (Module): 
     
    423423                hdf.setValue('ticket.changes.%d.new' % idx, util.escape(new)) 
    424424            idx = idx + 1 
    425425 
    426         insert_custom_fields(self.env, hdf, ticket) 
     426        insert_custom_fields(hdf, self.env, self.db, ticket) 
    427427        # List attached files 
    428428        self.env.get_attachments_hdf(self.db, 'ticket', str(id), self.req.hdf, 
    429429                                     'ticket.attachments')