Ejemplo n.º 1
0
def get_all(request):
    """Get a JSON string containing all projects, members of projects, and project votes"""
    info = []
    projects = Project.objects.all()
    
    for project in projects:
        data_dict = {}
        data_dict['name'] = project.name
        data_dict['members'] = ProjectMember.objects.filter(project=project)
        data_dict['stats'] = project.stat()
        info.append(data_dict)
    return HttpResponse(json_encode(info), mimetype='application/json')
Ejemplo n.º 2
0
def get_my_votes(request):
    """Get a JSON string containing all projects that a user voted on"""
    user = request.user
    info = UserVote.objects.my_votes(user)
    return HttpResponse(json_encode(info), mimetype='application/json')