forked from CMS/memberPlumbing
membershipViewer: Add search, try not to expose too much information
This commit is contained in:
parent
848520f327
commit
deddf1605a
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template, request
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@ -26,10 +26,6 @@ def parse_members(members):
|
|||||||
+ member['Access Card Number'],
|
+ member['Access Card Number'],
|
||||||
'Account on Hold': "Yes" if member['Account on Hold'] != '' else "No" }
|
'Account on Hold': "Yes" if member['Account on Hold'] != '' else "No" }
|
||||||
|
|
||||||
certifications = []
|
|
||||||
access = []
|
|
||||||
levels = []
|
|
||||||
|
|
||||||
props['Certifications'] = parse_list(member, 'Certified: (.*)')
|
props['Certifications'] = parse_list(member, 'Certified: (.*)')
|
||||||
props['Door Access'] = parse_list(member, 'Access (.*)\?')
|
props['Door Access'] = parse_list(member, 'Access (.*)\?')
|
||||||
props['Memebership Level'] = parse_list(member, 'CMS (.*)')
|
props['Memebership Level'] = parse_list(member, 'CMS (.*)')
|
||||||
@ -41,17 +37,28 @@ def parse_members(members):
|
|||||||
@app.route("/")
|
@app.route("/")
|
||||||
def main():
|
def main():
|
||||||
# maybe not now: membership agreement signed
|
# 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'],
|
['members', 'staff'],
|
||||||
"lvl,xws,xms,xsc,xas,xfd,xac,phn,eml,lbl,xcf,nam,end")
|
"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',
|
headers = ['Name', 'Certifications', 'Door Access', 'Memebership Level',
|
||||||
'Card Number', 'Renewal Date', 'Account on Hold']
|
'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__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True, host='0.0.0.0')
|
app.run(debug=True, host='0.0.0.0')
|
||||||
|
@ -24,7 +24,11 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Members</h1>
|
<form>
|
||||||
|
<input type="text" name="term" />
|
||||||
|
<button>Search</button>
|
||||||
|
</form>
|
||||||
|
{% if headers is not none %}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
{% for header in headers %}
|
{% for header in headers %}
|
||||||
@ -40,5 +44,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</table>
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
<span class="error">{{ error }}</span>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user