예제 #1
0
def audio_grid(request):
    """Audio list in json format for flexigrid.

    **Model**: AudioFile

    **Fields**: [id, name, description, updated_date]
    """
    grid_data = grid_common_function(request)
    page = int(grid_data['page'])
    start_page = int(grid_data['start_page'])
    end_page = int(grid_data['end_page'])
    sortorder_sign = grid_data['sortorder_sign']
    sortname = grid_data['sortname']

    audio_list = AudioFile.objects\
                     .values('id', 'name', 'audio_file', 'updated_date')\
                     .filter(user=request.user)

    count = audio_list.count()
    audio_list = audio_list\
            .order_by(sortorder_sign + sortname)[start_page:end_page]

    link_style = 'style="text-decoration:none;background-image:url(' + \
                    settings.STATIC_URL + 'newfies/icons/link.png);"'
    domain = Site.objects.get_current().domain

    rows = [{'id': row['id'],
            'cell': ['<input type="checkbox" name="select" class="checkbox"\
                value="' + str(row['id']) + '" />',
                row['name'],
                audio_file_player(row['audio_file']),
                '<input type="text" value="' + domain + \
                settings.MEDIA_URL + str(row['audio_file']) + '">',
                row['updated_date'].strftime('%Y-%m-%d %H:%M:%S'),
                '<a href="' + settings.MEDIA_URL + \
                str(row['audio_file']) + '" class="icon" ' \
                + link_style + ' title="' + _('Download audio') + \
                '">&nbsp;</a>' +
                '<a href="' + str(row['id']) + '/" class="icon" ' \
                + update_style + ' title="' + _('Update audio') + \
                '">&nbsp;</a>' +
                '<a href="del/' + str(row['id']) + '/" class="icon" ' \
                + delete_style + ' onClick="return get_alert_msg(' +
                str(row['id']) +
                ');"  title="' + _('Delete audio') + '">&nbsp;</a>']}\
                for row in audio_list]

    data = {'rows': rows,
            'page': page,
            'total': count}
    return HttpResponse(simplejson.dumps(data), mimetype='application/json',
                        content_type="application/json")
예제 #2
0
def notification_grid(request):
    """notification list in json format for flexigrid

    **Model**: notification.Notice
    """
    grid_data = grid_common_function(request)
    page = int(grid_data["page"])
    start_page = int(grid_data["start_page"])
    end_page = int(grid_data["end_page"])
    sortorder_sign = grid_data["sortorder_sign"]
    sortname = grid_data["sortname"]

    user_notification = notification.Notice.objects.filter(recipient=request.user)
    # Search on sender name
    q = Q(sender=request.user)
    if q:
        user_notification = user_notification.filter(q)

    count = user_notification.count()
    user_notification_list = user_notification.order_by(sortorder_sign + sortname)[start_page:end_page]

    rows = [
        {
            "id": row.id,
            "cell": [
                '<input type="checkbox" name="select" class="checkbox"\
                      value="'
                + str(row.id)
                + '" />',
                row.message,
                str(row.notice_type),
                str(row.sender),
                str(row.added),
                str(
                    '<a href="../update_notice_status_cust/'
                    + str(row.id)
                    + '/" class="icon" '
                    + call_style(row.unseen)
                    + ' ">&nbsp;</a>'
                ),
            ],
        }
        for row in user_notification_list
    ]

    data = {"rows": rows, "page": page, "total": count}

    return HttpResponse(simplejson.dumps(data), mimetype="application/json", content_type="application/json")
예제 #3
0
def voiceapp_grid(request):
    """Voce App list in json format for flexigrid

    **Model**: VoiceApp

    **Fields**: [id, name, user, description, type, gateway__name,
                 updated_date]
    """
    grid_data = grid_common_function(request)
    page = int(grid_data['page'])
    start_page = int(grid_data['start_page'])
    end_page = int(grid_data['end_page'])
    sortorder_sign = grid_data['sortorder_sign']
    sortname = grid_data['sortname']

    voiceapp_list = VoiceApp.objects\
                   .values('id', 'name', 'user', 'description', 'type',
                           'data', 'tts_language', 'gateway__name',
                           'updated_date').filter(user=request.user)

    count = voiceapp_list.count()
    voiceapp_list = \
        voiceapp_list.order_by(sortorder_sign + sortname)[start_page:end_page]

    rows = [{'id': row['id'],
             'cell': ['<input type="checkbox" name="select" class="checkbox"\
                      value="' + str(row['id']) + '" />',
                      row['name'],
                      row['description'],
                      get_voiceapp_type_name(row['type']),
                      row['gateway__name'],
                      row['data'],
                      row['tts_language'],
                      row['updated_date'].strftime('%Y-%m-%d %H:%M:%S'),
                      '<a href="' + str(row['id']) + '/" class="icon" ' \
                      + update_style + ' title="' + _('Update Voice App') +\
                      '">&nbsp;</a>' +\
                      '<a href="del/' + str(row['id']) + '/" class="icon" ' \
                      + delete_style + ' onClick="return get_alert_msg(' +\
                      str(row['id']) +\
                      ');"  title="' + _('Delete Voice App') + '">&nbsp;</a>'
                      ]} for row in voiceapp_list]

    data = {'rows': rows,
            'page': page,
            'total': count}
    return HttpResponse(simplejson.dumps(data), mimetype='application/json',
                        content_type="application/json")
