Added Search Downloading again

This commit is contained in:
Nile Walker 2020-12-19 21:56:21 -05:00
parent db6cbb2615
commit 46130dc993
5 changed files with 414 additions and 697 deletions

View File

@ -151,8 +151,7 @@ def index():
session["index_filter"]["location"] = form.location.data
if form.email.data:
session["index_filter"]["email"] = form.email.data
# if form.download.data:
# download = True
# # Store previous form submission settings in the session, so they are preseved through pagination.
filtered_samples = samples
@ -181,9 +180,10 @@ def index():
else:
# Default to Todays Results
filtered_samples = filtered_samples.filter(Sample.date >= date.today())
if download:
if request.args.get('download') == 'true':
csv = __make_csv(filtered_samples)
return send_file(csv, attachment_filename='data_export.csv', as_attachment=True)
############# Build Graphs ######################
# Analysis
station_charts = []
@ -305,6 +305,13 @@ def index():
stats = stats
))
@app.route('/activate', methods=['GET', 'POST'])
@superuser
def activate_station():
return render_template('layouts/default.html',
base_href=BASE_HREF,
content=render_template(
'pages/stations.html'))
def __make_csv(sample_query):
csvfile = io.StringIO()

View File

@ -78,7 +78,7 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/profile.html">
<a class="nav-link" href="/activate">
<em class="ni ni-single-02 text-yellow"></em> Active Locations
</a>
</li>
@ -97,7 +97,7 @@
</li>
<li class="nav-item">
<a class="nav-link" href="https://appseed.us/admin-dashboards/flask-dashboard-argon">
<a class="nav-link" href="/">
<em class="ni ni-book-bookmark"></em> App Information
</a>
</li>

View File

@ -11,7 +11,7 @@
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">Samples Today</h5>
<span id="stats_traffic" class="h2 font-weight-bold mb-0">{{stats.today}}</span>
<span id="stats_traffic" class="h2 font-weight-bold mb-0">{{stats.today|safe}}</span>
</div>
<div class="col-auto">
@ -34,7 +34,7 @@
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">2 Week Average</h5>
<span id="stats_users" class="h2 font-weight-bold mb-0">{{stats.weeks}}</span>
<span id="stats_users" class="h2 font-weight-bold mb-0">{{stats.weeks|safe}}</span>
</div>
<div class="col-auto">
@ -58,7 +58,7 @@
<h5 class="card-title text-uppercase text-muted mb-0">Samples in Search
</h5>
<span id="stats_sales" class="h2 font-weight-bold mb-0">{{stats.all}}</span>
<span id="stats_sales" class="h2 font-weight-bold mb-0">{{stats.all|safe}}</span>
</div>
<div class="col-auto">

View File

@ -121,7 +121,7 @@
<h3 class="mb-0">Records to be processed</h3>
</div>
<div class="col text-right">
<button type="submit" href="#!" class="btn btn-sm btn-primary">Download all</a>
<a href="{{ url_for('index') }}?download=true" class="btn btn-sm btn-primary">Download all</a>
</div>
</div>
</div>

File diff suppressed because it is too large Load Diff