Пример #1
0
    def render_POST(self, request):
        receipts = utils.parse_receipts_xml(request.content.read())
        for receipt in receipts:
            self.callback(receipt)

        request.setResponseCode(http.OK)
        return ''
Пример #2
0
    def render_POST(self, request):
        content = get_receipts_xml(request.content.read())
        receipts = utils.parse_receipts_xml(content)
        for receipt in receipts:
            self.callback(receipt)

        request.setResponseCode(http.OK)
        return ''
Пример #3
0
    def create(self, request):
        receipts = parse_receipts_xml(request.raw_post_data)
        success, fail = [], []
        for receipt in receipts:
            try:
                # internally we store MSISDNs without a leading plus,
                # strip that from the msisdn
                sms = SentSMS.objects.get(
                    transport_name="Opera",
                    transport_msg_id=receipt.reference,
                    to_msisdn=receipt.msisdn.replace("+", ""))
                sms.transport_status = receipt.status
                sms.delivery_timestamp = datetime.strptime(receipt.timestamp,
                                                        OPERA_TIMESTAMP_FORMAT)
                sms.save()

                signals.sms_receipt.send(sender=SentSMS, instance=sms,
                                         pk=sms.pk, receipt=receipt._asdict())
                success.append(receipt)
            except SentSMS.DoesNotExist, error:
                logging.error(error)
                fail.append(receipt)