membershipViewer: Add search, try not to expose too much information

This commit is contained in:
Adam Goldsmith 2018-08-13 16:27:15 -04:00
parent 848520f327
commit deddf1605a
2 changed files with 23 additions and 10 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import re
from flask import Flask, render_template
from flask import Flask, render_template, request
app = Flask(__name__)
@ -26,10 +26,6 @@ def parse_members(members):
+ member['Access Card Number'],
'Account on Hold': "Yes" if member['Account on Hold'] != '' else "No" }
certifications = []
access = []
levels = []
props['Certifications'] = parse_list(member, 'Certified: (.*)')
props['Door Access'] = parse_list(member, 'Access (.*)\?')
props['Memebership Level'] = parse_list(member, 'CMS (.*)')
@ -41,17 +37,28 @@ def parse_members(members):
@app.route("/")
def main():
# maybe not now: membership agreement signed
# TODO: renewal date
# TODO: renewal date check
term = request.args.get('term', '')
members = getMembershipworksData(
if len(term) < 3:
return render_template("members.html",
error="Enter at least 3 characters to search")
data = getMembershipworksData(
['members', 'staff'],
"lvl,xws,xms,xsc,xas,xfd,xac,phn,eml,lbl,xcf,nam,end")
data = parse_members(members)
members = parse_members(data)
members = [member for member in members
if term.lower() in member['Name'].lower()]
headers = ['Name', 'Certifications', 'Door Access', 'Memebership Level',
'Card Number', 'Renewal Date', 'Account on Hold']
return render_template("members.html", headers=headers, members=data)
if len(members) > 4:
return render_template(
"members.html", error="Too many results, please be more specific.")
return render_template("members.html", headers=headers, members=members)
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')

View File

@ -24,7 +24,11 @@
</style>
</head>
<body>
<h1>Members</h1>
<form>
<input type="text" name="term" />
<button>Search</button>
</form>
{% if headers is not none %}
<table>
<tr>
{% for header in headers %}
@ -40,5 +44,7 @@
{% endfor %}
</div>
</table>
{% endif %}
<span class="error">{{ error }}</span>
</body>
</html>