Explorar o código

linked shared bookmarks page, backend for username change

control %!s(int64=3) %!d(string=hai) anos
pai
achega
cabe4745dd
Modificáronse 2 ficheiros con 15 adicións e 4 borrados
  1. 12 1
      app/logic.py
  2. 3 3
      app/templates/home.html

+ 12 - 1
app/logic.py

@@ -14,11 +14,15 @@ logic = Blueprint('logic', __name__)
 @login_required
 def home():
     if request.method == "POST":
+        username = request.form.get('username')
         passwd = request.form.get('password')
         passwdc = request.form.get('password_confirm')
         new_pic = request.files.get('profile_image')
 
-        if passwd and passwdc:
+        if username:
+            nusern_dbcall = User.query.filter_by(id=current_user.id).first()
+            nusern_dbcall.username = username
+        elif passwd and passwdc:
             if passwd == passwdc:
                 npasswd_dbcall = User.query.filter_by(id=current_user.id).first()
                 npasswd_dbcall.password = generate_password_hash(passwdc, method='sha256')
@@ -60,6 +64,13 @@ def create():
 
     return render_template('create_bookmark.html', user=current_user)
 
+@logic.route('/shared', methods=['GET'])
+@login_required
+def shared():
+    pass
+
+    return render_template('shared.html', user=current_user)
+
 @logic.route('/login', methods=['GET', 'POST'])
 def login():
     if request.method == 'POST':

+ 3 - 3
app/templates/home.html

@@ -9,9 +9,9 @@
 <!------  Profile Information ---------->
 <p>Profile Information</p>
 <div class="card">
-    <img src="static/uploads/{{ user.profile_image }}" style="width:100%"><p>(Show user image)</p>
-    <h1>(User name)</h1>
-    <p>(email)</p>
+    <img src="static/uploads/{{ user.profile_image }}" style="width:100%">
+    <h1>{{ user.username }}</h1>
+    <p>{{ user.email }}</p>
 </div>
 <hr style="border: 5px dashed black;"/>