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]
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)
def test_save(self): issue = Issue(self.tracker) issue.title = 'test title' issue.save() # Get the path to the issue and assert that it's there. path = self.tracker.get_issue_path(issue.id) assert os.path.exists(path) # Does the issue initialized from file match the original? issue_clone = Issue(self.tracker, issue.id) assert issue_clone.fields == issue.fields
def test_save(self): issue = Issue(self.tracker) issue.title = "test title" issue.save() # Get the path to the issue and assert that it's there. path = self.tracker.get_issue_path(issue.id) assert os.path.exists(path) # Does the issue initialized from file match the original? issue_clone = Issue(self.tracker, issue.id) assert issue_clone.fields == issue.fields
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
def test_timestamps(self): issue = Issue(self.tracker) issue.title = 'test title' issue.save() assert issue.created == issue.updated
def test_setattr(self): issue = Issue(self.tracker) issue.title = 'test title' # Does the __setattr__ method work? # i.e.: setting issue.title shoud set issue.fields['title'] assert issue.title == issue.fields['title']
def test_timestamps(self): issue = Issue(self.tracker) issue.title = "test title" issue.save() assert issue.created == issue.updated
def test_setattr(self): issue = Issue(self.tracker) issue.title = "test title" # Does the __setattr__ method work? # i.e.: setting issue.title shoud set issue.fields['title'] assert issue.title == issue.fields["title"]