Skip to content

Commit a23764f

Browse files
Merge pull request #1499 from learning-unlimited/fix-finaid-scripts
Fix finaid scripts to run properly.
2 parents 5e6ab4c + a2713c9 commit a23764f

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

esp/useful_scripts/finaid_approve.py

+13-20
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,45 @@
44
#
55
# Approves not-yet-approved requests where both answers are non-blank/None/whitespace
66
# and prints the email address of these users to the screen. Make sure to configure
7-
# PROGRAM_ID and PROGRAM_COST (in dollars) below.
7+
# PROGRAM_ID below.
88
#
99

1010
from script_setup import *
1111

1212
from esp.program.models import FinancialAidRequest
1313
from esp.accounting.models import FinancialAidGrant
1414

15+
import re
16+
1517

1618
# CONFIGURATION
17-
PROGRAM = "Splash! 2013"
18-
PROGRAM_COST = 40
19+
PROGRAM = "Splash 2014"
1920

2021

2122
# ITERATE & APPROVE REQUESTS
22-
reqs = FinancialAidRequest.objects.filter(done = False, program__name=PROGRAM).exclude(household_income = None, extra_explaination = None)
23-
24-
print reqs.count()
23+
reqs = FinancialAidRequest.objects.filter(program__name=PROGRAM)
2524

2625
print "New Approvals:"
2726
approved_any = False
2827

29-
emails = []
30-
errors = []
28+
def is_blank(x):
29+
return x is None or re.match(r'^(\s)*$', x)
3130

3231
for req in reqs:
33-
# if (req.household_income is None or re.match(r'^(\s)*$', req.household_income)) and \
34-
# (req.extra_explaination is None or re.match(r'(\s)*$', req.extra_explaination)):
35-
36-
# if req.household_income is None and req.extra_explaination is None:
37-
# continue
38-
39-
print req.user
32+
if is_blank(req.household_income) and is_blank(req.extra_explaination):
33+
continue
4034

41-
if req.financialaidgrant_set.all().count() != 0 : continue
35+
if req.approved:
36+
continue
4237

43-
e = req.user.email
44-
print e
45-
emails.append(e)
38+
print req.user.email
4639
try:
4740
f = FinancialAidGrant(request = req, percent = 100)
4841
f.save()
4942
req.done = True
5043
req.save()
5144
except:
52-
errors.append(req.user)
45+
print "Error on user %s" % req.user.id
5346
approved_any = True
5447

5548
if not approved_any:

esp/useful_scripts/finaid_autoapproved.py

+22-14
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,38 @@
22
#
33
# Display Auto-Approved Financial Aid Requests
44
#
5-
# Displays financial aid requests where the student has reported that they
6-
# receive free or reduced-price lunch so that these students can be
7-
# contacted after the initial email batch has been sent. Sorted by date,
8-
# descending. Make sure to update PROGRAM_ID before running.
9-
#
10-
# This script should be run from the manage.py shell
5+
# Displays financial aid requests that have been approved or autoapproved,
6+
# sorted by date, so that students can be emailed easily. Make sure to update
7+
# PROGRAM_ID before running.
118
#
129

1310
from script_setup import *
1411

1512
from esp.program.models import FinancialAidRequest
1613

1714
# CONFIGURATION
18-
PROGRAM = "Splash! 2013"
15+
PROGRAM = "Splash 2014"
1916

2017
# ITERATE & APPROVE REQUESTS
21-
reqs = FinancialAidRequest.objects.filter(program__name=PROGRAM).exclude(done=False)
18+
reqs = FinancialAidRequest.objects.filter(program__name=PROGRAM)
19+
tagged_reqs = {}
2220

2321
print "Auto-Approved Requests"
24-
if reqs.count() == 0:
25-
print " No requests"
26-
27-
last_date = None
28-
29-
print ", ".join([ req.user.email for req in reqs ])
3022

23+
for req in reqs:
24+
if not req.approved:
25+
continue
26+
date = min(x['timestamp'].date() for x in req.financialaidgrant_set.values())
27+
lst = tagged_reqs.get(date, [])
28+
lst.append(req)
29+
tagged_reqs[date] = lst
30+
31+
dates = tagged_reqs.keys()
32+
dates.sort()
33+
for date in dates:
34+
print " " + str(date) + ":"
35+
for req in tagged_reqs[date]:
36+
print " %s <%s>" % (req.user.name(), req.user.email)
3137

38+
if reqs.count() == 0:
39+
print " No requests"

0 commit comments

Comments
 (0)