OSDN Git Service

temp
authoryasushiito <yas@pen-chan.jp>
Wed, 11 Dec 2013 02:56:30 +0000 (11:56 +0900)
committeryasushiito <yas@pen-chan.jp>
Wed, 11 Dec 2013 02:56:30 +0000 (11:56 +0900)
32 files changed:
app/controllers/application_controller.rb
app/controllers/comics_controller.rb
app/controllers/scrolls_controller.rb
app/models/artist.rb
app/models/author.rb
app/models/balloon.rb
app/models/comic.rb
app/models/ground_color.rb
app/models/ground_picture.rb
app/models/license.rb
app/models/license_group.rb
app/models/original_picture.rb
app/models/panel.rb
app/models/panel_picture.rb
app/models/picture.rb
app/models/resource_picture.rb
app/models/scroll.rb
app/models/scroll_panel.rb
app/models/sheet.rb
app/models/sheet_panel.rb
app/models/speech.rb
app/models/speech_balloon.rb
app/models/speech_balloon_template.rb
app/models/story.rb
app/models/story_sheet.rb
app/models/system_picture.rb
app/models/writing_format.rb
app/views/comics/_form.html.erb
app/views/comics/show.html.erb
app/views/stories/_form.html.erb
lib/item.rb
lib/manifest/filer.rb

index aa4f3a6..3d6d1af 100644 (file)
@@ -100,11 +100,29 @@ class ApplicationController < ActionController::Base
     end
   end
   
-  def set_filer 
-    @page = @@model.page_number params[:page]
-    @page_size = @@model.page_size params[:page_size]
-    list_method = 'list' || configurations['models'][@@model.to_s.underscore]['select']['method']
-    @items = @@model.__send__(list_method, @page, @page_size)
+  def self.controller
+    Pettanr::Application::manifest.controller_managers[self.model.item_name]
+  end
+  
+  def self.profiler_manager
+    Pettanr::Application::manifest.profiler_managers[self.model.item_name]
+  end
+  
+  def public_list
+    action_name = params[:action]
+    @action = self.class.controller.open(action_name, params, @operators)
+    @items = @action.items 
+    respond_to do |format|
+      format.html {
+        @filer = @action.filer
+        render :template => 'system/filer', :locals => {
+          :filer => @filer
+        }
+      }
+      format.json { render json: @items.to_json(self.class.model.list_json_opt) }
+      format.atom 
+      format.rss
+    end
   end
   
   def format_filer format
index 57f1eff..f1f2909 100644 (file)
@@ -13,28 +13,9 @@ class ComicsController < ApplicationController
   def self.model
     Comic
   end
-  def self.controller
-    Pettanr::Application::manifest.controller_managers[self.model.item_name]
-  end
-  def self.profiler_manager
-    Pettanr::Application::manifest.profiler_managers[self.model.item_name]
-  end
   
   def index
-    action_name = params[:action]
-    @action = self.class.controller.open(action_name, params, @operators)
-    @items = @action.items 
-    respond_to do |format|
-      format.html {
-        @filer = @action.filer
-        render :template => 'system/filer', :locals => {
-          :filer => @filer
-        }
-      }
-      format.json { render json: @items.to_json(self.class.model.list_json_opt) }
-      format.atom 
-      format.rss
-    end
+    public_list
   end
 
   def show
@@ -102,7 +83,7 @@ class ComicsController < ApplicationController
     @comic = Comic.new
     @comic.supply_default 
     @comic.attributes = params[:comic]
-    @comic.overwrite @author
+    @comic.overwrite @operators
 
     respond_to do |format|
       if @comic.save
@@ -118,9 +99,9 @@ class ComicsController < ApplicationController
   end
 
   def update
-    @comic = Comic.edit(params[:id], @author)
+    @comic = Comic.edit(params[:id], @operators)
     @comic.attributes = params[:comic]
-    @comic.overwrite @author
+    @comic.overwrite @operators
     respond_to do |format|
       if @comic.save
         flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
