def campaign_list(request):
"""List all campaigns for the logged in user
**Attributes**:
* ``template`` - dialer_campaign/campaign/list.html
**Logic Description**:
* List all campaigns belonging to the logged in user
"""
form = CampaignSearchForm(request.user, request.POST or None)
request.session['pagination_path'] = request.META['PATH_INFO'] + '?' + request.META['QUERY_STRING']
sort_col_field_list = ['id', 'name', 'startingdate', 'status', 'totalcontact']
pag_vars = get_pagination_vars(request, sort_col_field_list, default_sort_field='id')
phonebook_id = ''
status = 'all'
post_var_with_page = 0
if form.is_valid():
field_list = ['phonebook_id', 'status']
unset_session_var(request, field_list)
phonebook_id = getvar(request, 'phonebook_id', setsession=True)
status = getvar(request, 'status', setsession=True)
post_var_with_page = 1
# This logic to retain searched result set while accessing pagination or sorting on column
# post_var_with_page will check following thing
# 1) if page has previously searched value, then post_var_with_page become 1
# 2) if not then post_var_with_page remain 0 & flush the session variables' value
if request.GET.get('page') or request.GET.get('sort_by'):
post_var_with_page = 1
phonebook_id = request.session.get('session_phonebook_id')
status = request.session.get('session_status')
form = CampaignSearchForm(request.user, initial={'status': status, 'phonebook_id': phonebook_id})
if post_var_with_page == 0:
# default / unset session var
field_list = ['status', 'phonebook_id']
unset_session_var(request, field_list)
# Set search on user as default
kwargs = {'user': request.user}
if phonebook_id and phonebook_id != '0':
kwargs['phonebook__id__in'] = [int(phonebook_id)]
if status and status != 'all':
kwargs['status'] = status
all_campaign_list = Campaign.objects.filter(**kwargs).order_by(pag_vars['sort_order'])
campaign_list = all_campaign_list[pag_vars['start_page']:pag_vars['end_page']]
campaign_count = all_campaign_list.count()
Id = [2,3,4,5,6,7,8]
for w in Id:
A = w
Pending = pending(A)
data = {
'form': form,
'all_campaign_list': all_campaign_list,
'campaign_list': campaign_list,
'total_campaign': campaign_count,
'CAMPAIGN_COLUMN_NAME': CAMPAIGN_COLUMN_NAME,
'col_name_with_order': pag_vars['col_name_with_order'],
'msg': request.session.get('msg'),
'error_msg': request.session.get('error_msg'),
'info_msg': request.session.get('info_msg'),
'Pending': Pending,
}
request.session['msg'] = ''
request.session['error_msg'] = ''
request.session['info_msg'] = ''
return render_to_response('dialer_campaign/campaign/list.html', data, context_instance=RequestContext(request))
def pending(campaign_id):
A = Campaign_phonebook.objects.values_list('phonebook_id').filter(campaign_id = campaign_id)
## getting all contact_id of campaign_id = campaign_id in phonebook
B = Contact.objects.filter(phonebook_id__in=A).count()
## Check How many Contacts in Subscriber of "campaign_id = campaign_id"
C = Subscriber.objects.filter(campaign_id = campaign_id).exclude(status = 1).count()
Result = B - C
return Result
Sir Mandeep This is my full code When i give specific value instead of A it works,but when i give value through loop it did't Work
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8d63b224-ff2e-4d6f-94d3-76b26706a2f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment