Changeset 2703
- Timestamp:
- 10/25/07 06:30:38 (1 year ago)
- Files:
-
- clientsplugin/0.11/clients/api.py (modified) (1 diff)
- clientsplugin/0.11/clients/client.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
clientsplugin/0.11/clients/api.py
r2687 r2703 87 87 def ticket_fields_need_upgrade(self): 88 88 section = 'ticket-custom' 89 return not (self.config.get(section, 'client') and self.config.get(section, 'client_rate')) 89 return ('text' != self.config.get(section, 'client') \ 90 or 'text' != self.config.get(section, 'client_rate')) 90 91 91 92 def do_ticket_field_upgrade(self): 92 93 section = 'ticket-custom' 93 94 94 self.config.set(section,'client', 'select') 95 if not self.config.get(section, 'client.order'): 96 self.config.set(section, 'client.order', '1') 97 self.config.set(section,'client.options', 'custom:ClientsList') 95 self.config.set(section,'client', 'text') 98 96 self.config.set(section,'client.label', 'Client') 99 self.config.set(section,'client.value', '0')100 97 101 98 self.config.set(section,'client_rate', 'text') 102 if not self.config.get(section, 'client_rate.order'):103 self.config.set(section, 'client_rate.order', '2')104 99 self.config.set(section,'client_rate.label', 'Client Charge Rate') 105 self.config.set(section,'client_rate.value', '')106 100 107 101 self.config.save(); clientsplugin/0.11/clients/client.py
r2685 r2703 1 1 from trac.core import * 2 from trac.env import IEnvironmentSetupParticipant 3 from trac.ticket import ITicketCustomFieldValues 2 from trac.web.api import IRequestFilter 3 from trac.ticket.api import ITicketManipulator 4 from trac.ticket.model import Ticket 5 from trac.util.html import html, Markup 4 6 5 class ClientsList(Component): 6 implements(ITicketCustomFieldValues) 7 from genshi.core import Markup 8 from genshi.builder import tag 9 from genshi.filters.transform import Transformer 10 11 #from util import * 12 from clients import model 13 14 class ClientModule(Component): 15 """Allows for tickets to be assigned to particular clients.""" 7 16 8 def __init__(self): 17 implements(IRequestFilter) 18 19 # IRequestFilter methods 20 def pre_process_request(self, req, handler): 21 return handler 22 23 def post_process_request(self, req, template, data, content_type): 24 if req.path_info.startswith('/ticket/'): 25 for field in data['fields']: 26 if 'client' == field['name']: 27 field['type'] = 'select' 28 for client in model.Client.select(self.env): 29 field['options'].append(client.name) 30 break 31 32 return template, data, content_type 33 34 # ITicketManipulator methods 35 def prepare_ticket(self, req, ticket, fields, actions): 9 36 pass 10 def get_values(self): 11 db = self.env.get_db_cnx() 12 cursor = db.cursor() 13 cursor.execute("SELECT name FROM client") 14 rv = [] 15 for name in cursor: 16 rv.append((name,None)) 17 return rv 37 38 def validate_ticket(self, req, ticket): 39 # Todo validate client is valid 40 pass 41 #if req.args.get('action') == 'resolve': 42 # links = TicketLinks(self.env, ticket) 43 # for i in links.blocked_by: 44 # if Ticket(self.env, i)['status'] != 'closed': 45 # yield None, 'Ticket #%s is blocking this ticket'%i 18 46
