Ticket #5025: fix_populate_fields-r6787.diff
| File fix_populate_fields-r6787.diff, 3.5 KB (added by cboos, 4 years ago) |
|---|
-
trac/ticket/web_ui.py
140 140 141 141 def match_request(self, req): 142 142 if re.match(r'/newticket/?$', req.path_info) is not None: 143 if req.method != 'POST':144 for k in req.args.keys():145 if k.startswith('__'): # non field argument146 req.args[k[2:]] = req.args[k]147 else:148 req.args['field_'+k] = req.args[k]149 del req.args[k]150 143 return True 151 144 match = re.match(r'/ticket/([0-9]+)$', req.path_info) 152 145 if match: … … 342 335 req.perm.require('TICKET_CREATE') 343 336 ticket = Ticket(self.env) 344 337 345 if req.method == 'POST' and 'field_owner' in req.args and \ 346 'TICKET_MODIFY' not in req.perm: 347 del req.args['field_owner'] 338 plain_fields = True # support for /newticket?version=0.11 GETs 339 field_reporter = 'reporter' 348 340 349 self._populate(req, ticket) 350 reporter_id = req.args.get('field_reporter') or \ 341 if req.method == 'POST': 342 plain_fields = False 343 field_reporter = 'field_reporter' 344 if 'field_owner' in req.args and 'TICKET_MODIFY' not in req.perm: 345 del req.args['field_owner'] 346 347 self._populate(req, ticket, plain_fields) 348 reporter_id = req.args.get(field_reporter) or \ 351 349 get_reporter_id(req, 'author') 352 350 ticket.values['reporter'] = reporter_id 353 351 … … 576 574 action, entry = ('add', add[0]) 577 575 return (action, entry, cc_list) 578 576 579 def _populate(self, req, ticket): 580 ticket.populate(dict([(k[6:],v) for k,v in req.args.iteritems() 581 if k.startswith('field_')])) 582 577 def _populate(self, req, ticket, plain_fields=False): 578 fields = req.args 579 if not plain_fields: 580 fields = dict([(k[6:],v) for k,v in fields.items() 581 if k.startswith('field_')]) 582 ticket.populate(fields) 583 583 # special case for updating the Cc: field 584 584 if 'cc_update' in req.args: 585 585 cc_action, cc_entry, cc_list = self._toggle_cc(req, ticket['cc']) … … 835 835 ticket.values = ticket._old 836 836 valid = False 837 837 else: # TODO: field based checking 838 if 'description' in ticket._old or \ 839 'field_reporter' in ticket._old: 838 if 'description' in ticket._old or 'reporter' in ticket._old: 840 839 if 'TICKET_ADMIN' not in req.perm: 841 840 add_warning(req, _("No permissions to change ticket " 842 "fields."))841 "fields.")) 843 842 ticket.values = ticket._old 844 843 valid = False 845 844 -
trac/templates/error.html
51 51 </head> 52 52 53 53 <py:def function="create_ticket(teo=False)"> 54 <input type="hidden" name="__preview" value="1" />55 54 <input type="hidden" name="reporter" value="${get_reporter_id(req)}" /> 56 55 <input py:if="teo" type="hidden" name="version" 57 56 value="${'dev' in trac.version and 'devel' or trac.version}" />
