]> littlesong.place Git - littlesongplace.git/commitdiff
Add jam editor
authorChris Fulljames <christianfulljames@gmail.com>
Sun, 13 Apr 2025 19:06:20 +0000 (15:06 -0400)
committerChris Fulljames <christianfulljames@gmail.com>
Sun, 13 Apr 2025 19:06:20 +0000 (15:06 -0400)
src/littlesongplace/jams.py
src/littlesongplace/templates/jam.html

index 3aa5534c0b0d2e222c6ff785953e891cf55b5024..4f27233e01a1ad1ed40a31bde984e3ec5aafcb36 100644 (file)
@@ -50,7 +50,6 @@ def jams():
     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
     return render_template(
             "jams-main.html",
             ongoing=ongoing_events,
index 2020331293ea523f248135ad9981a9a854556c0a..0031052cbfe9ec54da348ba4dbf9f7cb3f6ce2e1 100644 (file)
     <strong>Host:</strong>
     <a href="/users/{{ jam.ownername }}" class="profile-link">{{ jam.ownername }}</a>
 </div>
-
-<h2>Description</h2>
-<div>
-{{ 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) }}
-{{ jam_event_list("Past Events", past) }}
+<br/>
+<div id="jam-view">
+    {% if session["userid"] == jam.ownerid -%}
+    <div class="jam-actions">
+    <button class="song-list-button" onclick="showJamEditor()" title="Edit"><img class="lsp_btn_edit02" /></button>
+    <a href="/jams/{{ jam.jamid }}/delete" class="song-list-button" onclick="return confirm('Are you sure you want to delete this jam and all events?')" title="Delete"><img class="lsp_btn_delete02" /></a>
+    </div>
+    {%- endif %}
+
+    <h2>Description</h2>
+    <div>
+    {{ jam.description|safe }}
+    </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) }}
+    {{ jam_event_list("Past Events", past) }}
+</div> <!-- jam-view -->
+
+{% if session["userid"] == jam.ownerid -%}
+<div id="jam-edit" hidden>
+    <form action="/jams/{{ jam.jamid }}/update" method="post">
+        <label>Title<input type="text" name="title" value="{{ jam.title }}"/></label>
+        <label>
+            Description
+            <textarea name="description">{{ jam.description|safe }}</textarea>
+        </label>
+        <input type="submit" value="Save"/>
+        <a href="javascript:hideJamEditor()">Cancel</a>
+    </form>
+</div> <!-- jam-edit -->
+
+<script>
+function showJamEditor() {
+    document.getElementById("jam-view").hidden = true;
+    document.getElementById("jam-edit").hidden = false;
+}
+function hideJamEditor() {
+    document.getElementById("jam-view").hidden = false;
+    document.getElementById("jam-edit").hidden = true;
+}
+</script>
+{%- endif %} {# jam owner #}
 
 {% endblock %}