def mk_notifiable_disease_alert(disease, alert_type, reporting_period, val, loc):
    notif = Notification(alert_type=alert_type)
    notif.uid = 'disease_%s_%s_%s' % (disease, reporting_period, loc.code)
    notif.text = '%d cases of %s reported in %s %s' % (val, disease, loc.name, loc.type.name)
    notif.url = None
    notif.originating_location = loc
    return notif
def notiftest1():
    for i in range(3):
        notif = Notification(alert_type='alerts._prototyping.TestAlertType')
        notif.uid = 'notif-%d' % i
        notif.text = 'This is alert %d' % i
        notif.url = 'http://google.com'
        yield notif
def notify():
    print 'notify'
    for i in xrange(3):
        notif = Notification(alert_type='thousand.example_notifications.DemoAlertType')
        notif.uid = 'notif-%d' % i
        notif.text = 'This is alert %d' % i
        notif.url = 'http://thousand-days.lobos.biz'
        yield notif
Beispiel #4
0
def mk_tagged_alert(user, comment):
    alert_type = 'aremind.notifications.tagged_in_note.TaggedInNoteNotificationType'

    notif = Notification(alert_type=alert_type)
    notif.uid = 'tagged_%s_%s' % (comment.id, user.username)
    notif.text = 'You have been tagged in a note by <strong>%s</strong>.' % comment.author
    notif.url = reverse('%s_report_single' % comment.program, kwargs={'id': comment.report.id})
    notif.data = json.dumps({'user_id': user.id})
    return notif
def mk_response_alert(user, report, reply, mode):
    alert_type = 'aremind.notifications.communicator_response.CommunicatorResponseNotificationType'

    notif = Notification(alert_type=alert_type)
    notif.uid = 'commreply_%s_%s' % (reply.id, user.username)
    if mode == 'sender':
        notif.text = 'A beneficiary has replied to an inquiry you sent them about a report'
    elif mode == 'tagged':
        notif.text = 'A beneficiary has replied to an inquiry about a report you were tagged on'
    elif mode == 'commenter':
        notif.text = 'A beneficiary has replied to an inquiry on a report that you\'ve left comments on'
    notif.url = reverse('fadama_report_single', kwargs={'id': report.id})
    notif.data = json.dumps({'user_id': user.id})
    return notif
def mk_notifiable_disease_alert2(disease, alert_type, reporting_period, loc, district_data):
    notif = Notification(alert_type=alert_type)
    rr = "%s_%s" % (reporting_period[0].date().strftime('%F'), reporting_period[0].strftime('%H:%M-') + reporting_period[1].strftime('%H:%M'))
    notif.uid = 'disease_%s_%s_%s' % (disease, rr, loc.code)
    txt = "Urgent - "
    has_cases = False
    for d in district_data['data'].values():
        if d['val'] > 0:
            has_cases = True
            txt += "%s at %s %s reported %s cases of %s" % (','.join(d['reporters']), d['name'], d['type'], d['val'], disease)
    if has_cases:
        notif.text = txt
        notif.sms_text = txt
    else: notif.text = ''
    notif.url = None
    notif.originating_location = loc
    return notif
def notiftest2():
    for i in range(2, 5):
        notif = Notification(alert_type='alerts._prototyping.TestAlertType')
        notif.uid = 'notif-%d' % i
        notif.text = 'This is alert %d' % i
        yield notif