OSDN Git Service

add lg_id in resource picture
authoryasushiito <yas@pen-chan.jp>
Sat, 21 Jun 2014 06:26:33 +0000 (15:26 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 21 Jun 2014 06:26:33 +0000 (15:26 +0900)
12 files changed:
app/assets/javascripts/manifest/work/controllers.js.coffee.erb
app/assets/javascripts/manifest/work/list_groups.js.coffee.erb
app/assets/javascripts/manifest/work/models.js.coffee.erb
app/assets/javascripts/manifest/work/profilers.js.coffee.erb
app/controllers/resource_pictures_controller.rb
app/models/license_group.rb
app/models/resource_picture.rb
config/locales/pettanr.ja.yml
config/routes.rb
db/migrate/20140621054351_license_on_extend_data.rb [new file with mode: 0644]
public/local_manifest.json
public/manifest.json

index cd24582..604a318 100644 (file)
           \r
         },\r
       },\r
+      by_license_group: {\r
+        type: 'list',\r
+      },\r
       by_license: {\r
         type: 'list',\r
       },\r
           list_name: 'public',\r
         },\r
       },\r
+      count_by_license_group: {\r
+        type: 'count',\r
+      },\r
       count_by_license: {\r
         type: 'count',\r
       },\r
index 59bd344..1d21685 100644 (file)
       by_original_picture: {\r
         type: 'filter',\r
       },\r
+      by_license_group: {\r
+        type: 'filter',\r
+      },\r
       by_license: {\r
         type: 'filter',\r
       },\r
       public: {\r
         type: 'public',\r
       },\r
+      by_resource_picture: {\r
+        type: 'filter',\r
+      },\r
       select_items: {\r
         type: 'system_resource',\r
       },\r
index b7972b0..58a9cb4 100644 (file)
       belongs_to: {\r
         original_picture: {\r
         }, \r
+        license_group: {\r
+        }, \r
         license: {\r
         }, \r
         artist: {\r
           number: true,\r
         }\r
       },\r
+      license_group_id: {\r
+        type: 'number',\r
+        rules : {\r
+          required: true,\r
+          number: true,\r
+        }\r
+      },\r
       license_id: {\r
         type: 'number',\r
         rules : {\r
       belongs_to: {\r
       },\r
       has_many: {\r
+        resource_pictures: {\r
+        }, \r
         licenses: {\r
         }, \r
       },\r
index 53b1244..45746b6 100644 (file)
     ],\r
     associations: {\r
       belongs_to: [\r
+        'license_group',\r
         'license',\r
         'artist',\r
       ],\r
     },\r
     associations: {\r
       has_many: [\r
+        'resource_pictures.by_license_group', \r
         'licenses.by_license_group', \r
       ],\r
     }, \r
index 644e735..a0847fe 100644 (file)
@@ -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
index 0849065..2fa5f67 100644 (file)
@@ -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
index 773c4c3..a43698a 100644 (file)
@@ -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
index d49c465..01dff37 100644 (file)
@@ -1284,6 +1284,8 @@ ja:
       title: 素材一覧
     by_artist:
       title: 絵師の素材一覧
+    by_license_group:
+      title: ライセンスの素材一覧
     by_license:
       title: ライセンスの素材一覧
     show:
index 42f8b46..46e8531 100644 (file)
@@ -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 (file)
index 0000000..8d3636c
--- /dev/null
@@ -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
index 9e781fe..3a665cb 100644 (file)
         "by_original_picture": {\r
           "type": "filter"\r
         },\r
+        "by_license_group": {\r
+          "type": "filter"\r
+        },\r
         "by_license": {\r
           "type": "filter"\r
         },\r
         "public": {\r
           "type": "public"\r
         },\r
+        "by_resource_picture": {\r
+          "type": "filter"\r
+        },\r
         "select_items": {\r
           "type": "system_resource"\r
         }\r
       ],\r
       "associations": {\r
         "belongs_to": [\r
+          "license_group",\r
           "license",\r
           "artist"\r
         ]\r
       },\r
       "associations": {\r
         "has_many": [\r
+          "resource_pictures.by_license_group",\r
           "licenses.by_license_group"\r
         ]\r
       }\r
index bd2e6ec..b72ecdf 100644 (file)
             "list_name": "public"\r
           }\r
         },\r
+        "by_license_group": {\r
+          "type": "list"\r
+        },\r
         "by_license": {\r
           "type": "list"\r
         },\r
             "list_name": "public"\r
           }\r
         },\r
+        "count_by_license_group": {\r
+          "type": "count"\r
+        },\r
         "count_by_license": {\r
           "type": "count"\r
         },\r
       "associations": {\r
         "belongs_to": {\r
           "original_picture": {},\r
+          "license_group": {},\r
           "license": {},\r
           "artist": {},\r
           "system_picture": {}\r
             "number": true\r
           }\r
         },\r
+        "license_group_id": {\r
+          "type": "number",\r
+          "rules": {\r
+            "required": true,\r
+            "number": true\r
+          }\r
+        },\r
         "license_id": {\r
           "type": "number",\r
           "rules": {\r
             "number": true\r
           }\r
         },\r
-        "license_group_id": {\r
-          "type": "number",\r
-          "rules": {\r
-            "required": true,\r
-            "number": true\r
-          }\r
-        },\r
         "license_group_settings": {\r
           "type": "text",\r
           "rules": {}\r
       "associations": {\r
         "belongs_to": {},\r
         "has_many": {\r
+          "resource_pictures": {},\r
           "licenses": {}\r
         },\r
         "has_one": {}\r