Beispiel #1
0
def message_log_report(request):
    show_dates = True

    datespan = request.datespan
    domains = Domain.get_all()
    for dom in domains:
        dom.sms_incoming = SMSLog.count_incoming_by_domain(dom.name, datespan.startdate_param, datespan.enddate_param)
        dom.sms_outgoing = SMSLog.count_outgoing_by_domain(dom.name, datespan.startdate_param, datespan.enddate_param)
        dom.sms_total = SMSLog.count_by_domain(dom.name, datespan.startdate_param, datespan.enddate_param)

    context = get_hqadmin_base_context(request)

    headers = DataTablesHeader(
        DataTablesColumn("Domain"),
        DataTablesColumn("Incoming Messages", sort_type=DTSortType.NUMERIC),
        DataTablesColumn("Outgoing Messages", sort_type=DTSortType.NUMERIC),
        DataTablesColumn("Total Messages", sort_type=DTSortType.NUMERIC),
    )
    context["headers"] = headers
    context["aoColumns"] = headers.render_aoColumns

    context.update({"domains": domains, "show_dates": show_dates, "datespan": datespan})

    context["layout_flush_content"] = True
    return render(request, "hqadmin/message_log_report.html", context)
Beispiel #2
0
def message_log_report(request):
    show_dates = True

    datespan = request.datespan
    domains = Domain.get_all()
    for dom in domains:
        dom.sms_incoming = SMSLog.count_incoming_by_domain(
            dom.name, datespan.startdate_param, datespan.enddate_param)
        dom.sms_outgoing = SMSLog.count_outgoing_by_domain(
            dom.name, datespan.startdate_param, datespan.enddate_param)
        dom.sms_total = SMSLog.count_by_domain(dom.name,
                                               datespan.startdate_param,
                                               datespan.enddate_param)

    context = get_hqadmin_base_context(request)

    headers = DataTablesHeader(
        DataTablesColumn("Domain"),
        DataTablesColumn("Incoming Messages", sort_type=DTSortType.NUMERIC),
        DataTablesColumn("Outgoing Messages", sort_type=DTSortType.NUMERIC),
        DataTablesColumn("Total Messages", sort_type=DTSortType.NUMERIC))
    context["headers"] = headers
    context["aoColumns"] = headers.render_aoColumns

    context.update({
        "domains": domains,
        "show_dates": show_dates,
        "datespan": datespan
    })

    context['layout_flush_content'] = True
    return render(request, "hqadmin/message_log_report.html", context)
 def handle(self, *args, **options):
     for domain in Domain.get_all():
         count = (SMSLog.count_by_domain(domain.name) +
             CallLog.count_by_domain(domain.name))
         if count > 0:
             if not domain.send_to_duplicated_case_numbers:
                 # if not True, explicitly set to False
                 print "Setting %s to False" % domain.name
                 domain.send_to_duplicated_case_numbers = False
                 domain.save()
         else:
             print "Setting %s to True" % domain.name
             domain.send_to_duplicated_case_numbers = True
             domain.save()
 def handle(self, *args, **options):
     for domain in Domain.get_all():
         count = (SMSLog.count_by_domain(domain.name) +
                  CallLog.count_by_domain(domain.name))
         if count > 0:
             if not domain.send_to_duplicated_case_numbers:
                 # if not True, explicitly set to False
                 print "Setting %s to False" % domain.name
                 domain.send_to_duplicated_case_numbers = False
                 domain.save()
         else:
             print "Setting %s to True" % domain.name
             domain.send_to_duplicated_case_numbers = True
             domain.save()
 def testPostToIncomingAscii(self):
     fake_post = {InboundParams.SENDER: str(self.number),
                  InboundParams.MESSAGE: self.message_ascii,
                  InboundParams.TIMESTAMP: datetime.now().strftime(DATE_FORMAT),
                  InboundParams.DCS: self.dcs,
                  InboundParams.UDHI: '0'}
     client = Client()
     response = client.post('/unicel/in/', fake_post)
     self.assertEqual(200, response.status_code)
     self.assertEqual(1, SMSLog.count_by_domain(self.domain))
     log = SMSLog.by_domain_dsc(self.domain).all()[0]
     self.assertEqual(self.message_ascii, log.text)
     self.assertEqual(INCOMING, log.direction)
     self.assertEqual(log.date.strftime(DATE_FORMAT),
                      fake_post[InboundParams.TIMESTAMP])