mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-21 20:48:00 +01:00
Admins can assign tracks to accounts
This commit is contained in:
parent
481a0a6b9f
commit
d01b24a91f
4 changed files with 24 additions and 1 deletions
|
@ -146,6 +146,15 @@ class EditTrackCommand extends CommandBase
|
|||
}
|
||||
}
|
||||
|
||||
$oldid = null;
|
||||
|
||||
if (isset($this->_input['user_id'])) {
|
||||
if ($track->user_id != $this->_input['user_id']) {
|
||||
$oldid = $track->user_id;
|
||||
$track->user_id = $this->_input['user_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$track->updateTags();
|
||||
$track->save();
|
||||
|
||||
|
@ -153,6 +162,12 @@ class EditTrackCommand extends CommandBase
|
|||
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = ' . $this->_track->user_id . ')')
|
||||
]);
|
||||
|
||||
if ($oldid != null) {
|
||||
User::whereId($oldid)->update([
|
||||
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = ' . $oldid . ')')
|
||||
]);
|
||||
}
|
||||
|
||||
return CommandResponse::succeed(['real_cover_url' => $track->getCoverUrl(Image::NORMAL)]);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,13 @@
|
|||
<label for="is_listed"><input ng-disabled="isSaving" ng-change="touchModel()" id="is_listed" type="checkbox" ng-model="track.is_listed" /> Is Listed</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid" ng-show="isAdmin">
|
||||
<div class="span6 form-row">
|
||||
<label for="title" class="strong">User:</label>
|
||||
<input ng-disabled="isSaving" ng-change="touchModel()" placeholder="Username" type="text" id="username" ng-model="track.user_id" />
|
||||
<div class="error">{{errors.title}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label class="strong">Choose a License:</label>
|
||||
<ul class="license-grid">
|
||||
|
|
|
@ -30,6 +30,7 @@ module.exports = angular.module('ponyfm').directive 'pfmTrackEditor', () ->
|
|||
$scope.selectedSongs = {}
|
||||
$scope.albums = []
|
||||
$scope.selectedAlbum = null
|
||||
$scope.isAdmin = auth.data.isAdmin
|
||||
albumsDb = {}
|
||||
|
||||
$scope.selectAlbum = (album) ->
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
module.exports = angular.module('ponyfm').factory('auth', [
|
||||
'$rootScope'
|
||||
($rootScope) ->
|
||||
data: {isLogged: window.pfm.auth.isLogged, user: window.pfm.auth.user}
|
||||
data: {isLogged: window.pfm.auth.isLogged, user: window.pfm.auth.user, isAdmin: window.pfm.auth.user.roles[0].id == 2}
|
||||
login: (email, password, remember) ->
|
||||
def = new $.Deferred()
|
||||
$.post('/api/web/auth/login', {email: email, password: password, remember: remember})
|
||||
|
|
Loading…
Reference in a new issue