Spaces:
Sleeping
Sleeping
fix(home): implement correct user profile creation workflow
Browse files- routes/home.py +13 -6
routes/home.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from flask import Blueprint, render_template, request, redirect
|
| 2 |
-
from
|
|
|
|
| 3 |
from constants.genres import GENRES
|
| 4 |
|
| 5 |
home_bp = Blueprint('home', __name__)
|
|
@@ -14,18 +15,24 @@ def inicio():
|
|
| 14 |
name = request.form.get('name')
|
| 15 |
preferences = request.form.getlist('preferences')
|
| 16 |
|
| 17 |
-
|
| 18 |
-
new_id = max(get_user_history.keys(), default=0) + 1
|
| 19 |
|
| 20 |
-
|
| 21 |
'name': name,
|
| 22 |
-
'preferences': preferences
|
|
|
|
| 23 |
}
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
return redirect(f'/chat/{new_id}')
|
| 26 |
|
| 27 |
return render_template(
|
| 28 |
'start.html',
|
| 29 |
-
profiles=
|
| 30 |
genres=GENRES
|
| 31 |
)
|
|
|
|
| 1 |
from flask import Blueprint, render_template, request, redirect
|
| 2 |
+
from time import time
|
| 3 |
+
from logs import save_log, get_all_users
|
| 4 |
from constants.genres import GENRES
|
| 5 |
|
| 6 |
home_bp = Blueprint('home', __name__)
|
|
|
|
| 15 |
name = request.form.get('name')
|
| 16 |
preferences = request.form.getlist('preferences')
|
| 17 |
|
| 18 |
+
new_id = int(time())
|
|
|
|
| 19 |
|
| 20 |
+
initial_history = {
|
| 21 |
'name': name,
|
| 22 |
+
'preferences': preferences,
|
| 23 |
+
'chat': []
|
| 24 |
}
|
| 25 |
|
| 26 |
+
save_log(
|
| 27 |
+
user_id=new_id,
|
| 28 |
+
history=initial_history,
|
| 29 |
+
response="Perfil criado."
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
return redirect(f'/chat/{new_id}')
|
| 33 |
|
| 34 |
return render_template(
|
| 35 |
'start.html',
|
| 36 |
+
profiles=get_all_users(),
|
| 37 |
genres=GENRES
|
| 38 |
)
|