index ef9bb0c..863243e 100644 (file)
@@ -9,26 +9,13 @@ class ScrollsController < ApplicationController
     before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   before_filter :authenticate_admin!, :only => [:list, :browse]
-
-  @@model = Scroll
-  @@controller = Pettanr::Application::manifest.controller_managers[@@model.item_name]
-  @@profiler_manager = Pettanr::Application::manifest.profiler_managers[@@model.item_name]
+  
+  def self.model
+    Scroll
+  end
   
   def index
-    action_name = params[:action]
-    @action = @@controller.open(action_name, params, @operators)
-    @items = @action.items 
-    respond_to do |format|
-      format.html {
-        @filer = @action.filer
-        render :template => 'system/filer', :locals => {
-          :filer => @filer
-        }
-      }
-      format.json { render json: @items.to_json(@@model.list_json_opt) }
-      format.atom 
-      format.rss
-    end
+    public_list
   end
 
   def show
index e1ef12d..9f702a4 100644 (file)
@@ -8,8 +8,22 @@ class Artist < Pettanr::Owner
   validates :user_id, :numericality => true, :existence => {:both => false}
   validates :provider_id, :numericality => {:allow_nil => true}
   
-  @@valid_encode_columns += ['name']
   @@visible_count_options = {:conditions => ['artists.author_id is not null']}
+  def self.singular
+    'Artist'
+  end
+  
+  def self.plural
+    'Artists'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['name']
+  end
   
   def supply_default
     self.name = 'no name' if self.name.blank?
index d095613..fda9f34 100644 (file)
@@ -10,10 +10,21 @@ class Author < Pettanr::Owner
   validates :working_panel_id, :numericality => {:allow_nil => true}
   validates :user_id, :numericality => true, :existence => {:both => false}
   
-  @@singular = 'Author'
-  @@plural = 'Authors'
-  @@valid_encode_columns += ['name']
-  # @@visible_count_options = {}
+  def self.singular
+    'Author'
+  end
+  
+  def self.plural
+    'Authors'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['name']
+  end
   
   def supply_default
     self.name = 'no name' if self.name.blank?
index 611481f..33e2c40 100644 (file)
@@ -1,4 +1,4 @@
-class Balloon < ActiveRecord::Base
+class Balloon < Pettanr::Item
   include ElementPart
   belongs_to :speech_balloon
   belongs_to :system_picture
@@ -13,13 +13,20 @@ class Balloon < ActiveRecord::Base
 #  validates :caption, :presence => true
   validates :settings, :extend_balloon => true
 
-  before_validation :valid_encode
+  def self.singular
+    'Balloon'
+  end
   
-  def valid_encode
-    ['settings'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'Balloons'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['settings']
   end
   
   def self.colum_structures
index fbb04e2..19149d5 100644 (file)
@@ -7,16 +7,31 @@ class Comic < Pettanr::Content
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   
-  @@valid_encode_columns += ['title', 'description']
   @@visible_count_options = {:conditions => 'visible > 0'}
   
+  def self.singular
+    'Comic'
+  end
+  
+  def self.plural
+    'Comics'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super + ['title', 'description']
+  end
+  
   def supply_default
     self.visible = 0 if self.visible.blank?
   end
   
-  def overwrite au
-    return false unless au
-    self.author_id = au.id
+  def overwrite operators
+    return false unless operators.author
+    self.author_id = operators.author.id
   end
   
   def visible? operators
index 2f61ce1..5e8651f 100644 (file)
@@ -1,4 +1,4 @@
-class GroundColor < ActiveRecord::Base
+class GroundColor < Pettanr::Item
   include Element
   include ElementInspire
   belongs_to :panel
@@ -12,13 +12,20 @@ class GroundColor < ActiveRecord::Base
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  before_validation :valid_encode
+  def self.singular
+    'GroundColor'
+  end
   
-  def valid_encode
-    ['caption'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'GroundColors'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['caption']
   end
   
   def self.colum_structures
index 647bf23..4b4269e 100644 (file)
@@ -1,4 +1,4 @@
-class GroundPicture < ActiveRecord::Base
+class GroundPicture < Pettanr::Item
   include Element
   include ElementInspire
   belongs_to :panel
@@ -14,13 +14,20 @@ class GroundPicture < ActiveRecord::Base
   
   @@repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat']
   
-  before_validation :valid_encode
+  def self.singular
+    'GroundPicture'
+  end
   
-  def valid_encode
-    ['caption'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'GroundPictures'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['caption']
   end
   
   def self.list_opt_for_panel
index 50c5116..f162b27 100644 (file)
@@ -1,5 +1,5 @@
 #
-class License < ActiveRecord::Base
+class License < Pettanr::Item
   belongs_to :license_group
   belongs_to :system_picture
   has_many :resource_pictures
@@ -10,13 +10,20 @@ class License < ActiveRecord::Base
   validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true, :url => {:message => I18n.t('errors.messages.url')} #{:allow_blank => true}
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   
-  before_validation :valid_encode
+  def self.singular
+    'License'
+  end
   
-  def valid_encode
-    ['name', 'caption', 'url', 'settings', 'credit_pictures'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'Licenses'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['name', 'caption', 'url', 'settings', 'credit_pictures']
   end
   
   def supply_default
index cc09080..dad8157 100644 (file)
@@ -1,5 +1,5 @@
 #ライセンスグループ
-class LicenseGroup < ActiveRecord::Base
+class LicenseGroup < Pettanr::Item
   has_many :licenses
   
   validates :name, :presence => true, :length => {:maximum => 50}, :uniqueness => true
@@ -7,13 +7,20 @@ class LicenseGroup < ActiveRecord::Base
   validates :caption, :presence => true, :length => {:maximum => 30}
   validates :url, :presence => true, :length => {:maximum => 200}, :url => {:message => I18n.t('errors.messages.url')}
   
-  before_validation :valid_encode
+  def self.singular
+    'LicenseGroup'
+  end
   
-  def valid_encode
-    ['name', 'classname', 'caption', 'url'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'LicenseGroups'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['name', 'classname', 'caption', 'url']
   end
   
   def supply_default
index db52744..c141cc8 100644 (file)
@@ -1,4 +1,4 @@
-class OriginalPicture < ActiveRecord::Base
+class OriginalPicture < Pettanr::Item
   belongs_to :artist
   belongs_to :original_picture_license_group
   has_one :resource_picture
@@ -11,6 +11,18 @@ class OriginalPicture < ActiveRecord::Base
   validates :artist_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :md5, :presence => true, :length => {:minimum => 32, :maximum => 32}
   
+  def self.singular
+    'OriginalPicture'
+  end
+  
+  def self.plural
+    'OriginalPictures'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
   def supply_default
   end
   
index 7856a9b..33a99b6 100644 (file)
@@ -1,5 +1,5 @@
 #コマ
-class Panel < ActiveRecord::Base
+class Panel < Pettanr::Item
   belongs_to :author
   has_many :scroll_panels
   has_many :sheet_panels
@@ -18,32 +18,20 @@ class Panel < ActiveRecord::Base
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :publish, :presence => true, :numericality => true
   
-  cattr_reader :singular, :plural
-  @@singular = 'Panel'
-  @@plural = 'Panels'
-  def self.item_name
-    self.singular.underscore
+  def self.singular
+    'Panel'
   end
   
-  def item_name
-    self.class.item_name
+  def self.plural
+    'Panels'
   end
   
-  def self.path_name with_engine = false
-    self.plural.underscore
+  def self.owner_type
+    :author
   end
   
-  def path_name 
-    self.class.path_name
-  end
-  
-  before_validation :valid_encode
-  
-  def valid_encode
-    ['caption'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.valid_encode_columns
+    super.merge ['caption']
   end
   
   def self.each_element_class_names
index 8aa6809..ccb5cd0 100644 (file)
@@ -1,4 +1,4 @@
-class PanelPicture < ActiveRecord::Base
+class PanelPicture < Pettanr::Item
   include Element
   include ElementInspire
   belongs_to :panel
@@ -14,13 +14,20 @@ class PanelPicture < ActiveRecord::Base
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  before_validation :valid_encode
+  def self.singular
+    'PanelPicture'
+  end
   
-  def valid_encode
-    ['link', 'caption'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'PanelPictures'
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['link', 'caption']
+  end
+  
+  def self.owner_type
+    :author
   end
   
   def self.colum_structures
index dc04329..16f654c 100644 (file)
@@ -1,5 +1,5 @@
 #実素材
-class Picture < ActiveRecord::Base
+class Picture < Pettanr::Item
   belongs_to :original_picture
   belongs_to :license
   belongs_to :artist
@@ -17,13 +17,20 @@ class Picture < ActiveRecord::Base
   validates :artist_name, :presence => true
   validates :classname, :presence => true, :length => {:maximum => 50}
   
-  before_validation :valid_encode
+  def self.singular
+    'Picture'
+  end
   
-  def valid_encode
-    ['artist_name', 'classname', 'credit', 'settings'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'Pictures'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['artist_name', 'classname', 'credit', 'settings']
   end
   
   def supply_default
index 935c3e2..92da32b 100644 (file)
@@ -1,5 +1,5 @@
 #素材
-class ResourcePicture < ActiveRecord::Base
+class ResourcePicture < Pettanr::Item
   belongs_to :artist
   belongs_to :license
   belongs_to :picture
@@ -17,13 +17,20 @@ class ResourcePicture < ActiveRecord::Base
   validates :classname, :presence => true, :length => {:maximum => 50}
   validates :picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   
-  before_validation :valid_encode
+  def self.singular
+    'ResourcePicture'
+  end
   
-  def valid_encode
-    ['artist_name', 'classname', 'credit', 'settings'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'ResourcePictures'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['artist_name', 'classname', 'credit', 'settings']
   end
   
   def supply_default
index 73eed47..291ff0c 100644 (file)
@@ -18,6 +18,10 @@ class Scroll < Pettanr::Item
     :author
   end
   
+  def self.valid_encode_columns
+    super.merge ['title']
+  end
+  
   def supply_default
     self.visible = 0 if self.visible.blank?
   end
index 1860ac1..048c289 100644 (file)
@@ -1,4 +1,4 @@
-class ScrollPanel < ActiveRecord::Base
+class ScrollPanel < Pettanr::Item
   belongs_to :author
   belongs_to :panel
   belongs_to :scroll
@@ -8,23 +8,16 @@ class ScrollPanel < ActiveRecord::Base
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  cattr_reader :singular, :plural
-  @@singular = 'ScrollPanel'
-  @@plural = 'ScrollPanels'
-  def self.item_name
-    self.singular.underscore
+  def self.singular
+    'ScrollPanel'
   end
   
-  def item_name
-    self.class.item_name
+  def self.plural
+    'ScrollPanels'
   end
   
-  def self.path_name with_engine = false
-    self.plural.underscore
-  end
-  
-  def path_name 
-    self.class.path_name
+  def self.owner_type
+    :author
   end
   
   def supply_default
index 780cdbe..0d9def8 100644 (file)
@@ -1,4 +1,4 @@
-class Sheet < ActiveRecord::Base
+class Sheet < Pettanr::Item
   has_many :sheet_panels
   has_many :story_sheets
   belongs_to :author
@@ -8,13 +8,21 @@ class Sheet < ActiveRecord::Base
   validates :height, :presence => true, :numericality => true, :natural_number => true
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   accepts_nested_attributes_for :sheet_panels, :allow_destroy => true
-  before_validation :valid_encode
   
-  def valid_encode
-    ['caption'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.singular
+    'Sheet'
+  end
+  
+  def self.plural
+    'Sheets'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['caption']
   end
   
   def self.each_element_class_names
index 1ff1de2..547d638 100644 (file)
@@ -1,4 +1,4 @@
-class SheetPanel < ActiveRecord::Base
+class SheetPanel < Pettanr::Item
   belongs_to :author
   belongs_to :panel
   belongs_to :sheet
@@ -12,6 +12,18 @@ class SheetPanel < ActiveRecord::Base
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
+  def self.singular
+    'SheetPanel'
+  end
+  
+  def self.plural
+    'SheetPanels'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
   def supply_default
     self.x = 15
     self.y = 15
index 7f31064..af6f09e 100644 (file)
@@ -1,4 +1,4 @@
-class Speech < ActiveRecord::Base
+class Speech < Pettanr::Item
   include ElementPart
   belongs_to :speech_balloon
   belongs_to :writing_format
@@ -17,13 +17,20 @@ class Speech < ActiveRecord::Base
   
   @@text_align_texts = ['left', 'left', 'right', 'center']
   
-  before_validation :valid_encode
+  def self.singular
+    'Speech'
+  end
   
-  def valid_encode
-    ['content', 'quotes', 'settings'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'Speeches'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['content', 'quotes', 'settings']
   end
   
   def self.colum_structures
index 00b5901..1033360 100644 (file)
@@ -1,4 +1,4 @@
-class SpeechBalloon < ActiveRecord::Base
+class SpeechBalloon < Pettanr::Item
   include Element
   include ElementInspire
   has_one :balloon, :dependent => :destroy
@@ -16,13 +16,20 @@ class SpeechBalloon < ActiveRecord::Base
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   validates :settings, :extend_speech_balloon => true
   
-  before_validation :valid_encode
+  def self.singular
+    'SpeechBalloon'
+  end
   
-  def valid_encode
-    ['caption', 'classname', 'settings'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'SpeechBalloons'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['caption', 'classname', 'settings']
   end
   
   def self.list_opt_for_panel
index a639bf6..edcd2d8 100644 (file)
@@ -1,5 +1,5 @@
 #フキダシテンプレート
-class SpeechBalloonTemplate < ActiveRecord::Base
+class SpeechBalloonTemplate < Pettanr::Item
   has_many :speech_balloons
   belongs_to :system_picture
   
@@ -10,13 +10,20 @@ class SpeechBalloonTemplate < ActiveRecord::Base
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :settings, :presence => true
   
-  before_validation :valid_encode
+  def self.singular
+    'SpeechBalloonTemplate'
+  end
   
-  def valid_encode
-    ['name', 'classname', 'caption', 'settings'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'SpeechBalloonTemplates'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['name', 'classname', 'caption', 'settings']
   end
   
   def supply_default
index 3d20165..88ce170 100644 (file)
@@ -1,5 +1,5 @@
 #ストーリー
-class Story < ActiveRecord::Base
+class Story < Pettanr::Item
   has_many :story_sheets
   belongs_to :comic
   
@@ -7,13 +7,21 @@ class Story < ActiveRecord::Base
   validates :title, :presence => true, :length => {:maximum => 100}
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
-  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
+  def self.singular
+    'Story'
+  end
+  
+  def self.plural
+    'Stories'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['title', 'description']
   end
   
   def supply_default
index 0f493b1..08eac83 100644 (file)
@@ -1,4 +1,4 @@
-class StorySheet < ActiveRecord::Base
+class StorySheet < Pettanr::Item
   belongs_to :author
   belongs_to :story
   belongs_to :sheet
@@ -8,6 +8,18 @@ class StorySheet < ActiveRecord::Base
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
+  def self.singular
+    'StorySheet'
+  end
+  
+  def self.plural
+    'StorySheets'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
   def supply_default
     self.story_id = nil
     self.sheet_id = nil
index 1d090bc..a9cf03e 100644 (file)
@@ -1,4 +1,4 @@
-class SystemPicture < ActiveRecord::Base
+class SystemPicture < Pettanr::Item
   has_many :balloons
   has_many :balloon_templates
   has_many :licenses
@@ -9,6 +9,18 @@ class SystemPicture < ActiveRecord::Base
   validates :filesize, :presence => true, :numericality => {:greater_than => 0, :less_than_or_equal_to => 2000000}, :natural_number => true
   validates :md5, :presence => true, :length => {:minimum => 32, :maximum => 32}
   
+  def self.singular
+    'SystemPicture'
+  end
+  
+  def self.plural
+    'SystemPictures'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
   before_destroy :destroy_with_file
   
   def destroy_with_file
index 9ea43fc..e7d04a2 100644 (file)
@@ -1,4 +1,4 @@
-class WritingFormat < ActiveRecord::Base
+class WritingFormat < Pettanr::Item
   has_many :speeches
   belongs_to :system_picture
   
@@ -9,13 +9,20 @@ class WritingFormat < ActiveRecord::Base
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :settings, :presence => true
   
-  before_validation :valid_encode
+  def self.singular
+    'WritingFormat'
+  end
   
-  def valid_encode
-    ['name', 'classname', 'caption', 'settings'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.plural
+    'WritingFormats'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['name', 'classname', 'caption', 'settings']
   end
   
   def supply_default
index 5d9ce6a..cc64501 100644 (file)
@@ -21,7 +21,7 @@
   </div>
   <div class="field">
     <%= f.label :author_id %><br />
-    <%= h @author.name %>
+    <%= h @operators.author.name %>
   </div>
   <div class="row_break">
   </div>
index 4b73f49..9b7a8d6 100644 (file)
@@ -40,7 +40,7 @@
   <%= l @comic.updated_at %>
 </p>
 
-<% if @comic.own? @author -%>
+<% if @comic.own? @operators -%>
   <%= link_to t('link.edit'), edit_comic_path(@comic) %>
   <%= link_to t('link.destroy'), comic_path(@comic), :method => :delete %>
 
index d5d80a4..d197e6c 100644 (file)
@@ -27,7 +27,7 @@
   </div>
   <div class="field">
     <%= f.label :author_id %><br />
-    <%= h @author.name %>
+    <%= h @operators.author.name %>
   </div>
   <div class="row_break">
   </div>
index 173850c..e021dfd 100644 (file)
@@ -6,15 +6,16 @@ class Pettanr::Item < ActiveRecord::Base
   
   before_validation :valid_encode
   
-  cattr_accessor :valid_encode_columns, :visible_count_options
-  @@valid_encode_columns = []
-  @@visible_count_options = {}
+  def self.valid_encode_columns
+    []
+  end
+  
   def self.singular
-    'Item'
+    self.class.to_s
   end
   
   def self.plural
-    'Items'
+    self.singular.pluralize
   end
   
   def self.item_name
@@ -61,6 +62,10 @@ class Pettanr::Item < ActiveRecord::Base
     self.count self.visible_count_options
   end
   
+  def self.visible_count_options
+    []
+  end
+  
   #InstanceMethods
   
   def item_name
index 03eea9f..811435a 100644 (file)
@@ -269,9 +269,9 @@ module Pettanr
       
       def type_default view, item, operators
         if item.own? operators
-          view.link_to tag(:img, :src => view.asset_path('edit.png'), :width => 32, :height => 32), 
+          view.link_to view.tag(:img, :src => view.asset_path('edit.png'), :width => 32, :height => 32), 
             view.polymorphic_path(item, :action => :edit)
-          view.link_to tag(:img, :src => view.asset_path('remove.png'), :width => 32, :height => 32), 
+          view.link_to view.tag(:img, :src => view.asset_path('remove.png'), :width => 32, :height => 32), 
             item, confirm: 'Are you sure?', :method => :delete
         end
       end