Exemplo n.º 1
0
def dnc_contact_list(request):
    """DNC Contact list for the logged in user

    **Attributes**:

        * ``template`` - frontend/dnc_contact/list.html
        * ``form`` - ContactSearchForm

    **Logic Description**:

        * List all dnc contacts from dnc lists belonging to the logged in user
    """
    sort_col_field_list = ['id', 'dnc', 'phone_number', 'updated_date']
    default_sort_field = 'id'
    pagination_data =\
        get_pagination_vars(request, sort_col_field_list, default_sort_field)

    PAGE_SIZE = pagination_data['PAGE_SIZE']
    sort_order = pagination_data['sort_order']
    start_page = pagination_data['start_page']
    end_page = pagination_data['end_page']

    form = DNCContactSearchForm(request.user)
    dnc_id_list = DNC.objects.values_list('id', flat=True)\
        .filter(user=request.user)
    search_tag = 1
    phone_number = ''
    dnc = ''

    if request.method == 'POST':
        form = DNCContactSearchForm(request.user, request.POST)
        if form.is_valid():
            request.session['session_phone_number'] = ''
            request.session['session_dnc'] = ''

            if request.POST.get('phone_number'):
                phone_number = request.POST.get('phone_number')
                request.session['session_phone_number'] = phone_number

            if request.POST.get('dnc'):
                dnc = request.POST.get('dnc')
                request.session['session_dnc'] = dnc

    post_var_with_page = 0
    try:
        if request.GET.get('page') or request.GET.get('sort_by'):
            post_var_with_page = 1
            phone_number = request.session.get('session_phone_number')
            dnc = request.session.get('session_dnc')
            form = DNCContactSearchForm(request.user,
                                        initial={
                                            'phone_number': phone_number,
                                            'dnc': dnc
                                        })
        else:
            post_var_with_page = 1
            if request.method == 'GET':
                post_var_with_page = 0
    except:
        pass

    if post_var_with_page == 0:
        # default
        # unset session var
        request.session['session_phone_number'] = ''
        request.session['session_dnc'] = ''

    kwargs = {}
    if dnc and dnc != '0':
        kwargs['dnc_id'] = dnc

    phone_number_type = '1'
    phone_number = type_field_chk(phone_number, phone_number_type,
                                  'phone_number')
    for i in phone_number:
        kwargs[i] = phone_number[i]

    phone_number_list = []
    all_phone_number_list = []
    phone_number_count = 0

    if dnc_id_list:
        phone_number_list = DNCContact.objects.values('id', 'dnc__name',
            'phone_number', 'updated_date')\
            .filter(dnc__in=dnc_id_list)

        if kwargs:
            phone_number_list = phone_number_list.filter(**kwargs)

        all_phone_number_list = phone_number_list.order_by(sort_order)
        phone_number_list = all_phone_number_list[start_page:end_page]
        phone_number_count = all_phone_number_list.count()

    template = 'frontend/dnc_contact/list.html'
    data = {
        'module': current_view(request),
        'phone_number_list': phone_number_list,
        'all_phone_number_list': all_phone_number_list,
        'total_phone_numbers': phone_number_count,
        'PAGE_SIZE': PAGE_SIZE,
        'DNC_CONTACT_COLUMN_NAME': DNC_CONTACT_COLUMN_NAME,
        'col_name_with_order': pagination_data['col_name_with_order'],
        'msg': request.session.get('msg'),
        'error_msg': request.session.get('error_msg'),
        'form': form,
        'dialer_setting_msg': user_dialer_setting_msg(request.user),
        'search_tag': search_tag,
    }
    request.session['msg'] = ''
    request.session['error_msg'] = ''
    return render_to_response(template,
                              data,
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def dnc_contact_list(request):
    """DNC Contact list for the logged in user

    **Attributes**:

        * ``template`` - frontend/dnc_contact/list.html
        * ``form`` - ContactSearchForm

    **Logic Description**:

        * List all dnc contacts from dnc lists belonging to the logged in user
    """
    sort_col_field_list = ['id', 'dnc', 'phone_number', 'updated_date']
    default_sort_field = 'id'
    pagination_data =\
        get_pagination_vars(request, sort_col_field_list, default_sort_field)

    PAGE_SIZE = pagination_data['PAGE_SIZE']
    sort_order = pagination_data['sort_order']
    start_page = pagination_data['start_page']
    end_page = pagination_data['end_page']

    form = DNCContactSearchForm(request.user)
    dnc_id_list = DNC.objects.values_list('id', flat=True)\
        .filter(user=request.user)
    search_tag = 1
    phone_number = ''
    dnc = ''

    if request.method == 'POST':
        form = DNCContactSearchForm(request.user, request.POST)
        if form.is_valid():
            request.session['session_phone_number'] = ''
            request.session['session_dnc'] = ''

            if request.POST.get('phone_number'):
                phone_number = request.POST.get('phone_number')
                request.session['session_phone_number'] = phone_number

            if request.POST.get('dnc'):
                dnc = request.POST.get('dnc')
                request.session['session_dnc'] = dnc

    post_var_with_page = 0
    try:
        if request.GET.get('page') or request.GET.get('sort_by'):
            post_var_with_page = 1
            phone_number = request.session.get('session_phone_number')
            dnc = request.session.get('session_dnc')
            form = DNCContactSearchForm(request.user, initial={'phone_number': phone_number,
                                                            'dnc': dnc})
        else:
            post_var_with_page = 1
            if request.method == 'GET':
                post_var_with_page = 0
    except:
        pass

    if post_var_with_page == 0:
        # default
        # unset session var
        request.session['session_phone_number'] = ''
        request.session['session_dnc'] = ''

    kwargs = {}
    if dnc and dnc != '0':
        kwargs['dnc_id'] = dnc

    phone_number_type = '1'
    phone_number = type_field_chk(phone_number, phone_number_type, 'phone_number')
    for i in phone_number:
        kwargs[i] = phone_number[i]

    phone_number_list = []
    all_phone_number_list = []
    phone_number_count = 0

    if dnc_id_list:
        phone_number_list = DNCContact.objects.values('id', 'dnc__name',
            'phone_number', 'updated_date')\
            .filter(dnc__in=dnc_id_list)

        if kwargs:
            phone_number_list = phone_number_list.filter(**kwargs)

        all_phone_number_list = phone_number_list.order_by(sort_order)
        phone_number_list = all_phone_number_list[start_page:end_page]
        phone_number_count = all_phone_number_list.count()

    template = 'frontend/dnc_contact/list.html'
    data = {
        'module': current_view(request),
        'phone_number_list': phone_number_list,
        'all_phone_number_list': all_phone_number_list,
        'total_phone_numbers': phone_number_count,
        'PAGE_SIZE': PAGE_SIZE,
        'DNC_CONTACT_COLUMN_NAME': DNC_CONTACT_COLUMN_NAME,
        'col_name_with_order': pagination_data['col_name_with_order'],
        'msg': request.session.get('msg'),
        'error_msg': request.session.get('error_msg'),
        'form': form,
        'dialer_setting_msg': user_dialer_setting_msg(request.user),
        'search_tag': search_tag,
    }
    request.session['msg'] = ''
    request.session['error_msg'] = ''
    return render_to_response(template, data,
                              context_instance=RequestContext(request))
Exemplo n.º 3
0
def dnc_contact_list(request):
    """DNC Contact list for the logged in user

    **Attributes**:

        * ``template`` - dnc/dnc_contact/list.html
        * ``form`` - ContactSearchForm

    **Logic Description**:

        * List all dnc contacts from dnc lists belonging to the logged in user
    """
    sort_col_field_list = ['id', 'dnc', 'phone_number', 'updated_date']
    pag_vars = get_pagination_vars(request, sort_col_field_list, default_sort_field='id')
    form = DNCContactSearchForm(request.user, request.POST or None)
    dnc_id_list = DNC.objects.values_list('id', flat=True).filter(user=request.user)
    phone_number = ''
    dnc = ''
    post_var_with_page = 0
    if form.is_valid():
        request.session['session_phone_number'] = ''
        request.session['session_dnc'] = ''
        post_var_with_page = 1
        phone_number = getvar(request, 'phone_number', setsession=True)
        dnc = getvar(request, 'dnc', setsession=True)

    if request.GET.get('page') or request.GET.get('sort_by'):
        post_var_with_page = 1
        phone_number = request.session.get('session_phone_number')
        dnc = request.session.get('session_dnc')
        form = DNCContactSearchForm(request.user, initial={'phone_number': phone_number, 'dnc': dnc})

    if post_var_with_page == 0:
        # default
        # unset session var
        request.session['session_phone_number'] = ''
        request.session['session_dnc'] = ''

    kwargs = {'dnc__in': dnc_id_list}
    if dnc and dnc != '0':
        kwargs['dnc_id'] = dnc

    phone_number_type = '1'
    phone_number = source_desti_field_chk(phone_number, phone_number_type, 'phone_number')
    for i in phone_number:
        kwargs[i] = phone_number[i]

    phone_number_list = []
    all_phone_number_list = []
    phone_number_count = 0

    if dnc_id_list:
        all_phone_number_list = DNCContact.objects.values(
            'id', 'dnc__name', 'phone_number', 'updated_date').filter(**kwargs).order_by(pag_vars['sort_order'])

        phone_number_list = all_phone_number_list[pag_vars['start_page']:pag_vars['end_page']]
        phone_number_count = all_phone_number_list.count()

    data = {
        'phone_number_list': phone_number_list,
        'all_phone_number_list': all_phone_number_list,
        'total_phone_numbers': phone_number_count,
        'DNC_CONTACT_COLUMN_NAME': DNC_CONTACT_COLUMN_NAME,
        'col_name_with_order': pag_vars['col_name_with_order'],
        'msg': request.session.get('msg'),
        'error_msg': request.session.get('error_msg'),
        'form': form,
    }
    request.session['msg'] = ''
    request.session['error_msg'] = ''
    return render_to_response('dnc/dnc_contact/list.html', data, context_instance=RequestContext(request))
Exemplo n.º 4
0
def dnc_contact_list(request):
    """DNC Contact list for the logged in user

    **Attributes**:

        * ``template`` - dnc/dnc_contact/list.html
        * ``form`` - ContactSearchForm

    **Logic Description**:

        * List all dnc contacts from dnc lists belonging to the logged in user
    """
    sort_col_field_list = ['id', 'dnc', 'phone_number', 'updated_date']
    pag_vars = get_pagination_vars(request,
                                   sort_col_field_list,
                                   default_sort_field='id')
    form = DNCContactSearchForm(request.user, request.POST or None)
    dnc_id_list = DNC.objects.values_list('id',
                                          flat=True).filter(user=request.user)
    phone_number = ''
    dnc = ''
    post_var_with_page = 0
    if form.is_valid():
        request.session['session_phone_number'] = ''
        request.session['session_dnc'] = ''
        post_var_with_page = 1
        phone_number = getvar(request, 'phone_number', setsession=True)
        dnc = getvar(request, 'dnc', setsession=True)

    if request.GET.get('page') or request.GET.get('sort_by'):
        post_var_with_page = 1
        phone_number = request.session.get('session_phone_number')
        dnc = request.session.get('session_dnc')
        form = DNCContactSearchForm(request.user,
                                    initial={
                                        'phone_number': phone_number,
                                        'dnc': dnc
                                    })

    if post_var_with_page == 0:
        # default
        # unset session var
        request.session['session_phone_number'] = ''
        request.session['session_dnc'] = ''

    kwargs = {'dnc__in': dnc_id_list}
    if dnc and dnc != '0':
        kwargs['dnc_id'] = dnc

    phone_number_type = '1'
    phone_number = source_desti_field_chk(phone_number, phone_number_type,
                                          'phone_number')
    for i in phone_number:
        kwargs[i] = phone_number[i]

    phone_number_list = []
    all_phone_number_list = []
    phone_number_count = 0

    if dnc_id_list:
        all_phone_number_list = DNCContact.objects.values(
            'id', 'dnc__name', 'phone_number',
            'updated_date').filter(**kwargs).order_by(pag_vars['sort_order'])

        phone_number_list = all_phone_number_list[
            pag_vars['start_page']:pag_vars['end_page']]
        phone_number_count = all_phone_number_list.count()

    data = {
        'phone_number_list': phone_number_list,
        'all_phone_number_list': all_phone_number_list,
        'total_phone_numbers': phone_number_count,
        'DNC_CONTACT_COLUMN_NAME': DNC_CONTACT_COLUMN_NAME,
        'col_name_with_order': pag_vars['col_name_with_order'],
        'msg': request.session.get('msg'),
        'error_msg': request.session.get('error_msg'),
        'form': form,
    }
    request.session['msg'] = ''
    request.session['error_msg'] = ''
    return render_to_response('dnc/dnc_contact/list.html',
                              data,
                              context_instance=RequestContext(request))
Exemplo n.º 5
0
def dnc_contact_list(request):
    """DNC Contact list for the logged in user

    **Attributes**:

        * ``template`` - dnc/dnc_contact/list.html
        * ``form`` - ContactSearchForm

    **Logic Description**:

        * List all dnc contacts from dnc lists belonging to the logged in user
    """
    sort_col_field_list = ["id", "dnc", "phone_number", "updated_date"]
    pag_vars = get_pagination_vars(request, sort_col_field_list, default_sort_field="id")
    form = DNCContactSearchForm(request.user, request.POST or None)
    dnc_id_list = DNC.objects.values_list("id", flat=True).filter(user=request.user)
    phone_number = ""
    dnc = ""
    post_var_with_page = 0
    if form.is_valid():
        request.session["session_phone_number"] = ""
        request.session["session_dnc"] = ""
        post_var_with_page = 1
        phone_number = getvar(request, "phone_number", setsession=True)
        dnc = getvar(request, "dnc", setsession=True)

    if request.GET.get("page") or request.GET.get("sort_by"):
        post_var_with_page = 1
        phone_number = request.session.get("session_phone_number")
        dnc = request.session.get("session_dnc")
        form = DNCContactSearchForm(request.user, initial={"phone_number": phone_number, "dnc": dnc})

    if post_var_with_page == 0:
        # default
        # unset session var
        request.session["session_phone_number"] = ""
        request.session["session_dnc"] = ""

    kwargs = {"dnc__in": dnc_id_list}
    if dnc and dnc != "0":
        kwargs["dnc_id"] = dnc

    phone_number_type = "1"
    phone_number = source_desti_field_chk(phone_number, phone_number_type, "phone_number")
    for i in phone_number:
        kwargs[i] = phone_number[i]

    phone_number_list = []
    all_phone_number_list = []
    phone_number_count = 0

    if dnc_id_list:
        all_phone_number_list = (
            DNCContact.objects.values("id", "dnc__name", "phone_number", "updated_date")
            .filter(**kwargs)
            .order_by(pag_vars["sort_order"])
        )

        phone_number_list = all_phone_number_list[pag_vars["start_page"] : pag_vars["end_page"]]
        phone_number_count = all_phone_number_list.count()

    data = {
        "phone_number_list": phone_number_list,
        "all_phone_number_list": all_phone_number_list,
        "total_phone_numbers": phone_number_count,
        "DNC_CONTACT_COLUMN_NAME": DNC_CONTACT_COLUMN_NAME,
        "col_name_with_order": pag_vars["col_name_with_order"],
        "msg": request.session.get("msg"),
        "error_msg": request.session.get("error_msg"),
        "form": form,
    }
    request.session["msg"] = ""
    request.session["error_msg"] = ""
    return render_to_response("dnc/dnc_contact/list.html", data, context_instance=RequestContext(request))