mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-12 19:17:45 +02:00
refactor: harmonize redirects after submitting forms
go back to form after submitting an edit form
This commit is contained in:
parent
6e9451a110
commit
d0cb964b0f
36 changed files with 179 additions and 57 deletions
|
|
@ -166,7 +166,10 @@ class ContributorController extends BaseController
|
|||
(int) $this->request->getPost('role'),
|
||||
);
|
||||
|
||||
return redirect()->route('contributor-list', [$this->podcast->id]);
|
||||
return redirect()->route('contributor-edit', [$this->podcast->id, $this->user->id])->with(
|
||||
'message',
|
||||
lang('Contributor.messages.editSuccess')
|
||||
);
|
||||
}
|
||||
|
||||
public function remove(): RedirectResponse
|
||||
|
|
@ -174,7 +177,7 @@ class ContributorController extends BaseController
|
|||
if ($this->podcast->created_by === $this->user->id) {
|
||||
return redirect()
|
||||
->back()
|
||||
->with('errors', [lang('Contributor.messages.removeOwnerContributorError')]);
|
||||
->with('errors', [lang('Contributor.messages.removeOwnerError')]);
|
||||
}
|
||||
|
||||
$podcastModel = new PodcastModel();
|
||||
|
|
@ -187,10 +190,10 @@ class ContributorController extends BaseController
|
|||
}
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->route('contributor-list', [$this->podcast->id])
|
||||
->with(
|
||||
'message',
|
||||
lang('Contributor.messages.removeContributorSuccess', [
|
||||
lang('Contributor.messages.removeSuccess', [
|
||||
'username' => $this->user->username,
|
||||
'podcastTitle' => $this->podcast->title,
|
||||
]),
|
||||
|
|
|
|||
|
|
@ -205,7 +205,10 @@ class EpisodeController extends BaseController
|
|||
|
||||
$db->transComplete();
|
||||
|
||||
return redirect()->route('episode-view', [$this->podcast->id, $newEpisodeId]);
|
||||
return redirect()->route('episode-view', [$this->podcast->id, $newEpisodeId])->with(
|
||||
'message',
|
||||
lang('Episode.messages.createSuccess')
|
||||
);
|
||||
}
|
||||
|
||||
public function edit(): string
|
||||
|
|
@ -334,11 +337,18 @@ class EpisodeController extends BaseController
|
|||
|
||||
$db->transComplete();
|
||||
|
||||
return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id]);
|
||||
return redirect()->route('episode-edit', [$this->podcast->id, $this->episode->id])->with(
|
||||
'message',
|
||||
lang('Episode.messages.editSuccess')
|
||||
);
|
||||
}
|
||||
|
||||
public function transcriptDelete(): RedirectResponse
|
||||
{
|
||||
if ($this->episode->transcript === null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$mediaModel = new MediaModel();
|
||||
if (! $mediaModel->deleteMedia($this->episode->transcript)) {
|
||||
return redirect()
|
||||
|
|
@ -352,6 +362,10 @@ class EpisodeController extends BaseController
|
|||
|
||||
public function chaptersDelete(): RedirectResponse
|
||||
{
|
||||
if ($this->episode->chapters === null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$mediaModel = new MediaModel();
|
||||
if (! $mediaModel->deleteMedia($this->episode->chapters)) {
|
||||
return redirect()
|
||||
|
|
@ -699,16 +713,18 @@ class EpisodeController extends BaseController
|
|||
(new PostModel())->removePost($post);
|
||||
}
|
||||
|
||||
// set episode published_at to null to unpublish before deletion
|
||||
$this->episode->published_at = null;
|
||||
|
||||
$episodeModel = new EpisodeModel();
|
||||
if (! $episodeModel->update($this->episode->id, $this->episode)) {
|
||||
$db->transRollback();
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $episodeModel->errors());
|
||||
if ($this->episode->published_at !== null) {
|
||||
// if episode is published, set episode published_at to null to unpublish before deletion
|
||||
$this->episode->published_at = null;
|
||||
|
||||
if (! $episodeModel->update($this->episode->id, $this->episode)) {
|
||||
$db->transRollback();
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $episodeModel->errors());
|
||||
}
|
||||
}
|
||||
|
||||
$episodeModel->delete($this->episode->id);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class PageController extends BaseController
|
|||
->with('errors', $pageModel->errors());
|
||||
}
|
||||
|
||||
return redirect()->route('page-list');
|
||||
return redirect()->route('page-edit', [$this->page->id])->with('message', lang('Page.messages.editSuccess'));
|
||||
}
|
||||
|
||||
public function delete(): RedirectResponse
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ class PersonController extends BaseController
|
|||
|
||||
$db->transComplete();
|
||||
|
||||
return redirect()->route('person-list');
|
||||
return redirect()->route('person-list')
|
||||
->with('message', lang('Person.messages.createSuccess'));
|
||||
}
|
||||
|
||||
public function edit(): string
|
||||
|
|
@ -145,13 +146,17 @@ class PersonController extends BaseController
|
|||
->with('errors', $personModel->errors());
|
||||
}
|
||||
|
||||
return redirect()->route('person-view', [$this->person->id]);
|
||||
return redirect()->route('person-edit', [$this->person->id])->with(
|
||||
'message',
|
||||
lang('Person.messages.editSuccess')
|
||||
);
|
||||
}
|
||||
|
||||
public function delete(): RedirectResponse
|
||||
{
|
||||
(new PersonModel())->delete($this->person->id);
|
||||
|
||||
return redirect()->route('person-list');
|
||||
return redirect()->route('person-list')
|
||||
->with('message', lang('Person.messages.deleteSuccess'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -255,7 +255,10 @@ class PodcastController extends BaseController
|
|||
|
||||
$db->transComplete();
|
||||
|
||||
return redirect()->route('podcast-view', [$newPodcastId]);
|
||||
return redirect()->route('podcast-view', [$newPodcastId])->with(
|
||||
'message',
|
||||
lang('Podcast.messages.createSuccess')
|
||||
);
|
||||
}
|
||||
|
||||
public function edit(): string
|
||||
|
|
@ -354,7 +357,10 @@ class PodcastController extends BaseController
|
|||
|
||||
$db->transComplete();
|
||||
|
||||
return redirect()->back();
|
||||
return redirect()->route('podcast-edit', [$this->podcast->id])->with(
|
||||
'message',
|
||||
lang('Podcast.messages.editSuccess')
|
||||
);
|
||||
}
|
||||
|
||||
public function deleteBanner(): RedirectResponse
|
||||
|
|
|
|||
|
|
@ -134,7 +134,10 @@ class SoundbiteController extends BaseController
|
|||
->with('errors', $clipModel->errors());
|
||||
}
|
||||
|
||||
return redirect()->route('soundbites-list', [$this->podcast->id, $this->episode->id]);
|
||||
return redirect()->route('soundbites-list', [$this->podcast->id, $this->episode->id])->with(
|
||||
'message',
|
||||
lang('Soundbite.messages.createSuccess')
|
||||
);
|
||||
}
|
||||
|
||||
public function delete(string $soundbiteId): RedirectResponse
|
||||
|
|
@ -158,6 +161,9 @@ class SoundbiteController extends BaseController
|
|||
}
|
||||
}
|
||||
|
||||
return redirect()->route('soundbites-list', [$this->podcast->id, $this->episode->id]);
|
||||
return redirect()->route('soundbites-list', [$this->podcast->id, $this->episode->id])->with(
|
||||
'message',
|
||||
lang('Soundbite.messages.deleteSuccess')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue