Ticket #1459: add_remove_checkbox_for_CC-r6191.patch
| File add_remove_checkbox_for_CC-r6191.patch, 5.8 KB (added by cboos, 4 years ago) |
|---|
-
trac/ticket/api.py
275 275 276 276 def get_permission_actions(self): 277 277 return ['TICKET_APPEND', 'TICKET_CREATE', 'TICKET_CHGPROP', 278 'TICKET_VIEW', 279 ('TICKET_MODIFY', ['TICKET_APPEND', 'TICKET_CHGPROP']), 278 'TICKET_VIEW', 'TICKET_EDIT_CC', 279 ('TICKET_MODIFY', ['TICKET_APPEND', 'TICKET_CHGPROP', 280 'TICKET_EDIT_CC']), 280 281 ('TICKET_ADMIN', ['TICKET_CREATE', 'TICKET_MODIFY', 281 282 'TICKET_VIEW'])] 282 283 -
trac/ticket/web_ui.py
538 538 absurls=absurls), 539 539 'preserve_newlines': preserve_newlines} 540 540 541 def _toggle_cc(self, req, cc): 542 """Return an (action, recipient) tuple corresponding to a change 543 of CC status for this user relative to the current `cc_list`.""" 544 entries = [] 545 email = req.session.get('email', '').strip() 546 if email: 547 entries.append(email) 548 if req.authname != 'anonymous': 549 entries.append(req.authname) 550 else: 551 author = get_reporter_id(req, 'author').strip() 552 if author != 'anonymous': 553 entries.append(author) 554 add = [] 555 remove = [] 556 cc_list = Chrome(self.env).cc_list(cc) 557 for entry in entries: 558 if entry in cc_list: 559 remove.append(entry) 560 else: 561 add.append(entry) 562 print repr((entries, cc_list, add, remove)) 563 action = entry = '' 564 if remove: 565 action, entry = ('remove', remove[0]) 566 elif add: 567 action, entry = ('add', add[0]) 568 return (action, entry, cc_list) 569 541 570 def _populate(self, req, ticket): 542 571 ticket.populate(dict([(k[6:],v) for k,v in req.args.iteritems() 543 572 if k.startswith('field_')])) 544 573 574 # special case for updating the Cc: field 575 if 'cc_update' in req.args: 576 cc_action, cc_entry, cc_list = self._toggle_cc(req, ticket['cc']) 577 if cc_action == 'remove': 578 cc_list.remove(cc_entry) 579 elif cc_action == 'add': 580 cc_list.append(cc_entry) 581 print repr((cc_entry, cc_list, ', '.join(cc_list))) 582 ticket['cc'] = ', '.join(cc_list) 583 545 584 def _get_history(self, req, ticket): 546 585 history = [] 547 586 for change in self.rendered_changelog_entries(req, ticket): … … 982 1021 field['rendered'] = render_resource_link(self.env, context, 983 1022 milestone, 'compact') 984 1023 elif name == 'cc': 985 emails = Chrome(self.env).format_emails(context, ticket[name]) 1024 emails = Chrome(self.env).format_emails(context, ticket[name]) 986 1025 field['rendered'] = emails 1026 if ticket.exists and \ 1027 'TICKET_EDIT_CC' not in req.perm(ticket.resource): 1028 cc = ticket._old.get('cc', ticket['cc']) 1029 cc_action, cc_entry, cc_list = self._toggle_cc(req, cc) 1030 field['edit_label'] = { 1031 'add': _("Add to Cc"), 1032 'remove': _("Remove from Cc"), 1033 '': _("Add/Remove from Cc")}[cc_action] 1034 field['cc_entry'] = cc_entry or _("the <Author>") 1035 field['cc_update'] = 'cc_update' in req.args or None 987 1036 988 1037 # per type settings 989 1038 if type_ in ('radio', 'select'): -
trac/ticket/templates/ticket.html
309 309 <py:for each="idx, field in enumerate(row)"> 310 310 <th class="col${idx + 1}" py:if="idx == 0 or not fullrow"> 311 311 <label for="field-${field.name}" py:if="field" 312 py:strip="field.type == 'radio'">${field. label or field.name}:</label>312 py:strip="field.type == 'radio'">${field.edit_label or field.label or field.name}:</label> 313 313 </th> 314 314 <td class="col${idx + 1}" py:if="idx == 0 or not fullrow" 315 315 colspan="${fullrow and 3 or None}"> … … 340 340 checked="${ticket[field.name] == option or None}" /> 341 341 ${option} 342 342 </label> 343 <input py:otherwise="" type="text" id="field-${field.name}" 344 name="field_${field.name}" value="${ticket[field.name]}" /> 343 <py:otherwise><!--! Text input fields --> 344 <py:choose> 345 <span py:when="field.cc_entry"><!--! Special case for Cc: field --> 346 <em>${field.cc_entry}</em> 347 <input type="checkbox" id="field-cc" name="cc_update" checked="${field.cc_update}" /> 348 </span> 349 <!--! All the other text input fields, including Cc: when TICKET_EDIT_CC is allowed --> 350 <input py:otherwise="" type="text" id="field-${field.name}" 351 name="field_${field.name}" value="${ticket[field.name]}" /> 352 </py:choose> 353 </py:otherwise> 345 354 </py:choose> 346 355 </td> 347 356 </py:for>
