mirror of
https://github.com/krateng/maloja.git
synced 2025-04-17 01:02:20 +03:00
Implemented web editing for albums
This commit is contained in:
parent
c7f392a74f
commit
688cac81ee
@ -714,6 +714,16 @@ def edit_track(id,title):
|
||||
"status":"success"
|
||||
}
|
||||
|
||||
@api.post("edit_album")
|
||||
@authenticated_function(api=True)
|
||||
@catch_exceptions
|
||||
def edit_album(id,albumtitle):
|
||||
"""Internal Use Only"""
|
||||
result = database.edit_album(id,{'albumtitle':albumtitle})
|
||||
return {
|
||||
"status":"success"
|
||||
}
|
||||
|
||||
|
||||
@api.post("merge_tracks")
|
||||
@authenticated_function(api=True)
|
||||
|
@ -189,6 +189,16 @@ def edit_track(id,trackinfo):
|
||||
|
||||
return result
|
||||
|
||||
@waitfordb
|
||||
def edit_album(id,albuminfo):
|
||||
album = sqldb.get_album(id)
|
||||
log(f"Renaming {album['albumtitle']} to {albuminfo['albumtitle']}")
|
||||
result = sqldb.edit_album(id,albuminfo)
|
||||
dbcache.invalidate_entity_cache()
|
||||
dbcache.invalidate_caches()
|
||||
|
||||
return result
|
||||
|
||||
@waitfordb
|
||||
def merge_artists(target_id,source_ids):
|
||||
sources = [sqldb.get_artist(id) for id in source_ids]
|
||||
|
@ -558,6 +558,28 @@ def edit_track(id,trackupdatedict,dbconn=None):
|
||||
|
||||
return True
|
||||
|
||||
@connection_provider
|
||||
def edit_album(id,albumupdatedict,dbconn=None):
|
||||
|
||||
album = get_album(id,dbconn=dbconn)
|
||||
changedalbum = {**album,**albumupdatedict}
|
||||
|
||||
dbentry = album_dict_to_db(albumupdatedict,dbconn=dbconn)
|
||||
dbentry = {k:v for k,v in dbentry.items() if v}
|
||||
|
||||
existing_album_id = get_album_id(changedalbum,create_new=False,dbconn=dbconn)
|
||||
if existing_album_id not in (None,id):
|
||||
raise exc.TrackExists(changedalbum)
|
||||
|
||||
op = DB['albums'].update().where(
|
||||
DB['albums'].c.id==id
|
||||
).values(
|
||||
**dbentry
|
||||
)
|
||||
result = dbconn.execute(op)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
### Merge
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
<td>
|
||||
<a href="{{ links.url(album) }}">
|
||||
<div class="lazy" data-bg="{{ images.get_album_image(album) }}"'>
|
||||
<span class='stats'>#{{ rank }}</span> <span>{{ album.title }}</span>
|
||||
<span class='stats'>#{{ rank }}</span> <span>{{ album.albumtitle }}</span>
|
||||
</div>
|
||||
</a>
|
||||
</td>
|
||||
|
@ -161,6 +161,11 @@ function doneEditing() {
|
||||
searchParams.set("title", newname);
|
||||
var payload = {'id':entity_id,'title':newname}
|
||||
}
|
||||
else if (entity_type == 'album') {
|
||||
var endpoint = "/apis/mlj_1/edit_album";
|
||||
searchParams.set("albumtitle", newname);
|
||||
var payload = {'id':entity_id,'albumtitle':newname}
|
||||
}
|
||||
|
||||
callback_func = function(req){
|
||||
if (req.status == 200) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user