Skip to content
Snippets Groups Projects
Commit 46c12822 authored by hwilks's avatar hwilks
Browse files

fix frontend of account events

parent 33636f5e
No related branches found
No related tags found
3 merge requests!74v.1.0,!64Issue/password val,!48Feature/add events to account
......@@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS users (
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS account_events{
CREATE TABLE IF NOT EXISTS account_events {
user_id INT NOT NULL,
event_id INT,
PRIMARY KEY (user_id, event_id),
......
......@@ -135,7 +135,7 @@ def getDatesp():
return data_output
return render_template('eventSummary.html')
@app.route('/account/<int: account_id>', methods=['GET'])
@app.route('/account/<int:account_id>', methods=['GET'])
def get_events(account_id):
if request.method == 'GET':
data = {'account_id':account_id}
......@@ -150,9 +150,13 @@ def get_events(account_id):
response = requests.get(f"{EVENT_API_URL}/get_event_info", json = data_input)
data_output = response.json() if response.status_code == 200 else []
event['name'] = data_output['name']
event['url'] = url_for('availability', event_id=event_id)
event['url'] = url_for('eventSummary', event_id=event_id)
events.append(event)
#Test data
event1= {'name':'An event','url':url_for('eventSummary', event_id=1)}
event2= {'name':'An event 2','url':'a url'}
events = [event1, event2]
return render_template('accountEvents.html', event=events)
return render_template('accountEvents.html')
......
......@@ -353,13 +353,20 @@ function new_list_element(availabilities, dates){
function show_account_events(events){
event_block = document.getElementById('event_block')
for (const event in events){
console.log(events)
for (i=0;i<events.length;i++){
event_i=events[i]
var button = document.createElement("button");
button.classList.add('show_event');
button.textContent = event['name'];
button.onclick = "window.location.href = {{event[url]}}";
button.textContent = event_i['name'];
console.log(event_i['url'])
button.onclick = button.onclick = function(event_i) {
return function() {
console.log('button pressed')
window.location.href = event_i['url'];
};
}(event_i);
event_block.append(button);
}
......
......@@ -11,7 +11,7 @@
<div class="centered">
<div class="card">
<h1>These are your events</h1>
<h3>Click to go see the details</h3>
<h3>Click to see the details</h3>
<div class="card internal">
<div id="event_block">
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment