]> littlesong.place Git - littlesongplace.git/commitdiff
Fix jam event lists
authorChris Fulljames <christianfulljames@gmail.com>
Sun, 13 Apr 2025 18:42:51 +0000 (14:42 -0400)
committerChris Fulljames <christianfulljames@gmail.com>
Sun, 13 Apr 2025 18:42:51 +0000 (14:42 -0400)
src/littlesongplace/jams.py
src/littlesongplace/templates/jam-event-list.html
src/littlesongplace/templates/jam.html
src/littlesongplace/templates/jams-main.html
src/littlesongplace/templates/song-list.html

index dfc19de8d8ef5be87c78f60d6912b8f61b080021..3aa5534c0b0d2e222c6ff785953e891cf55b5024 100644 (file)
@@ -25,11 +25,12 @@ def jam_owner_only(f):
 def _sort_events(events):
     now = datetime.now(timezone.utc)
     # Only show events with valid timestamps
-    events = [e for e in events if e.startdate and e.enddate]
-    ongoing_events = [e for e in events if e.startdate <= now and e.enddate >= now]
-    upcoming_events = [e for e in events if e.startdate > now]
-    past_events = [e for e in events if e.enddate < now]
-    return ongoing_events, upcoming_events, past_events
+    timed_events = [e for e in events if e.startdate and e.enddate]
+    ongoing_events = [e for e in timed_events if e.startdate <= now and e.enddate >= now]
+    upcoming_events = [e for e in timed_events if e.startdate > now]
+    past_events = [e for e in timed_events if e.enddate < now]
+    other_events = [e for e in events if e not in timed_events]
+    return ongoing_events, upcoming_events, past_events, other_events
 
 @bp.get("")
 def jams():
@@ -46,9 +47,7 @@ def jams():
         all_events.extend(j.events)
 
     # Only show events with valid timestamps
-    all_events = [e for e in all_events if e.startdate and e.enddate]
-
-    ongoing_events, upcoming_events, past_events = _sort_events(all_events)
+    ongoing_events, upcoming_events, past_events, _ = _sort_events(all_events)
     past_events = past_events[-5:] # Only show 5 most recent events
 
     # TODO: Sort into groups based on start/end dates
@@ -79,13 +78,13 @@ def create():
 @bp.get("/<int:jamid>")
 def jam(jamid):
     jam = _get_jam_by_id(jamid)
-    ongoing_events, upcoming_events, past_events = _sort_events(jam.events)
+    ongoing_events, upcoming_events, past_events, other_events = _sort_events(jam.events)
     # Show the main jam page
     return render_template(
             "jam.html",
             jam=jam,
             ongoing=ongoing_events,
-            upcoming=upcoming_events,
+            upcoming=upcoming_events+other_events,  # Show events without timestamps as upcoming
             past=past_events)
 
 
index 0e6a80219841c91647295ebe0404e0e0b5a56768..715b2b7aa49d66df41341667af86c6ad5d21b20f 100644 (file)
@@ -1,6 +1,6 @@
 {% macro jam_event_list(list_title, events) %}
 {% if events %}
-<h2>{{ list_title }}</h2>
+<h3>{{ list_title }}</h3>
 <div class="jam-event-list">
     {% for event in events %}
     <div class="jam-event-list-entry">
index 776d7b53cbafe5fd3892ff364a30fabc2365f965..2020331293ea523f248135ad9981a9a854556c0a 100644 (file)
 {{ jam.description }}
 </div>
 
+<h2>Events</h2>
+{%- if jam.ownerid == session["userid"] -%}
+<a class="song-list-button" title="Create Event" href="/jams/{{ jam.jamid }}/events/create"><img class="lsp_btn_add02" /></a>
+{%- endif -%}
+
 {% from "jam-event-list.html" import jam_event_list %}
 {{ jam_event_list("Ongoing Events", ongoing) }}
 {{ jam_event_list("Upcoming Events", upcoming) }}
index 397d35715853d1f8a2fe2c217fde60c482e951ec..a1829d11547f97af6f534053a9ed9d8526b497c3 100644 (file)
@@ -6,23 +6,17 @@
 
 <h1>Jams</h1>
 
+<h2>Events</h2>
 {% from "jam-event-list.html" import jam_event_list %}
 {{ jam_event_list("Ongoing Events", ongoing) }}
 {{ jam_event_list("Upcoming Events", upcoming) }}
 {{ jam_event_list("Recent Events", past) }}
 
 <h2>All Jams</h2>
-<div class="jam-list">
-    {% for jam in jams %}
-    <div class="jam-list-entry">
-        <span class="jam-list-title">
-            {{ jam.title }}
-        </span>
-        <span class="jam-list-owner">
-            Hosted by <a href="/users/{{ jam.username }}" class="profile-link">{{ jam.username }}</a>
-        </span>
-    </div>
-    {% endfor %}
-</div>
+<ul class="jam-list">
+    {% for jam in jams -%}
+    <li><a href="/jams/{{ jam.jamid }}">{{ jam.title }}</a></li>
+    {%- endfor %}
+</ul>
 
 {% endblock %}
index 20831c1c60b1feb4357c283fcd1e577938c2a5d5..c2a85b9958bbb0a8d1c5ca45bb7786cd1a6d4767 100644 (file)
@@ -9,7 +9,7 @@
 
     <div class="song-list-songs">
         {% for song in songs %}
-        {%- if not (song.hidden and g.uiserid != song.userid) -%}
+        {%- if not (song.hidden and session['uiserid'] != song.userid) -%}
         <div class="song" data-song="{{ song.json() }}">
             <div class="song-main">
                 <div class="song-list-pfp-container">