def fragment_add(request, cid, fid): con = get_construct(request.user, cid) if con: f = get_fragment(request.user, fid) if f: con.add_fragment(f) # return HttpResponse('OK') return HttpResponseRedirect('/gibthon/'+cid+'/'+con.name+'/') else: return HttpResponseNotFound() else: return HttpResponseNotFound()
def fragment_viewer(request, cid, fid): if get_construct(request.user, cid): f = get_fragment(request.user, fid) if f: t = loader.get_template('gibson/fragment_viewer.html') c = RequestContext(request, { 'fragment': f, }) return HttpResponse(t.render(c)) else: return HttpResponseNotFound() else: return HttpResponseNotFound()
def fragment_viewer(request, cid, fid): if get_construct(request.user, cid): f = get_fragment(request.user, fid) if f: t = loader.get_template('gibson/fragment_viewer.html') c = RequestContext(request,{ 'fragment':f, }) return HttpResponse(t.render(c)) else: return HttpResponseNotFound() else: return HttpResponseNotFound()
def fragment_add(request, cid): con = get_construct(request.user, cid) if con: fid = request.POST.get('fid') if not fid: return JsonResponse("No fragment id provided", ERROR) f = get_fragment(request.user, fid) pos = request.POST.get('pos', 0) strand = request.POST.get('dir', 1) try: pos = int(pos) except ValueError as e: return JsonResponse('Position must be an integer, not "%s"' % pos, ERROR) try: strand = int(strand) except ValueError as e: return JsonResponse( 'Direction must be an integer, not "%s"' % strand, ERROR) if strand not in [-1, 1]: return JsonResponse('Strand must be 1 or -1, not "%s"' % strand, ERROR) direction = 'f' if strand == -1: direction = 'r' if f: cf = con.add_fragment(f, pos, direction) if cf: return JsonResponse(cf2dict(cf)) else: return JsonResponse( 'Could not add fragment %s to construct %s' % (fid, cid), ERROR) else: if request.is_ajax(): return JsonResponse('Could not find fragment "%s"' % fid, ERROR) return HttpResponseNotFound() else: return HttpResponseNotFound()
def fragment_add(request, cid): con = get_construct(request.user, cid) if con: fid = request.POST.get('fid') if not fid: return JsonResponse("No fragment id provided", ERROR) f = get_fragment(request.user, fid) pos = request.POST.get('pos', 0); strand = request.POST.get('dir', 1); try: pos = int(pos) except ValueError as e: return JsonResponse('Position must be an integer, not "%s"' % pos, ERROR) try: strand = int(strand) except ValueError as e: return JsonResponse('Direction must be an integer, not "%s"' % strand, ERROR) if strand not in [-1, 1]: return JsonResponse('Strand must be 1 or -1, not "%s"' %strand, ERROR) direction = 'f' if strand == -1: direction = 'r' if f: cf = con.add_fragment(f, pos, direction) if cf: return JsonResponse(cf2dict(cf)) else: return JsonResponse('Could not add fragment %s to construct %s' % (fid, cid), ERROR) else: if request.is_ajax(): return JsonResponse('Could not find fragment "%s"' % fid, ERROR) return HttpResponseNotFound() else: return HttpResponseNotFound()