feat: episode publish date editing
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
2d424d0be6
commit
e2c1e24b03
2 changed files with 13 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
import urllib.parse
|
||||
import uuid
|
||||
from contextlib import asynccontextmanager
|
||||
from datetime import timedelta, timezone
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Any, Generator, Optional
|
||||
|
||||
|
@ -345,6 +345,7 @@ def admin_edit_episode_post(
|
|||
user: AuthDep,
|
||||
name: Annotated[str, Form()],
|
||||
description: Annotated[str, Form()],
|
||||
publish_date: Annotated[str, Form()],
|
||||
):
|
||||
episode = session.exec(
|
||||
select(models.PodcastEpisode).where(
|
||||
|
@ -378,6 +379,12 @@ def admin_edit_episode_post(
|
|||
else:
|
||||
episode.description = None
|
||||
|
||||
if publish_date.strip() != "":
|
||||
publish_dt = datetime.strptime(publish_date, "%Y-%m-%dT%H:%M")
|
||||
# only update the date if it's changed by 2 mins or more as the input doesn't allow for seconds
|
||||
if (episode.publish_date - publish_dt).seconds > 120:
|
||||
episode.publish_date = publish_dt
|
||||
|
||||
session.add(episode)
|
||||
session.commit()
|
||||
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
Name
|
||||
<input name="name" value="{{ episode.name }}" />
|
||||
</label>
|
||||
<label>
|
||||
Publish Date
|
||||
<input type="datetime-local" name="publish_date"
|
||||
value="{{ episode.publish_date.strftime('%Y-%m-%dT%H:%M') }}" />
|
||||
</label>
|
||||
<label>
|
||||
Description
|
||||
<textarea name="description"
|
||||
|
|
Loading…
Reference in a new issue