From: Chris Fulljames Date: Tue, 18 Feb 2025 23:36:13 +0000 (-0500) Subject: Add server-side checks for pfp on profile and song list X-Git-Url: https://littlesong.place/gitweb/?a=commitdiff_plain;h=5ddbe9e44d86e6748f62b0f51a6a25d433339b4b;p=littlesongplace.git Add server-side checks for pfp on profile and song list --- diff --git a/main.py b/main.py index abd6748..ce82110 100644 --- a/main.py +++ b/main.py @@ -179,6 +179,7 @@ def users_profile(profile_username): user_accolor=profile_data["accolor"], playlists=plist_data, songs=songs, + user_has_pfp=(get_user_images_path(profile_userid)/"pfp.jpg").exists(), song_list=render_template("song-list.html", songs=songs, is_profile_song_list=True)) @app.post("/edit-profile") @@ -1028,6 +1029,9 @@ class Song: return song_comments + def user_has_pfp(self): + return (get_user_images_path(self.userid)/"pfp.jpg").exists() + @classmethod def by_id(cls, songid): songs = cls._from_db("select * from songs inner join users on songs.userid = users.userid where songid = ?", [songid]) diff --git a/templates/base.html b/templates/base.html index 0aa52b8..f14ef47 100644 --- a/templates/base.html +++ b/templates/base.html @@ -33,7 +33,6 @@ // Get page content from JSON response var data = await response.json(); - console.log(data); document.getElementById("main").innerHTML = data.body; document.title = data.title; diff --git a/templates/profile.html b/templates/profile.html index e002a66..5adc9e1 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -25,9 +25,11 @@

{{ name }}

+{% if user_has_pfp %}
+{% endif %}