def list_(args): """List the tracker's issues (filtered by criteria)""" t = args['tracker'] c = UserConfig() query = Query(t) args.setdefault('order', 'updated') args.setdefault('status', 'open') issues = query.select(order_by=args['order'], status=args['status']) # short mode if args['short']: for i in issues: print '%s %s' % (c.decorate('red', i.id[:6]), i.title) # normal mode else: for i in issues: print '%s %s' % (c.decorate('red', 'issue'), i.id) print '%s %s <%s>' % (c.decorate( 'yellow', 'Author:'), i.author['name'], i.author['email']) print '%s %s' % (c.decorate('yellow', 'Created:'), relative_time(i.created)) if i.updated != i.created: print '%s %s' % (c.decorate( 'yellow', 'Updated:'), relative_time(i.updated)) print '%s %s' % (c.decorate('yellow', 'Status:'), i.status) num_comments = len(i.comments()) if num_comments: print '%d Comments' % num_comments print print ' ' + c.decorate('bold', i.title) print content = wrap(i.content) for line in content.splitlines(): print ' ' + line print
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 <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)
def show(args): """Show an issue.""" t = args['tracker'] c = UserConfig() try: i = t.issue(args['issue']) except AmbiguousReference: print c.decorate('yellow', 'Multiple matches. Try adding another character.') return except BadReference: print c.decorate('red', 'No issue matched that id.') return print '%s %s' % (c.decorate('red', 'issue'), i.id) print '%s %s <%s>' % (c.decorate( 'yellow', 'Author:'), i.author['name'], i.author['email']) print '%s %s' % (c.decorate('yellow', 'Created:'), relative_time( i.created)) if i.updated != i.created: print '%s %s' % (c.decorate('yellow', 'Updated:'), relative_time(i.updated)) print '%s %s' % (c.decorate('yellow', 'Status:'), i.status) print print ' ' + c.decorate('bold', i.title) print content = wrap(i.content) for line in content.splitlines(): print ' ' + line print
def show(args): """Show an issue.""" t = args['tracker'] c = UserConfig() try: i = t.issue(args['issue']) except AmbiguousReference: print c.decorate('yellow', 'Multiple matches. Try adding another character.') return except BadReference: print c.decorate('red', 'No issue matched that id.') return print '%s %s' % (c.decorate('red', 'issue'), i.id) print '%s %s <%s>' % (c.decorate('yellow', 'Author:'), i.author['name'], i.author['email']) print '%s %s' % (c.decorate('yellow', 'Created:'), relative_time(i.created)) if i.updated != i.created: print '%s %s' % (c.decorate('yellow', 'Updated:'), relative_time(i.updated)) print '%s %s' % (c.decorate('yellow', 'Status:'), i.status) print print ' ' + c.decorate('bold', i.title) print content = wrap(i.content) for line in content.splitlines(): print ' ' + line print
def list_(args): """List the tracker's issues (filtered by criteria)""" t = args['tracker'] c = UserConfig() query = Query(t) args.setdefault('order', 'updated') args.setdefault('status', 'open') issues = query.select(order_by=args['order'], status=args['status']) # short mode if args['short']: for i in issues: print '%s %s' % (c.decorate('red', i.id[:6]), i.title) # normal mode else: for i in issues: print '%s %s' % (c.decorate('red', 'issue'), i.id) print '%s %s <%s>' % (c.decorate('yellow', 'Author:'), i.author['name'], i.author['email']) print '%s %s' % (c.decorate('yellow', 'Created:'), relative_time(i.created)) if i.updated != i.created: print '%s %s' % (c.decorate('yellow', 'Updated:'), relative_time(i.updated)) print '%s %s' % (c.decorate('yellow', 'Status:'), i.status) num_comments = len(i.comments()) if num_comments: print '%d Comments' % num_comments print print ' ' + c.decorate('bold', i.title) print content = wrap(i.content) for line in content.splitlines(): print ' ' + line print
def main(): tracker, config = setup() # get the offset param (intended for javascript requests) offset = int(request.args.get('offset', 0)) # Get up to 20 commits starting at whatever offset. raw_history = tracker.history(n=offset+20, offset=offset) # Don't want the performance hit of checking how many commits there are. # Instead, we're guessing that there's more if we get a full 20 in the # first batch. more_history = False if len(raw_history) < 20 else True # get the unique set of authors (in this history segment) users = set(strip_email(c.author) for c in raw_history) docs = tracker.docs() history = [] for c in raw_history: split = c.author.index('<') name = c.author[:split] email = c.author[(split + 1):-1] time = relative_time(c.commit_time) message, obj = interpret(c.message, tracker) snippet = title = link = button = None if type(obj) is Comment: snippet = cut(obj.content, 190) link = url_for('issues.view', id=obj.issue.id[:6]) + '#comment-' + obj.id[:6] button = obj.issue.id[:6] if type(obj) is Issue: title = obj.title snippet = cut(obj.content, 190) link = url_for('issues.view', id=obj.id[:6]) button = obj.id[:6] history.append({'user': {'name': name, 'email': email}, 'message': message.strip(), 'time': time, 'link': link, 'button': button, 'title': title, 'snippet': snippet } ) # If the request is async, we're all set. if request.is_xhr: return to_json(history) # Otherwise, we have to get some more info. header = 'Recent Activity for %s' % tracker.config.name # Issue counts n_open = tracker.query().count('open') n_closed = tracker.query().count('closed') n_total = n_open + n_closed # Graph percentages # the subtraction is spacing for the CSS. g_open = (float(n_open) / n_total) * 100 - 2 if n_total > 0 else 0 g_closed = (float(n_closed) / n_total) * 100 - 2 if n_total > 0 else 0 g_open = 1 if g_open < 1 else g_open g_closed = 1 if g_closed < 1 else g_closed return render_template('feed.html', history=history, selected='feed', header=header, tracker=tracker, users=users, docs=docs, n_open=n_open, n_closed=n_closed, n_total=n_total, g_open=g_open, g_closed=g_closed, more_history=more_history)
def main(): tracker, config = setup() # get the offset param (intended for javascript requests) offset = int(request.args.get('offset', 0)) # Get up to 20 commits starting at whatever offset. raw_history = tracker.history(n=offset + 20, offset=offset) # Don't want the performance hit of checking how many commits there are. # Instead, we're guessing that there's more if we get a full 20 in the # first batch. more_history = False if len(raw_history) < 20 else True # get the unique set of authors (in this history segment) users = set(strip_email(c.author) for c in raw_history) docs = tracker.docs() history = [] for c in raw_history: split = c.author.index('<') name = c.author[:split] email = c.author[(split + 1):-1] time = relative_time(c.commit_time) message, obj = interpret(c.message, tracker) snippet = title = link = button = None if type(obj) is Comment: snippet = cut(obj.content, 190) link = url_for('issues.view', id=obj.issue.id[:6]) + '#comment-' + obj.id[:6] button = obj.issue.id[:6] if type(obj) is Issue: title = obj.title snippet = cut(obj.content, 190) link = url_for('issues.view', id=obj.id[:6]) button = obj.id[:6] history.append({ 'user': { 'name': name, 'email': email }, 'message': message.strip(), 'time': time, 'link': link, 'button': button, 'title': title, 'snippet': snippet }) # If the request is async, we're all set. if request.is_xhr: return to_json(history) # Otherwise, we have to get some more info. header = 'Recent Activity for %s' % tracker.config.name # Issue counts n_open = tracker.query().count('open') n_closed = tracker.query().count('closed') n_total = n_open + n_closed # Graph percentages # the subtraction is spacing for the CSS. g_open = (float(n_open) / n_total) * 100 - 2 if n_total > 0 else 0 g_closed = (float(n_closed) / n_total) * 100 - 2 if n_total > 0 else 0 g_open = 1 if g_open < 1 else g_open g_closed = 1 if g_closed < 1 else g_closed return render_template('feed.html', history=history, selected='feed', header=header, tracker=tracker, users=users, docs=docs, n_open=n_open, n_closed=n_closed, n_total=n_total, g_open=g_open, g_closed=g_closed, more_history=more_history)