Exemple #1
0
 def _create_html_body(self, chrome, req, ticket, cnum, link):
     tktmod = TicketModule(self.env)
     attmod = AttachmentModule(self.env)
     data = tktmod._prepare_data(req, ticket)
     tktmod._insert_ticket_data(req, ticket, data, req.authname, {})
     data['ticket']['link'] = link
     changes = data.get('changes')
     if cnum is None:
         changes = []
     else:
         changes = [
             change for change in (changes or [])
             if change.get('cnum') == cnum
         ]
     data['changes'] = changes
     context = Context.from_request(req, ticket.resource, absurls=True)
     data.update({
         'can_append': False,
         'show_editor': False,
         'start_time': ticket['changetime'],
         'context': context,
         'alist': attmod.attachment_data(context),
         'styles': self._get_styles(chrome),
         'link': tag.a(link, href=link),
         'tag_': tag_,
     })
     rendered = chrome.render_template(req,
                                       'htmlnotification_ticket.html',
                                       data,
                                       fragment=True)
     return unicode(rendered)
Exemple #2
0
    def process_request(self, req):
        id = req.args.getint('id')
        req.perm('ticket', id).require('TICKET_ADMIN')
        ticket = Ticket(self.env, id)
        action = req.args['action']
        cnum = req.args.get('cnum')
        if req.method == 'POST':
            if 'cancel' in req.args:
                href = req.href.ticket(id)
                if action == 'delete-comment':
                    href += '#comment:%s' % cnum
                req.redirect(href)

            if action == 'delete':
                ticket.delete()
                add_notice(
                    req,
                    _("Ticket #%(num)s and all associated data "
                      "removed.",
                      num=ticket.id))
                req.redirect(req.href())

            elif action == 'delete-comment':
                cdate = from_utimestamp(long(req.args.get('cdate')))
                ticket.delete_change(cdate=cdate)
                add_notice(
                    req,
                    _(
                        "The ticket comment %(num)s on ticket "
                        "#%(id)s has been deleted.",
                        num=cnum,
                        id=ticket.id))
                req.redirect(req.href.ticket(id))

        tm = TicketModule(self.env)
        data = tm._prepare_data(req, ticket)
        tm._insert_ticket_data(req, ticket, data,
                               get_reporter_id(req, 'author'), {})
        data.update(action=action, cdate=None)

        if action == 'delete-comment':
            data['cdate'] = req.args.get('cdate')
            cdate = from_utimestamp(long(data['cdate']))
            for change in data['changes']:
                if change.get('date') == cdate:
                    data['change'] = change
                    data['cnum'] = change.get('cnum')
                    break
            else:
                raise TracError(_("Comment %(num)s not found", num=cnum))
        elif action == 'delete':
            attachments = Attachment.select(self.env, ticket.realm, ticket.id)
            data.update(attachments=list(attachments))

        add_stylesheet(req, 'common/css/ticket.css')
        return 'ticket_delete.html', data
Exemple #3
0
    def process_request(self, req):
        id = int(req.args.get('id'))
        req.perm('ticket', id).require('TICKET_ADMIN')
        ticket = Ticket(self.env, id)
        action = req.args['action']
        cnum = req.args.get('cnum')
        if req.method == 'POST':
            if 'cancel' in req.args:
                href = req.href.ticket(id)
                if action == 'delete-comment':
                    href += '#comment:%s' % cnum
                req.redirect(href)

            if action == 'delete':
                ticket.delete()
                add_notice(req, _('The ticket #%(id)s has been deleted.',
                                  id=ticket.id))
                req.redirect(req.href())

            elif action == 'delete-comment':
                cdate = from_utimestamp(long(req.args.get('cdate')))
                ticket.delete_change(cdate=cdate)
                add_notice(req, _('The ticket comment %(num)s on ticket '
                                  '#%(id)s has been deleted.',
                                  num=cnum, id=ticket.id))
                req.redirect(req.href.ticket(id))

        tm = TicketModule(self.env)
        data = tm._prepare_data(req, ticket)
        tm._insert_ticket_data(req, ticket, data,
                               get_reporter_id(req, 'author'), {})
        data.update(action=action, cdate=None)

        if action == 'delete-comment':
            data['cdate'] = req.args.get('cdate')
            cdate = from_utimestamp(long(data['cdate']))
            for change in data['changes']:
                if change.get('date') == cdate:
                    data['change'] = change
                    data['cnum'] = change.get('cnum')
                    break
            else:
                raise TracError(_('Comment %(num)s not found', num=cnum))
        elif action == 'delete':
            attachments = Attachment.select(self.env, ticket.realm, ticket.id)
            data.update(attachments=list(attachments))

        add_stylesheet(req, 'common/css/ticket.css')
        return 'ticket_delete.html', data, None
Exemple #4
0
    def process_request(self, req):
        id = int(req.args.get('id'))
        req.perm('ticket', id).require('TICKET_ADMIN')
        ticket = Ticket(self.env, id)
        action = req.args['action']
        if req.method == 'POST':
            if 'cancel' in req.args:
                href = req.href.ticket(id)
                if action == 'delete-comment':
                    href += '#comment:%s' % req.args.get('cnum')
                req.redirect(href)

            if action == 'delete':
                ticket.delete()
                add_notice(
                    req, _('The ticket #%(id)s has been deleted.',
                           id=ticket.id))
                req.redirect(req.href())

            elif action == 'delete-comment':
                cnum = int(req.args.get('cnum'))
                ticket.delete_change(cnum)
                add_notice(
                    req,
                    _(
                        'The ticket comment %(num)s on ticket '
                        '#%(id)s has been deleted.',
                        num=cnum,
                        id=ticket.id))
                req.redirect(req.href.ticket(id))

        tm = TicketModule(self.env)
        data = tm._prepare_data(req, ticket)
        tm._insert_ticket_data(req, ticket, data,
                               get_reporter_id(req, 'author'), {})
        data.update(action=action, del_cnum=None)

        if action == 'delete-comment':
            cnum = int(req.args.get('cnum'))
            data['del_cnum'] = cnum
            for change in data['changes']:
                if change.get('cnum') == cnum:
                    data['change'] = change
                    break
            else:
                raise TracError(_('Comment %(num)s not found', num=cnum))

        add_stylesheet(req, 'common/css/ticket.css')
        return 'ticket_delete.html', data, None