Esempio n. 1
0
    def save(self, *args, **kwargs):
        if self.values:
            self.rule_regex = self.get_regex()
        super(AutoregGroupRules, self).save()


    class Meta:
        app_label = 'ureport'


from .litseners import autoreg, update_latest_poll, ussd_poll, add_poll_to_blacklist, add_poll_recipients_to_blacklist

script_progress_was_completed.connect(autoreg, weak=False)
post_save.connect(update_latest_poll, sender=Poll, weak=False)
ussd_complete.connect(ussd_poll, weak=False)
poll_started.connect(add_poll_to_blacklist, weak=False)
poll_started.connect(add_poll_recipients_to_blacklist, weak=False)

class UPoll(Poll):
    def _get_set_attr(self):
        values = self.pollattributevalue_set.all()
        key_value = {}
        for value in values:
            try:
                key_value[value.get_key()] = value.get_value()
            except PollAttribute.DoesNotExist:
                pass
        return key_value

    def __init__(self, *args, **kwargs):
        super(UPoll, self).__init__(*args, **kwargs)
Esempio n. 2
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)
Esempio n. 3
0
    def save(self, *args, **kwargs):
        if self.values:
            self.rule_regex = self.get_regex()
        super(AutoregGroupRules, self).save()

    class Meta:
        app_label = 'ureport'


from .litseners import autoreg, update_latest_poll, ussd_poll, add_poll_to_blacklist, add_poll_recipients_to_blacklist

script_progress_was_completed.connect(autoreg, weak=False)
post_save.connect(update_latest_poll, sender=Poll, weak=False)
ussd_complete.connect(ussd_poll, weak=False)
poll_started.connect(add_poll_to_blacklist, weak=False)
poll_started.connect(add_poll_recipients_to_blacklist, weak=False)


class UPoll(Poll):
    def _get_set_attr(self):
        values = self.pollattributevalue_set.all()
        key_value = {}
        for value in values:
            try:
                key_value[value.get_key()] = value.get_value()
            except PollAttribute.DoesNotExist:
                pass
        return key_value

    def __init__(self, *args, **kwargs):