Don't allow adding songs to smart playlists
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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 =
|
||||||
|
|||||||
@@ -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' },
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user