This repository was archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtasks.py
125 lines (94 loc) · 4.1 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
"""
Invoke tasks to be run from the command line.
"""
import os
from invoke import task
from eptools import talks, people
from eptools.gspread_utils import get_api_key_file
from eptools.config import (
conference,
sponsors_billing_worksheet,
finaid_submissions_worksheet
)
@task
def sponsor_agreement(ctx, company_name, output_dir, template_file="", api_key_file=""):
""" Call docstamp to produce a sponsor agreement for `company_name`
using `template_file`. The output will be saved in `output_dir`.
Parameters
----------
company_name: str
Can be a substring of the company name in the spreadsheet.
template_file: str
output_dir: str
api_key_file: str
The path to the Google Credentials json file.
If left empty will try to look for its path in the config.py file.
"""
from eptools.sponsors import (
get_sponsor,
get_sponsors_ws_data,
create_sponsor_agreement,
contract_template,
company_name_column,
)
if not template_file:
template_file = contract_template
if not api_key_file:
api_key_file = get_api_key_file()
output_dir = os.path.abspath(output_dir)
responses = get_sponsors_ws_data(api_key_file=api_key_file, doc_key=sponsors_billing_worksheet[0])
try:
sponsor_data = get_sponsor(sponsor_name=company_name, sponsors=responses, col_name=company_name_column)
except Exception:
raise KeyError("Could not find data for sponsor {}.".format(company_name))
else:
fpath = create_sponsor_agreement(sponsor_data, template_file=template_file, output_dir=output_dir)
print("Created {}.".format(fpath))
@task
def finaid_receipt(ctx, applicant_name, output_dir, template_file="", api_key_file=""):
""" Call docstamp to produce a financial aid receipt
for `applicant_name` using `template_file`.
The output will be saved in `output_dir`.
Parameters
----------
applicant_name: str
template_file: str
output_dir: str
api_key_file: str
Path to the Google credentials json file.
If left empty will try to look for its path in the config.py file.
"""
from eptools.finaid import get_finaid_ws_data, get_applicant, receipt_template_spa, create_receipt
if not template_file:
template_file = receipt_template_spa
if not api_key_file:
api_key_file = get_api_key_file()
output_dir = os.path.abspath(output_dir)
responses = get_finaid_ws_data(api_key_file=api_key_file, doc_key=finaid_submissions_worksheet[0])
try:
applicant_data = get_applicant(applicant_name=applicant_name, submissions=responses, col_name="full_name")
except Exception:
raise KeyError("Could not find data for applicant {}.".format(applicant_name))
else:
fpath = create_receipt(applicant_data, template_file=template_file, output_dir=output_dir)
print("Created {}.".format(fpath))
@task
def fetch_ticket_profiles(ctx, out_filepath, conf=conference, status="all", nondups=False, raise_=False, ticket_id=""):
""" Create a json file with the all the tickets of the conference.
make_option('--status',
choices=['all', 'complete', 'incomplete'],
help='Status of the orders related with the tickets.',
make_option('--nondups',
help='If enables will remove the tickets with '
'same owner/email.',
make_option('--raise',
help='If enabled will raise any error that it may find.',
make_option('--ticket-id',
help='Will output the profile of the given ticket only.',
"""
return people.fetch_files(out_filepath, conf=conf, status=status, nondups=nondups, raise_=raise_, ticket_id=ticket_id)
@task
def fetch_talks_json(ctx, out_filepath="", status="proposed", conf=conference, host="europython.io", with_votes=False):
""" Return the talks in a json format. `status` choices: ['accepted', 'proposed']
"""
return talks.fetch_talks_json(out_filepath=out_filepath, status=status, conf=conf, host=host, with_votes=with_votes)