Ejemplo n.º 1
0
def notify_weekly_payment_report_slack():
    pdf_contents = weekly_payment_report(render_format='pdf')

    today = datetime.datetime.utcnow()
    filename = 'weekly_payment_report_{}_{}__{}.pdf'.format(
        today.isocalendar()[1], today.year, today.strftime('%d%b%y'))

    reports_dir = os.path.join(MEDIA_ROOT, 'reports')

    if not os.path.exists(reports_dir):
        os.makedirs(reports_dir)

    filepath = os.path.join(reports_dir, filename)

    pdf_file = open(filepath, 'w')
    pdf_file.write(pdf_contents)
    pdf_file.close()

    slack_utils.upload_file(
        SLACK_STAFF_TOKEN,
        SLACK_STAFF_REPORTS_CHANNEL,
        filepath,
        filename=filename,
        initial_comment='<!channel> *Payment updates* for *week {}*'.format(
            today.isocalendar()[1]))
Ejemplo n.º 2
0
def notify_weekly_payment_report_slack():
    pdf_contents = weekly_payment_report(render_format='pdf')

    today = datetime.datetime.utcnow()
    filename = 'weekly_payment_report_{}_{}__{}.pdf'.format(
        today.isocalendar()[1], today.year, today.strftime('%d%b%y')
    )

    reports_dir = os.path.join(MEDIA_ROOT, 'reports')

    if not os.path.exists(reports_dir):
        os.makedirs(reports_dir)

    filepath = os.path.join(reports_dir, filename)

    pdf_file = open(filepath, 'w')
    pdf_file.write(pdf_contents)
    pdf_file.close()

    slack_utils.upload_file(
        SLACK_STAFF_TOKEN, SLACK_STAFF_REPORTS_CHANNEL, filepath, filename=filename,
        initial_comment='<!channel> *Payment updates* for *week {}*'.format(today.isocalendar()[1])
    )