From c39e7039ac37e8a90c3263f9dc737ef6f9d71f32 Mon Sep 17 00:00:00 2001 From: dece Date: Sat, 14 Oct 2023 18:26:09 +0200 Subject: [PATCH] Podcast management (WIP) --- src/Controller/PodcastController.php | 4 +- src/Form/PodcastType.php | 2 +- src/Repository/PodcastRepository.php | 5 +- templates/base.html.twig | 12 +++-- templates/feed/index.html.twig | 1 + templates/login/index.html.twig | 3 +- templates/podcast/_delete_form.html.twig | 10 ++-- templates/podcast/_form.html.twig | 4 +- templates/podcast/edit.html.twig | 8 +-- templates/podcast/index.html.twig | 66 ++++++++++++------------ templates/podcast/new.html.twig | 6 +-- templates/podcast/show.html.twig | 9 +++- 12 files changed, 73 insertions(+), 57 deletions(-) diff --git a/src/Controller/PodcastController.php b/src/Controller/PodcastController.php index ef9b7a0..4032406 100644 --- a/src/Controller/PodcastController.php +++ b/src/Controller/PodcastController.php @@ -15,14 +15,14 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\String\Slugger\SluggerInterface; -#[Route('/manage/podcast')] +#[Route('/manage/podcasts')] class PodcastController extends AbstractController { #[Route('/', name: 'app_podcast_index', methods: ['GET'])] public function index(PodcastRepository $podcastRepository): Response { return $this->render('podcast/index.html.twig', [ - 'podcasts' => $podcastRepository->findAllOrderedById(), + 'podcasts' => $podcastRepository->findOwnedBy($this->getUser()) ]); } diff --git a/src/Form/PodcastType.php b/src/Form/PodcastType.php index 7343d63..384a37b 100644 --- a/src/Form/PodcastType.php +++ b/src/Form/PodcastType.php @@ -47,7 +47,7 @@ class PodcastType extends AbstractType ]), ]) ->add('owner', EntityType::class, [ - 'help' => 'The podcast owner is the only user of this instance able to see and modify it.', + 'help' => 'The podcast owner is the only user of this instance able to modify it.', 'class' => User::class, 'disabled' => true, ]) diff --git a/src/Repository/PodcastRepository.php b/src/Repository/PodcastRepository.php index 4ad6110..3a5bbfc 100644 --- a/src/Repository/PodcastRepository.php +++ b/src/Repository/PodcastRepository.php @@ -3,6 +3,7 @@ namespace App\Repository; use App\Entity\Podcast; +use App\Entity\User; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; @@ -39,8 +40,8 @@ class PodcastRepository extends ServiceEntityRepository } } - public function findAllOrderedById(): array + public function findOwnedBy(User $user): array { - return $this->findBy([], ['id' => 'ASC']); + return $this->findBy(['owner' => $user], ['id' => 'ASC']); } } diff --git a/templates/base.html.twig b/templates/base.html.twig index 99928ec..7f9ff9b 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -4,11 +4,13 @@ {% block title %}LSBC{% endblock %} - - + {% block stylesheets %} + + + {% endblock %} {% block body %}{% endblock %} diff --git a/templates/feed/index.html.twig b/templates/feed/index.html.twig index a65ab14..5b4081f 100644 --- a/templates/feed/index.html.twig +++ b/templates/feed/index.html.twig @@ -8,4 +8,5 @@ {% endfor %}

The LSBC project is licensed as GPLv3.

+ {% endblock %} diff --git a/templates/login/index.html.twig b/templates/login/index.html.twig index 6418537..90e2d91 100644 --- a/templates/login/index.html.twig +++ b/templates/login/index.html.twig @@ -22,8 +22,7 @@ form { display: flex; flex-direction: column; gap: 0.5em; } - {# If you want to control the URL the user is redirected to on success - #} + diff --git a/templates/podcast/_delete_form.html.twig b/templates/podcast/_delete_form.html.twig index aae9488..462b284 100644 --- a/templates/podcast/_delete_form.html.twig +++ b/templates/podcast/_delete_form.html.twig @@ -1,4 +1,8 @@ -
- - + + +
diff --git a/templates/podcast/_form.html.twig b/templates/podcast/_form.html.twig index bf20b98..06442b5 100644 --- a/templates/podcast/_form.html.twig +++ b/templates/podcast/_form.html.twig @@ -1,4 +1,4 @@ {{ form_start(form) }} - {{ form_widget(form) }} - + {{ form_widget(form) }} + {{ form_end(form) }} diff --git a/templates/podcast/edit.html.twig b/templates/podcast/edit.html.twig index 6d80131..c3153f5 100644 --- a/templates/podcast/edit.html.twig +++ b/templates/podcast/edit.html.twig @@ -3,11 +3,11 @@ {% block title %}Edit Podcast{% endblock %} {% block body %} -

Edit Podcast

+

Edit Podcast

- {{ include('podcast/_form.html.twig', {'button_label': 'Update'}) }} + {{ include('podcast/_form.html.twig', {'button_label': 'Update'}) }} - back to list + back to list - {{ include('podcast/_delete_form.html.twig') }} + {{ include('podcast/_delete_form.html.twig') }} {% endblock %} diff --git a/templates/podcast/index.html.twig b/templates/podcast/index.html.twig index daa245a..ec396b6 100644 --- a/templates/podcast/index.html.twig +++ b/templates/podcast/index.html.twig @@ -5,42 +5,44 @@ {% block stylesheets %} {{ parent() }} {% endblock %} {% block body %} -

Podcast index

+

Your podcasts

- - - - - - - - - - - - {% for podcast in podcasts %} - - - - - - - - {% else %} - - - - {% endfor %} - -
IdNameAuthorLogoactions
{{ podcast.id }}{{ podcast.name }}
({{ podcast.slug }})
{{ podcast.author }}{{ podcast.name }} logo - show - edit -
no records found
+ + + + + + + + + + + + {% for podcast in podcasts %} + + + + + + + + {% else %} + + + + {% endfor %} + +
IdNameAuthorLogoactions
{{ podcast.id }}{{ podcast.name }}
({{ podcast.slug }})
{{ podcast.author }}{{ podcast.name }} logo + + +
No podcasts found.
- Create new + {% endblock %} diff --git a/templates/podcast/new.html.twig b/templates/podcast/new.html.twig index f47fe0c..d2b229a 100644 --- a/templates/podcast/new.html.twig +++ b/templates/podcast/new.html.twig @@ -3,9 +3,9 @@ {% block title %}New Podcast{% endblock %} {% block body %} -

Create new Podcast

+

Create new Podcast

- {{ include('podcast/_form.html.twig') }} + {{ include('podcast/_form.html.twig') }} - back to list + back to list {% endblock %} diff --git a/templates/podcast/show.html.twig b/templates/podcast/show.html.twig index f2f993c..b7e5386 100644 --- a/templates/podcast/show.html.twig +++ b/templates/podcast/show.html.twig @@ -2,8 +2,15 @@ {% block title %}Podcast{% endblock %} +{% block stylesheets %} + {{ parent() }} + +{% endblock %} + {% block body %} -

Podcast

+

Podcast {{ podcast.name }}