示例#1
0
def ureport_polls(request, pk):
    access = get_access(request)
    columns = [(_('Name'), True, 'name', SimpleSorter()),
               (_('Question'), True, 'question', SimpleSorter(),),
               (_('Start Date'), True, 'start_date', SimpleSorter(),),
               (_('Closing Date'), True, 'end_date', SimpleSorter()),
               ('', False, '', None)]
    queryset = get_polls(request=request)
    if access:
        queryset = queryset.filter(user=access.user)
    return generic(request,
                   model=Poll,
                   queryset=queryset,
                   objects_per_page=10,
                   selectable=False,
                   partial_row='ureport/partials/polls/poll_admin_row.html',
                   base_template='ureport/poll_admin_base.html',
                   paginator_template='ureport/partials/new_pagination.html',
                   results_title='Polls',
                   paginator_func=ureport_paginate,
                   sort_column='start_date',
                   sort_ascending=False,
                   filter_forms=[SearchPollsForm],
                   columns=columns
    )
示例#2
0
def ureport_polls(request):
    access = get_access(request)
    columns = [('Name', True, 'name', SimpleSorter()),
               (
                   'Question',
                   True,
                   'question',
                   SimpleSorter(),
               ), (
                   'Start Date',
                   True,
                   'start_date',
                   SimpleSorter(),
               ), ('Closing Date', True, 'end_date', SimpleSorter()),
               ('', False, '', None)]
    queryset = get_polls(request=request)
    if access:
        queryset = queryset.filter(user=access.user)
    return generic(request,
                   model=Poll,
                   queryset=queryset,
                   objects_per_page=10,
                   selectable=False,
                   partial_row='ureport/partials/polls/poll_admin_row.html',
                   base_template='ureport/poll_admin_base.html',
                   paginator_template='ureport/partials/new_pagination.html',
                   results_title='Polls',
                   paginator_func=ureport_paginate,
                   sort_column='start_date',
                   sort_ascending=False,
                   columns=columns)
示例#3
0
def ureport_polls(request):
	access = get_access(request)
	columns = [('Name', True, 'name', SimpleSorter()),
               ('Question', True, 'question', SimpleSorter(),),
               ('Start Date', True, 'start_date', SimpleSorter(),),
               ('Closing Date', True, 'end_date', SimpleSorter()),
               ('', False, '', None)]
	#queryset = get_polls(request=request).filter(user__groups__in=request.user.groups.values_list('id'))

	list_of_poll_id = []
	for pol in Poll.objects.all():
		contacts = Contact.objects.filter(polls=pol.id,groups = request.user.groups.values_list('id'))
		if contacts.count() != 0:
			list_of_poll_id.append(pol.id)


	queryset = get_polls(request=request)
	if access:
		queryset = queryset.filter(user__groups__in=request.user.groups.values_list('id'))

	queryset = get_polls(request=request).filter(id__in=list_of_poll_id)

	return generic(request,
                   model=Poll,
                   queryset=queryset,
                   objects_per_page=10,
                   selectable=False,
                   partial_row='ureport/partials/polls/poll_admin_row.html',
                   base_template='ureport/poll_admin_base.html',
                   paginator_template='ureport/partials/new_pagination.html',
                   results_title='Polls',
                   paginator_func=ureport_paginate,
                   sort_column='start_date',
                   sort_ascending=False,
                   columns=columns
    )