mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +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->updateTags();
|
||||||
$track->save();
|
$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 . ')')
|
'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)]);
|
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>
|
<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>
|
</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">
|
<div class="form-row">
|
||||||
<label class="strong">Choose a License:</label>
|
<label class="strong">Choose a License:</label>
|
||||||
<ul class="license-grid">
|
<ul class="license-grid">
|
||||||
|
|
|
@ -30,6 +30,7 @@ module.exports = angular.module('ponyfm').directive 'pfmTrackEditor', () ->
|
||||||
$scope.selectedSongs = {}
|
$scope.selectedSongs = {}
|
||||||
$scope.albums = []
|
$scope.albums = []
|
||||||
$scope.selectedAlbum = null
|
$scope.selectedAlbum = null
|
||||||
|
$scope.isAdmin = auth.data.isAdmin
|
||||||
albumsDb = {}
|
albumsDb = {}
|
||||||
|
|
||||||
$scope.selectAlbum = (album) ->
|
$scope.selectAlbum = (album) ->
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
module.exports = angular.module('ponyfm').factory('auth', [
|
module.exports = angular.module('ponyfm').factory('auth', [
|
||||||
'$rootScope'
|
'$rootScope'
|
||||||
($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) ->
|
login: (email, password, remember) ->
|
||||||
def = new $.Deferred()
|
def = new $.Deferred()
|
||||||
$.post('/api/web/auth/login', {email: email, password: password, remember: remember})
|
$.post('/api/web/auth/login', {email: email, password: password, remember: remember})
|
||||||
|
|
Loading…
Reference in a new issue