Ticket #3068: milestone_attachments_r3304.patch
| File milestone_attachments_r3304.patch, 6.8 kB (added by cboos, 2 years ago) |
|---|
-
htdocs/css/trac.css
319 319 .attachment #preview { margin-top: 1em } 320 320 321 321 /* Styles for the list of attachments. */ 322 #attachments { border: 1px outset #996; padding: 1em } 322 #list-of-attachments { clear: both; } 323 #attachments { border: 1px outset #996; padding: 1em } 323 324 #attachments .attachments { margin-left: 2em; padding: 0 } 324 325 #attachments dt { display: list-item; list-style: square; } 325 326 #attachments dd { font-style: italic; margin-left: 0; padding-left: 0; } -
trac/attachment.py
256 256 # IRequestHandler methods 257 257 258 258 def match_request(self, req): 259 match = re.match(r'^/attachment/( ticket|wiki)(?:[/:](.*))?$',259 match = re.match(r'^/attachment/([^/]+)(?:[/:](.*))?$', 260 260 req.path_info) 261 261 if match: 262 262 req.args['type'] = match.group(1) … … 268 268 path = req.args.get('path') 269 269 if not parent_type or not path: 270 270 raise HTTPBadRequest('Bad request') 271 if not parent_type in ['ticket', 'wiki']:272 raise HTTPBadRequest('Unknown attachment type')271 #if not parent_type in ['ticket', 'wiki']: 272 # raise HTTPBadRequest('Unknown attachment type') 273 273 274 274 action = req.args.get('action', 'view') 275 275 if action == 'new': … … 308 308 parent_link = req.href(parent_type, parent_id) 309 309 if parent_type == 'ticket': 310 310 parent_text = 'Ticket #' + parent_id 311 elif parent_type == 'milestone': 312 parent_text = 'Milestone ' + parent_id 311 313 else: # 'wiki' 312 314 parent_text = parent_id 313 315 req.hdf['attachment.parent'] = { … … 327 329 # Internal methods 328 330 329 331 def _do_save(self, req, attachment): 330 perm_map = {'ticket': 'TICKET_APPEND', 'wiki': 'WIKI_MODIFY'} 332 perm_map = {'ticket': 'TICKET_APPEND', 'wiki': 'WIKI_MODIFY', 333 'milestone': 'MILESTONE_MODIFY'} 331 334 req.perm.assert_permission(perm_map[attachment.parent_type]) 332 335 333 336 if req.args.has_key('cancel'): … … 367 370 attachment.parent_id, filename) 368 371 if not (old_attachment.author and req.authname \ 369 372 and old_attachment.author == req.authname): 370 perm_map = {'ticket': 'TICKET_ADMIN', 'wiki': 'WIKI_DELETE'} 373 perm_map = {'ticket': 'TICKET_ADMIN', 'wiki': 'WIKI_DELETE', 374 'milestone': 'MILESTONE_DELETE'} 371 375 req.perm.assert_permission(perm_map[old_attachment.parent_type]) 372 376 old_attachment.delete() 373 377 except TracError: … … 399 403 'mode': 'delete'} 400 404 401 405 def _render_form(self, req, attachment): 402 perm_map = {'ticket': 'TICKET_APPEND', 'wiki': 'WIKI_MODIFY'} 406 perm_map = {'ticket': 'TICKET_APPEND', 'wiki': 'WIKI_MODIFY', 407 'milestone': 'MILESTONE_MODIFY'} 403 408 req.perm.assert_permission(perm_map[attachment.parent_type]) 404 409 405 410 req.hdf['attachment'] = {'mode': 'new', 406 411 'author': util.get_reporter_id(req)} 407 412 408 413 def _render_view(self, req, attachment): 409 perm_map = {'ticket': 'TICKET_VIEW', 'wiki': 'WIKI_VIEW'} 414 perm_map = {'ticket': 'TICKET_VIEW', 'wiki': 'WIKI_VIEW', 415 'milestone': 'MILESTONE_MODIFY'} 410 416 req.perm.assert_permission(perm_map[attachment.parent_type]) 411 417 412 418 req.check_modified(attachment.time) … … 416 422 req.hdf['attachment'] = attachment_to_hdf(self.env, req, None, 417 423 attachment) 418 424 419 perm_map = {'ticket': 'TICKET_ADMIN', 'wiki': 'WIKI_DELETE'} 425 perm_map = {'ticket': 'TICKET_ADMIN', 'wiki': 'WIKI_DELETE', 426 'milestone': 'MILESTONE_DELETE'} 420 427 if req.perm.has_permission(perm_map[attachment.parent_type]): 421 428 req.hdf['attachment.can_delete'] = 1 422 429 -
trac/ticket/roadmap.py
19 19 from time import localtime, strftime, time 20 20 21 21 from trac import __version__ 22 from trac.attachment import attachments_to_hdf 22 23 from trac.core import * 23 24 from trac.perm import IPermissionRequestor 24 25 from trac.util import format_date, format_datetime, parse_date, \ … … 445 446 446 447 def _render_view(self, req, db, milestone): 447 448 req.hdf['title'] = 'Milestone %s' % milestone.name 448 req.hdf['milestone.mode'] = 'view' 449 449 req.hdf['milestone'] = { 450 'mode': 'view', 451 'attachments': attachments_to_hdf(self.env, req, db, 452 'milestone', milestone.name), 453 } 454 if req.perm.has_permission('MILESTONE_MODIFY'): 455 req.hdf['milestone.attach_href'] = req.href.attachment('milestone', 456 milestone.name) 450 457 req.hdf['milestone'] = milestone_to_hdf(self.env, db, req, milestone) 451 452 458 available_groups = [] 453 459 component_group_available = False 454 460 for field in TicketSystem(self.env).get_ticket_fields(): -
templates/macros.cs
172 172 /def ?><?cs 173 173 174 174 def:list_of_attachments(attachments, attach_href) ?> 175 <div id="list-of-attachments"> 175 176 <h2>Attachments</h2><?cs 176 177 if:len(attachments) ?><div id="attachments"> 177 178 <dl class="attachments"><?cs each:attachment = attachments ?> … … 189 190 <input type="hidden" name="action" value="new" /> 190 191 <input type="submit" value="Attach File" /> 191 192 </div></form><?cs 192 /if ?><?cs if:len(attachments) ?></div><?cs /if ?>< ?cs193 /if ?><?cs if:len(attachments) ?></div><?cs /if ?></div><?cs 193 194 /def ?> -
templates/milestone.cs
194 194 </fieldset> 195 195 </form> 196 196 <div class="description"><?cs var:milestone.description ?></div><?cs 197 if:milestone.attach_href || len(milestone.attachments) ?><?cs 198 call:list_of_attachments(milestone.attachments, milestone.attach_href) ?><?cs 199 /if ?><?cs 197 200 if:trac.acl.MILESTONE_MODIFY || trac.acl.MILESTONE_DELETE ?> 198 201 <div class="buttons"><?cs 199 202 if:trac.acl.MILESTONE_MODIFY ?>
