示例#1
0
def project_new():
    project = Project()
    form = ProjectForm(request.form, project)
    if form.validate_on_submit():
        if Counter.objects(id_for="project").count() == 0:
            counter = Counter("project")
            counter.save()
        else:
            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)
示例#2
0
文件: views.py 项目: ljb-2000/neobug
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)
示例#3
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():
        if Counter.objects(id_for="issue").count() == 0:
            counter = Counter("issue")
            counter.save()
        else:
            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)
示例#4
0
文件: views.py 项目: ljb-2000/neobug
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)
示例#5
0
文件: views.py 项目: ljb-2000/neobug
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)
示例#6
0
文件: views.py 项目: ljb-2000/neobug
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)