def mail_birthday(api = None, id = None, links = True): api = api or logic.get_api() employee = api.get_employee(id) if id else api.self_employee() name = employee.get("full_name", None) working = employee.get("working", None) contact_information = employee.get("primary_contact_information", {}) email = contact_information.get("email", None) if not name: raise quorum.OperationalError("No name defined") if not email: raise quorum.OperationalError("No email defined") if not working == 1: raise quorum.OperationalError("No longer working") quorum.debug("Sending birthday email to %s <%s>" % (name, email)) quorum.send_mail( subject = BIRTHDAY_SUBJECT[config.LOCALE], sender = config.SENDER_EMAIL, receivers = ["%s <%s>" % (name, email)], rich = "email/birthday.%s.html.tpl" % config.LOCALE, context = dict( settings = dict( logo = True, links = links ), base_url = config.BASE_URL, omnix_base_url = config.OMNI_URL, commission_rate = config.COMMISSION_RATE ) )
def mail_activity( api = None, id = None, year = None, month = None, validate = False, links = True ): api = api or logic.get_api() employee = api.get_employee(id) if id else api.self_employee() name = employee.get("full_name", None) working = employee.get("working", None) contact_information = employee.get("primary_contact_information", {}) email = contact_information.get("email", None) if not name: raise quorum.OperationalError("No name defined") if not email: raise quorum.OperationalError("No email defined") if not working == 1: raise quorum.OperationalError("No longer working") now = datetime.datetime.utcnow() now_s = now.strftime("%B %d %Y") operations,\ target_s,\ sales_total,\ sales_s,\ returns_s,\ _previous_month,\ _previous_year,\ _next_month,\ _next_year,\ _has_next = get_sales(api = api, id = id, year = year, month = month) if validate and not operations: return quorum.debug("Sending activity email to %s <%s>" % (name, email)) quorum.send_mail( subject = ACTIVITY_SUBJECT[config.LOCALE] % (target_s, now_s), sender = config.SENDER_EMAIL, receivers = ["%s <%s>" % (name, email)], rich = "email/activity.%s.html.tpl" % config.LOCALE, context = dict( settings = dict( logo = True, links = links ), target = target_s, operations = operations, sales_total = sales_total, sales_count = len(sales_s), returns_count = len(returns_s), base_url = config.BASE_URL, omnix_base_url = config.OMNI_URL, commission_rate = config.COMMISSION_RATE ) )
def mail_activity(api=None, id=None, year=None, month=None, validate=False, links=True): api = api or logic.get_api() employee = api.get_employee(id) if id else api.self_employee() name = employee.get("full_name", None) working = employee.get("working", None) contact_information = employee.get("primary_contact_information", {}) email = contact_information.get("email", None) if not name: raise quorum.OperationalError("No name defined") if not email: raise quorum.OperationalError("No email defined") if not working == 1: raise quorum.OperationalError("No longer working") now = datetime.datetime.utcnow() now_s = now.strftime("%B %d %Y") operations,\ target_s,\ sales_total,\ sales_s,\ returns_s,\ _previous_month,\ _previous_year,\ _next_month,\ _next_year,\ _has_next = get_sales(api = api, id = id, year = year, month = month) if validate and not operations: return quorum.debug("Sending activity email to %s <%s>" % (name, email)) quorum.send_mail(subject=ACTIVITY_SUBJECT[config.LOCALE] % (target_s, now_s), sender=config.SENDER_EMAIL, receivers=["%s <%s>" % (name, email)], rich="email/activity.%s.html.tpl" % config.LOCALE, context=dict(settings=dict(logo=True, links=links), target=target_s, operations=operations, sales_total=sales_total, sales_count=len(sales_s), returns_count=len(returns_s), base_url=config.BASE_URL, omnix_base_url=config.OMNI_URL, commission_rate=config.COMMISSION_RATE))
def mail_birthday(api=None, id=None, links=True): api = api or logic.get_api() employee = api.get_employee(id) if id else api.self_employee() name = employee.get("full_name", None) working = employee.get("working", None) contact_information = employee.get("primary_contact_information", {}) email = contact_information.get("email", None) if not name: raise quorum.OperationalError("No name defined") if not email: raise quorum.OperationalError("No email defined") if not working == 1: raise quorum.OperationalError("No longer working") quorum.debug("Sending birthday email to %s <%s>" % (name, email)) quorum.send_mail(subject=BIRTHDAY_SUBJECT[config.LOCALE], sender=config.SENDER_EMAIL, receivers=["%s <%s>" % (name, email)], rich=config.BIRTHDAY_TEMPLATE, context=dict(settings=dict(logo=True, links=links), base_url=config.BASE_URL, omnix_base_url=config.OMNI_URL, commission_rate=config.COMMISSION_RATE))