def batch(request, mongo, id_): models.update_batch_progress(id_) models.update_batch_reliability(id_) batch = mongo.get_collection("tb_app_batch").find_one( {"_id": ObjectId(id_)}, fields={ "profile": 1, "reports": 1, "documents": 1 }) #print json.dumps(batch, cls=MongoEncoder, indent=1) result = { 'batch': batch, 'codebook': mongo.get_collection("tb_app_codebook").find_one( {"_id": ObjectId(batch["profile"]["codebook_id"])}, { "profile": 1, "variables": 1 }), 'collection': mongo.get_collection("tb_app_collection").find_one( {"_id": ObjectId(batch["profile"]["collection_id"])}, {"profile": 1}), 'users': jsonifyRecords(User.objects.all(), [ 'username', 'first_name', 'last_name', 'email', 'is_active', 'is_superuser' ]), } return render_to_response('batch.html', result, context_instance=RequestContext(request))
def update_batch_reliability(request): batch_id = request.POST["batch_id"] #! Validate batch_id models.update_batch_reliability(batch_id) return gen_json_response({"status": "success", "msg": "Successfully updated reliability report."})
def update_batch_reliability(request): batch_id = request.POST["batch_id"] #! Validate batch_id models.update_batch_reliability(batch_id) return gen_json_response({ "status": "success", "msg": "Successfully updated reliability report." })
def shared_resources(request, mongo): codebooks = list( mongo.get_collection("tb_app_codebook").find( sort=[('profile.created_at', 1)])) #! This is migration code to add 'variables' objects to all codebooks for c in codebooks: c["variables"] = models.get_codebook_variables_from_questions( c["questions"]) mongo.get_collection("tb_app_codebook").save(c) batches = list( mongo.get_collection("tb_app_batch").find(fields={ "profile": 1, "reports": 1 }, sort=[('profile.created_at', 1)])) for b in batches: models.update_batch_progress(b["_id"]) models.update_batch_reliability(b["_id"]) # print list(mongo.get_collection("tb_app_codebook").find(sort=[('created_at',1)])) result = { 'codebooks': codebooks, 'collections': list( mongo.get_collection("tb_app_collection").find( fields={"profile": 1 })), #fields={"id": 1, "name": 1, "description": 1})), 'batches': batches, 'users': jsonifyRecords(User.objects.all(), [ 'username', 'first_name', 'last_name', 'email', 'is_active', 'is_superuser' ]), } #print json.dumps(result, indent=2, cls=MongoEncoder) return render_to_response('shared-resources.html', result, context_instance=RequestContext(request))
def batch(request, mongo, id_): models.update_batch_progress(id_) models.update_batch_reliability(id_) batch = mongo.get_collection("tb_app_batch").find_one({"_id": ObjectId(id_)}, fields={"profile": 1, "reports": 1, "documents": 1}) #print json.dumps(batch, cls=MongoEncoder, indent=1) result = { 'batch': batch, 'codebook': mongo.get_collection("tb_app_codebook").find_one( {"_id": ObjectId(batch["profile"]["codebook_id"])}, {"profile":1, "variables":1} ), 'collection': mongo.get_collection("tb_app_collection").find_one( {"_id": ObjectId(batch["profile"]["collection_id"])}, {"profile":1} ), 'users': jsonifyRecords(User.objects.all(), ['username', 'first_name', 'last_name', 'email', 'is_active', 'is_superuser']), } return render_to_response('batch.html', result, context_instance=RequestContext(request))
def shared_resources(request, mongo): codebooks = list(mongo.get_collection("tb_app_codebook").find(sort=[('profile.created_at', 1)])) #! This is migration code to add 'variables' objects to all codebooks for c in codebooks: c["variables"] = models.get_codebook_variables_from_questions(c["questions"]) mongo.get_collection("tb_app_codebook").save(c) batches = list(mongo.get_collection("tb_app_batch").find(fields={"profile": 1, "reports": 1}, sort=[('profile.created_at', 1)])) for b in batches: models.update_batch_progress(b["_id"]) models.update_batch_reliability(b["_id"]) # print list(mongo.get_collection("tb_app_codebook").find(sort=[('created_at',1)])) result = { 'codebooks': codebooks, 'collections': list(mongo.get_collection("tb_app_collection").find(fields={"profile":1})),#fields={"id": 1, "name": 1, "description": 1})), 'batches': batches, 'users': jsonifyRecords(User.objects.all(), ['username', 'first_name', 'last_name', 'email', 'is_active', 'is_superuser']), } #print json.dumps(result, indent=2, cls=MongoEncoder) return render_to_response('shared-resources.html', result, context_instance=RequestContext(request))