(request)
return render(request, 'recycle_bin.html', context=context)
Recycle bin view for a user
Recycle bin view for a user
Recycle bin view for a user
def recycle_bin(request):
    "Recycle bin view for a user"
    user = request.user

    BIN_LIMIT = 200

    if user.is_superuser:
        # Super users get access to all deleted objects.
        projects = Project.objects.all()
        query_dict = dict(project__in=projects)
    else:
        # Only searches projects user have access.
        projects = auth.get_project_list(user=user, include_deleted=True)
        query_dict = dict(project__in=projects, owner=user)

    projects = projects.filter(deleted=True).order_by("-lastedit_date")[:BIN_LIMIT]

    # Filter data, recipes, and jobs according to projects user has access to.
    data = Data.objects.filter(**query_dict, deleted=True).order_by("-lastedit_date")[:BIN_LIMIT]

    recipes = Analysis.objects.filter(**query_dict, deleted=True).order_by("-lastedit_date")[:BIN_LIMIT]

    jobs = Job.objects.filter(**query_dict, deleted=True).order_by("-lastedit_date")[:BIN_LIMIT]

    deleted = []

    for obj in [projects, data, recipes, jobs]:
        for item in obj:
            deleted.append(item)

    deleted = sorted(deleted, key=lambda x: x.lastedit_date, reverse=True)
    context = dict(deleted=deleted, active="bin")

    return render(request, 'recycle_bin.html', context=context)
def recycle_bin ( request ) : user = request . user BIN_LIMIT = 200 if user . is_superuser : # Super users get access to all deleted objects. projects = Project . objects . all ( ) query_dict = dict ( project__in = projects ) else : # Only searches projects user have access. projects = auth . get_project_list ( user = user , include_deleted = True ) query_dict = dict ( project__in = projects , owner = user ) projects = projects . filter ( deleted = True ) . order_by ( "-lastedit_date" ) [ : BIN_LIMIT ] # Filter data, recipes, and jobs according to projects user has access to. data = Data . objects . filter ( * * query_dict , deleted = True ) . order_by ( "-lastedit_date" ) [ : BIN_LIMIT ] recipes = Analysis . objects . filter ( * * query_dict , deleted = True ) . order_by ( "-lastedit_date" ) [ : BIN_LIMIT ] jobs = Job . objects . filter ( * * query_dict , deleted = True ) . order_by ( "-lastedit_date" ) [ : BIN_LIMIT ] deleted = [ ] for obj in [ projects , data , recipes , jobs ] : for item in obj : deleted . append ( item ) deleted = sorted ( deleted , key = lambda x : x . lastedit_date , reverse = True ) context = dict ( deleted = deleted , active = "bin" ) return render ( request , 'recycle_bin.html' , context = context )