Skip to content

Commit

Permalink
Make the venue search work
Browse files Browse the repository at this point in the history
  • Loading branch information
spudooli committed Mar 15, 2024
1 parent 1edec79 commit 79203d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 14 additions & 3 deletions spudoolicom/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import requests
import random
import string

from flask import jsonify

@app.route("/admin/create", methods=("GET", "POST"))
@login_required
Expand Down Expand Up @@ -147,7 +147,7 @@ def create_checkin():
checkinCount = cursor.fetchone()
cursor.close()

flash('Stored checkin to "{}" - You have checked in here {} times'.format(checkinVenue, checkinCount['count']))
flash('Stored checkin to "{}" - You have checked in here {} times'.format(checkinVenue, checkinCount))

return redirect(url_for("create_checkin"))

Expand All @@ -170,8 +170,19 @@ def checkin_search():
cursor.execute("SELECT name, address FROM recently WHERE name LIKE %s and type = 'swarm' GROUP by name, address LIMIT 10", (f'%{search_term}%',))
results = cursor.fetchall()
cursor.close()
rows = []

print(f"results: {results}")
return results
html = f"<div id='comments'><ul>"
for row in results:
html += f"<li><strong>{row[0]}</strong><br />"
html += f"{row[1]}"
html += f"<form action='/admin/checkin' method='post' style='text-align: right; color: #195ddd'>"
html += f"<input name='venue' class='form-control' id='venue' value='{row[0]}' type='hidden'>"
html += f"<input name='address' class='form-control' id='address' value='{row[1]}' type='hidden'>"
html += f"<input type='submit' value='Checkin Here ' style='border: none; background: none; padding: 0;' ></form></li>"
html += f"</ul>"
return jsonify(html)



Expand Down
9 changes: 3 additions & 6 deletions spudoolicom/templates/admin-checkins.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1 class="title-un">{% block title %}Checkins{% endblock %}</h1>
<li><strong>{{ venue[0] }} </strong><br />
{{ venue[1] }}

<form action="{{ url_for('create_checkin') }}" method="post" style="text-align: right;">
<form action="{{ url_for('create_checkin') }}" method="post" style="text-align: right; color: #195ddd">
<input name="venue" class="form-control" id="venue" value="{{ venue[0] }}" type="hidden">
<input name="address" class="form-control" id="address" value="{{ venue[1] }}" type="hidden">
<input class="danger" type="submit" value="Checkin Here " style="border: none; background: none; padding: 0;" >
Expand Down Expand Up @@ -61,11 +61,8 @@ <h1 class="title-un">{% block title %}Checkins{% endblock %}</h1>
$.get('/admin/checkin-search', {q: $(this).val()}, function(data) {
// Update your search results here
// For example, you can create a dropdown list with the results
var dropdown = $('#search-results');
dropdown.empty();
for (var i = 0; i < data.length; i++) {
dropdown.append('<li>' + data[i] + '</li>');
}

$('#search-results').html(data);
});
});</script>

Expand Down

0 comments on commit 79203d1

Please sign in to comment.