def refresh_pdb_ajax(request, owner_id, sub_id ): pdblist = [ b.pdb_code.lower() for b in PdbRef.objects.all() ] subobj = get_object_or_404( Submission, pk = sub_id ) owned_list = subobj.pdbref_set.all() ownobj = get_object_or_404( Owner, myt_id = owner_id ) olist = [ b.pdb_code.lower() for b in owned_list ] if request.POST.has_key('client_response') and request.POST['client_response'].lower() != '': client_response = request.POST['client_response'].lower() if client_response in pdblist: p = PdbRef.objects.get( pdb_code = client_response ) p.get_descriptors() p.get_release_status() p.save() response_dict = { 'server_response' : p.title } if p.pdb_code.lower() not in olist: sp = SubPdb.objects.create( submission = subobj, pdbref = p, trigger_release = True, release_override = False ) p.save() subobj.save() else: p = PdbRef( pdb_code = client_response ) p.get_descriptors() p.get_release_status() p.save() response_dict = { 'server_response' : p.title } sp = SubPdb.objects.create( submission = subobj, pdbref = p, trigger_release = True, release_override = False ) p.save() subobj.save() context = { 'submission' : subobj, 'owner' : ownobj } return HttpResponse(render(request, 'subform/refresh_form_pdb.html', context) ) else: context = { 'submission' : subobj, 'owner' : ownobj } return HttpResponse(render(request, 'subform/refresh_form_pdb.html', context) )
def form_pdb_ajax(request): pdblist = [ b.pdb_code.lower() for b in PdbRef.objects.all() ] if request.POST.has_key('client_response'): client_response = request.POST['client_response'].lower() if client_response in pdblist: p = PdbRef.objects.get( pdb_code = client_response ) p.get_descriptors() response_dict = { 'server_response' : p.pubmed_id } return HttpResponse(json.dumps( response_dict )) else: p = PdbRef( pdb_code = client_response ) p.get_descriptors() p.save() response_dict = { 'pdb_code' : p.pdb_code, 'authors' : p.authors, 'title' : p.title, 'pubmed_id' : p.pubmed_id } return HttpResponse(json.dumps( response_dict )) else: return render_to_response('subform/ftemp.html', context_instance=RequestContext(request))