Changeset 3994
- Timestamp:
- 07/09/08 12:36:22 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ticketsubmitpolicyplugin/0.11/ticketsubmitpolicy/templates/ticketsubmitpolicy.html
r3993 r3994 10 10 </head> 11 11 <body> 12 13 <div py:if="not saved"> 14 The policy is not saved. Please click 'Apply Changes' to save 15 </div> 12 16 13 17 <form method="post"> … … 92 96 </py:for> 93 97 </select> 98 99 <!-- dummy submit button for action adding --> 100 <input type="submit" name="actionbutton_${name}" value="+"/> 94 101 </py:if> 95 102 ticketsubmitpolicyplugin/0.11/ticketsubmitpolicy/ticketsubmitpolicy.py
r3993 r3994 51 51 retval[policy.name()] = policy 52 52 return retval 53 54 def save(self, policies): 55 56 # shorthand 57 section = 'ticket-submit-policy' 58 config = self.env.config 59 60 # remove the old section 61 for key, value in config.options(section): 62 config.remove(section, key) 63 64 # create new section from policy dictionary 65 for policy in policies: 66 condition = policies[policy]['condition'] 67 if condition: 68 value = ' && '.join(['%s %s %s' % (i['field'], i['comparitor'], i['value']) for i in condition]) 69 config.set(section, 70 '%s.condition' % policy, 71 value) 72 for action in policies[policy]['actions']: 73 config.set(section, 74 '%s.%s' % (policy, action['name']), 75 ', '.join(action['args'])) 76 77 # save the policy 78 config.save() 53 79 54 80 def parse(self): … … 327 353 data['comparitors'] = self.comparitors # implemented comparitors 328 354 data['self_actions'] = self.policies # available policies 355 data['saved'] = True 329 356 330 357 if req.method == 'POST': 358 359 # mark the page as unsaved 360 data['saved'] = False 331 361 332 362 # organize request args based on policy … … 339 369 340 370 # get the conditions and policies from the request 341 old_policies = data['policies'] 371 old_policies = data['policies'] # XXX for debugging 342 372 data['policies'] = {} 343 373 for policy in args: … … 360 390 if field.startswith(token): 361 391 name = field.split(token, 1)[1] 362 action_args = [ i.strip() for i in value.split(',') ] 363 data['policies'][policy]['actions'].append(dict(name=name, args=action_args)) 392 if args[policy].get('rm_action_%s' % name, False): 393 continue 394 395 if isinstance(value, basestring): 396 value = [ value ] 397 data['policies'][policy]['actions'].append(dict(name=name, args=value)) 364 398 365 399 # added action … … 383 417 # save the data if the user clicks apply 384 418 if 'apply' in req.args: 385 pass 419 self.save(data['policies']) 420 data['saved'] = True 386 421 387 422 return ('ticketsubmitpolicy.html', data)
