Exemplo n.º 1
0
def process_reg_data(reg_num, pull=False):
    s = s3.S3(reg_num)
    dbh = db.DB()
    registree_set = dbh.get_registrees(reg_num)
    fn = build_doc(registree_set, pull)
    s.upload_pdf_file(fn)
    print(f"Processed payment details for reg num {registree_set.reg_num}. File: {fn}")
    pyperclip.copy(f"evince {fn} &")
def main(reg_num=None, registree_set=None, out_dir="."):
    if not registree_set:
        if reg_num is not None:
            dbh = db.DB()
            registree_set = dbh.get_registrees(reg_num)
        else:
            raise ValueError(
                "Either a reg num to look up or a RegistreeSet should be provided"
            )
    renderer = RegistreeSetRenderer(registree_set, out_dir)

    renderer.save()
    return renderer.fn
Exemplo n.º 3
0
def send_email(reg_num=None, registree_set=None, fn=None):
    if fn is None:
        s = s3.S3(reg_num)
        fn = s.download_pdf_reg_file(reg_num)

    if reg_num is not None:
        dbh = db.DB()
        registree_set = dbh.get_registrees(args.reg_num)
    elif registree_set is None:
        raise ValueError(
            "Either a reg num to look up or a RegistreeSet should be provided"
        )

    emails = "; ".join(set([r.email for r in registree_set.registrees if r.email]))

    if emails:
        pyperclip.copy(emails)
        print(f"To: addresses copied to clipboard: {emails}")
        input()
        pyperclip.copy(BCC)
        print(f"BCC: addresses copied to clipboard: {BCC}")
        input()
        subject = f"Registration for the 2021 MD410 Convention for {registree_set.registree_names}. Registration number: MDC{registree_set.reg_num:003}"
        pyperclip.copy(subject)
        print(f"Subject copied to clipboard: {subject}")
        input()
        kwds = locals()
        kwds.update(globals())
        body = BODY.format(**kwds)
        pyperclip.copy(body)
        print(body)
        input()
        pyperclip.copy(fn)
        print(os.path.abspath(fn))
    else:
        print("No email addresses supplied")
def process_reg_data(reg_num, rebuild=False, pull=False):
    s = s3.S3(reg_num)
    dbh = db.DB()
    if not rebuild:
        fn = s.download_data_file()

        registree_set = parse_data_file(fn)
        payees = dbh.get_2020_payees()
        print(f"Registrees: {registree_set.registree_names}")
        print(
            "Should any of the below payments from 2020 be applied to this registration?"
        )
        for (r, (name, amt)) in payees.items():
            print(f"{r:003}: {name}: R{amt}")
        print()
        previously_paid = 0
        while True:
            payee_reg = input("Applicable reg num: ")
            if not payee_reg:
                break
            previously_paid += payees[int(payee_reg)][-1]
        if previously_paid:
            registree_set.payments = [
                db.Payment(date(year=2020, month=5, day=1), previously_paid)
            ]
            registree_set.process_payments()
        dbh.save_registree_set(registree_set)

    else:
        registree_set = dbh.get_registrees(reg_num)
    fn = build_doc(registree_set, pull)
    s.upload_pdf_file(fn)
    print(
        f"{'re' if rebuild else ''}processed reg num {registree_set.reg_num}. File: {fn}"
    )
    pyperclip.copy(f"evince {fn} &")