From 69b61b39006c1951fc8c08746e884e63e50233b3 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Sat, 21 Jun 2014 15:26:33 +0900 Subject: [PATCH] add lg_id in resource picture --- .../manifest/work/controllers.js.coffee.erb | 6 ++++++ .../manifest/work/list_groups.js.coffee.erb | 6 ++++++ .../javascripts/manifest/work/models.js.coffee.erb | 11 +++++++++++ .../manifest/work/profilers.js.coffee.erb | 2 ++ app/controllers/resource_pictures_controller.rb | 10 +++++++++- app/models/license_group.rb | 1 + app/models/resource_picture.rb | 1 + config/locales/pettanr.ja.yml | 2 ++ config/routes.rb | 4 ++++ .../20140621054351_license_on_extend_data.rb | 14 ++++++++++++++ public/local_manifest.json | 8 ++++++++ public/manifest.json | 22 +++++++++++++++------- 12 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20140621054351_license_on_extend_data.rb diff --git a/app/assets/javascripts/manifest/work/controllers.js.coffee.erb b/app/assets/javascripts/manifest/work/controllers.js.coffee.erb index cd24582f..604a318a 100644 --- a/app/assets/javascripts/manifest/work/controllers.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/controllers.js.coffee.erb @@ -820,6 +820,9 @@ }, }, + by_license_group: { + type: 'list', + }, by_license: { type: 'list', }, @@ -835,6 +838,9 @@ list_name: 'public', }, }, + count_by_license_group: { + type: 'count', + }, count_by_license: { type: 'count', }, diff --git a/app/assets/javascripts/manifest/work/list_groups.js.coffee.erb b/app/assets/javascripts/manifest/work/list_groups.js.coffee.erb index 59bd3442..1d21685f 100644 --- a/app/assets/javascripts/manifest/work/list_groups.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/list_groups.js.coffee.erb @@ -432,6 +432,9 @@ by_original_picture: { type: 'filter', }, + by_license_group: { + type: 'filter', + }, by_license: { type: 'filter', }, @@ -477,6 +480,9 @@ public: { type: 'public', }, + by_resource_picture: { + type: 'filter', + }, select_items: { type: 'system_resource', }, diff --git a/app/assets/javascripts/manifest/work/models.js.coffee.erb b/app/assets/javascripts/manifest/work/models.js.coffee.erb index b7972b0e..58a9cb45 100644 --- a/app/assets/javascripts/manifest/work/models.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/models.js.coffee.erb @@ -1240,6 +1240,8 @@ belongs_to: { original_picture: { }, + license_group: { + }, license: { }, artist: { @@ -1294,6 +1296,13 @@ number: true, } }, + license_group_id: { + type: 'number', + rules : { + required: true, + number: true, + } + }, license_id: { type: 'number', rules : { @@ -1554,6 +1563,8 @@ belongs_to: { }, has_many: { + resource_pictures: { + }, licenses: { }, }, diff --git a/app/assets/javascripts/manifest/work/profilers.js.coffee.erb b/app/assets/javascripts/manifest/work/profilers.js.coffee.erb index 53b1244d..45746b6c 100644 --- a/app/assets/javascripts/manifest/work/profilers.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/profilers.js.coffee.erb @@ -419,6 +419,7 @@ ], associations: { belongs_to: [ + 'license_group', 'license', 'artist', ], @@ -768,6 +769,7 @@ }, associations: { has_many: [ + 'resource_pictures.by_license_group', 'licenses.by_license_group', ], }, diff --git a/app/controllers/resource_pictures_controller.rb b/app/controllers/resource_pictures_controller.rb index 644e735a..a0847fe5 100644 --- a/app/controllers/resource_pictures_controller.rb +++ b/app/controllers/resource_pictures_controller.rb @@ -4,7 +4,7 @@ class ResourcePicturesController < ApplicationController before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy] else before_filter :authenticate_resource_reader, :only => [ - :index, :show, :credit, :by_license, :by_artist, :count, :count_by_license, :count_by_artist + :index, :show, :credit, :by_license_group, :by_license, :by_artist, :count, :count_by_license_group, :count_by_license, :count_by_artist ] before_filter :authenticate_user, :only => [:new, :create, :update, :destroy] before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy] @@ -18,6 +18,10 @@ class ResourcePicturesController < ApplicationController filer_list end + def by_license_group + filer_list + end + def by_license filer_list end @@ -57,6 +61,10 @@ class ResourcePicturesController < ApplicationController list_count end + def count_by_license_group + list_count + end + def count_by_license list_count end diff --git a/app/models/license_group.rb b/app/models/license_group.rb index 08490656..2fa5f67f 100644 --- a/app/models/license_group.rb +++ b/app/models/license_group.rb @@ -1,6 +1,7 @@ #ライセンスグループ class LicenseGroup < Peta::Template load_manifest + has_many :resource_pictures has_many :licenses validates :name, :presence => true, :length => {:maximum => 50}, :uniqueness => true diff --git a/app/models/resource_picture.rb b/app/models/resource_picture.rb index 773c4c32..a43698a1 100644 --- a/app/models/resource_picture.rb +++ b/app/models/resource_picture.rb @@ -2,6 +2,7 @@ class ResourcePicture < Peta::Content load_manifest belongs_to :artist + belongs_to :license_group belongs_to :license belongs_to :system_picture belongs_to :picture diff --git a/config/locales/pettanr.ja.yml b/config/locales/pettanr.ja.yml index d49c4652..01dff375 100644 --- a/config/locales/pettanr.ja.yml +++ b/config/locales/pettanr.ja.yml @@ -1284,6 +1284,8 @@ ja: title: 素材一覧 by_artist: title: 絵師の素材一覧 + by_license_group: + title: ライセンスの素材一覧 by_license: title: ライセンスの素材一覧 show: diff --git a/config/routes.rb b/config/routes.rb index 42f8b464..46e85317 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -382,8 +382,10 @@ Pettanr::Application.routes.draw do get :count end member do + get :by_license_group get :by_license get :by_artist + get :count_by_license_group get :count_by_license get :count_by_artist delete :destroy @@ -430,6 +432,8 @@ Pettanr::Application.routes.draw do post :create end member do + get :resource_pictures + get :resource_pictures_count get :licenses get :licenses_count put :update diff --git a/db/migrate/20140621054351_license_on_extend_data.rb b/db/migrate/20140621054351_license_on_extend_data.rb new file mode 100644 index 00000000..8d3636ca --- /dev/null +++ b/db/migrate/20140621054351_license_on_extend_data.rb @@ -0,0 +1,14 @@ +class LicenseOnExtendData < ActiveRecord::Migration + def up + ResourcePicture.all.each do |rp| + if rp.license_group_id.blank? or rp.license_group_id == 0 + rp.license_group_id = rp.license.license_group_id + rp.boosts 'post' + rp.save! + end + end + end + + def down + end +end diff --git a/public/local_manifest.json b/public/local_manifest.json index 9e781fe2..3a665cbc 100644 --- a/public/local_manifest.json +++ b/public/local_manifest.json @@ -432,6 +432,9 @@ "by_original_picture": { "type": "filter" }, + "by_license_group": { + "type": "filter" + }, "by_license": { "type": "filter" }, @@ -477,6 +480,9 @@ "public": { "type": "public" }, + "by_resource_picture": { + "type": "filter" + }, "select_items": { "type": "system_resource" } @@ -934,6 +940,7 @@ ], "associations": { "belongs_to": [ + "license_group", "license", "artist" ] @@ -1240,6 +1247,7 @@ }, "associations": { "has_many": [ + "resource_pictures.by_license_group", "licenses.by_license_group" ] } diff --git a/public/manifest.json b/public/manifest.json index bd2e6ecc..b72ecdfd 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1010,6 +1010,9 @@ "list_name": "public" } }, + "by_license_group": { + "type": "list" + }, "by_license": { "type": "list" }, @@ -1025,6 +1028,9 @@ "list_name": "public" } }, + "count_by_license_group": { + "type": "count" + }, "count_by_license": { "type": "count" }, @@ -2572,6 +2578,7 @@ "associations": { "belongs_to": { "original_picture": {}, + "license_group": {}, "license": {}, "artist": {}, "system_picture": {} @@ -2621,6 +2628,13 @@ "number": true } }, + "license_group_id": { + "type": "number", + "rules": { + "required": true, + "number": true + } + }, "license_id": { "type": "number", "rules": { @@ -2641,13 +2655,6 @@ "number": true } }, - "license_group_id": { - "type": "number", - "rules": { - "required": true, - "number": true - } - }, "license_group_settings": { "type": "text", "rules": {} @@ -2861,6 +2868,7 @@ "associations": { "belongs_to": {}, "has_many": { + "resource_pictures": {}, "licenses": {} }, "has_one": {} -- 2.11.0