-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from blackcandy-org/playlist-songs-controller…
…s-refactoring Refactor playlist songs controllers
- Loading branch information
Showing
46 changed files
with
358 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/controllers/api/v1/current_playlist/songs/albums_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V1 | ||
class CurrentPlaylist::Songs::AlbumsController < ApiController | ||
before_action :find_current_playlist | ||
before_action :find_album | ||
after_action :add_to_recently_played, only: [:update] | ||
|
||
def update | ||
@current_playlist.replace(@album.song_ids) | ||
end | ||
|
||
private | ||
|
||
def find_current_playlist | ||
@current_playlist = Current.user.current_playlist | ||
end | ||
|
||
def find_album | ||
@album = Album.find(params[:id]) | ||
end | ||
|
||
def add_to_recently_played | ||
Current.user.add_album_to_recently_played(@album) | ||
end | ||
end | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
app/controllers/api/v1/current_playlist/songs/playlists_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V1 | ||
class CurrentPlaylist::Songs::PlaylistsController < ApiController | ||
before_action :find_current_playlist | ||
before_action :find_playlist | ||
|
||
def update | ||
@current_playlist.replace(@playlist.song_ids) | ||
end | ||
|
||
private | ||
|
||
def find_current_playlist | ||
@current_playlist = Current.user.current_playlist | ||
end | ||
|
||
def find_playlist | ||
@playlist = Current.user.playlists_with_favorite.find(params[:id]) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
app/controllers/current_playlist/songs/albums_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
class CurrentPlaylist::Songs::AlbumsController < ApplicationController | ||
before_action :find_current_playlist | ||
before_action :find_album | ||
after_action :add_to_recently_played, only: [:update] | ||
|
||
def update | ||
@current_playlist.replace(@album.song_ids) | ||
redirect_to current_playlist_songs_path(should_play_all: true) | ||
end | ||
|
||
private | ||
|
||
def find_current_playlist | ||
@current_playlist = Current.user.current_playlist | ||
end | ||
|
||
def find_album | ||
@album = Album.find(params[:id]) | ||
end | ||
|
||
def add_to_recently_played | ||
Current.user.add_album_to_recently_played(@album) | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
app/controllers/current_playlist/songs/playlists_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class CurrentPlaylist::Songs::PlaylistsController < ApplicationController | ||
before_action :find_current_playlist | ||
before_action :find_playlist | ||
|
||
def update | ||
@current_playlist.replace(@playlist.song_ids) | ||
redirect_to current_playlist_songs_path(should_play_all: true) | ||
end | ||
|
||
private | ||
|
||
def find_current_playlist | ||
@current_playlist = Current.user.current_playlist | ||
end | ||
|
||
def find_playlist | ||
@playlist = Current.user.playlists_with_favorite.find(params[:id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.