예제 #4
0
def survey_grid(request):
    """Survey list in json format for flexigrid.

    **Model**: SurveyApp

    **Fields**: [id, name, description, updated_date]
    """
    grid_data = grid_common_function(request)
    page = int(grid_data['page'])
    start_page = int(grid_data['start_page'])
    end_page = int(grid_data['end_page'])
    sortorder_sign = grid_data['sortorder_sign']
    sortname = grid_data['sortname']

    survey_list = SurveyApp.objects\
                     .values('id', 'name', 'description', 'updated_date')\
                     .filter(user=request.user)

    count = survey_list.count()
    survey_list = \
        survey_list.order_by(sortorder_sign + sortname)[start_page:end_page]

    rows = [{'id': row['id'],
             'cell': ['<input type="checkbox" name="select" class="checkbox"\
                      value="' + str(row['id']) + '" />',
                      row['name'],
                      row['description'],
                      row['updated_date'].strftime('%Y-%m-%d %H:%M:%S'),
                      '<a href="' + str(row['id']) + '/" class="icon" ' \
                      + update_style + ' title="' + _('Update survey') + '">&nbsp;</a>' +
                      '<a href="del/' + str(row['id']) + '/" class="icon" ' \
                      + delete_style + ' onClick="return get_alert_msg(' +
                      str(row['id']) +
                      ');"  title="' + _('Delete survey') + '">&nbsp;</a>']}\
                      for row in survey_list]

    data = {'rows': rows,
            'page': page,
            'total': count}
    return HttpResponse(simplejson.dumps(data), mimetype='application/json',
                        content_type="application/json")
예제 #5
0
def notification_grid(request):
    """notification list in json format for flexigrid

    **Model**: notification.Notice
    """
    grid_data = grid_common_function(request)
    page = int(grid_data['page'])
    start_page = int(grid_data['start_page'])
    end_page = int(grid_data['end_page'])
    sortorder_sign = grid_data['sortorder_sign']
    sortname = grid_data['sortname']

    user_notification = \
        notification.Notice.objects.filter(recipient=request.user)
    # Search on sender name
    q = (Q(sender=request.user))
    if q:
        user_notification = user_notification.filter(q)

    count = user_notification.count()
    user_notification_list = user_notification\
                     .order_by(sortorder_sign + sortname)[start_page:end_page]

    rows = [{'id': row.id,
             'cell': ['<input type="checkbox" name="select" class="checkbox"\
                      value="' + str(row.id) + '" />',
                      str(row.message),
                      str(row.notice_type),
                      str(row.sender),
                      str(row.added),
                      str('<a href="../update_notice_status_cust/' \
                      + str(row.id) + '/" class="icon" ' \
                      + call_style(row.unseen) + '>&nbsp;</a>'),
             ]}for row in user_notification_list]

    data = {'rows': rows,
            'page': page,
            'total': count}

    return HttpResponse(simplejson.dumps(data), mimetype='application/json',
                        content_type="application/json")
예제 #6
0
def notification_grid(request):
    """notification list in json format for flexigrid

    **Model**: notification.Notice
    """
    grid_data = grid_common_function(request)
    page = int(grid_data['page'])
    start_page = int(grid_data['start_page'])
    end_page = int(grid_data['end_page'])
    sortorder_sign = grid_data['sortorder_sign']
    sortname = grid_data['sortname']

    user_notification = \
        notification.Notice.objects.filter(recipient=request.user)
    # Search on sender name
    q = (Q(sender=request.user))
    if q:
        user_notification = user_notification.filter(q)

    count = user_notification.count()
    user_notification_list = user_notification\
                     .order_by(sortorder_sign + sortname)[start_page:end_page]

    rows = [{'id': row.id,
             'cell': ['<input type="checkbox" name="select" class="checkbox"\
                      value="'                               + str(row.id) + '" />',
                      str(row.message),
                      str(row.notice_type),
                      str(row.sender),
                      str(row.added),
                      str('<a href="../update_notice_status_cust/' \
                      + str(row.id) + '/" class="icon" ' \
                      + call_style(row.unseen) + '>&nbsp;</a>'),
             ]}for row in user_notification_list]

    data = {'rows': rows, 'page': page, 'total': count}

    return HttpResponse(simplejson.dumps(data),
                        mimetype='application/json',
                        content_type="application/json")
