Don't allow adding songs to smart playlists

This commit is contained in:
Deluan
2022-10-02 13:56:39 -04:00
parent 552989a05b
commit 3d5a1cef92
4 changed files with 10 additions and 5 deletions
+6 -1
View File
@@ -32,7 +32,8 @@ func NewPlaylistRepository(ctx context.Context, o orm.QueryExecutor) model.Playl
r.ormer = o r.ormer = o
r.tableName = "playlist" r.tableName = "playlist"
r.filterMappings = map[string]filterFunc{ r.filterMappings = map[string]filterFunc{
"q": playlistFilter, "q": playlistFilter,
"smart": smartPlaylistFilter,
} }
return r return r
} }
@@ -44,6 +45,10 @@ func playlistFilter(field string, value interface{}) Sqlizer {
} }
} }
func smartPlaylistFilter(field string, value interface{}) Sqlizer {
return Eq{"rules": ""}
}
func (r *playlistRepository) userFilter() Sqlizer { func (r *playlistRepository) userFilter() Sqlizer {
user := loggedUser(r.ctx) user := loggedUser(r.ctx)
if user.IsAdmin { if user.IsAdmin {
+1 -1
View File
@@ -45,7 +45,7 @@ const createTestUtils = (mockDataProvider) =>
data: mockIndexedData, data: mockIndexedData,
list: { list: {
cachedRequests: { cachedRequests: {
'{"pagination":{"page":1,"perPage":-1},"sort":{"field":"name","order":"ASC"},"filter":{}}': '{"pagination":{"page":1,"perPage":-1},"sort":{"field":"name","order":"ASC"},"filter":{"smart":false}}':
{ {
ids: ['sample-id1', 'sample-id2'], ids: ['sample-id1', 'sample-id2'],
total: 2, total: 2,
+1 -1
View File
@@ -25,7 +25,7 @@ export const SelectPlaylistInput = ({ onChange }) => {
'playlist', 'playlist',
{ page: 1, perPage: -1 }, { page: 1, perPage: -1 },
{ field: 'name', order: 'ASC' }, { field: 'name', order: 'ASC' },
{} { smart: false }
) )
const options = const options =
+2 -2
View File
@@ -51,7 +51,7 @@ describe('SelectPlaylistInput', () => {
data: mockIndexedData, data: mockIndexedData,
list: { list: {
cachedRequests: { cachedRequests: {
'{"pagination":{"page":1,"perPage":-1},"sort":{"field":"name","order":"ASC"},"filter":{}}': '{"pagination":{"page":1,"perPage":-1},"sort":{"field":"name","order":"ASC"},"filter":{"smart":false}}':
{ {
ids: ['sample-id1', 'sample-id2'], ids: ['sample-id1', 'sample-id2'],
total: 2, total: 2,
@@ -70,7 +70,7 @@ describe('SelectPlaylistInput', () => {
await waitFor(() => { await waitFor(() => {
expect(mockDataProvider.getList).toHaveBeenCalledWith('playlist', { expect(mockDataProvider.getList).toHaveBeenCalledWith('playlist', {
filter: {}, filter: { smart: false },
pagination: { page: 1, perPage: -1 }, pagination: { page: 1, perPage: -1 },
sort: { field: 'name', order: 'ASC' }, sort: { field: 'name', order: 'ASC' },
}) })