示例#1
0
def new(request):
    p = Project(user=request.user)
    p.projectname = 'New Project ' + strftime("%Y-%m-%d %H%M%S")
    p.save()
    proj_form = ProjectForm({
        'projectname': p.projectname,
        'description': p.description,
        'version': p.version,
        'shared': p.shared,
    })
    file_form = ProjectFileForm({'filename': p.filename})
    return render_to_response('project_detail.html', {
        'project': p,
        'project_form': proj_form,
        'file_form': file_form
    },
                              context_instance=RequestContext(request))
示例#2
0
def new(request):
    p = Project(user=request.user)
    p.projectname   = 'New Project '+strftime("%Y-%m-%d %H%M%S")
    p.save()
    proj_form = ProjectForm({
        'projectname': p.projectname,
        'description': p.description,
        'version':     p.version,
        'shared':      p.shared,
    })
    file_form = ProjectFileForm({
        'filename':    p.filename
    })
    return render_to_response('project_detail.html', {
                              'project':      p, 
                              'project_form': proj_form,
                              'file_form':    file_form},
                              context_instance=RequestContext(request))
示例#3
0
def add(request):
    ''' upload a file and add it to the project database
    '''
    if request.method == 'POST':
        if 'myfile' in request.FILES:
            file = request.FILES['myfile']
            filename = file.name
            if len(filename) > 0:
                p = Project(user=request.user)
                p.projectname = 'Added ' + filename + strftime(
                    " %Y-%m-%d %H%M%S")
                p.save()

                dir = 'projects/' + request.user.username
                if not os.path.isdir(dir):
                    os.makedirs(dir)
                file_content = ContentFile(file.read())
                p.filename.save(filename, file_content)

                return HttpResponseRedirect('/projects/' + str(p.id))

    return render_to_response('add_project.html',
                              context_instance=RequestContext(request))
示例#4
0
def add(request):
    ''' upload a file and add it to the project database
    '''
    if request.method=='POST':
        if 'myfile' in request.FILES:
            file = request.FILES['myfile']
            filename = file.name
            if len(filename) > 0:
                p = Project(user=request.user)
                p.projectname   = 'Added ' + filename + strftime(" %Y-%m-%d %H%M%S")
                p.save()
            
                dir = 'projects/'+request.user.username
                if not os.path.isdir(dir):
                    os.makedirs(dir)
                file_content = ContentFile(file.read())
                p.filename.save(filename, file_content)
                
                return HttpResponseRedirect('/projects/'+str(p.id))


    return render_to_response('add_project.html', 
                              context_instance=RequestContext(request))