def workspace(request, wid): if request.method == "GET": ws = get_document_or_404(Workspace,id=wid) jsonstr = documents_to_json(ws) return HttpResponse(jsonstr, mimetype="application/json") elif request.method == "POST": return create_workspace(request)
def fetch_many_users(request, retformat=""): context = {} # For now just return 100 users, eventually this will be based on submitted parameters users = User.objects.limit(100) if retformat == 'json': context['json'] = documents_to_json(users) return render(request, 'data_app/json_template', context) context["retformat"] = retformat count = User.objects.count() context["count"] = count return render(request, 'data_app/many_users.html', context)
def fetch_one_user(request, attr, id, retformat=""): context = {} filter = { attr : id } user = get_document_or_404(User, **filter) if retformat == 'json': context['json'] = documents_to_json(user) return render(request, 'data_app/json_template', context) context["retformat"] = retformat context["attribute"] = attr context["id"] = id context["user"] = user return render(request, 'data_app/one_user.html', context)
def fetch_upload_list(request, wid): uploads = UserSubmittedData.objects(workspaces=wid) return HttpResponse(documents_to_json(uploads), mimetype="application/json")
def fetch_gradebooks_for_sections(request): gradebooks = Gradebook.objects(sections__in=[request.POST['sections[]']]) return HttpResponse(documents_to_json(gradebooks), mimetype="application/json")
def fetch_workspaces_for_user(request, uid): workspaces = all_workspaces_for_user(uid) jsonstr = documents_to_json(workspaces) return HttpResponse(jsonstr, mimetype="application/json")
def fetch_workspace_users(request, wid): ws = get_document_or_404(Workspace, id=wid) rcpids = ws.owners users = User.objects(rcpid__in=rcpids).exclude("courses") jsonstr = documents_to_json(users) return HttpResponse(jsonstr, mimetype="application/json")