Ejemplo n.º 1
0
    def post_process_request(self, req, template, data, content_type):
        if template is not None:
            if req.path_info.startswith('/ticket/'):
                # In case of an invalid ticket, the data is invalid
                if not data:
                    return template, data, content_type
                tkt = data['ticket']
                links = TicketLinks(self.env, tkt)

                for i in links.blocked_by:
                    if Ticket(self.env, i)['status'] != 'closed':
                        add_script(req, 'mastertickets/js/disable_resolve.js')
                        break

                # Add link to depgraph if needed.
                if links:
                    add_ctxtnav(req, 'Depgraph',
                                req.href.depgraph('ticket', tkt.id))

                for change in data.get('changes', {}):
                    if 'fields' not in change:
                        continue
                    for field, field_data in change['fields'].iteritems():
                        if field in self.fields:
                            if field_data['new'].strip():
                                new = to_int_set(field_data['new'])
                            else:
                                new = set()
                            if field_data['old'].strip():
                                old = to_int_set(field_data['old'])
                            else:
                                old = set()
                            add = new - old
                            sub = old - new
                            elms = html()
                            if add:
                                elms.append(
                                    html.em(u', '.join(
                                        unicode(n) for n in sorted(add))))
                                elms.append(u' added')
                            if add and sub:
                                elms.append(u'; ')
                            if sub:
                                elms.append(
                                    html.em(u', '.join(
                                        unicode(n) for n in sorted(sub))))
                                elms.append(u' removed')
                            field_data['rendered'] = elms

            # Add a link to generate a dependency graph for all the tickets
            # in the milestone
            if req.path_info.startswith('/milestone/'):
                if not data:
                    return template, data, content_type
                milestone = data['milestone']
                add_ctxtnav(req, 'Depgraph',
                            req.href.depgraph('milestone', milestone.name))

        return template, data, content_type
Ejemplo n.º 2
0
    def post_process_request(self,
                             req,
                             template,
                             data,
                             content_type,
                             method=None):
        if req.path_info.startswith('/ticket/'):
            # In case of an invalid ticket, the data is invalid
            if not data:
                return template, data, content_type, method
            tkt = data['ticket']
            with self.env.db_query as db:
                links = CrashDumpTicketLinks(self.env, tkt, db=db)

                for change in data.get('changes', {}):
                    if not change.has_key('fields'):
                        continue
                    for field, field_data in change['fields'].iteritems():
                        if field in self.crashdump_link_fields:
                            if field_data['new'].strip():
                                new = set([
                                    CrashDumpSystem.get_crash_id(n)
                                    for n in field_data['new'].split(',')
                                ])
                            else:
                                new = set()
                            if field_data['old'].strip():
                                old = set([
                                    CrashDumpSystem.get_crash_id(n)
                                    for n in field_data['old'].split(',')
                                ])
                            else:
                                old = set()
                            add = new - old
                            sub = old - new
                            elms = tag()
                            if add:
                                elms.append(
                                    tag.em(u', '.join(
                                        [unicode(n) for n in sorted(add)])))
                                elms.append(u' added')
                            if add and sub:
                                elms.append(u'; ')
                            if sub:
                                elms.append(
                                    tag.em(u', '.join(
                                        [unicode(n) for n in sorted(sub)])))
                                elms.append(u' removed')
                            field_data['rendered'] = elms
                            links.crashes = new

        return template, data, content_type, method
Ejemplo n.º 3
0
def render_tag_changes(old_tags, new_tags):
    old_tags = split_into_tags(old_tags or '')
    new_tags = split_into_tags(new_tags or '')
    added = sorted(new_tags - old_tags)
    added = added and \
            tagn_("%(tags)s added", "%(tags)s added",
                  len(added), tags=builder.em(', '.join(added)))
    removed = sorted(old_tags - new_tags)
    removed = removed and \
              tagn_("%(tags)s removed", "%(tags)s removed",
                    len(removed), tags=builder.em(', '.join(removed)))
    # TRANSLATOR: How to delimit added and removed tags.
    delim = added and removed and _("; ")
    return builder(builder.strong(_("Tags")), ' ', added, delim, removed)
Ejemplo n.º 4
0
 def render_timeline_event(self, context, field, event):
     resource = event[3][0]
     if field == 'url':
         return get_resource_url(self.env, resource, context.href)
     elif field == 'title':
         name = builder.em(get_resource_name(self.env, resource))
         return tag_("Tag change on %(resource)s", resource=name)
     elif field == 'description':
         return render_tag_changes(event[3][1], event[3][2])
Ejemplo n.º 5
0
    def render_timeline_event(self, context, field, event):
        # Decompose event data.
        id = event[3]

        # Return appropriate content.
        resource = Resource('downloads', id)
        if field == 'url':
            if 'DOWNLOADS_VIEW' in context.req.perm(resource):
                return get_resource_url(self.env, resource, context.req.href)
            else:
                return '#'
        elif field == 'title':
            return html('New download ',
                        html.em(get_resource_name(self.env, resource)),
                        ' created')
        elif field == 'description':
            return get_resource_description(self.env, resource, 'summary')
