mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Error handling and switched to username
This commit is contained in:
parent
1a77341ce2
commit
17a9f6e50c
4 changed files with 12 additions and 7 deletions
|
@ -71,7 +71,8 @@ class EditTrackCommand extends CommandBase
|
|||
'track_type_id' => 'required|exists:track_types,id|not_in:'.TrackType::UNCLASSIFIED_TRACK,
|
||||
'songs' => 'required_when:track_type,2|exists:songs,id',
|
||||
'cover_id' => 'exists:images,id',
|
||||
'album_id' => 'exists:albums,id'
|
||||
'album_id' => 'exists:albums,id',
|
||||
'username' => 'exists:users,username'
|
||||
];
|
||||
|
||||
if (isset($this->_input['track_type_id']) && $this->_input['track_type_id'] == 2) {
|
||||
|
@ -148,10 +149,12 @@ class EditTrackCommand extends CommandBase
|
|||
|
||||
$oldid = null;
|
||||
|
||||
if (isset($this->_input['user_id'])) {
|
||||
if ($track->user_id != $this->_input['user_id']) {
|
||||
if (isset($this->_input['username'])) {
|
||||
$newid = User::where('username', $this->_input['username'])->first()->id;
|
||||
|
||||
if ($track->user_id != $newid) {
|
||||
$oldid = $track->user_id;
|
||||
$track->user_id = $this->_input['user_id'];
|
||||
$track->user_id = $newid;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -448,6 +448,7 @@ class Track extends Model implements Searchable
|
|||
$returnValue['description'] = $track->description;
|
||||
$returnValue['is_downloadable'] = !$track->isPublished() ? true : (bool) $track->is_downloadable;
|
||||
$returnValue['license_id'] = $track->license_id != null ? $track->license_id : 3;
|
||||
$returnValue['username'] = User::whereId($track->user_id)->first()->username;
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
|
|
@ -108,10 +108,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row-fluid" ng-show="isAdmin">
|
||||
<div class="span6 form-row">
|
||||
<div class="span6 form-row" ng-class="{'has-error': errors.username != null}">
|
||||
<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>
|
||||
<input ng-disabled="isSaving" ng-change="touchModel()" placeholder="Username" type="text" id="username" ng-model="track.username" />
|
||||
<div class="error">{{errors.username}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
|
|
@ -157,6 +157,7 @@ module.exports = angular.module('ponyfm').directive 'pfmTrackEditor', () ->
|
|||
id: track.id
|
||||
title: track.title
|
||||
user_id: track.user_id
|
||||
username: track.username
|
||||
description: track.description
|
||||
lyrics: track.lyrics
|
||||
is_explicit: track.is_explicit
|
||||
|
|
Loading…
Reference in a new issue