Esempio n. 1
0
def summary(request, allocationround_id=None):

    all_rounds = AllocationRound.objects.all()
    allocation_round = None
    if allocationround_id:
        allocation_round = AllocationRound.objects.get(id=allocationround_id)

    query_list = get_querylist(request=request)
    if query_list:
        apps = Application.objects.filter(reduce(operator.or_,query_list)).filter(complete=True)
    else:
        apps = Application.objects.none()
        
    if allocation_round:
        apps = apps.filter(allocation_round=allocation_round)

    # Build a dictionary full of application objects keyed on priority_area name
    all_apps = {}
    for a in apps:
        if a.priority_area.name not in all_apps.keys():
            all_apps[a.priority_area.name] = []
        all_apps[a.priority_area.name].append(a)


    # Flag to show/hide the review column based on user permissions
    show_review = False
    reviewer_permissions = ['allocation.add_reviewerscore', 'allocation.add_reviewercomment']
    if all(permission in request.user.get_all_permissions() for permission in reviewer_permissions):
        show_review = True

    return render_to_response('allocation/summary.html', {
#        'tool': tool,
        'user':request.user,
        'title': 'Resource Application Summary',
        'root_path':urlresolvers.reverse('admin:index'),
        'all_apps':all_apps,
        'edit_url': urlresolvers.reverse('admin:allocation_application_change', args=(1,)),
        'urlresolvers':urlresolvers,
        'show_review':show_review,
        'allocation_round': allocation_round,
        'all_rounds': all_rounds,
#        'edit_url': urlresolvers.reverse('admin:yabi_tool_change', args=(tool.id,)),
#        'json_url': webhelpers.url('/ws/tool/' + quote(tool.name)),
#        'tool_params': format_params(tool.toolparameter_set.order_by('id')),
        })
Esempio n. 2
0
    def queryset(self, request):

        # superuser - return all
        if request.user.is_superuser:
            return Application.objects.all()

        query_list = get_querylist(request=request)
    
        # reviewer - return all
        if query_list:
            return Application.objects.filter(reduce(operator.or_,query_list))

        # has change privilege - show them just their applications
        elif self.has_change_permission(request):
            return Application.objects.filter(created_by=request.user)

        # show none
        else:
            return Application.objects.none()