Beispiel #1
0
        messages.filter(status='P').filter(connection__in=bad_conns).update(status='C')

def log_bulk_process_info(poll, message):
    log.info("[bulk-process-poll-" + str(poll.pk) + "]" + message)

def bulk_process_poll(sender, **kwargs):
    log.info("[bulk_process_poll] sender=" + str(type(sender)) + " - toString " + str(sender))
    poll = sender
    bad_conns = Blacklist.objects.values_list('connection__pk', flat=True).distinct()
    log_bulk_process_info(poll, " found [%d] bad connections..." % len(bad_conns))
    log_bulk_process_info(poll, " setting status to Q for anything thats in Blacklisted.objects and has status P...")
    poll.messages.filter(status='P').exclude(connection__in=bad_conns).update(status='Q')
    log_bulk_process_info(poll, " ok. setting status to C for all the blacklisted connections...")
    poll.messages.filter(status='P').filter(connection__in=bad_conns).update(status='C')
    log_bulk_process_info(poll, "ok.")

def blacklist(sender, **kwargs):
    m = kwargs['instance']
    raw = kwargs['raw']
    if not raw and m.direction == 'O' and m.status == 'P':
        bad_conns = Blacklist.objects.values_list('connection__pk', flat=True).distinct()
        bad_conns = Connection.objects.filter(pk__in=bad_conns)
        if m.connection in bad_conns:
            m.status = 'C'
        else:
            m.status = 'Q'

mass_text_sent.connect(bulk_process, weak=False)
poll_started.connect(bulk_process_poll, weak=False)
#pre_save.connect(blacklist, sender=Message, weak=False)
Beispiel #2
0
    district = models.ForeignKey(Location, null=True, default=None, related_name='district_reports')
    categories = models.ManyToManyField(Category, related_name='reports')
    amount_freeform = models.TextField(null=True, blank=True)
    amount = models.DecimalField(decimal_places=2, max_digits=26, null=True)
    names = models.TextField(null=True, blank=True)

    @property
    def reference_number(self):
        return "SMS/%d/%d/%d" % (self.id, self.datetime.month, self.datetime.year)

    class Meta:
        verbose_name = 'Report'
        verbose_name_plural = 'Reports'

class Unprocessed(Message):
    class Meta:
        proxy = True
        verbose_name = 'Unprocessed Message'
        verbose_name_plural = 'Unprocessed Messages'

def bulk_process(sender, **kwargs):
    messages = kwargs['messages']
    status = kwargs['status']
    if status == 'P':
        messages.filter(status='P').update(status='Q')

mass_text_sent.connect(bulk_process, weak=False)
        
script_progress_was_completed.connect(handle_report, weak=False)
pre_save.connect(igreport_pre_save, sender=IGReport, weak=False)
Beispiel #3
0
            except IndexError:
                submission.response = "Thank you. Your data on %s has been received" % xform.keyword
        elif xform.keyword in other_keywords:
            submission.response = "Thank you. Your data on %s has been received" % xform.keyword
            submission.save()
    else:
        submission.response = "Thank you.  Your data on %s has been received" % xform.keyword
        submission.save()


def eliminate_duplicates(sender, **kwargs):
    messages = kwargs["messages"]
    messages.exclude(connection__backend__name="yo6200").update(status="C")


Poll.register_poll_type("date", "Date Response", parse_date_value, db_type=Attribute.TYPE_OBJECT)

XFormField.register_field_type("emisdate", "Date", parse_date, db_type=XFormField.TYPE_INT, xforms_type="integer")

XFormField.register_field_type("emisbool", "YesNo", parse_yesno, db_type=XFormField.TYPE_INT, xforms_type="integer")

XFormField.register_field_type(
    "fuzzynum", "Fuzzy Numbers (o/0/none)", parse_fuzzy_number, db_type=XFormField.TYPE_INT, xforms_type="integer"
)

script_progress_was_completed.connect(emis_autoreg, weak=False)
script_progress_was_completed.connect(emis_reschedule_script, weak=False)
script_progress.connect(emis_autoreg_transition, weak=False)
xform_received.connect(xform_received_handler, weak=False)
mass_text_sent.connect(eliminate_duplicates, weak=False)