o k`'@sddlmZddlmZmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZddlmZmZdd lmZmZmZmZmZGd d d eZd S) ) Attachment) Component TracError implements)Ticket) TicketModule)get_reporter_id)from_utimestamp)_)IRequestFilterIRequestHandler)ITemplateProvider add_notice add_scriptadd_script_dataadd_stylesheetc@sLeZdZdZeeeeddZddZ ddZ dd Z d d Z d d Z dS) TicketDeleteraTicket and ticket comment deleter. This component allows deleting ticket comments and complete tickets. For users having `TICKET_ADMIN` permission, it adds a "Delete" button next to each "Reply" button on the page. The button in the ticket description requests deletion of the complete ticket, and the buttons in the change history request deletion of a single comment. '''Comment and ticket deletion are irreversible (and therefore ''dangerous'') operations.''' For that reason, a confirmation step is requested. The confirmation page shows the ticket box (in the case of a ticket deletion) or the ticket change (in the case of a comment deletion). ccs"ddlm}d|tdfVdS)Nrresource_filename ticketopthtdocs pkg_resourcesr__name__selfrr8/usr/lib/python3/dist-packages/tracopt/ticket/deleter.pyget_htdocs_dirs-s zTicketDeleter.get_htdocs_dirscCsddlm}|tdgS)Nrr templatesrrrrrget_templates_dirs1s  z TicketDeleter.get_templates_dirscCs.|t|jur |S|jd}|dvr|S|S)Naction)deletedelete-comment)renvargsget)rreqhandlerr!rrrpre_process_request7s  z!TicketDeleter.pre_process_requestcCsX|dvr'|d}|r'|jr'd||jvr't|dt|d|jdid|||fS)N)z ticket.htmlzticket_preview.htmlticket TICKET_ADMINzticketopt/ticketdeleter.js use_symbolszui.use_symbols)ui)r&existspermresourcerrsession)rr'templatedatametadatar*rrrpost_process_request@s     z"TicketDeleter.post_process_requestcCsdS)NFr)rr'rrr match_requestLszTicketDeleter.match_requestcCs$|jd}|d|dt|j|}|jd}|jd}|jdkrd|jvr?|j |}|dkr:|d |7}| ||d krt| t |t d |jd |j}d |jvrn|jd }t|j|vrn|jd}| |n(|dkrtt|jd} |j| dt |t d||jd| |j |t|j} | ||} | ||| t|di| j|dd|dkr|jd| d<tt| d} | dD]} | d| kr| | d<| d| d<n qtt d|d n|d kr t|j|j|j} | jt| dt |dd| fS)Nidr*r+r!cnumPOSTcancelr#z #comment:%sr"z0Ticket #%(num)s and all associated data removed.)num query_tickets query_hrefcdate)r>z>The ticket comment %(num)s on ticket #%(id)s has been deleted.)r;r7author)r!r>changesdatechangezComment %(num)s not found) attachmentszcommon/css/ticket.csszticket_delete.html)!r%getintr/requirerr$r&methodhrefr*redirectr"rr r7queryr1splitstrr int delete_changer _prepare_data_insert_ticket_datarupdaterrselectrealmlistr)rr'r7r*r!r8rG redirect_toticketsr>tmr3rBrCrrrprocess_requestOsf                     zTicketDeleter.process_requestN)r __module__ __qualname____doc__rr r r rr r)r5r6rWrrrrrs   rN)trac.attachmentr trac.corerrrtrac.ticket.modelrtrac.ticket.web_uir trac.utilrtrac.util.datefmtr trac.util.translationr trac.web.apir r trac.web.chromer rrrrrrrrrs