Пример #1
0
def new_issue_create(request):
    try:
        p = Project.objects.get(key=request.POST['project'])
    except Project.DoesNotExist:
        raise Http404('Unable to find project with key ' + request.POST['project'])

    try:
        version_string = request.POST['version']
        print 'Version string:', version_string
        if (is_empty(version_string) or version_string == 'Future'):
            v = None
        else:
            v = p.version_set.get(version_number=version_string)
    except Version.DoesNotExist:
        raise Http404

    i = Issue()
    i.project = p
    i.state = 'o'
    i.name = request.POST['issue_name']
    i.description = request.POST['issue_description']

    if v:
        v.issuesAsFix.add(i)
        v.save()

    i.save()

    return redirect('/squash/issue/' + p.key + '/' + str(i.issue_number))
Пример #2
0
def create_project(request):
    proj_key = request.POST['project_key']
    existing_project = Project.objects.filter(key=proj_key)
    if (len(existing_project) > 0):
        return render_to_response('squash/create_project.html',
            {'error_message': 'A project with that key already exists'}, context_instance=RequestContext(request))

    proj_name = request.POST['project_name']

    if (is_empty(proj_key) or is_empty(proj_name)):
        return render_to_response('squash/create_project.html',
            {'error_message': 'Key or Name empty, both must be provided'}, context_instance=RequestContext(request))

    proj = Project()
    proj.key = proj_key
    proj.name = proj_name
    proj.save()

    return redirect('/squash/project/' + proj.key)