コード例 #1
0
ファイル: cli.py プロジェクト: ndreynolds/hopper
def new(args):
    """Create a new issue."""
    t = args['tracker']
    i = Issue(t)
    config = UserConfig()
    # set the author info
    i.author['name'] = config.user['name']
    i.author['email'] = config.user['email']

    # no editor for inline calls
    if args['message'] is not None:
        i.title = args['message']
        i.content = '.'
    else:
        # get the user's editor
        editor = args['editor'] if args['editor'] else config.core['editor']
        # the Template object opens templates in the editor and parses them.
        template = IssueTemplate('new.hpr')
        path = template.open(editor)
        fields = template.parse(path)
        i.title = fields['title']
        i.content = fields['content']

    if i.save():
        # commit the changes
        if config.core['autocommit']:
            t.autocommit(message='Created a new issue %s' % i.id[:6],
                         author=config.user)
        print 'Created issue %s' % i.id[:6]
コード例 #2
0
ファイル: cli.py プロジェクト: ndreynolds/hopper
def new(args):
    """Create a new issue."""
    t = args['tracker']
    i = Issue(t)
    config = UserConfig()
    # set the author info
    i.author['name'] = config.user['name']
    i.author['email'] = config.user['email']

    # no editor for inline calls
    if args['message'] is not None:
        i.title = args['message']
        i.content = '.'
    else:
        # get the user's editor
        editor = args['editor'] if args['editor'] else config.core['editor']
        # the Template object opens templates in the editor and parses them.
        template = IssueTemplate('new.hpr')
        path = template.open(editor)
        fields = template.parse(path)
        i.title = fields['title']
        i.content = fields['content']

    if i.save():
        # commit the changes
        if config.core['autocommit']:
            t.autocommit(message='Created a new issue %s' % i.id[:6],
                         author=config.user)
        print 'Created issue %s' % i.id[:6]
コード例 #3
0
def new():
    """Render the new issue view."""
    tracker, config = setup()
    header = 'Create a new issue'
    if request.method == 'POST':
        issue = Issue(tracker)
        issue.content = request.form['content']
        issue.title = request.form['title']
        labels = request.form['labels']
        if labels:
            issue.labels = labels.split(',')
        else:
            issue.labels = []
        issue.author['name'] = config.user['name']
        issue.author['email'] = config.user['email']
        if issue.save():
            tracker.autocommit(message='Created a new issue %s' % issue.id[:6], 
                               author=config.user)
            return redirect(url_for('issues.view', id=issue.id)) 
        else:
            flash('There was an error saving your issue.')
            return render_template('new.html', selected='issues', 
                                   header=header, tracker=tracker)
    else:
        return render_template('new.html', selected='issues', 
                               header=header, tracker=tracker)
コード例 #4
0
 def test_insert(self):
     '''Tests the `insert` method'''
     db = Database(self.env.tracker)
     # make and insert the issue
     issue1 = Issue(self.env.tracker)
     issue1.content = 'test'
     issue1.title = 'Test'
     issue1.save()
     db.insert(issue1)
     rows = db.select().execute()
     issue2 = [Issue(self.env.tracker, r['id']) for r in rows][0]
     # make sure the issues are equal which triggers the __eq__ method.
     assert issue1 == issue2
コード例 #5
0
ファイル: test_database.py プロジェクト: ndreynolds/hopper
 def test_insert(self):
     '''Tests the `insert` method'''
     db = Database(self.env.tracker)
     # make and insert the issue
     issue1 = Issue(self.env.tracker)
     issue1.content = 'test'
     issue1.title = 'Test'
     issue1.save()
     db.insert(issue1)
     rows = db.select().execute()
     issue2 = [Issue(self.env.tracker, r['id']) for r in rows][0]
     # make sure the issues are equal which triggers the __eq__ method.
     assert issue1 == issue2