Changeset 4446
- Timestamp:
- 10/12/08 15:54:58 (3 months ago)
- Files:
-
- clientsplugin/0.11/clients/action_email.py (modified) (1 diff)
- clientsplugin/0.11/clients/action.py (modified) (1 diff)
- clientsplugin/0.11/clients/admin.py (modified) (4 diffs)
- clientsplugin/0.11/clients/eventsadmin.py (modified) (1 diff)
- clientsplugin/0.11/clients/events.py (modified) (9 diffs)
- clientsplugin/0.11/clients/summary_milestone.py (modified) (1 diff)
- clientsplugin/0.11/clients/summary.py (modified) (1 diff)
- clientsplugin/0.11/clients/summary_ticketchanges.py (modified) (1 diff)
- clientsplugin/0.11/clients/templates/admin_clients.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
clientsplugin/0.11/clients/action_email.py
r4438 r4446 31 31 return "Send an email to a certain list of addresses" 32 32 33 def instance_options(self): 34 yield {'name': 'XSLT', 'description': 'Formatting XSLT to convert the summary to an email'} 33 def options(self, client=None): 34 if client is None: 35 yield {'name': 'XSLT', 'description': 'Formatting XSLT to convert the summary to an email'} 36 else: 37 yield {'name': 'Email Addresses', 'description': 'Comma separated list of email addresses'} 35 38 36 def client_options(self):37 return []38 39 39 40 def init(self, instance, client): clientsplugin/0.11/clients/action.py
r4438 r4446 15 15 """ 16 16 17 def options(client=None): 18 """The options for this action 19 If the client option is None then these options are defined as being per instance. 20 """ 21 17 22 def perform(summary): 18 23 """Perform the action. This must return an etree object clientsplugin/0.11/clients/admin.py
r4444 r4446 7 7 8 8 from clients.model import Client 9 from clients.events import ClientEvent 9 10 from trac.util.datefmt import utc, parse_date, get_date_format_hint, \ 10 11 get_datetime_format_hint … … 21 22 if client: 22 23 clnt = Client(self.env, client) 24 events = ClientEvent.select(self.env, client) 23 25 if req.method == 'POST': 24 26 if req.args.get('save'): … … 32 34 clnt.currency = req.args.get('currency') 33 35 clnt.update() 36 37 for clev in events: 38 for option in clev.summary_options: 39 arg = 'summary-option-%s-%s' % (clev.md5, clev.summary_options[option]['md5']) 40 clev.summary_options[option]['value'] = req.args.get(arg) 41 for option in clev.action_options: 42 arg = 'action-option-%s-%s' % (clev.md5, clev.action_options[option]['md5']) 43 print arg 44 print req.args.get(arg) 45 clev.action_options[option]['value'] = req.args.get(arg) 46 clev.update_options(client) 47 34 48 req.redirect(req.href.admin(cat, page)) 35 49 elif req.args.get('cancel'): … … 37 51 38 52 add_script(req, 'common/js/wikitoolbar.js') 39 data = {'view': 'detail', 'client': clnt }53 data = {'view': 'detail', 'client': clnt, 'events': events} 40 54 41 55 else: clientsplugin/0.11/clients/eventsadmin.py
r4445 r4446 65 65 66 66 data = {'view': 'list', 67 'events': ClientEvent.select(self.env), 68 'summaries': ClientEventsSystem(self.env).get_summaries(), 69 'actions': ClientEventsSystem(self.env).get_actions()} 67 'events': ClientEvent.select(self.env)} 70 68 71 69 return 'admin_client_events.html', data clientsplugin/0.11/clients/events.py
r4445 r4446 42 42 class ClientEvent(object): 43 43 44 def __init__(self, env, name=None, db=None):44 def __init__(self, env, name=None, client=None, db=None): 45 45 self.env = env 46 46 if name: … … 56 56 if not row: 57 57 raise TracError('Client Event %s does not exist.' % name) 58 self.md5 = md5.new(name).hexdigest() 58 59 self.name = self._old_name = name 59 60 self.summary = row[0] or '' 60 61 self.action = row[1] or '' 61 62 self.lastrun = row[2] or 0 62 self.loadoptions( db)63 self.loadoptions(client, db) 63 64 else: 64 65 self.name = self._old_name = None … … 68 69 69 70 70 def loadoptions(self, db):71 def loadoptions(self, client, db): 71 72 assert self.exists, 'Cannot load options for a non-existent client event' 72 73 system = ClientEventsSystem(self.env); … … 80 81 cursor.execute("SELECT name, value " 81 82 "FROM client_event_summary_options " 82 "WHERE client_event=%s AND client=''", (self._old_name,)) 83 "WHERE client_event=%s AND client=%s", 84 (self._old_name, client or '')) 83 85 for name, value in cursor: 84 86 options[name] = value 85 87 self.summary_options = {} 86 for option in summary. instance_options():88 for option in summary.options(client): 87 89 option['md5'] = md5.new(option['name']).hexdigest() 88 90 if options.has_key(option['name']): … … 94 96 cursor.execute("SELECT name, value " 95 97 "FROM client_event_action_options " 96 "WHERE client_event=%s AND client=''", (self._old_name,)) 98 "WHERE client_event=%s AND client=%s", 99 (self._old_name, client or '')) 97 100 for name, value in cursor: 98 101 options[name] = value 99 102 self.action_options = {} 100 for option in action. instance_options():103 for option in action.options(client): 101 104 option['md5'] = md5.new(option['name']).hexdigest() 102 105 if options.has_key(option['name']): … … 163 166 cursor.execute("DELETE FROM " + table + " " 164 167 "WHERE client_event=%s AND client=%s", 165 (self._old_name, client ))168 (self._old_name, client or '')) 166 169 for option in options.values(): 167 170 cursor.execute("INSERT INTO " + table + " (client_event, client, name, value) " 168 171 "VALUES (%s, %s, %s, %s)", 169 (self._old_name, client , option['name'], option['value']))170 171 if handle_ta: 172 db.commit() 173 174 175 def update_options(self, db=None):172 (self._old_name, client or '', option['name'], option['value'])) 173 174 if handle_ta: 175 db.commit() 176 177 178 def update_options(self, client=None, db=None): 176 179 assert self.exists, 'Cannot update non-existent client event' 177 180 if not db: … … 181 184 handle_ta = False 182 185 183 self.update_client_options( '', 'summary', self.summary_options, db)184 self.update_client_options( '', 'action', self.action_options, db)186 self.update_client_options(client, 'summary', self.summary_options, db) 187 self.update_client_options(client, 'action', self.action_options, db) 185 188 186 189 if handle_ta: … … 207 210 db.commit() 208 211 209 def select(cls, env, db=None):212 def select(cls, env, client=None, db=None): 210 213 if not db: 211 214 db = env.get_db_cnx() … … 215 218 "ORDER BY name") 216 219 for name, summary, action, lastrun in cursor: 217 client = cls(env) 218 client.name = client._old_name = name 219 client.summary = summary or '' 220 client.action = action or '' 221 client.lastrun = lastrun or 0 222 client.loadoptions(db) 223 yield client 220 clev = cls(env) 221 clev.md5 = md5.new(name).hexdigest() 222 clev.name = clev._old_name = name 223 clev.summary = summary or '' 224 clev.action = action or '' 225 clev.lastrun = lastrun or 0 226 clev.loadoptions(client, db) 227 yield clev 224 228 select = classmethod(select) clientsplugin/0.11/clients/summary_milestone.py
r4436 r4446 32 32 return "Provide a summary of tickets within all milestones that have completion dates set and give summaries of a milestone" 33 33 34 def instance_options(self): 35 return [] 36 37 def client_options(self): 34 def options(self, client=None): 38 35 return [] 39 36 clientsplugin/0.11/clients/summary.py
r4436 r4446 15 15 """ 16 16 17 def instance_options(): 18 """Return a series of tupoles defining the option that can be set on this instance 19 """ 20 21 def client_options(): 22 """Return a series of tupoles defining the option that can be set on this client 23 for this specific instance. 17 def options(client=None): 18 """Return a series of tupoles defining the options 24 19 """ 25 20 clientsplugin/0.11/clients/summary_ticketchanges.py
r4436 r4446 32 32 return "Provide a summary of ticket changes since the last run" 33 33 34 def instance_options(self): 35 return [] 36 37 def client_options(self): 34 def options(self, client=None): 38 35 return [] 39 36 clientsplugin/0.11/clients/templates/admin_clients.html
r2708 r4446 49 49 </div> 50 50 </fieldset> 51 <py:for each="event in events"> 52 <py:for each="options in (event.summary_options, event.action_options)"> 53 <fieldset py:if="options"> 54 <py:with vars="field = options==event.summary_options and 'summary' or 'action'"> 55 <legend py:if="'summary'==field">Client Specific Summary Options for $event.name</legend> 56 <legend py:if="'action'==field">Client Specific Action Options for $event.name</legend> 57 <div py:for="option in options.values()" class="field"> 58 <label>$option.name</label><br /> 59 <!-- Todo: Support more modes other than intput type=text... --> 60 <input type="text" name="${field}-option-${event.md5}-${option.md5}" size="60" value="$option.value"/> 61 <p class="help">$option.description</p> 62 </div> 63 </py:with> 64 </fieldset> 65 </py:for> 66 </py:for> 67 68 51 69 <fieldset> 52 70 <legend>Change Notification Settings</legend>