Ejemplo n.º 6
0
    def expand_macro(self, formatter, name, content):
        attachment_type = ""
        if content:
            argv = [arg.strip() for arg in content.split(',')]
            if len(argv) > 0:
                attachment_type = argv[0]

        with self.env.db_transaction as db:
            if attachment_type is None or attachment_type == "":
                attachments = db("""
                   SELECT type,id,filename,size,time,
                    description,author,ipnr FROM attachment
                   """)
            else:
                attachments = db(
                    """
                   SELECT type,id,filename,size,time,
                    description,author,ipnr FROM attachment
                   WHERE type=%s
                   """, (attachment_type, ))

        formatters = {
            'wiki': formatter.href.wiki,
            'ticket': formatter.href.ticket,
            'milestone': formatter.href.milestone,
        }
        types = {
            'wiki': '',
            'ticket': 'ticket ',
            'milestone': 'milestone ',
        }

        return html.ul([
            html.li(
                html.a(filename,
                       href=formatter.href.attachment(type + '/' + id + '/' +
                                                      filename)), " (",
                html.span(pretty_size(size), title=size), ") - added by ",
                html.em(author), " to ",
                html.a(types[type] + ' ' + id, href=formatters[type](id)), ' ')
            for type, id, filename, size, time, description, author, ipnr in
            attachments
            if self._has_perm(type, id, filename, formatter.context)
        ])
Ejemplo n.º 7
0
    def expand_macro(self, formatter, name, content):
        attachment_type = ""
        if content:
            argv = [arg.strip() for arg in content.split(',')]
            if len(argv) > 0:
                attachment_type = argv[0]

        with self.env.db_transaction as db:
            if attachment_type is None or attachment_type == "":
                attachments = db("""
                   SELECT type,id,filename,size,time,
                    description,author,ipnr FROM attachment
                   """)
            else:
                attachments = db("""
                   SELECT type,id,filename,size,time,
                    description,author,ipnr FROM attachment
                   WHERE type=%s
                   """, (attachment_type, ))

        formatters = {
            'wiki': formatter.href.wiki,
            'ticket': formatter.href.ticket,
            'milestone': formatter.href.milestone,
        }
        types = {
            'wiki': '',
            'ticket': 'ticket ',
            'milestone': 'milestone ',
        }

        return html.ul(
            [html.li(
                html.a(filename, href=formatter.href.attachment(type + '/' +
                                                                id + '/' +
                                                                filename)),
                " (", html.span(pretty_size(size), title=size), ") - added by ",
                html.em(author), " to ",
                html.a(types[type] + ' ' + id, href=formatters[type](id)), ' ')
             for type, id, filename, size, time, description, author, ipnr
             in attachments
             if self._has_perm(type, id, filename, formatter.context)])
Ejemplo n.º 8
0
    def post_process_request(self, req, template, data, content_type):
        if template is not None:
            if req.path_info.startswith('/ticket/'):
                # In case of an invalid ticket, the data is invalid
                if not data:
                    return template, data, content_type
                tkt = data['ticket']
                links = TicketLinks(self.env, tkt)

                for i in links.blocked_by:
                    if Ticket(self.env, i)['status'] != 'closed':
                        add_script(req, 'mastertickets/js/disable_resolve.js')
                        break

                # Add link to depgraph if needed.
                if links:
                    add_ctxtnav(req, 'Depgraph',
                                req.href.depgraph('ticket', tkt.id))

                for change in data.get('changes', {}):
                    if 'fields' not in change:
                        continue
                    for field, field_data in change['fields'].iteritems():
                        if field in self.fields:
                            if field_data['new'].strip():
                                new = to_int_set(field_data['new'])
                            else:
                                new = set()
                            if field_data['old'].strip():
                                old = to_int_set(field_data['old'])
                            else:
                                old = set()
                            add = new - old
                            sub = old - new
                            elms = html()
                            if add:
                                elms.append(
                                    html.em(u', '.join(unicode(n)
                                                       for n in sorted(add)))
                                )
                                elms.append(u' added')
                            if add and sub:
                                elms.append(u'; ')
                            if sub:
                                elms.append(
                                    html.em(u', '.join(unicode(n)
                                                       for n in sorted(sub)))
                                )
                                elms.append(u' removed')
                            field_data['rendered'] = elms

            # Add a link to generate a dependency graph for all the tickets
            # in the milestone
            if req.path_info.startswith('/milestone/'):
                if not data:
                    return template, data, content_type
                milestone = data['milestone']
                add_ctxtnav(req, 'Depgraph',
                            req.href.depgraph('milestone', milestone.name))

        return template, data, content_type