def soh_summary_task(): """ 6th business day of the month @ 3pm Tanzania time """ now = datetime.utcnow() sixth_business_day = get_business_day_of_month(month=now.month, year=now.year, count=6) if now.day != sixth_business_day.day: return for domain in ILSGatewayConfig.get_all_enabled_domains(): for user in get_district_people(domain): send_translated_message(user, REMINDER_MONTHLY_SOH_SUMMARY, **construct_soh_summary(user.location))
def soh_thank_you_task(): """ Last business day before the 20th at 4:00 PM Tanzania time """ now = datetime.utcnow() business_day = get_business_day_of_month_before(month=now.month, year=now.year, day=20) if now.day != business_day.day: return last_month = datetime(now.year, now.month, 1) - timedelta(days=1) for domain in ILSGatewayConfig.get_all_enabled_domains(): SOHThankYouReminder(domain=domain, date=last_month).send()
def delivery_summary_task(): """ last business day of month 3pm Tanzania time """ now = datetime.utcnow() last_business_day = get_business_day_of_month(month=now.month, year=now.year, count=-1) if now.day != last_business_day.day: return for domain in ILSGatewayConfig.get_all_enabled_domains(): for user in get_district_people(domain): send_translated_message( user, REMINDER_MONTHLY_DELIVERY_SUMMARY, **construct_delivery_summary(user.location) )
def randr_summary_task(): """ on 17th day of month or before if it's not a business day @ 3pm Tanzania time """ now = datetime.utcnow() business_day = get_business_day_of_month_before(month=now.month, year=now.year, day=17) if now.day != business_day.day: return for domain in ILSGatewayConfig.get_all_enabled_domains(): for user in get_district_people(domain): send_translated_message( user, REMINDER_MONTHLY_RANDR_SUMMARY, **construct_randr_summary(user.location) )
def _get_logistics_domains(self): from custom.ewsghana.models import EWSGhanaConfig return ILSGatewayConfig.get_all_enabled_domains() + EWSGhanaConfig.get_all_enabled_domains()
def send_for_all_domains(date, reminder_class, **kwargs): for domain in ILSGatewayConfig.get_all_enabled_domains(): reminder_class(domain=domain, date=date, **kwargs).send()
def send_for_all_domains(date, fn, **kwargs): for domain in ILSGatewayConfig.get_all_enabled_domains(): fn(domain, date, **kwargs)
def test_domains_report_run_periodic_task(): for domain in ILSGatewayConfig.get_all_enabled_domains(): if domain == 'ils-gateway': # skip live domain continue report_run(domain)
def _get_logistics_domains(self): from custom.ewsghana.models import EWSGhanaConfig return ILSGatewayConfig.get_all_enabled_domains( ) + EWSGhanaConfig.get_all_enabled_domains()
def _get_logistics_domains(self): return ILSGatewayConfig.get_all_enabled_domains() + EWSGhanaConfig.get_all_enabled_domains()