Exemplo n.º 1
0
def reply(*args):
    '''Reply to comment.

    Call $EDITOR to write the comment and add the past comment, quoted.

    Example:
    >>> reply  # reply to latest
    >>> reply 1234  # reply to specific comment
    '''
    assert_current()

    if not args:
        event = CURRENT_CASE.events[-1]
    else:
        event_id = args[0]
        all_events = {
            e.id: e for e in CURRENT_CASE.events
        }
        event = all_events[int(event_id)]

    assert event.comment, 'Empty event'
    header = '\n'.join(
        '> {}'.format(line)
        for line in event.comment.splitlines()
    ) + '\n\n'
    with editor.writing(header) as text:
        editor.abort_if_empty(text)
        params = text.get_params_for_comment()
        CURRENT_CASE.edit(**params)
Exemplo n.º 2
0
def new():
    '''Create a new ticket.

    $EDITOR will be opened and used to edit the case. The case
    template has an "header" in .yaml format. "Title", "Project",
    "Area", "Files", etc. are all available fields.
    The body of the ticket is separated by "---".

    Example:
    >>> new
    '''

    tmpl = Template('''Title: <title>
Project: <project>
# Area: <area>
# Assign to: {{ user.fullname }}
# Priority: Need to fix
# Parent: <id>
# Milestone: Infrastructure and Internal Errors
# Tags: <list>

---

<Insert description here>

''')  # noqa

    header = tmpl.generate(user=CURRENT_USER).decode('utf-8')
    with editor.writing(header=header) as text:
        editor.abort_if_empty(text)
        params = text.get_params_for_new()
        FBCase.new(**params)
Exemplo n.º 3
0
def comment():
    '''Add a comment to the current ticket.

    Call $EDITOR to write the comment.

    Example:
    >>> comment
    '''
    assert_current()
    with editor.writing() as text:
        editor.abort_if_empty(text)
        params = text.get_params_for_comment()
        CURRENT_CASE.edit(**params)