예제 #1
0
    configurable  sitewide settings. Its better to store in db table

    """
    attribute=models.CharField(max_length=50,null=False)
    value=models.CharField(default='',max_length=50,null=True)
    description= models.TextField(null=True)
    user=models.ForeignKey(User,null=True,blank=True)


    class Meta:
        app_label = 'ureport'


class AutoregGroupRules(models.Model):
    group=models.ForeignKey(Group)
    values=models.TextField(default=None)
    class Meta:
        app_label = 'ureport'






from .litseners import  autoreg,check_conn,update_latest_poll,ussd_poll,add_to_poll

script_progress_was_completed.connect(autoreg, weak=False)
post_save.connect(check_conn, sender=Connection, weak=False)
post_save.connect(update_latest_poll, sender=Poll, weak=False)
ussd_complete.connect(ussd_poll, weak=False)
#post_save.connect(add_to_poll, sender=Blacklist, weak=False)
예제 #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)
예제 #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)
예제 #4
0
    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'


class MessageLog(Message):
    class Meta:
        proxy = True
        verbose_name = 'Message'
        verbose_name_plural = '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)
예제 #5
0
                    poll.responses.exclude(contact__emisreporter__schools=None).filter(date__lte = now).\
                        select_related().values_list('poll__name', 'contact__emisreporter__schools__pk', 'date'))

        # populate the res_dict with school_pk and sent_at values as a list of lists
        for poll_name, school_pk, sent_at in all_responses:
            resp_dict[poll_name].append([school_pk, sent_at])

        for poll_name in resp_dict.keys():
            try:
                poll = Poll.objects.get(name=poll_name)
                other_responses = resp_dict[poll_name]
                for school_pk, sent_at in other_responses:
                    school = School.objects.select_related().get(pk=school_pk)
                    model.objects.create(poll=poll,
                                         school=school,
                                         sent_at=sent_at)
            except ObjectDoesNotExist:
                pass
            return


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

script_progress_was_completed.connect(edtrac_autoreg, weak=False)
script_progress_was_completed.connect(edtrac_reschedule_script, weak=False)
script_progress.connect(edtrac_autoreg_transition, weak=False)
script_progress.connect(edtrac_attendance_script_transition, weak=False)
예제 #6
0
        self.key = self.key.replace(" ", "_")
        super(PollAttribute, self).save()

    def make_native(self, default):
        if self.key_type == 'bool':
            return True if default.lower() == 'true' else False
        elif self.key_type == 'int':
            return int(default)
        else:
            return default


class SentToMtrac(models.Model):
    message = models.OneToOneField(Message)
    sent_on = models.DateTimeField(auto_now_add=True)

    class Meta:
        app_label = 'ureport'


from .litseners import autoreg, check_conn, update_latest_poll, ussd_poll, add_to_poll

script_progress_was_completed.connect(autoreg, weak=False)
post_save.connect(check_conn, sender=Connection, weak=False)
ussd_complete.connect(ussd_poll, weak=False)

if settings.USSD_ENABLED:
    post_save.connect(update_latest_poll, sender=Poll, weak=False)

#post_save.connect(add_to_poll, sender=Blacklist, weak=False)
        return msg
    
    def overdue(self):
        return self.date_uploaded + datetime.timedelta(seconds=ScriptStep.objects.filter(script__slug='consingee')[0].start_offset) >= datetime.datetime.now()

    def __unicode__(self):
        return '%s'%self.waybill
    
class DeliveryBackLog(models.Model):
    delivery=models.ForeignKey(Delivery)

def schedule_deliveries(sender,instance, **kwargs):
    if DeliveryBackLog.objects.all().exists():
        delivery=DeliveryBackLog.objects.order_by(delivery__dateuploaded)[0]
        #delete from backlog
        DeliveryBackLog.objects.get(deliver=delivery).delete()
       
        if delivery.transporter:
            transporter_progress=ScriptProgress.objects.create(script=Script.objects.get(slug="transporter"),
                                              connection=delivery.transporter.default_connection)
        consignee_progress=ScriptProgress.objects.create(script=Script.objects.get(slug="consignee"),
                                              connection=delivery.consignee.default_connection)

        return True

script_progress_was_completed.connect(schedule_deliveries,sender=ScriptProgress)