From da97b4d4fc8f6978796a64b3a2d606b7eaf0d0c5 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Wed, 14 Sep 2011 20:54:39 +0400 Subject: [PATCH] Album status --- app/controllers/artist_controller.rb | 2 +- app/controllers/import_controller.rb | 3 +++ db/migrate/20110914163231_add_status_to_albums.rb | 5 +++++ db/schema.rb | 3 ++- 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20110914163231_add_status_to_albums.rb diff --git a/app/controllers/artist_controller.rb b/app/controllers/artist_controller.rb index de160cd..5b3a719 100644 --- a/app/controllers/artist_controller.rb +++ b/app/controllers/artist_controller.rb @@ -81,7 +81,7 @@ class ArtistController < ApplicationController @artist[:albums] = [] artist.albums.each do |album| - if @@default_album_types.include? album.album_type + if @@default_album_types.include? album.album_type and album.status == 1 tmp_album = {id: album.id, name: album.name, year: album.year, pic: album.pic_url} album_tracks = [] bonus_tracks = [] diff --git a/app/controllers/import_controller.rb b/app/controllers/import_controller.rb index 43114a4..6d7cba2 100644 --- a/app/controllers/import_controller.rb +++ b/app/controllers/import_controller.rb @@ -48,6 +48,7 @@ class ImportController < ApplicationController album.album_type = brainz_release_group.type album.pic_url = album_image album.has_pic = (album_image != '' and not album_image.nil?) + album.status = 0 dry_run ? ap(album) : album.save # Tracks from the first release tracks_hashed = [] @@ -72,6 +73,8 @@ class ImportController < ApplicationController dry_run ? ap(track) : track.save end end + album.status = 1 + album.save unless dry_run end artist.status = 1 diff --git a/db/migrate/20110914163231_add_status_to_albums.rb b/db/migrate/20110914163231_add_status_to_albums.rb new file mode 100644 index 0000000..810f0c2 --- /dev/null +++ b/db/migrate/20110914163231_add_status_to_albums.rb @@ -0,0 +1,5 @@ +class AddStatusToAlbums < ActiveRecord::Migration + def change + add_column :albums, :status, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 20b1a85..52f0a0a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110630052149) do +ActiveRecord::Schema.define(:version => 20110914163231) do create_table "albums", :force => true do |t| t.string "name" @@ -23,6 +23,7 @@ ActiveRecord::Schema.define(:version => 20110630052149) do t.string "album_type" t.string "mbid" t.integer "has_pic" + t.integer "status" end create_table "artists", :force => true do |t|