]> littlesong.place Git - littlesongplace.git/commitdiff
Add server-side checks for pfp on profile and song list
authorChris Fulljames <christianfulljames@gmail.com>
Tue, 18 Feb 2025 23:36:13 +0000 (18:36 -0500)
committerChris Fulljames <christianfulljames@gmail.com>
Tue, 18 Feb 2025 23:36:13 +0000 (18:36 -0500)
main.py
templates/base.html
templates/profile.html
templates/song-list.html
todo.txt

diff --git a/main.py b/main.py
index abd67485e2a92c34f9027e47d43cfb69e14917d4..ce821101a8f5da1a4065c2c17dd7fa702e7e5d13 100644 (file)
--- 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])
index 0aa52b86dea08c0e8cd19ff2c8fd34001a07427e..f14ef47868b136dfdb6dcdd08e08b3cbf38ef60f 100644 (file)
@@ -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;
 
index e002a660e33b85679b5fa6b1f2c3772d33cdffbd..5adc9e181dbcdcd154ac987961aaf1f1cf77285a 100644 (file)
 <h1 class="profile-name">{{ name }}</h1>
 
 <!-- Profile Picture -->
+{% if user_has_pfp %}
 <div class="big-pfp-container">
     <img src="/pfp/{{ userid }}" onerror="hidePfp(this)" class="big-pfp">
 </div>
+{% endif %}
 
 <script>
     function hidePfp(pfp) {
index b822f5505fdd0033c85edc0edc2d2546e6c66af0..1bb003c221e3264c84825ae761c6679a074d2193 100644 (file)
@@ -3,7 +3,9 @@
     <div class="song" data-song="{{ song.json() }}">
         <div class="song-main">
             <!-- Profile Picture -->
+            {% if song.user_has_pfp() %}
             <img class="small-pfp" src="/pfp/{{ song.userid }}" onerror="this.style.display = 'none'" />
+            {% endif %}
 
             <div class="song-info">
 
index 3606dc459e35bd0fb1aee8cdaa8d4361f708bb58..e93e8834410abd683eff09b6b3b3c52618dfb3e1 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -1,12 +1,9 @@
 NOW
 - AJAX pages so songs can play during navigation
-    - Nav bar
     - Forms
     - Back (history stack)
     - Other on-site links (songs, profiles, tags, etc.)
     - Update page colors
-    - PFP on profile when missing PFP
-    - Signout doesn't refresh navbar (should show sign in link)
 - Break up main.py, test_offline.py
 - Pinned profile playlists