예제 #7
0
def survey_grid(request):
    """Survey list in json format for flexigrid.

    **Model**: SurveyApp

    **Fields**: [id, name, description, updated_date]
    """
    grid_data = grid_common_function(request)
    page = int(grid_data['page'])
    start_page = int(grid_data['start_page'])
    end_page = int(grid_data['end_page'])
    sortorder_sign = grid_data['sortorder_sign']
    sortname = grid_data['sortname']

    survey_list = SurveyApp.objects\
                     .values('id', 'name', 'description', 'updated_date')\
                     .filter(user=request.user)

    count = survey_list.count()
    survey_list = \
        survey_list.order_by(sortorder_sign + sortname)[start_page:end_page]

    rows = [{'id': row['id'],
             'cell': ['<input type="checkbox" name="select" class="checkbox"\
                      value="'                               + str(row['id']) + '" />',
                      row['name'],
                      row['description'],
                      row['updated_date'].strftime('%Y-%m-%d %H:%M:%S'),
                      '<a href="' + str(row['id']) + '/" class="icon" ' \
                      + update_style + ' title="' + _('Update survey') + '">&nbsp;</a>' +
                      '<a href="del/' + str(row['id']) + '/" class="icon" ' \
                      + delete_style + ' onClick="return get_alert_msg(' +
                      str(row['id']) +
                      ');"  title="' + _('Delete survey') + '">&nbsp;</a>']}\
                      for row in survey_list]

    data = {'rows': rows, 'page': page, 'total': count}
    return HttpResponse(simplejson.dumps(data),
                        mimetype='application/json',
                        content_type="application/json")
예제 #8
0
def voipcall_report_grid(request):
    """VoIP Call list in json format for flexigrid

    **Model**: VoIPCall

    **Fields**: [id, user__username, used_gateway__name, callid, request_uuid,
                 callerid, phone_number, starting_date, sessiontime,
                 disposition, leg_type]

    **Logic Description**:

        * Get VoIP call list according to search parameters for loggedin user
    """
    grid_data = grid_common_function(request)
    page = int(grid_data['page'])
    start_page = int(grid_data['start_page'])
    end_page = int(grid_data['end_page'])
    sortorder_sign = grid_data['sortorder_sign']
    sortname = grid_data['sortname']

    # Search vars
    kwargs = {}
    kwargs['user'] = request.user
    from_date = ''
    start_date = ''
    to_date = ''
    end_date = ''
    disposition = 'all'

    if not sortorder_sign == '':
        sortorder_sign = '-'

    # get querystring from URL
    q_arr = list(request.get_full_path().split('?'))
    j = 0
    q_para = ''

    # get para from querystring
    for i in q_arr:
        if j == 1:
            q_para = i
        j = j + 1

    if "from_date" in q_para:
        # decode query string
        decoded_string = urllib.unquote(q_para.decode("utf8"))

        temp_list = list(decoded_string.split('&'))
        for i in range(0, len(temp_list)):
            if temp_list[i].find('='):
                kwargs_list = list(temp_list[i].split('='))

                if kwargs_list[0] == 'from_date':
                    if kwargs_list[1]:
                        from_date = kwargs_list[1]
                        start_date = \
                        datetime(int(from_date[0:4]), int(from_date[5:7]),
                                 int(from_date[8:10]), 0, 0, 0, 0)

                if kwargs_list[0] == 'to_date':
                    if kwargs_list[1]:
                        to_date = kwargs_list[1]
                        end_date = \
                        datetime(int(to_date[0:4]), int(to_date[5:7]),
                                 int(to_date[8:10]), 23, 59, 59, 999999)

                if kwargs_list[0] == 'disposition':
                    if kwargs_list[1]:
                        disposition = kwargs_list[1]

        if start_date and end_date:
            kwargs['starting_date__range'] = (start_date, end_date)
        if start_date and end_date == '':
            kwargs['starting_date__gte'] = start_date
        if start_date == '' and end_date:
            kwargs['starting_date__lte'] = end_date

        if disposition != 'all':
            kwargs['disposition__exact'] = disposition

        if len(kwargs) == 0:
            tday = datetime.today()
            kwargs['starting_date__gte'] = datetime(tday.year, tday.month,
                                                    tday.day, 0, 0, 0, 0)

    voipcall_list = VoIPCall.objects.filter(**kwargs)

    count = voipcall_list.count()
    voipcall_list = \
        voipcall_list.order_by(sortorder_sign + sortname)[start_page:end_page]

    rows = []
    for row in voipcall_list:
        gateway_used = row.used_gateway.name if row.used_gateway else ''
        rows.append({
            'id':
            row.id,
            'cell': [
                row.starting_date.strftime('%Y-%m-%d %H:%M:%S'),
                row.callid,
                row.get_leg_type_display(),
                row.callerid,
                row.phone_number,
                gateway_used,
                #str(timedelta(seconds=row.duration)), # original
                row.duration,  # dilla test
                row.billsec,
                row.get_disposition_display(),
                #row.hangup_cause,
                #row.hangup_cause_q850,
            ]
        })

    data = {'rows': rows, 'page': page, 'total': count}
    return HttpResponse(simplejson.dumps(data),
                        mimetype='application/json',
                        content_type="application/json")
