On Thursday, November 17, 2016 at 1:35:37 AM UTC-8, RjOllos wrote:
>
>
>
> On Thursday, November 17, 2016 at 1:28:30 AM UTC-8, Mo wrote:
>>
>> Hi, thank you for your fast solution.
>>
>> How can I install a single .py as Plugin?
>>
>
> See this section:
> https://trac.edgewall.org/wiki/TracPlugins#Requirements
>  
>
>> Trying to understand how to configure it, would this be a correct 
>> configuration by listing all fields in the desired order?
>>
>>  
>
>> [ticket]
>> field_order = type, priority, milestone, component, version, keywords, cc
>>
>> I don't even know the internal names of the builtin fields.
>>
>
> Yes, that looks good. For internal names, see first column of tuple or 
> name entry of dictionary here:
>
> https://trac.edgewall.org/browser/tags/trac-1.0.13/trac/ticket/api.py?marks=311-318,336-339#L289
>  
>
>> BR,
>> Mo
>>
>
> - Ryan 
>

The version of the plugin I posted before incorrectly cached 
data['fields'], so ticket property changes would not be shown in the ticket 
properties box. The attached version of the plugin fixes that issue.

- Ryan
 

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://trac.edgewall.org/wiki/TracLicense.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://trac.edgewall.org/log/.

from trac.core import Component, implements
from trac.config import ListOption
from trac.web.api import IRequestFilter


class TicketFieldOrderer(Component):

    implements(IRequestFilter)

    field_order = ListOption('ticket', 'field_order',
        doc="Ticket field order.")

    def pre_process_request(self, req, handler):
        return handler

    def post_process_request(self, req, template, data, content_type):
        if template == 'ticket.html' and self.field_order:
            fields = data['fields']
            def index_of(f):
                name = f['name']
                return self.field_order.index(name) \
                       if name in self.field_order \
                       else len(self.field_order)
            fields.sort(cmp=lambda x, y: cmp(index_of(x), index_of(y)))
            data['fields'] = fields
        return template, data, content_type

Reply via email to