Exemplo n.º 1
0
def project_new():
    project = Project()
    form = ProjectForm(request.form, project)
    if form.validate_on_submit():
        counter = Counter.objects(id_for="project")[0]
        counter.set_next_id()
        counter.save()
        form.populate_obj(project)
        project.number = counter.number
        project.save()
        return redirect('/projects/')
    return render_template('projects_create.html', project=project, form=form)
Exemplo n.º 2
0
def project_new():
    project = Project()
    form = ProjectForm(request.form, project)
    if form.validate_on_submit():
        counter = Counter.objects(id_for="project")[0]
        counter.set_next_id()
        counter.save()
        form.populate_obj(project)
        project.number = counter.number
        project.save()
        return redirect('/projects/')
    return render_template('projects_create.html',
                           project=project,
                           form=form)
Exemplo n.º 3
0
def projects_childissue(num):
    base_issue = Issue.objects(number=num)[0]
    project = Project.objects(id=base_issue.project_id)[0]
    issue = Issue()
    form = IssueForm(request.form, issue)
    if form.validate_on_submit():
        form.populate_obj(issue)
        counter = Counter.objects(id_for="issue")[0]
        counter.set_next_id()
        counter.save()
        issue.number = counter.number
        issue.author = session['user_id']
        issue.base_issue = num
        issue.save()
        return redirect('projects/issues/' + str(num))
    return render_template('projects_childissue.html',
                           project=project,
                           base_issue=base_issue,
                           issue=issue,
                           form=form)
Exemplo n.º 4
0
def project_show(num):
    project = Project.objects(number=num)[0]
    issues = Issue.objects(project_id=str(project.id))
    for issue in issues:
        issue.comments_count = len(issue.comments)
    issue = Issue()
    form = IssueForm(request.form, issue)
    if form.validate_on_submit():
        counter = Counter.objects(id_for="issue")[0]
        counter.set_next_id()
        counter.save()
        form.populate_obj(issue)
        issue.number = counter.number
        issue.author = session['user_id']
        issue.save()
        return redirect('/projects/' + str(project.number))
    return render_template('projects_show.html',
                           project=project,
                           issues=issues,
                           form=form)
Exemplo n.º 5
0
def projects_childissue(num):
    base_issue = Issue.objects(number=num)[0]
    project = Project.objects(id=base_issue.project_id)[0]
    issue = Issue()
    form = IssueForm(request.form, issue)
    if form.validate_on_submit():
        form.populate_obj(issue)
        counter = Counter.objects(id_for="issue")[0]
        counter.set_next_id()
        counter.save()
        issue.number = counter.number
        issue.author = session['user_id']
        issue.base_issue = num
        issue.save()
        return redirect('projects/issues/' + str(num))
    return render_template('projects_childissue.html',
                            project=project,
                            base_issue=base_issue,
                            issue=issue,
                            form=form)
Exemplo n.º 6
0
def project_show(num):
    project = Project.objects(number=num)[0]
    issues = Issue.objects(project_id=str(project.id))
    for issue in issues:
        issue.comments_count = len(issue.comments)
    issue = Issue()
    form = IssueForm(request.form, issue)
    if form.validate_on_submit():
        counter = Counter.objects(id_for="issue")[0]
        counter.set_next_id()
        counter.save()
        form.populate_obj(issue)
        issue.number = counter.number
        issue.author = session['user_id']
        issue.save()
        return redirect('/projects/' + str(project.number))
    return render_template('projects_show.html',
                           project=project,
                           issues=issues,
                           form=form)
Exemplo n.º 7
0
Arquivo: tests.py Projeto: kosc/neobug
def add_issue(app, project_num, title, body, csrf_token, project_id):
    return app.post('/projects/'+str(project_num), data=dict(
        project_id=project_id,
        status='New',
        category='Bug',
        title=title,
        body=body,
        csrf_token=csrf_token
    ), follow_redirects=True)


def get_csrf_token(app, token_for):
    rv = app.get('/' + token_for)
    html = lxml.html.document_fromstring(rv.data)
    return html.get_element_by_id('csrf_token').value

if __name__ == '__main__':
    if len(User.objects(username='******')) == 0:
        """We need to add test user only for first test run"""
        app = neobug.test_client()
        token = get_csrf_token(app, 'register')
        register(app, 'test', '*****@*****.**', 'proverka', token)
        token = get_csrf_token(app, 'projects/new')
        add_project(app, 'Test project', 'Test project description', token)
        project = Project.objects(name='Test project')[0]
        project_num = project.number
        project_id = project.id
        token = get_csrf_token(app, 'projects/' + str(project_num))
        add_issue(app, project_num, 'Test issue', 'Test issue body', token, project_id)
    unittest.main()