예제 #9
0
def voipcall_report_grid(request):
    """VoIP Call list in json format for flexigrid

    **Model**: VoIPCall

    **Fields**: [id, user__username, used_gateway__name, callid, request_uuid,
                 callerid, phone_number, starting_date, sessiontime,
                 disposition, leg_type]

    **Logic Description**:

        * Get VoIP call list according to search parameters for loggedin user
    """
    grid_data = grid_common_function(request)
    page = int(grid_data['page'])
    start_page = int(grid_data['start_page'])
    end_page = int(grid_data['end_page'])
    sortorder_sign = grid_data['sortorder_sign']
    sortname = grid_data['sortname']


    # Search vars
    kwargs = {}
    kwargs['user'] = request.user
    from_date = ''
    start_date = ''
    to_date = ''
    end_date = ''
    disposition = 'all'

    if not sortorder_sign == '':
        sortorder_sign = '-'
    
    # get querystring from URL
    q_arr = list(request.get_full_path().split('?'))
    j = 0
    q_para = ''

    # get para from querystring
    for i in q_arr:
        if j == 1:
            q_para = i
        j = j + 1

    if "from_date" in q_para:
        # decode query string
        decoded_string = urllib.unquote(q_para.decode("utf8"))

        temp_list = list(decoded_string.split('&'))
        for i in range(0, len(temp_list)):
            if temp_list[i].find('='):
                kwargs_list = list(temp_list[i].split('='))

                if kwargs_list[0] == 'from_date':
                    if kwargs_list[1]:
                        from_date = kwargs_list[1]
                        start_date = \
                        datetime(int(from_date[0:4]), int(from_date[5:7]),
                                 int(from_date[8:10]), 0, 0, 0, 0)

                if kwargs_list[0] == 'to_date':
                    if kwargs_list[1]:
                        to_date = kwargs_list[1]
                        end_date = \
                        datetime(int(to_date[0:4]), int(to_date[5:7]),
                                 int(to_date[8:10]), 23, 59, 59, 999999)

                if kwargs_list[0] == 'disposition':
                    if kwargs_list[1]:
                        disposition = kwargs_list[1]

        if start_date and end_date:
            kwargs['starting_date__range'] = (start_date, end_date)
        if start_date and end_date == '':
            kwargs['starting_date__gte'] = start_date
        if start_date == '' and end_date:
            kwargs['starting_date__lte'] = end_date

        if disposition != 'all':
            kwargs['disposition__exact'] = disposition

        if len(kwargs) == 0:
            tday = datetime.today()
            kwargs['starting_date__gte'] = datetime(tday.year,
                                                    tday.month,
                                                    tday.day, 0, 0, 0, 0)
    
    voipcall_list = VoIPCall.objects.filter(**kwargs)

    count = voipcall_list.count()
    voipcall_list = \
        voipcall_list.order_by(sortorder_sign + sortname)[start_page:end_page]
    
    rows = []
    for row in voipcall_list:
        gateway_used = row.used_gateway.name if row.used_gateway else ''
        rows.append({'id': row.id,
                     'cell': [ row.starting_date.strftime('%Y-%m-%d %H:%M:%S'),
                               row.callid,
                               row.get_leg_type_display(),
                               row.callerid,
                               row.phone_number,
                               gateway_used,
                               #str(timedelta(seconds=row.duration)), # original
                               row.duration, # dilla test
                               row.billsec,
                               row.get_disposition_display(),
                               #row.hangup_cause,
                               #row.hangup_cause_q850,
                               ]})
        
    data = {'rows': rows,
            'page': page,
            'total': count}
    return HttpResponse(simplejson.dumps(data), mimetype='application/json',
                        content_type="application/json")