Ejemplo n.º 1
0
def view(id):
    """
    Render the issue view to display information about a single issue.

    :param id: id of the issue to view.
    """
    tracker, config = setup()
    issue = tracker.issue(id)
    if request.method == 'POST':
        comment = Comment(issue)
        comment.content = request.form['content']
        comment.author['name'] = config.user['name']
        comment.author['email'] = config.user['email']
        comment.save()
        if issue.save(): # ping the issue (updated = now)
            tracker.autocommit(message='Commented on issue %s/%s' % \
                                        (issue.id[:6], comment.id[:6]),
                               author=config.user)
        else:
            flash('There was an error saving your comment.')
        return redirect(url_for('issues.view', id=issue.id))
    else:
        issue.updated = relative_time(issue.updated)
        issue.created = relative_time(issue.created)
        issue.content = markdown_to_html(issue.content)
        comments = issue.comments()
        header = 'Viewing Issue &nbsp;<span class="fancy-monospace">%s</span>' \
                % issue.id[:6]
        if comments:
            map_attr(comments, 'timestamp', relative_time)
            map_attr(comments, 'content', markdown_to_html)
        return render_template('issue.html', issue=issue,
                               comments=comments, selected='issues',
                               config=config, header=header, tracker=tracker)
Ejemplo n.º 2
0
def comment(args):
    """Comment on an issue."""
    t = args['tracker']
    i = t.issue(args['issue'])
    if not i:
        print 'No such issue'
        return
    c = Comment(i)
    config = UserConfig()
    # set the author info
    c.author['name'] = config.user['name']
    c.author['email'] = config.user['email']
    editor = args['editor'] if args['editor'] else config.core['editor']
    template = Template('comment.hpr')
    path = template.open(editor)
    fields = template.parse(path)
    c.content = fields['content']
    if c.save() and i.save():
        # commit the changes
        if config.core['autocommit']:
            t.autocommit(message='Commented on issue %s' % i.id[:6],
                         author=config.user)
        print 'Posted comment %s on issue %s' % (c.id[:3], i.id[:6])
Ejemplo n.º 3
0
def comment(args):
    """Comment on an issue."""
    t = args['tracker']
    i = t.issue(args['issue'])
    if not i:
        print 'No such issue'
        return
    c = Comment(i)
    config = UserConfig()
    # set the author info
    c.author['name'] = config.user['name']
    c.author['email'] = config.user['email']
    editor = args['editor'] if args['editor'] else config.core['editor']
    template = Template('comment.hpr')
    path = template.open(editor)
    fields = template.parse(path)
    c.content = fields['content']
    if c.save() and i.save():
        # commit the changes
        if config.core['autocommit']:
            t.autocommit(message='Commented on issue %s' % i.id[:6],
                         author=config.user)
        print 'Posted comment %s on issue %s' % (c.id[:3], i.id[:6])