Added is listed feature

This commit is contained in:
nelsonlaquet 2013-09-24 01:27:13 -05:00
parent 675ba17901
commit cca292049e
10 changed files with 43 additions and 6 deletions

View file

@ -57,7 +57,7 @@
if (!$user)
App::abort(404);
$query = Track::summary()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at');
$query = Track::summary()->published()->listed()->explicitFilter()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at');
$tracks = [];
$singles = [];
@ -88,7 +88,7 @@
if (!$user)
App::abort(404);
$trackQuery = Track::summary()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at')->orderBy('created_at', 'desc')->take(20);
$trackQuery = Track::summary()->published()->explicitFilter()->listed()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at')->orderBy('created_at', 'desc')->take(20);
$latestTracks = [];
foreach ($trackQuery->get() as $track) {

View file

@ -18,6 +18,7 @@
$recentQuery = Track::summary()
->with(['genre', 'user', 'cover', 'user.avatar'])
->whereIsLatest(true)
->listed()
->userDetails()
->explicitFilter()
->published()

View file

@ -52,6 +52,7 @@
$query = Track::summary()
->userDetails()
->listed()
->explicitFilter()
->published()
->with('user', 'genre', 'cover', 'album', 'album.user');

View file

@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
class TrackIsListed extends Migration {
public function up() {
Schema::table('tracks', function($table) {
$table->boolean('is_listed')->notNullable()->indexed();
});
DB::update('
UPDATE
tracks
SET
is_listed = true');
}
public function down() {
Schema::table('tracks', function($table) {
$table->dropColumn('is_listed');
});
}
}

View file

@ -70,6 +70,7 @@
$track->track_type_id = $this->_input['track_type_id'];
$track->is_explicit = $this->_input['is_explicit'] == 'true';
$track->is_downloadable = $this->_input['is_downloadable'] == 'true';
$track->is_listed = $this->_input['is_listed'] == 'true';
$track->is_vocal = $isVocal;
if (isset($this->_input['album_id']) && strlen(trim($this->_input['album_id']))) {

View file

@ -40,6 +40,7 @@
$track->user_id = $user->id;
$track->title = pathinfo($trackFile->getClientOriginalName(), PATHINFO_FILENAME);
$track->duration = $audio->getDuration();
$track->is_listed = true;
$track->save();

View file

@ -47,6 +47,10 @@
$query->whereNotNull('published_at');
}
public function scopeListed($query) {
$query->whereIsListed(true);
}
public function scopeExplicitFilter($query) {
if (!Auth::check() || !Auth::user()->can_see_explicit_content)
$query->whereIsExplicit(false);
@ -60,6 +64,7 @@
$trackIds = Cache::remember('popular_tracks' . $count . '-' . ($allowExplicit ? 'explicit' : 'safe'), 5, function() use ($allowExplicit, $count) {
$query = static
::published()
->listed()
->join(DB::raw('
( SELECT `track_id`, `created_at`
FROM `resource_log_items`
@ -249,7 +254,8 @@
'duration' => $track->duration,
'genre_id' => $track->genre_id,
'track_type_id' => $track->track_type_id,
'cover_url' => $track->getCoverUrl(Image::SMALL)
'cover_url' => $track->getCoverUrl(Image::SMALL),
'is_listed' => !!$track->is_listed
];
}

View file

@ -57,7 +57,7 @@
return $this->email;
}
public function setDisplayName($value) {
public function setDisplayNameAttribute($value) {
$this->attributes['display_name'] = $value;
$this->attributes['slug'] = Str::slug($value);
}

View file

@ -122,6 +122,7 @@ angular.module('ponyfm').controller "account-track", [
cover: track.cover_url
album_id: track.album_id
is_published: track.is_published
is_listed: track.is_listed
$scope.selectedAlbum = if track.album_id then albumsDb[track.album_id] else null
$scope.selectedSongs = {}

View file

@ -91,12 +91,15 @@
</div>
</div>
<div class="row-fluid">
<div class="span6 form-row">
<div class="span4 form-row">
<label for="is_explicit"><input ng-disabled="isSaving" ng-change="touchModel()" id="is_explicit" type="checkbox" ng-model="edit.is_explicit" /> Contains Explicit Content</label>
</div>
<div class="span6 form-row">
<div class="span4 form-row">
<label for="is_downloadable"><input ng-disabled="isSaving" ng-change="touchModel()" id="is_downloadable" type="checkbox" ng-model="edit.is_downloadable" /> Is Downloadable</label>
</div>
<div class="span4 form-row">
<label for="is_listed"><input ng-disabled="isSaving" ng-change="touchModel()" id="is_listed" type="checkbox" ng-model="edit.is_listed" /> Is Listed</label>
</div>
</div>
<div class="form-row">
<label class="strong">Choose a License:</label>