Skip to content

Instantly share code, notes, and snippets.

@hkouns
Created December 6, 2015 08:05
Show Gist options
  • Save hkouns/e988675d78968b3dd8a8 to your computer and use it in GitHub Desktop.
Save hkouns/e988675d78968b3dd8a8 to your computer and use it in GitHub Desktop.
template = '''
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
th, td {
padding: 2px;
}
td {
border-style:dotted dotted dotted dotted;
}
</style>
</head>
<body>
<table width="1005">
<tbody>
<tr>
<th width="50">
<p>&nbsp;</p>
</th>
<th width="190">
<p>&nbsp;&nbsp;</p>
</th>
<th width="150">
<p>&nbsp;&nbsp;</p>
</th>
<th width="50">
<p>&nbsp;&nbsp;</p>
</th>
<th width="110">
<p align="center"><strong>Tithe</strong></p>
</th>
<th width="110">
<p align="center"><strong>Bldg Fund</strong></p>
</th>
<th colspan="3" width="438">
<p align="center"><strong>Other Funds </strong><em>(enter Fund Name)</em></p>
</th>
</tr>
<tr>
<th width="50">
<p align="center"><strong>Id</strong></p>
</th>
<th width="190">
<p><strong>Name</strong></p>
</th>
<th width="150">
<p><strong>Spouse</strong></p>
</th>
<th width="50">
<p align="center"><small>Type</small></p>
</th>
<th width="110">
<p align="center"><strong>Amount</strong></p>
</th>
<th width="110">
<p align="center"><strong>Amount</strong></p>
</th>
<th width="146">
<p align="center"><strong>______________</strong></p>
</th>
<th width="146">
<p align="center"><strong>______________</strong></p>
</th>
<th width="146">
<p align="center"><strong>______________</strong></p>
</th>
</tr>
{{#each this}}
<tr>
<td width="50">
<p align="center">{{PeopleId}}</p>
</td>
<td width="190">
<p>{{Name2}}</p>
</td>
<td width="150">
<p>
{{#IfEqual ContributionOptionsId 2}}{{Spouse}} <small>({{SpouseId}})</small>{{/IfEqual}}
</p>
</td>
<td width="50" >
<p align="center"><small>
{{#IfEqual ContributionOptionsId 1}}Ind.{{/IfEqual}}
{{#IfEqual ContributionOptionsId 2}}Joint{{/IfEqual}}
</small></p>
</td>
<td width="110">
<p>&nbsp;</p>
</td>
<td width="110">
<p>&nbsp;</p>
</td>
<td width="146">
<p>&nbsp;</p>
</td>
<td width="146">
<p>&nbsp;</p>
</td>
<td width="146">
<p>&nbsp;</p>
</td>
</tr>
{{/each}}
</tbody>
</table>
</body>
</html>
'''
class SimpleClass(object):
pass
sqlpeople = q.QuerySqltoList('GivingUnits',"")
people=[]
for q in sqlpeople:
x = SimpleClass()
x.Name2 = q["Name2"]
x.PeopleId = q["PeopleId"]
x.Spouse = q["Spouse"]
x.SpouseId = q["SpouseId"]
x.ContributionOptionsId = q["ContributionOptionsId"]
people.append(x)
body = model.RenderTemplate(template, people)
print body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment