OSDN Git Service

temp
authoryasushiito <yas@pen-chan.jp>
Mon, 25 Nov 2013 07:47:19 +0000 (16:47 +0900)
committeryasushiito <yas@pen-chan.jp>
Mon, 25 Nov 2013 07:47:19 +0000 (16:47 +0900)
19 files changed:
app/controllers/application_controller.rb
app/controllers/artists_controller.rb
app/models/artist.rb
app/models/author.rb
app/models/comic.rb
app/models/user.rb
app/views/layouts/system.html.erb
app/views/layouts/test.html.erb
config/environment.rb
db/migrate/20131121230958_artist_belongs_to_user.rb [new file with mode: 0644]
lib/content.rb [new file with mode: 0644]
lib/item.rb [new file with mode: 0644]
lib/operator.rb [new file with mode: 0644]
lib/owner.rb [new file with mode: 0644]
spec/models/item_spec.rb [new file with mode: 0644]
vendor/plugins/content/init.rb [deleted file]
vendor/plugins/content/lib/content.rb [deleted file]
vendor/plugins/item/init.rb [deleted file]
vendor/plugins/item/lib/item.rb [deleted file]

index 5c5b63a..0f952e8 100644 (file)
@@ -29,42 +29,49 @@ class ApplicationController < ActionController::Base
         redirect_to :controller => '/system', :action => 'start'
       end
     else
-      if user_signed_in?
-        @user = current_user
-        @author = @user.author
-        @artist = if @author and @author.artist?
-          @author.artist
-        else
-          nil
-        end
+      user = if user_signed_in?
+        current_user
+      else
+        nil
+      end
+      author = if user
+        user.author
+      else
+        nil
+      end
+      artist = if user
+        user.artist
+      else
+        nil
       end
-      @admin = if admin_signed_in?
+      admin = if admin_signed_in?
         current_admin
       else
         nil
       end
-      @demand_user = if demand_user_signed_in?
+      demand_user = if demand_user_signed_in?
         current_demand_user
       else
         nil
       end
+      @operators = Operator.new [user, author, artist, admin, demand_user]
     end
   end
   
   def authenticate_reader
-    authenticate_user! unless (@user || @admin)
+    authenticate_user! unless @operators.reader?
   end
   
   def authenticate_user
-    authenticate_user! unless (@user)
+    authenticate_user! unless @operators.user?
   end
   
   def authenticate_resource_reader
-    authenticate_user! unless (@user || @admin || @demand_user)
+    authenticate_user! unless @operators.resource_reader?
   end
   
   def authenticate_author
-    if @author
+    if @operators.author
       true
     else
       respond_to do |format|
@@ -79,7 +86,7 @@ class ApplicationController < ActionController::Base
   end
       
   def authenticate_artist
-    if @artist
+    if @operators.artist
       true
     else
       respond_to do |format|
index 4c523ed..732dae7 100644 (file)
@@ -11,7 +11,7 @@ class ArtistsController < ApplicationController
   before_filter :authenticate_admin!, :only => [:list, :browse]
 
   def index
-    @page = Artist.page params[:page]
+    @page = Artist.page_number params[:page]
     @page_size = Artist.page_size params[:page_size]
     @artists = Artist.list(@page, @page_size)
 
@@ -20,7 +20,7 @@ class ArtistsController < ApplicationController
         @paginate = Artist.list_paginate(@page, @page_size)
         render :template => 'system/filer', :locals => {
           :items => @artists, :model => Artist, 
-          :roles => [@user, @admin], :pager => @paginate
+          :perator => @operators, :pager => @paginate
         }
       }
       format.json { render :json => @artists.to_json(Artist.list_json_opt) }
@@ -28,32 +28,32 @@ class ArtistsController < ApplicationController
   end
 
   def show
-    @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
+    @artist = Artist.show(params[:id], @operators)
 
     respond_to do |format|
       format.html # show.html.erb
       format.prof  { render :template => 'top/prof', :layout => true }
-      format.json { render :json => @ar.to_json(Artist.show_json_opt) }
+      format.json { render :json => @artist.to_json(Artist.show_json_opt) }
     end
   end
 
   def resource_pictures
-    @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
+    @artist = Artist.show(params[:id], @operators)
     @page = Author.page params[:page]
     @page_size = Author.resource_picture_page_size params[:page_size]
-    @resource_pictures = ResourcePicture.himlist(@ar, @page, @page_size)
+    @resource_pictures = ResourcePicture.himlist(@artist, @page, @page_size)
     respond_to do |format|
       format.html {
-        @paginate = ResourcePicture.himlist_paginate(@ar, @page, @page_size)
+        @paginate = ResourcePicture.himlist_paginate(@artist, @page, @page_size)
       }
       format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
     end
   end
   
   def count
-    @ar = {:count => Artist.visible_count}
+    @artist = {:count => Artist.visible_count}
     respond_to do |format|
-      format.json { render json: @ar.to_json }
+      format.json { render json: @artist.to_json }
     end
   end
   
@@ -67,81 +67,72 @@ class ArtistsController < ApplicationController
   end
 
   def browse
-    @ar = Artist.find(params[:id])
+    @artist = Artist.find(params[:id])
 
     respond_to do |format|
       format.html { render layout: 'system' }
-      format.json { render json: @ar }
+      format.json { render json: @artist }
     end
   end
 
-  # GET /artists/new
-  # GET /artists/new.json
   def new
-    @ar = Artist.new
-    @ar.supply_default 
+    @artist = Artist.new
+    @artist.supply_default 
 
     respond_to do |format|
       format.html # new.html.erb
       format.js
-      format.json { render json: @ar.to_json(Artist.show_json_opt) }
+      format.json { render json: @artist.to_json(Artist.show_json_opt) }
     end
   end
 
-  # GET /artists/1/edit
   def edit
-    @ar = Artist.edit(params[:id], @author)
+    @artist = Artist.edit(params[:id], @operators)
     respond_to do |format|
       format.html 
       format.js
     end
   end
 
-  # POST /artists
-  # POST /artists.json
   def create
-    @ar = Artist.new()
-    @ar.supply_default 
-    @ar.attributes = params[:artist]
-    @ar.overwrite @author
+    @artist = Artist.new()
+    @artist.supply_default 
+    @artist.attributes = params[:artist]
+    @artist.overwrite @operators
     respond_to do |format|
-      if @ar.save
+      if @artist.save
         flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
         format.html { redirect_to root_path }
-        format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
+        format.json { render json: @artist.to_json(Artist.show_json_opt), status: :created, location: @artist }
       else
         flash[:notice] = I18n.t('flash.notice.not_created', :model => Artist.model_name.human)
         format.html { render action: "new" }
-        format.json { render json: @ar.errors, status: :unprocessable_entity }
+        format.json { render json: @artist.errors, status: :unprocessable_entity }
       end
     end
   end
 
-  # PUT /artists/1
-  # PUT /artists/1.json
   def update
-    @ar = Artist.edit(params[:id], @author)
-    @ar.attributes = params[:artist]
-    @ar.overwrite @author
+    @artist = Artist.edit(params[:id], @operators)
+    @artist.attributes = params[:artist]
+    @artist.overwrite @operators
 
     respond_to do |format|
-      if @ar.save
+      if @artist.save
         flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
         format.html { redirect_to '/home/configure' }
         format.json { head :ok }
       else
         flash[:notice] = I18n.t('flash.notice.not_updated', :model => Artist.model_name.human)
         format.html { render action: "edit" }
-        format.json { render json: @ar.errors, status: :unprocessable_entity }
+        format.json { render json: @artist.errors, status: :unprocessable_entity }
       end
     end
   end
 
-  # DELETE /artists/1
-  # DELETE /artists/1.json
   def destroy
-    @ar = Artist.edit(params[:id], @author)
-    @ar.destroy
+    @artist = Artist.edit(params[:id], @operators)
+    @artist.destroy
 
     respond_to do |format|
       format.html { redirect_to artists_url }
index bef4215..72fb2b1 100644 (file)
@@ -1,89 +1,30 @@
-class Artist < ActiveRecord::Base
-  belongs_to :author
+class Artist < Pettanr::Owner
+  belongs_to :user
   has_many :original_pictures
   has_many :pictures
   has_many :resource_pictures
   
   validates :name, :presence => true, :length => {:maximum => 30}
-  validates :author_id, :numericality => {:allow_blank => true}
+  validates :user_id, :numericality => true, :existence => {:both => false}
+  validates :provider, :numericality => true
   
-  before_validation :valid_encode
-  
-  def valid_encode
-    ['name'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
-  end
+  @@valid_encode_columns += ['name']
+  @@visible_count_options = {:conditions => ['artists.author_id is not null']}
   
   def supply_default
     self.name = 'no name' if self.name.blank?
   end
   
-  def overwrite au
-    return false unless au
-    self.author_id = au.id
-  end
-  
-  def own? roles
-    roles = [roles] unless roles.respond_to?(:each)
-    au = Artist.get_author_from_roles roles
-    return false unless au
-    self.author_id == au.id
-  end
-  
-  def visible? roles
-    if MagicNumber['run_mode'] == 0
-      return false unless guest_role_check(roles)
-    else
-      return false unless resource_reader_role_check(roles)
-    end
-    true
-  end
-  
   def self.find_by_author author
     Artist.find( :first, :conditions => ['author_id = ?', author.id])
   end
   
-  def self.default_page_size
-    25
-  end
-  
-  def self.max_page_size
-    100
-  end
-  
-  def self.page prm = nil
-    page = prm.to_i
-    page = 1 if page < 1
-    page
-  end
-  
-  def self.page_size prm = self.default_page_size
-    page_size = prm.to_i
-    page_size = self.max_page_size if page_size > self.max_page_size
-    page_size = self.default_page_size if page_size < 1
-    page_size
-  end
-  
-  def self.offset cnt, prm = nil
-    offset = prm.to_i
-    offset = cnt - 1 if offset >= cnt
-    offset = cnt - offset.abs if offset < 0
-    offset = 0 if offset < 0
-    offset
-  end
-  
   def self.list_where
-    'artists.author_id is not null'
-  end
-  
-  def self.list page = 1, page_size = self.default_page_size
-    Artist.where(self.list_where()).includes(Artist.list_opt).order('artists.created_at desc').offset((page -1) * page_size).limit(page_size)
+    'artists.provider = 0'
   end
   
-  def self.list_paginate page = 1, page_size = self.default_page_size
-    Kaminari.paginate_array(Array.new(Artist.where(self.list_where()).count, nil)).page(page).per(page_size)
+  def self.list_order
+    'artists.created_at desc'
   end
   
   def self.list_opt
@@ -94,22 +35,6 @@ class Artist < ActiveRecord::Base
     {:include => {:author => {}} }
   end
   
-  def self.show aid, au
-    opt = {}
-    opt.merge!(Artist.show_opt)
-    res = Artist.find(aid, opt)
-    raise ActiveRecord::Forbidden unless res.visible?(au)
-    res
-  end
-  
-  def self.edit sid, au
-    opt = {}
-    opt.merge!(Artist.show_opt)
-    res = Artist.find sid, opt
-    raise ActiveRecord::Forbidden unless res.own?(au)
-    res
-  end
-  
   def self.show_opt
     {:include => {:author => {}} }
   end
@@ -118,16 +43,12 @@ class Artist < ActiveRecord::Base
     {:include => {:author => {}} }
   end
   
-  def self.visible_count
-    Artist.count :conditions => ['artists.author_id is not null']
-  end
-  
   def self.export(dt = nil)
     opt = {}
     cond = if dt
-      ['artists.author_id is not null and artists.updated_at >= ?', dt]
+      ['artists.artists.provider = 0 and artists.updated_at >= ?', dt]
     else
-      'artists.author_id is not null'
+      'artists.artists.provider = 0'
     end
     opt.merge!({:conditions => cond}) 
     opt.merge!({:order => 'id'})
index 460d2e8..487cb67 100644 (file)
@@ -1,5 +1,4 @@
-class Author < ActiveRecord::Base
-  has_one :artist
+class Author < Pettanr::Owner
   belongs_to :user
   has_many :scrolls
   has_many :comics
@@ -12,79 +11,23 @@ class Author < ActiveRecord::Base
   validates :working_panel_id, :numericality => {:allow_nil => true}
   validates :user_id, :numericality => true, :existence => {:both => false}
   
-  before_validation :valid_encode
-  
-  def valid_encode
-    ['name'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
-  end
+  @@valid_encode_columns += ['name']
+  # @@visible_count_options = {}
   
   def supply_default
     self.name = 'no name' if self.name.blank?
   end
   
-  def overwrite uid
-    self.user_id = uid
-  end
-  
-  def own? roles
-    roles = [roles] unless roles.respond_to?(:each)
-    au = Author.get_author_from_roles roles
-    return false unless au
-    self.id == au.id
-  end
-  
-  def visible? roles
-    if MagicNumber['run_mode'] == 0
-      return false unless guest_role_check(roles)
-    else
-      return false unless reader_role_check(roles)
-    end
-    return true
-  end
-  
-  def artist?
-    Artist.find_by_author(self) != nil
-  end
-  
   def working?
     self.working_panel_id and self.working_panel
   end
   
-  def step2 n
-    self.name = n
-    self.save
-  end
-  
-  def self.default_page_size
-    25
-  end
-  
-  def self.max_page_size
-    100
-  end
-  
-  def self.page prm = nil
-    page = prm.to_i
-    page = 1 if page < 1
-    page
-  end
-  
-  def self.page_size prm = self.default_page_size
-    page_size = prm.to_i
-    page_size = self.max_page_size if page_size > self.max_page_size
-    page_size = self.default_page_size if page_size < 1
-    page_size
+  def self.list_where
+    ''
   end
   
-  def self.list page = 1, page_size = self.default_page_size
-    Author.includes(Author.list_opt).order('authors.created_at desc').offset((page -1) * page_size).limit(page_size)
-  end
-  
-  def self.list_paginate page = 1, page_size = self.default_page_size
-    Kaminari.paginate_array(Array.new(Author.count, nil)).page(page).per(page_size)
+  def self.list_order
+    'authors.created_at desc'
   end
   
   def self.list_opt
@@ -95,14 +38,6 @@ class Author < ActiveRecord::Base
     {:include => {:artist => {}} }
   end
   
-  def self.show aid, roles
-    opt = {}
-    opt.merge!(Author.show_opt)
-    res = Author.find(aid, opt)
-    raise ActiveRecord::Forbidden unless res.visible?(roles)
-    res
-  end
-  
   def self.show_opt
     {:include => {:artist => {}} }
   end
@@ -111,14 +46,6 @@ class Author < ActiveRecord::Base
     {:include => {:artist => {}} }
   end
   
-  def self.edit aid, au
-    opt = {}
-    opt.merge!(Author.show_opt)
-    res = Author.find aid, opt
-    raise ActiveRecord::Forbidden unless res.own?(au)
-    res
-  end
-  
   def self.default_scroll_page_size
     25
   end
@@ -329,8 +256,4 @@ class Author < ActiveRecord::Base
     page_size
   end
   
-  def self.visible_count
-    Author.count
-  end
-  
 end
index 3a27abc..0c47010 100644 (file)
@@ -1,5 +1,5 @@
 #コミック
-class Comic < ActiveRecord::Base
+class Comic < Pettanr::Content
   has_many :stories, :order => 't'
   belongs_to :author
   
@@ -7,14 +7,8 @@ class Comic < ActiveRecord::Base
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   
-  before_validation :valid_encode
-  
-  def valid_encode
-    ['title', 'description'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
-  end
+  @@valid_encode_columns += ['title', 'description']
+  @@visible_count_options = {:conditions => 'visible > 0'}
   
   def supply_default
     self.visible = 0 if self.visible.blank?
@@ -25,20 +19,8 @@ class Comic < ActiveRecord::Base
     self.author_id = au.id
   end
   
-  def own? roles
-    roles = [roles] unless roles.respond_to?(:each)
-    au = Comic.get_author_from_roles roles
-    return false unless au
-    self.author_id == au.id
-  end
-  
-  def visible? roles
-    if MagicNumber['run_mode'] == 0
-      return false unless guest_role_check(roles)
-    else
-      return false unless reader_role_check(roles)
-    end
-    return true if self.own?(roles)
+  def visible? operators
+    super
     self.visible > 0
   end
   
@@ -49,69 +31,28 @@ class Comic < ActiveRecord::Base
   def symbol_filename
   end
   
-  def self.default_page_size
-    25
-  end
-  
-  def self.max_page_size
-    100
-  end
-  
-  def self.default_panel_size
-    30
-  end
-  
-  def self.max_panel_size
-    200
-  end
-  
-  def self.page prm = nil
-    page = prm.to_i
-    page = 1 if page < 1
-    page
-  end
-  
-  def self.page_size prm = self.default_page_size
-    page_size = prm.to_i
-    page_size = self.max_page_size if page_size > self.max_page_size
-    page_size = self.default_page_size if page_size < 1
-    page_size
-  end
-  
   def self.list_where
     'comics.visible > 0'
   end
   
-  def self.mylist_where au
-    ['comics.author_id = ?', au.id]
-  end
-  
-  def self.himlist_where au
-    ['comics.author_id = ? and comics.visible > 0', au.id]
-  end
-  
-  def self.list page = 1, page_size = self.default_page_size
-    Comic.where(self.list_where()).includes(Comic.list_opt).order('comics.updated_at desc').offset((page -1) * page_size).limit(page_size)
-  end
-  
-  def self.mylist au, page = 1, page_size = Author.default_comic_page_size
-    Comic.where(self.mylist_where(au)).includes(Comic.list_opt).order('comics.updated_at desc').offset((page -1) * page_size).limit(page_size)
+  def self.list_order
+    'comics.updated_at desc'
   end
   
-  def self.himlist au, page = 1, page_size = Author.default_comic_page_size
-    Comic.where(self.himlist_where(au)).includes(Comic.list_opt).order('comics.updated_at desc').offset((page -1) * page_size).limit(page_size)
+  def self.mylist_where me
+    ['comics.author_id = ?', me.id]
   end
   
-  def self.list_paginate page = 1, page_size = self.default_page_size
-    Kaminari.paginate_array(Array.new(Comic.where(self.list_where()).count, nil)).page(page).per(page_size)
+  def self.mylist_order
+    'comics.updated_at desc'
   end
   
-  def self.mylist_paginate au, page = 1, page_size = Author.default_comic_page_size
-    Kaminari.paginate_array(Array.new(Comic.where(self.mylist_where(au)).count, nil)).page(page).per(page_size)
+  def self.himlist_where anybody
+    ['comics.author_id = ? and comics.visible > 0', anybody.id]
   end
   
-  def self.himlist_paginate au, page = 1, page_size = Author.default_comic_page_size
-    Kaminari.paginate_array(Array.new(Comic.where(self.himlist_where(au)).count, nil)).page(page).per(page_size)
+  def self.himlist_order
+    'comics.updated_at desc'
   end
   
   def self.list_opt
@@ -122,22 +63,6 @@ class Comic < ActiveRecord::Base
     {:include => {:stories => {}, :author => {}} }
   end
   
-  def self.show cid, roles
-    opt = {}
-    opt.merge!(Comic.show_opt)
-    res = Comic.find(cid, opt)
-    raise ActiveRecord::Forbidden unless res.visible?(roles)
-    res
-  end
-  
-  def self.edit cid, au
-    opt = {}
-    opt.merge!(Comic.show_opt)
-    res = Comic.find(cid, opt)
-    raise ActiveRecord::Forbidden unless res.own?(au)
-    res
-  end
-  
   def self.show_opt
     {:include => {:stories => {}, :author => {}} }
   end
@@ -146,10 +71,6 @@ class Comic < ActiveRecord::Base
     {:include => {:stories => {}, :author => {}} }
   end
   
-  def self.visible_count
-    Comic.count 'visible > 0'
-  end
-  
   def destroy_with_story
     res = false
     Comic.transaction do
index 48a344c..d59f35e 100644 (file)
@@ -1,5 +1,6 @@
 class User < ActiveRecord::Base
   has_one :author
+  has_one :artist
   
   # Include default devise modules. Others available are:
   # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
@@ -28,11 +29,11 @@ class User < ActiveRecord::Base
       self.author.panels.each do |panel|
         raise ActiveRecord::Rollback unless panel.destroy_with_elements
       end
-      if self.author.artist
-        self.author.artist.original_pictures.each do |original_picture|
+      if self.artist
+        self.artist.original_pictures.each do |original_picture|
           raise ActiveRecord::Rollback unless original_picture.destroy_with_resource_picture
         end
-        raise ActiveRecord::Rollback unless self.author.artist.destroy
+        raise ActiveRecord::Rollback unless self.artist.destroy
       end
       raise ActiveRecord::Rollback unless self.author.destroy
       raise ActiveRecord::Rollback unless super
index f5abbcf..9937819 100644 (file)
 <div>
 <% if user_signed_in? %>
   <%= link_to t('home.index.title'), '/home' %>
-  <%= link_to t('home.scrolls.title'), '/home/scroll' %>
-  <%= link_to t('home.panels.title'), '/home/panel' %>
-  <%= link_to t('home.panel_pictures.title'), '/home/panel_picture' %>
-  <%= link_to h(truncate(@author.name, :length => 12)), main_app.author_path(@author) %>
-  <% if @artist %>
+  <% if @operators.author %>
+    <%= link_to t('home.scrolls.title'), '/home/scroll' %>
+    <%= link_to t('home.panels.title'), '/home/panel' %>
+    <%= link_to t('home.panel_pictures.title'), '/home/panel_picture' %>
+    <%= link_to h(truncate(@operators.author.name, :length => 12)), main_app.author_path(@operators.author) %>
+  <% end %>
+  <% if @operators.artist %>
     <%= link_to t('home.pictures.title'), main_app.original_pictures_path %>
-    <%= link_to h(truncate(@artist.name, :length => 12)), main_app.artist_path(@artist) %>
+    <%= link_to h(truncate(@operators.artist.name, :length => 12)), main_app.artist_path(@operators.artist) %>
   <% end %>
   <%= link_to t('home.configure.title'), '/home/configure' %>
   <%= link_to t('home.sign_out.title'), main_app.destroy_user_session_path, :method => :delete %>
index d6ad022..93aeab0 100644 (file)
     </td>\r
     <td>\r
       <div>\r
-        <% if @author %>\r
-          <%= link_to h(truncate(@author.name, :length => 12)), main_app.author_path(@author) %>\r
+        <% if @operators.author %>\r
+          <%= link_to h(truncate(@operators.author.name, :length => 12)), main_app.author_path(@operators.author) %>\r
         <% end %>\r
       </div>\r
       <div>\r
-        <% if @artist %>\r
-          <%= link_to h(truncate(@artist.name, :length => 12)), main_app.artist_path(@artist) %>\r
+        <% if @operators.artist %>\r
+          <%= link_to h(truncate(@operators.artist.name, :length => 12)), main_app.artist_path(@operators.artist) %>\r
         <% end %>\r
       </div>\r
     </td>\r
@@ -61,9 +61,9 @@
   <%= link_to t_m('Author'), main_app.authors_path %>\r
   <%= link_to t_m('Artist'), main_app.artists_path %>\r
 </div>\r
-<% if @author %>\r
-  <div width="100%" style="background-color: #fadddd; padding: 5px;">\r
-    <%= link_to t('tab.creator.home'), '/home' %>\r
+<div width="100%" style="background-color: #fadddd; padding: 5px;">\r
+  <%= link_to t('tab.creator.home'), '/home' %>\r
+  <% if @operators.author %>\r
     <%= link_to t('tab.creator.comic'), '/home/comics' %>\r
     <%= link_to t('*'), main_app.new_comic_path %>\r
     <%= link_to t('tab.creator.story'), '/home/stories' %>\r
     <%= link_to t('*'), main_app.new_scroll_path %>\r
     <%= link_to t('tab.creator.panel'), '/home/panels' %>\r
     <%= link_to t('*'), main_app.new_panel_path %>\r
-    <% if @artist %>\r
-      <%= link_to t('tab.creator.original_picture'), main_app.original_pictures_path %>\r
-      <%= link_to t('*'), main_app.new_original_picture_path %>\r
-      <%= link_to t('tab.creator.resource_picture'), '/home/resource_pictures' %>\r
-    <% end %>\r
-    <% if @author and @author.working? -%>\r
-      <%= link_to t('tab.creator..catch'), main_app.panel_path(@author.working_panel) %>\r
-    <% end -%>\r
-  </div>\r
-<% end %>\r
+  <% end -%>\r
+  <% if @operators.artist %>\r
+    <%= link_to t('tab.creator.original_picture'), main_app.original_pictures_path %>\r
+    <%= link_to t('*'), main_app.new_original_picture_path %>\r
+    <%= link_to t('tab.creator.resource_picture'), '/home/resource_pictures' %>\r
+  <% end %>\r
+  <% if @operators.author and @operators.author.working? -%>\r
+    <%= link_to t('tab.creator..catch'), main_app.panel_path(@operators.author.working_panel) %>\r
+  <% end %>\r
+</div>\r
 <%= yield %>\r
 <div width="100%" style="background-color: #faddfa; padding: 5px;">\r
   <%= link_to t('tab.demander.title'), main_app.demanders_path %>\r
index c6824f7..7cceeb6 100644 (file)
@@ -7,8 +7,12 @@ require 'inspire'
 require 'picture_io'
 require 'pettan_imager'
 require 'ar_helper'
+require 'operator'
 require 'import_result'
 require 'common'
+require 'item'
+require 'owner'
+require 'content'
 require 'element'
 require 'element_part'
 # Initialize the rails application
diff --git a/db/migrate/20131121230958_artist_belongs_to_user.rb b/db/migrate/20131121230958_artist_belongs_to_user.rb
new file mode 100644 (file)
index 0000000..dd1327c
--- /dev/null
@@ -0,0 +1,18 @@
+class ArtistBelongsToUser < ActiveRecord::Migration
+  def up
+    add_column :artists, :user_id, :integer, :null => false, :default => 0
+    add_column :artists, :provider, :integer, :null => false, :default => 0
+    Artist.find(:all).each do |artist|
+      if artist.author_id
+        artist.user_id = Author.find(artist.author_id).user_id
+      else
+        artist.provider = 1
+      end
+      artist.save!
+    end
+  end
+
+  def down
+    remove_column :artists, :author_id
+  end
+end
diff --git a/lib/content.rb b/lib/content.rb
new file mode 100644 (file)
index 0000000..83f00ac
--- /dev/null
@@ -0,0 +1,61 @@
+class Pettanr::Content < Pettanr::Item
+  self.abstract_class = true
+  # ClassMethods
+  
+  def self.mylist_where me
+    ''
+  end
+  
+  def self.mylist_order
+    ''
+  end
+  
+  def self.himlist_where anybody
+    ''
+  end
+  
+  def self.himlist_order
+    ''
+  end
+  
+  def self.mylist me, page = 1, page_size = self.default_page_size
+    self.where(self.mylist_where(me)).includes(self.list_opt).order(self.mylist_order).offset((page -1) * page_size).limit(page_size)
+  end
+  
+  def self.himlist anybody, page = 1, page_size = self.default_page_size
+    self.where(self.himlist_where(anybody)).includes(self.list_opt).order(self.mylist_order).offset((page -1) * page_size).limit(page_size)
+  end
+  
+  def self.mylist_paginate me, page = 1, page_size = self.default_page_size
+    Kaminari.paginate_array(
+      Array.new(self.where(self.mylist_where(me)
+    ).includes(self.list_opt).count, nil)).page(page).per(page_size)
+  end
+  
+  def self.himlist_paginate anybody, page = 1, page_size = self.default_page_size
+    Kaminari.paginate_array(
+      Array.new(self.where(self.himlist_where(anybody)
+    ).includes(self.list_opt).count, nil)).page(page).per(page_size)
+  end
+  
+  def self.edit content_id, operators
+    content = self.find content_id, self.show_opt
+    raise ActiveRecord::Forbidden unless content.own?(operators)
+    content
+  end
+  
+  #InstanceMethods
+  
+  def visible? operators
+    super
+    return true if self.own?(operators)
+    true
+  end
+  
+  def own? operators
+    return false unless operators.author
+    self.author_id == operators.author.id
+  end
+  
+end
+
diff --git a/lib/item.rb b/lib/item.rb
new file mode 100644 (file)
index 0000000..32f6958
--- /dev/null
@@ -0,0 +1,175 @@
+class Pettanr::Item < ActiveRecord::Base
+  self.abstract_class = true
+  # ClassMethods
+  # class_name
+  # table_name
+  
+  before_validation :valid_encode
+  
+  cattr_accessor :valid_encode_columns, :default_page_size, :max_page_size, :visible_count_options
+  @@valid_encode_columns = []
+  @@default_page_size = 25
+  @@max_page_size = 100
+  @@visible_count_options = {}
+  cattr_reader :singular, :plural
+  @@singular = 'Item'
+  @@plural = 'Items'
+  
+  def self.item_name
+    self.singular.underscore
+  end
+  
+  def self.path_name with_engine = false
+    self.plural.underscore
+  end
+  
+  def self.page_number prm = nil
+    page = prm.to_i
+    page = 1 if page < 1
+    page
+  end
+  
+  def self.page_size prm = self.default_page_size
+    page_size = prm.to_i
+    page_size = self.max_page_size if page_size > self.max_page_size
+    page_size = self.default_page_size if page_size < 1
+    page_size
+  end
+  
+  def self.list_where
+    ''
+  end
+  
+  def self.list_order
+    ''
+  end
+  
+  def self.list page = 1, page_size = self.default_page_size
+    self.where(self.list_where()).includes(self.list_opt).order(self.list_order).offset((page -1) * page_size).limit(page_size)
+  end
+  
+  def self.list_paginate page = 1, page_size = self.default_page_size
+    Kaminari.paginate_array(
+      Array.new(self.where(self.list_where()).includes(self.list_opt).count, nil)
+    ).page(page).per(page_size)
+  end
+  
+  def self.list_opt
+    {}
+  end
+  
+  def self.list_json_opt
+    {}
+  end
+  
+  def self.show item_id, au
+    opt = {}
+    opt.merge!(self.show_opt)
+    item = self.find(item_id, opt)
+    raise ActiveRecord::Forbidden unless item.visible?(au)
+    item
+  end
+  
+  def self.show_opt
+    {}
+  end
+  
+  def self.show_json_opt
+    {}
+  end
+  
+  def self.visible_count
+    self.count self.visible_count_options
+  end
+  
+  #InstanceMethods
+  
+  def item_name
+    self.class.item_name
+  end
+  
+  def valid_encode
+    self.class.valid_encode_columns.each do |a|
+      next if attributes[a] == nil
+      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
+    end
+  end
+  
+  def supply_default
+  end
+  
+  def overwrite 
+  end
+  
+  def visible? operators
+    if MagicNumber['run_mode'] == 0
+      return false unless operators.guest?
+    else
+      return false unless operators.resource_reader?
+    end
+    true
+  end
+  
+  def dom_id_item 
+    self.new_record? ? '0' : self.id.to_s
+  end
+  
+  def tag_item_id c = nil
+    self.item_name + self.item_id + c.to_s
+  end
+  
+  def dom_id_item_field field_name
+    self.tag_item_id + field_name.to_s
+  end
+  
+  def path_name with_engine = false
+    self.class.path_name(with_engine)
+  end
+  
+  def form_template with_engine = false
+    self.path_name(with_engine) + '/form'
+  end
+  
+  def tag_item_attributes column = nil, opt = {}
+    {
+      :id => self.field_tag_id(column), :panel_id => self.tag_panel_id, 
+      :element_id => self.tag_element_id, :element_type => self.tag_element_type
+    }.merge(opt)
+  end
+  
+  def field_tag_attributes column, no_attr, opt = {}
+    self.tag_attributes(column).merge(
+      {:column => column, :new_index => self.tag_new_index, :no_attr => no_attr}
+    ).merge(opt)
+  end
+  
+  #render element by body
+  def any_tag_attributes name = nil, opt = {}
+    r = self.tag_attributes(name)
+    r.merge!(
+      {:new_index => self.tag_new_index}
+    ) if self.new_index
+    r.merge(opt)
+  end
+  
+  def select_tag_attributes(selected, column, no_attr)
+    [
+      :last, :first, 
+      {:html => {:selected => selected}}, 
+      self.field_tag_attributes(column, no_attr)
+    ]
+  end
+  
+  def tag_attr column = nil, opt = {}
+    self.tag_attributes(column, opt).to_attr
+  end
+  
+  def field_tag_attr column, no_attr, opt = {}
+    self.field_tag_attributes(column, no_attr, opt).to_attr
+  end
+  
+  def any_tag_attr name = nil, opt = {}
+    self.any_tag_attributes(name, opt).to_attr
+  end
+  
+end
diff --git a/lib/operator.rb b/lib/operator.rb
new file mode 100644 (file)
index 0000000..316bcbb
--- /dev/null
@@ -0,0 +1,82 @@
+class Operator
+  
+  def initialize operators
+    @operators = operators
+    @operators = [@operators] unless @operators.respond_to?(:each)
+    @operators.compact!
+  end
+  
+  #InstanceMethods
+  def find_author
+    @operators.each do |operator|
+      return operator if operator.is_a?(Author)
+      return operator.author if operator.is_a?(User)
+      return operator.user.author if operator.is_a?(Artist) and operator.user.author
+    end
+    nil
+  end
+  
+  def find_artist
+    @operators.each do |operator|
+      return operator.user.artist if operator.is_a?(Author) and operator.user.artist
+      return operator.artist if operator.is_a?(User)
+      return operator if operator.is_a?(Artist)
+    end
+    nil
+  end
+  
+  def find_admin
+    @operators.each do |operator|
+      return operator if operator.is_a?(Admin)
+    end
+    nil
+  end
+  
+  def author
+    return @author if @author
+    @author = find_author
+  end
+  
+  def artist
+    return @artist if @artist
+    @artist = find_artist
+  end
+  
+  def admin
+    return @admin if @admin
+    @admin = find_admin
+  end
+  
+  def guest?
+    true
+  end
+  
+  def reader?
+    @operators.each do |operator|
+      return true if operator.is_a?(Author) or operator.is_a?(Artist) or operator.is_a?(Admin) or operator.is_a?(User)
+    end
+    false
+  end
+  
+  def user?
+    @operators.each do |operator|
+      return true if operator.is_a?(Author) or operator.is_a?(Artist) or operator.is_a?(User)
+    end
+    false
+  end
+  
+  def resource_reader?
+    @operators.each do |operator|
+      return true if operator.is_a?(Author) or operator.is_a?(Artist) or operator.is_a?(Admin) or operator.is_a?(User) or operator.is_a?(DemandUser)
+    end
+    false
+  end
+  
+  def admin?
+    @operators.each do |operator|
+      return true if operator.is_a?(Admin)
+    end
+    false
+  end
+  
+end
diff --git a/lib/owner.rb b/lib/owner.rb
new file mode 100644 (file)
index 0000000..0d232d5
--- /dev/null
@@ -0,0 +1,23 @@
+class Pettanr::Owner < Pettanr::Item
+  self.abstract_class = true
+  # ClassMethods
+  
+  def self.edit owner_id, operators
+    owner = self.find owner_id, self.show_opt
+    raise ActiveRecord::Forbidden unless owner.own?(operators)
+    owner
+  end
+  
+  #InstanceMethods
+  
+  def overwrite operators
+    self.user_id = operators.user.id
+  end
+  
+  def own? operators
+    return false unless operators.user
+    self.user_id == operators.user.id
+  end
+  
+end
+
diff --git a/spec/models/item_spec.rb b/spec/models/item_spec.rb
new file mode 100644 (file)
index 0000000..d6fc310
--- /dev/null
@@ -0,0 +1,206 @@
+# -*- encoding: utf-8 -*-
+#管理者
+require 'spec_helper'
+
+describe Pettanr::Item do
+  before do
+    SpeechBalloonTemplate.delete_all
+    @admin = FactoryGirl.create :admin
+    @user = FactoryGirl.create( :user_yas)
+    @author = FactoryGirl.create :author, :user_id => @user.id
+    @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
+    @other_user = FactoryGirl.create( :user_yas)
+    @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+    @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+    @sp = FactoryGirl.create :system_picture
+    @lg = FactoryGirl.create :license_group
+    @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+  end
+  
+  describe '検証に於いて' do
+    before do
+    end
+    
+    context 'オーソドックスなデータのとき' do
+=begin
+      it 'nullなら失敗する' do
+        @gc = User.singular
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.plural
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.item_name
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.path_name
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.default_page_size
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.max_page_size
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.page_number 
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.page_size 
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.list_where
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.list
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.list_paginate
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.list_opt
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.list_json_opt
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.show 1, 1
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.show_opt
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = User.show_json_opt
+        @gc.should be_nil
+      end
+=end
+    end
+    
+    context 'オーソドックスなデータのとき' do
+      before do
+      end
+=begin
+      it 'nullなら失敗する' do
+        @user.item_name
+      end
+      it 'nullなら失敗する' do
+        @user.dom_id_item
+      end
+      it 'nullなら失敗する' do
+        @user.tag_item_id
+      end
+      it 'nullなら失敗する' do
+        @user.dom_id_item_field ''
+      end
+      it 'nullなら失敗する' do
+        @user.path_name
+      end
+      it 'nullなら失敗する' do
+        @user.form_template
+      end
+      it 'nullなら失敗する' do
+        @user.tag_item_attributes
+      end
+      it 'nullなら失敗する' do
+        @user.field_tag_attributes
+      end
+      it 'nullなら失敗する' do
+        @user.any_tag_attributes
+      end
+      it 'nullなら失敗する' do
+        @user.select_tag_attributes
+      end
+      it 'nullなら失敗する' do
+        @user.tag_attr
+      end
+      it 'nullなら失敗する' do
+        @user.field_tag_attr
+      end
+      it 'nullなら失敗する' do
+        @user.any_tag_attr
+      end
+=end
+    end
+    
+    context 'オーソドックスなデータのとき' do
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.singular
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.plural
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.item_name
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.path_name
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.default_page_size
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.max_page_size
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.page 
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.page_size 
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.list_where
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.list
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.list_paginate
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.list_opt
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.list_json_opt
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.show 1, 1
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.show_opt
+        @gc.should be_nil
+      end
+      it 'nullなら失敗する' do
+        @gc = Pettanr::Item.show_json_opt
+        @gc.should be_nil
+      end
+    end
+  end
+end
diff --git a/vendor/plugins/content/init.rb b/vendor/plugins/content/init.rb
deleted file mode 100644 (file)
index c5f49cc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-require 'content'
diff --git a/vendor/plugins/content/lib/content.rb b/vendor/plugins/content/lib/content.rb
deleted file mode 100644 (file)
index 7842593..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-=begin
-module ActiveRecord
-  class Base
-    module Content
-      def self.included(base)
-        base.extend(ClassMethods)
-        base.__send__ :include, InstanceMethods
-      end
-      
-      module ClassMethods
-        
-        def self.mylist_where au
-          ['panels.author_id = ?', au.id]
-        end
-        
-        def self.himlist_where au
-          ['panels.author_id = ? and panels.publish > 0', au.id]
-        end
-        
-        def self.mylist au, page = 1, page_size = Author.default_panel_picture_page_size
-          PanelPicture.where(self.mylist_where(au)).includes(PanelPicture.list_opt).order('panel_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
-        end
-        
-        def self.himlist au, page = 1, page_size = Author.default_panel_picture_page_size
-          PanelPicture.where(self.himlist_where(au)).includes(PanelPicture.list_opt).order('panel_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
-        end
-        
-        def self.mylist_paginate au, page = 1, page_size = Author.default_panel_picture_page_size
-          Kaminari.paginate_array(Array.new(PanelPicture.where(self.mylist_where(au)).includes(PanelPicture.list_opt).count, nil)).page(page).per(page_size)
-        end
-        
-        def self.himlist_paginate au, page = 1, page_size = Author.default_panel_picture_page_size
-          Kaminari.paginate_array(Array.new(PanelPicture.where(self.himlist_where(au)).includes(PanelPicture.list_opt).count, nil)).page(page).per(page_size)
-        end
-        
-      end
-      
-      module InstanceMethods
-        private
-        
-        public
-        
-        def visible? roles
-          if MagicNumber['run_mode'] == 0
-            return false unless guest_role_check(roles)
-          else
-            return false unless reader_role_check(roles)
-          end
-          return true if self.panel.own?(roles)
-          self.panel.visible? roles
-        end
-        
-        def supply_default
-          self.x = 0
-          self.y = 0
-          if self.picture
-            self.width = self.picture.width 
-            self.height = self.picture.height 
-          end
-          if self.panel
-            self.t = self.panel.new_t 
-            self.z = self.panel.new_z 
-          end
-        end
-        
-        def overwrite  pid
-          self.panel_id = pid
-        end
-        
-      end
-      
-    end
-    include Content
-  end
-end
-
-=end
diff --git a/vendor/plugins/item/init.rb b/vendor/plugins/item/init.rb
deleted file mode 100644 (file)
index e81018b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-require 'item'
diff --git a/vendor/plugins/item/lib/item.rb b/vendor/plugins/item/lib/item.rb
deleted file mode 100644 (file)
index 2110fe9..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-=begin
-module ActiveRecord
-  class Base
-    module Item
-      def self.included(base)
-        base.extend(ClassMethods)
-        base.__send__ :include, InstanceMethods
-      end
-      
-      module ClassMethods
-        # class_name
-        # table_name
-        
-        def singular
-        end
-        
-        def plural
-        end
-        
-        def item_name
-        end
-        
-        def path_name
-        end
-        
-        def self.default_page_size
-          25
-        end
-        
-        def self.max_page_size
-          100
-        end
-        
-        def self.page prm = nil
-          page = prm.to_i
-          page = 1 if page < 1
-          page
-        end
-        
-        def self.page_size prm = self.default_page_size
-          page_size = prm.to_i
-          page_size = self.max_page_size if page_size > self.max_page_size
-          page_size = self.default_page_size if page_size < 1
-          page_size
-        end
-        
-        def self.list_where
-          'panels.publish > 0'
-        end
-        
-        def self.list page = 1, page_size = self.default_page_size
-          PanelPicture.where(self.list_where()).includes(PanelPicture.list_opt).order('panel_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
-        end
-        
-        def self.list_paginate page = 1, page_size = self.default_page_size
-          Kaminari.paginate_array(Array.new(PanelPicture.where(self.list_where()).includes(PanelPicture.list_opt).count, nil)).page(page).per(page_size)
-        end
-        
-        def self.list_opt
-          {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}} }
-        end
-        
-        def self.list_json_opt
-          {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
-        end
-        
-        def self.show cid, au
-          opt = {}
-          opt.merge!(PanelPicture.show_opt)
-          res = PanelPicture.find(cid, opt)
-          raise ActiveRecord::Forbidden unless res.visible?(au)
-          res
-        end
-        
-        def self.show_opt
-          {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}}
-        end
-        
-        def self.show_json_opt
-          {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
-        end
-        
-      end
-      
-      module InstanceMethods
-        private
-        
-        public
-        
-        def item_name
-        end
-        
-        def dom_id_item 
-          self.new_record? ? '0' : self.id.to_s
-        end
-        
-        def tag_item_id c = nil
-          self.item_name + self.item_id + c.to_s
-        end
-        
-        def dom_id_item_field field_name
-          self.tag_item_id + field_name.to_s
-        end
-        
-        def path_name with_engine = false
-          self.class.path_name(with_engine)
-        end
-        
-        def form_template with_engine = false
-          self.path_name(with_engine) + '/form'
-        end
-        
-        def tag_item_attributes column = nil, opt = {}
-          {
-            :id => self.field_tag_id(column), :panel_id => self.tag_panel_id, 
-            :element_id => self.tag_element_id, :element_type => self.tag_element_type
-          }.merge(opt)
-        end
-        
-        def field_tag_attributes column, no_attr, opt = {}
-          self.tag_attributes(column).merge(
-            {:column => column, :new_index => self.tag_new_index, :no_attr => no_attr}
-          ).merge(opt)
-        end
-        
-        #render element by body
-        def any_tag_attributes name = nil, opt = {}
-          r = self.tag_attributes(name)
-          r.merge!(
-            {:new_index => self.tag_new_index}
-          ) if self.new_index
-          r.merge(opt)
-        end
-        
-        def select_tag_attributes(selected, column, no_attr)
-          [
-            :last, :first, 
-            {:html => {:selected => selected}}, 
-            self.field_tag_attributes(column, no_attr)
-          ]
-        end
-        
-        def tag_attr column = nil, opt = {}
-          self.tag_attributes(column, opt).to_attr
-        end
-        
-        def field_tag_attr column, no_attr, opt = {}
-          self.field_tag_attributes(column, no_attr, opt).to_attr
-        end
-        
-        def any_tag_attr name = nil, opt = {}
-          self.any_tag_attributes(name, opt).to_attr
-        end
-        
-      end
-      
-    end
-    include Item
-  end
-end
-
-=end
-