def test_admin_voipcall_view_report(self): """Test Function to check admin voipcall list""" response = self.client.get( '/admin/dialer_cdr/voipcall/voip_daily_report/') self.failUnlessEqual(response.status_code, 200) response = self.client.post( '/admin/dialer_cdr/voipcall/voip_daily_report/', data={ 'from_date': datetime.utcnow().replace(tzinfo=utc).strftime("%Y-%m-%d"), 'to_date': datetime.utcnow().replace(tzinfo=utc).strftime("%Y-%m-%d") }) self.assertEqual(response.status_code, 200) request = self.factory.post( '/admin/dialer_cdr/voipcall/voip_daily_report/', data={ 'from_date': datetime.utcnow().replace(tzinfo=utc).strftime("%Y-%m-%d"), 'to_date': datetime.utcnow().replace(tzinfo=utc).strftime("%Y-%m-%d") }) request.user = self.user request.session = {} response = voipcall_search_admin_form_fun(request) self.assertTrue(response)
def test_admin_voipcall_view_report(self): """Test Function to check admin voipcall list""" response = self.client.get('/admin/dialer_cdr/voipcall/voip_daily_report/') self.failUnlessEqual(response.status_code, 200) response = self.client.post('/admin/dialer_cdr/voipcall/voip_daily_report/', data={'from_date': datetime.utcnow().replace(tzinfo=utc).strftime("%Y-%m-%d"), 'to_date': datetime.utcnow().replace(tzinfo=utc).strftime("%Y-%m-%d")}) self.assertEqual(response.status_code, 200) request = self.factory.post( '/admin/dialer_cdr/voipcall/voip_daily_report/', data={'from_date': datetime.utcnow().replace(tzinfo=utc).strftime("%Y-%m-%d"), 'to_date': datetime.utcnow().replace(tzinfo=utc).strftime("%Y-%m-%d")}) request.user = self.user request.session = {} response = voipcall_search_admin_form_fun(request) self.assertTrue(response)
def changelist_view(self, request, extra_context=None): """ Override changelist_view method of django-admin for search parameters **Attributes**: * ``form`` - VoipSearchForm * ``template`` - admin/dialer_cdr/voipcall/change_list.html **Logic Description**: * VoIP report Record Listing with search option & Daily Call Report search Parameters: by date, by status and by billed. """ opts = VoIPCall._meta query_string = '' form = VoipSearchForm(request.user) if request.method == 'POST': # Session variable get record set with searched option into export file request.session['admin_voipcall_record_kwargs'] = voipcall_record_common_fun(request) query_string = voipcall_search_admin_form_fun(request) return HttpResponseRedirect("/admin/%s/%s/?%s" % (opts.app_label, opts.object_name.lower(), query_string)) else: status = '' from_date = '' to_date = '' campaign_id = '' from_date = getvar(request, 'starting_date__gte') to_date = getvar(request, 'starting_date__lte')[0:10] status = getvar(request, 'disposition__exact') campaign_id = getvar(request, 'callrequest__campaign_id') form = VoipSearchForm(request.user, initial={'status': status, 'from_date': from_date, 'to_date': to_date, 'campaign_id': campaign_id}) ChangeList = self.get_changelist(request) try: cl = ChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_max_show_all, self.list_editable, self) except IncorrectLookupParameters: if ERROR_FLAG in request.GET.keys(): return render_to_response('admin/invalid_setup.html', {'title': _('Database error')}) return HttpResponseRedirect('%s?%s=1' % (request.path, ERROR_FLAG)) if request.META['QUERY_STRING'] == '': # Default # Session variable get record set with searched option into export file request.session['admin_voipcall_record_kwargs'] = voipcall_record_common_fun(request) query_string = voipcall_search_admin_form_fun(request) return HttpResponseRedirect("/admin/%s/%s/?%s" % (opts.app_label, opts.object_name.lower(), query_string)) cl.formset = None selection_note_all = ungettext('%(total_count)s selected', 'All %(total_count)s selected', cl.result_count) ctx = { 'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)}, 'selection_note_all': selection_note_all % {'total_count': cl.result_count}, 'cl': cl, 'form': form, 'opts': opts, 'model_name': opts.object_name.lower(), 'app_label': APP_LABEL, 'title': _('call report'), } return super(VoIPCallAdmin, self).changelist_view(request, extra_context=ctx)
def changelist_view(self, request, extra_context=None): """Override changelist_view method of django-admin for search parameters **Attributes**: * ``form`` - VoipSearchForm * ``template`` - admin/dialer_cdr/voipcall/change_list.html **Logic Description**: * VoIP report Record Listing with search option & Daily Call Report search Parameters: by date, by status and by billed. """ opts = VoIPCall._meta app_label = opts.app_label query_string = '' form = VoipSearchForm() if request.method == 'POST': query_string = voipcall_search_admin_form_fun(request) return HttpResponseRedirect("/admin/" + opts.app_label + "/" + \ opts.object_name.lower() + "/?" + query_string) else: status = '' from_date = '' to_date = '' if request.GET.get('starting_date__gte'): from_date = variable_value(request, 'starting_date__gte') if request.GET.get('starting_date__lte'): to_date = variable_value(request, 'starting_date__lte')[0:10] if request.GET.get('disposition__exact'): status = variable_value(request, 'disposition__exact') form = VoipSearchForm(initial={ 'status': status, 'from_date': from_date, 'to_date': to_date }) ChangeList = self.get_changelist(request) try: cl = ChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_max_show_all, self.list_editable, self) except IncorrectLookupParameters: if ERROR_FLAG in request.GET.keys(): return render_to_response('admin/invalid_setup.html', {'title': _('Database error')}) return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1') kwargs = {} if request.META['QUERY_STRING'] == '': tday = datetime.today() kwargs['starting_date__gte'] = datetime(tday.year, tday.month, tday.day, 0, 0, 0, 0) cl.root_query_set.filter(**kwargs) formset = cl.formset = None # Session variable is used to get record set with searched option into export file request.session['admin_voipcall_record_qs'] = cl.root_query_set selection_note_all = ungettext('%(total_count)s selected', 'All %(total_count)s selected', cl.result_count) ctx = { 'selection_note': _('0 of %(cnt)s selected') % { 'cnt': len(cl.result_list) }, 'selection_note_all': selection_note_all % { 'total_count': cl.result_count }, 'cl': cl, 'form': form, 'opts': opts, 'model_name': opts.object_name.lower(), 'app_label': _('VoIP Report'), 'title': _('Call Report'), } return super(VoIPCallAdmin, self)\ .changelist_view(request, extra_context=ctx)
def changelist_view(self, request, extra_context=None): """Override changelist_view method of django-admin for search parameters **Attributes**: * ``form`` - VoipSearchForm * ``template`` - admin/dialer_cdr/voipcall/change_list.html **Logic Description**: * VoIP report Record Listing with search option & Daily Call Report search Parameters: by date, by status and by billed. """ opts = VoIPCall._meta app_label = opts.app_label query_string = '' form = VoipSearchForm() if request.method == 'POST': query_string = voipcall_search_admin_form_fun(request) return HttpResponseRedirect("/admin/"+opts.app_label+"/"+opts.object_name.lower()+"/?"+query_string) else: status = '' from_date = '' to_date = '' if request.GET.get('starting_date__gte'): from_date = variable_value(request, 'starting_date__gte') if request.GET.get('starting_date__lte'): to_date = variable_value(request, 'starting_date__lte')[0:10] if request.GET.get('disposition__exact'): status = variable_value(request, 'disposition__exact') form = VoipSearchForm(initial={'status': status, 'from_date': from_date, 'to_date': to_date}) ChangeList = self.get_changelist(request) try: cl = ChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_max_show_all, self.list_editable, self) except IncorrectLookupParameters: if ERROR_FLAG in request.GET.keys(): return render_to_response('admin/invalid_setup.html', {'title': _('Database error')}) return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1') kwargs = {} if request.META['QUERY_STRING'] == '': tday = datetime.today() kwargs['starting_date__gte'] = datetime(tday.year, tday.month, tday.day, 0, 0, 0, 0) cl.root_query_set.filter(**kwargs) formset = cl.formset = None # Session variable is used to get record set with searched option into export file request.session['admin_voipcall_record_qs'] = cl.root_query_set selection_note_all = ungettext('%(total_count)s selected', 'All %(total_count)s selected', cl.result_count) ctx = { 'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)}, 'selection_note_all': selection_note_all % {'total_count': cl.result_count}, 'cl': cl, 'form': form, 'opts': opts, 'model_name': opts.object_name.lower(), 'app_label': _('VoIP Report'), 'title': _('Call Report'), } return super(VoIPCallAdmin, self)\ .changelist_view(request, extra_context=ctx)
def changelist_view(self, request, extra_context=None): """ Override changelist_view method of django-admin for search parameters **Attributes**: * ``form`` - AdminVoipSearchForm * ``template`` - admin/dialer_cdr/voipcall/change_list.html **Logic Description**: * VoIP report Record Listing with search option & Daily Call Report search Parameters: by date, by status and by billed. """ opts = VoIPCall._meta query_string = '' form = AdminVoipSearchForm() if request.method == 'POST': # Session variable get record set with searched option into export file request.session['admin_voipcall_record_kwargs'] = voipcall_record_common_fun(request) query_string = voipcall_search_admin_form_fun(request) return HttpResponseRedirect("/admin/%s/%s/?%s" % (opts.app_label, opts.object_name.lower(), query_string)) else: disposition = '' from_date = '' to_date = '' campaign_id = '' leg_type = '' from_date = getvar(request, 'starting_date__gte') to_date = getvar(request, 'starting_date__lte')[0:10] disposition = getvar(request, 'disposition__exact') campaign_id = getvar(request, 'callrequest__campaign_id') leg_type = getvar(request, 'leg_type__exact') form = AdminVoipSearchForm(initial={'disposition': disposition, 'from_date': from_date, 'to_date': to_date, 'campaign_id': campaign_id, 'leg_type': leg_type}) ChangeList = self.get_changelist(request) try: cl = ChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_max_show_all, self.list_editable, self) except IncorrectLookupParameters: if ERROR_FLAG in request.GET.keys(): return render_to_response('admin/invalid_setup.html', {'title': _('Database error')}) return HttpResponseRedirect('%s?%s=1' % (request.path, ERROR_FLAG)) if request.META['QUERY_STRING'] == '': # Default # Session variable get record set with searched option into export file request.session['admin_voipcall_record_kwargs'] = voipcall_record_common_fun(request) query_string = voipcall_search_admin_form_fun(request) return HttpResponseRedirect("/admin/%s/%s/?%s" % (opts.app_label, opts.object_name.lower(), query_string)) cl.formset = None selection_note_all = ungettext('%(total_count)s selected', 'All %(total_count)s selected', cl.result_count) ctx = { 'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)}, 'selection_note_all': selection_note_all % {'total_count': cl.result_count}, 'cl': cl, 'form': form, 'opts': opts, 'model_name': opts.object_name.lower(), 'app_label': APP_LABEL, 'title': _('call report'), } return super(VoIPCallAdmin, self).changelist_view(request, extra_context=ctx)
def changelist_view(self, request, extra_context=None): """ Override changelist_view method of django-admin for search parameters **Attributes**: * ``form`` - AdminVoipSearchForm * ``template`` - admin/dialer_cdr/voipcall/change_list.html **Logic Description**: * VoIP report Record Listing with search option & Daily Call Report search Parameters: by date, by status and by billed. """ opts = VoIPCall._meta query_string = "" form = AdminVoipSearchForm() if request.method == "POST": # Session variable get record set with searched option into export file request.session["admin_voipcall_record_kwargs"] = voipcall_record_common_fun(request) query_string = voipcall_search_admin_form_fun(request) return HttpResponseRedirect("/admin/%s/%s/?%s" % (opts.app_label, opts.object_name.lower(), query_string)) else: disposition = "" from_date = "" to_date = "" campaign_id = "" leg_type = "" from_date = getvar(request, "starting_date__gte") to_date = getvar(request, "starting_date__lte")[0:10] disposition = getvar(request, "disposition__exact") campaign_id = getvar(request, "callrequest__campaign_id") leg_type = getvar(request, "leg_type__exact") form = AdminVoipSearchForm( initial={ "disposition": disposition, "from_date": from_date, "to_date": to_date, "campaign_id": campaign_id, "leg_type": leg_type, } ) ChangeList = self.get_changelist(request) try: cl = ChangeList( request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_max_show_all, self.list_editable, self, ) except IncorrectLookupParameters: if ERROR_FLAG in request.GET.keys(): return render_to_response("admin/invalid_setup.html", {"title": _("Database error")}) return HttpResponseRedirect("%s?%s=1" % (request.path, ERROR_FLAG)) if request.META["QUERY_STRING"] == "": # Default # Session variable get record set with searched option into export file request.session["admin_voipcall_record_kwargs"] = voipcall_record_common_fun(request) query_string = voipcall_search_admin_form_fun(request) return HttpResponseRedirect("/admin/%s/%s/?%s" % (opts.app_label, opts.object_name.lower(), query_string)) cl.formset = None selection_note_all = ungettext("%(total_count)s selected", "All %(total_count)s selected", cl.result_count) ctx = { "selection_note": _("0 of %(cnt)s selected") % {"cnt": len(cl.result_list)}, "selection_note_all": selection_note_all % {"total_count": cl.result_count}, "cl": cl, "form": form, "opts": opts, "model_name": opts.object_name.lower(), "app_label": APP_LABEL, "title": _("call report"), } return super(VoIPCallAdmin, self).changelist_view(request, extra_context=ctx)