Exemplo n.º 1
0
def create_project(request):
    if request.user.is_authenticated():
        ur = UserResource()
        mr = MembershipResource()
        user = ur.obj_get(id=request.user.id)
        projects = mr.obj_get_list(user=request.user)
        ur_bundle = ur.build_bundle(obj=user, request=request)#what is this
        bundles = [mr.build_bundle(obj=project, request=request) for project in projects]
        
        return render_to_response('home.html', 
            {
                'user': ur.serialize(None, ur.full_dehydrate(ur_bundle), 'application/json'),
                'projects': mr.serialize(None, [mr.full_dehydrate(bundle) for bundle in bundles], 'application/json'),
            },
            context_instance=RequestContext(request))
    else:
        return HttpResponse("haven't logged in")
Exemplo n.º 2
0
def project(request, project_name):
    if request.user.is_authenticated():
        ur = UserResource()
        mr = MembershipResource()
        user = ur.obj_get(id=request.user.id)
        projects = mr.obj_get_list(user=request.user)
        found = False
        for memb in projects:
            if memb.project.name == project_name:
                found = True
                break
        if not found:
            return HttpResponse("you do not have access")    
        ur_bundle = ur.build_bundle(obj=user, request=request)#what is this
        bundles = [mr.build_bundle(obj=project, request=request) for project in projects]
        
        return render_to_response('home.html', 
            {
                'user': ur.serialize(None, ur.full_dehydrate(ur_bundle), 'application/json'),
                'projects': mr.serialize(None, [mr.full_dehydrate(bundle) for bundle in bundles], 'application/json'),
            },
            context_instance=RequestContext(request))
    else:
        return HttpResponse("haven't logged in")