summaryrefslogtreecommitdiff
path: root/Biz/PodcastItLater/Web.py
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/PodcastItLater/Web.py')
-rw-r--r--Biz/PodcastItLater/Web.py41
1 files changed, 38 insertions, 3 deletions
diff --git a/Biz/PodcastItLater/Web.py b/Biz/PodcastItLater/Web.py
index 2868147..97ec439 100644
--- a/Biz/PodcastItLater/Web.py
+++ b/Biz/PodcastItLater/Web.py
@@ -515,6 +515,7 @@ class EpisodeListAttrs(Attrs):
episodes: list[dict[str, typing.Any]]
rss_url: str | None
+ user: dict[str, typing.Any] | None
class EpisodeList(Component[AnyChildren, EpisodeListAttrs]):
@@ -524,6 +525,7 @@ class EpisodeList(Component[AnyChildren, EpisodeListAttrs]):
def render(self) -> html.div:
episodes = self.attrs["episodes"]
rss_url = self.attrs.get("rss_url")
+ user = self.attrs.get("user")
if not episodes:
return html.div(
@@ -539,8 +541,37 @@ class EpisodeList(Component[AnyChildren, EpisodeListAttrs]):
for episode in episodes:
duration_str = UI.format_duration(episode.get("duration"))
episode_sqid = encode_episode_id(episode["id"])
+ is_public = episode.get("is_public", 0) == 1
+
+ # Admin toggle button for public/private status
+ admin_toggle = html.div()
+ if user and Core.is_admin(user):
+ admin_toggle = html.div(
+ html.button(
+ html.i(
+ classes=[
+ "bi",
+ "bi-globe" if is_public else "bi-lock",
+ "me-1",
+ ],
+ ),
+ "Public" if is_public else "Private",
+ hx_post=f"/admin/episode/{episode['id']}/toggle-public",
+ hx_target="body",
+ hx_swap="outerHTML",
+ classes=[
+ "btn",
+ "btn-sm",
+ "btn-success" if is_public else "btn-secondary",
+ ],
+ ),
+ classes=["position-absolute", "top-0", "end-0", "m-2"],
+ style={"z-index": "10"},
+ )
+
episode_items.append(
html.div(
+ admin_toggle,
html.div(
html.h5(
html.a(
@@ -589,7 +620,7 @@ class EpisodeList(Component[AnyChildren, EpisodeListAttrs]):
else html.div(),
classes=["card-body"],
),
- classes=["card", "mb-3"],
+ classes=["card", "mb-3", "position-relative"],
),
)
@@ -750,6 +781,7 @@ class HomePage(Component[AnyChildren, HomePageAttrs]):
EpisodeList(
episodes=episodes,
rss_url=f"{BASE_URL}/feed/{user['token']}.xml",
+ user=user,
),
id="dashboard-content",
hx_get="/dashboard-updates",
@@ -1461,7 +1493,7 @@ def dashboard_updates(request: Request) -> html.div:
if not user_id:
return html.div(
QueueStatus(items=[]),
- EpisodeList(episodes=[], rss_url=None),
+ EpisodeList(episodes=[], rss_url=None, user=None),
)
# Get user info for RSS URL
@@ -1474,7 +1506,7 @@ def dashboard_updates(request: Request) -> html.div:
return html.div(
QueueStatus(items=queue_items),
- EpisodeList(episodes=episodes, rss_url=rss_url),
+ EpisodeList(episodes=episodes, rss_url=rss_url, user=user),
id="dashboard-content",
)
@@ -1574,6 +1606,9 @@ def cancel_queue_item(request: Request, job_id: int) -> Response:
app.delete("/queue/{job_id}")(Admin.delete_queue_item)
app.get("/admin/users")(Admin.admin_users)
app.post("/admin/users/{user_id}/status")(Admin.update_user_status)
+app.post("/admin/episode/{episode_id}/toggle-public")(
+ Admin.toggle_episode_public,
+)
class BaseWebTest(Test.TestCase):