예제 #1
0
파일: views.py 프로젝트: jpihl/plotato
def create_plot(request, project_id):
    """ Create a new Plot.

    """
    project = get_object_or_404(Project, pk=project_id)
    form = PlotForm(request.POST or None)
    if form.is_valid():
        new_plot = form.save(commit=False) # returns unsaved instance
        new_plot.project = project
        new_plot.save() # real save to DB.
        messages.add_message(request, messages.SUCCESS, 'The plot has been successfully created.')
        return redirect(details_project, project_id=project_id)
    return render_to_response('form.html',
                              {'form'    : form,
                               'project' : project},
                              context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: jpihl/plotato
def edit_plot(request, plot_id):
    """ Edit a plot.

    """
    plot = get_object_or_404(Plot, pk=plot_id)
    if request.method == "POST":
        form = PlotForm(request.POST, instance=plot)
    else:
        form = PlotForm(instance=plot)
    if form.is_valid(): # All validation rules pass
        form.save()
        messages.add_message(request, messages.INFO, 'The plot has been successfully modified.')
        return redirect(details_plot, plot_id=plot_id)

    return render_to_response('form.html',
                              {'form'    : form,
                               'project' : plot.project},
                              context_instance=RequestContext(request))
예제 #3
0
파일: views.py 프로젝트: jpihl/plotato
def create_plot(request, project_id):
    """ Create a new Plot.

    """
    project = get_object_or_404(Project, pk=project_id)
    form = PlotForm(request.POST or None)
    if form.is_valid():
        new_plot = form.save(commit=False)  # returns unsaved instance
        new_plot.project = project
        new_plot.save()  # real save to DB.
        messages.add_message(request, messages.SUCCESS,
                             'The plot has been successfully created.')
        return redirect(details_project, project_id=project_id)
    return render_to_response('form.html', {
        'form': form,
        'project': project
    },
                              context_instance=RequestContext(request))
예제 #4
0
파일: views.py 프로젝트: jpihl/plotato
def edit_plot(request, plot_id):
    """ Edit a plot.

    """
    plot = get_object_or_404(Plot, pk=plot_id)
    if request.method == "POST":
        form = PlotForm(request.POST, instance=plot)
    else:
        form = PlotForm(instance=plot)
    if form.is_valid():  # All validation rules pass
        form.save()
        messages.add_message(request, messages.INFO,
                             'The plot has been successfully modified.')
        return redirect(details_plot, plot_id=plot_id)

    return render_to_response('form.html', {
        'form': form,
        'project': plot.project
    },
                              context_instance=RequestContext(request))
예제 #5
0
파일: views.py 프로젝트: drmatthews/plot
def plot(request, conn=None, **kwargs):
    annotation_id = request.session['annotation_id']
    annotation = conn.getObject("Annotation",annotation_id)
    fpath = download_annotation(annotation)
    header_row = request.session['header']
    sheet = request.session['sheet']
    fname, fextension = os.path.splitext(fpath)
    cols,message,csv_path = parse_annotation(fpath,fextension,header_row,sheet)
    if request.POST:
        form = PlotForm(options=cols,data=request.POST.copy())
        if form.is_valid():
            title = annotation.getFile().getName()
            if form.cleaned_data['title']:
                title = form.cleaned_data['title']
            x = form.cleaned_data['x_data']
            y = form.cleaned_data['y_data']
            print 'first y',y
            xLabel = x
            if form.cleaned_data['x_Label']:
                xLabel = form.cleaned_data['x_Label']
            yLabel = y
            if form.cleaned_data['y_Label']:
                yLabel = form.cleaned_data['y_Label']
            #tick_size = form.cleaned_data['tick_size']
            plot_mode = form.cleaned_data['plot_mode']
            xdata = [floor(xd) for xd in get_column(fpath,fextension,x,header_row,sheet)]
            xmin = min(xdata)
            xmax = max(xdata)
            ydata = get_column(fpath,fextension,y,header_row,sheet)
            #graph = flot_data(xdata,ydata)
            #d3data = d3_data(xdata,ydata)
            rv = {'message': message,\
                  'title': title, 'x' : x, 'y' : y,\
                  'xLabel': xLabel, 'yLabel': yLabel,\
                  'xdata': xdata, 'ydata': ydata,\
                  'num_series': len(ydata),'plot_mode':plot_mode,\
                  'xmin': xmin, 'xmax': xmax,'csv_path': csv_path}
            data = json.dumps(rv)
            return HttpResponse(data, mimetype='application/json')