Esempio n. 1
0
def send_summary_delinquent_to_super(router, recipient, context):
    """ SMS document 2: second set 
    Send all supervisors a summary of delinquent chv's
    """
    logging.debug("Running brac sms send_summary_delinquent_to_super")
    usernames = [chv.chw_username for chv in context['delinquent_reporterprofiles']]
    if usernames is None or len(usernames)==0:
        recipient.send_message(router, _t(_('No delinquents found for delinquent alert'),recipient.language))
    response = ", ".join(usernames)
    response = response + _t( _(" has not sent any forms for 2 or more days. " + \
               "Please follow up to determine the problem."), recipient.language)
    recipient.send_message(router, response)
Esempio n. 2
0
def send_summary_activity_to_reporter(router, recipient, context ):
    """ SMS document 1: third set 
    Messages all chv's with a summary of activity from their group
    """
    logging.debug("Running brac sms send_summary_activity_to_reporter")
    response = []
    for chv in context['group_members']:
        response.append( _t( _("%(username)s submitted %(count)s forms"), 
                             recipient.language ) % 
                             { 'username':chv.chw_username, 'count':chv.forms_this_week } )
    response = _t(_("Forms submitted: "), recipient.language) + ", ".join(response)
    recipient.send_message(router, response)
Esempio n. 3
0
    def test_sms(self):
        # this gets cleaned up once rapidsms unit tests are fixed
        init()
        self.assertEquals( _t("You said: %(message)s"), "You said: %(message)s" )

        # this gets cleaned up once rapidsms unit tests are fixed
        init('fr', [ ['en','English'],['fr','Francais'],['de','Deutsche'] ])
        self.assertEquals( _t("You said: %(message)s", 'en'), "You said: %(message)s" )
        self.assertEquals( _t("You said: %(message)s", 'fr'), "Vous avez dit: %(message)s" )
        self.assertEquals( _t("You said: %(message)s", 'de'), "Ni Dichte: %(message)s" )
        # for unknown language codes, revert to default translator
        self.assertEquals( _t("You said: %(message)s", 'ru' ), "Vous avez dit: %(message)s" )
Esempio n. 4
0
    def test_sms(self):
        # this gets cleaned up once rapidsms unit tests are fixed
        init()
        self.assertEquals(_t("You said: %(message)s"), "You said: %(message)s")

        # this gets cleaned up once rapidsms unit tests are fixed
        init("fr", [["en", "English"], ["fr", "Francais"], ["de", "Deutsche"]])
        self.assertEquals(_t("You said: %(message)s", "en"), "You said: %(message)s")
        self.assertEquals(_t("You said: %(message)s", "fr"), "Vous avez dit: %(message)s")
        self.assertEquals(_t("You said: %(message)s", "de"), "Ni Dichte: %(message)s")
        # for unknown language codes, revert to default translator
        self.assertEquals(_t("You said: %(message)s", "ru"), "Vous avez dit: %(message)s")
Esempio n. 5
0
    def test_sms(self):
        # this gets cleaned up once rapidsms unit tests are fixed
        init()
        self.assertEquals(_t("You said: %(message)s"), "You said: %(message)s")

        # this gets cleaned up once rapidsms unit tests are fixed
        init('fr', [['en', 'English'], ['fr', 'Francais'], ['de', 'Deutsche']])
        self.assertEquals(_t("You said: %(message)s", 'en'),
                          "You said: %(message)s")
        self.assertEquals(_t("You said: %(message)s", 'fr'),
                          "Vous avez dit: %(message)s")
        self.assertEquals(_t("You said: %(message)s", 'de'),
                          "Ni Dichte: %(message)s")
        # for unknown language codes, revert to default translator
        self.assertEquals(_t("You said: %(message)s", 'ru'),
                          "Vous avez dit: %(message)s")
Esempio n. 6
0
def alert_delinquent_reporter(router, recipient, context):
    """ SMS document 2: first set
    Send chv an alert when they haven't submitted anything in 2 days
    """
    logging.debug("Running brac sms alert_delinquent_reporter")
    last_seen = context['last_seen']
    # do not break this string without updating the translation files
    response = _t( _("Hi %(username)s, we haven't received any forms " +
                     "from you for the last %(count)s days. " + 
                     "Please send your forms."), 
                 recipient.language) % \
                 { 'username':recipient.chw_username, 'count':last_seen }
    recipient.send_message(router, response)
Esempio n. 7
0
def send_activity_to_super(router, recipient, context ):
    """ SMS document 1: second set 
        Messages supervisor with activity report for a given chv
    """
    logging.debug("Running brac sms send_activity_to_super")
    forms_submitted = context['count']
    chv = context['chv']
    if forms_submitted >= 45:
        response = _t( _("%(username)s has submitted %(count)s forms this week. "), recipient.language) + \
          _t( _("A work well done!"), recipient.language)
    elif forms_submitted >= 26:
        response = _t( _("%(username)s has submitted %(count)s forms this week. "), recipient.language) + \
          _t( _("Please remind her to submit all the forms every week"), recipient.language)
    else:
        response = _t( _("%(username)s has submitted %(count)s forms this week. "), recipient.language) + \
          _t( _("Please do follow up and ask what seems to be the problem."), recipient.language)
    response = response % { 'username':chv.chw_username, 'count':forms_submitted }
    recipient.send_message(router, response)
Esempio n. 8
0
def send_activity_to_reporter(router, recipient, username, forms_submitted ):
    """ SMS document 1: first set 
        Messages chv with a report of her activity in the past week
    """
    logging.debug("Running brac sms send_activity_to_reporter")
    if forms_submitted >= 45:
        greeting = _t( _("Congratulations for the work done %(username)s. "), 
                       recipient.language)
        instructions = ""
    elif forms_submitted >= 26:
        greeting = _t( _("Thank you %(username)s. "), recipient.language)
        instructions = _t( _("Please do your best to complete and send all the forms. "), 
                             recipient.language)
    else:
        greeting = _t( _("Sorry for the trouble %(username)s. "), recipient.language)
        instructions = _t( _("Please remember to fill and send the complete reports every week. "), 
                             recipient.language)
    info = _t(_("You have submitted %(count)s forms this week. "), recipient.language)
    response = greeting + info + instructions + \
               _t(_("If the number is incorrect, call Gayo 0786151272."), recipient.language)
    response = response % { 'username':username, 'count':forms_submitted }
    recipient.send_message(router, response)