OSDN Git Service

rename model name
[pettanr/pettanr.git] / app / controllers / home_controller.rb
index 92a2b13..3ee6e97 100644 (file)
@@ -1,11 +1,14 @@
 class HomeController < ApplicationController
-  layout 'test' if MagicNumber['test_layout']
   before_filter :authenticate_user, :only => [
     :index, :show, :profile, :configure, :create_token, :delete_token, 
-    :comic, :story, :panel, :resource_picture, :panel_picture, :panel_color, :ground_picture, :ground_color
+    :scrolls, :scroll_panels, :comics, :comic_stories, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :panel_pictures, :speech_balloons, :balloons, :speeches, :ground_pictures, :ground_colors,
+    :scrolls_count, :scroll_panels_count, :comics_count, :comic_stories_count, :stories_count, :story_sheets_count, :sheets_count, :sheet_panels_count, :panels_count, :resource_pictures_count, :panel_pictures_count, :speech_balloons_count, :balloons_count, :speeches_count, :ground_pictures_count, :ground_colors_count
   ]
-  before_filter :authenticate_author, :only => [:comic, :story, :panel, :panel_picture, :panel_color, :ground_picture, :ground_color]
-  before_filter :authenticate_artist, :only => [:resource_picture]
+  before_filter :authenticate_author, :only => [
+    :scrolls, :scroll_panels, :comics, :comic_stories, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :panel_pictures, :speech_balloons, :balloons, :speeches, :ground_pictures, :ground_colors,
+    :scrolls_count, :scroll_panels_count, :comics_count, :comic_stories_count, :stories_count, :story_sheets_count, :sheets_count, :sheet_panels_count, :panels_count, :resource_pictures_count, :panel_pictures_count, :speech_balloons_count, :balloons_count, :speeches_count, :ground_pictures_count, :ground_colors_count
+  ]
+  before_filter :authenticate_artist, :only => [:resource_pictures]
   
   def index
   end
@@ -14,10 +17,24 @@ class HomeController < ApplicationController
   end
   
   def configure
+    @author = @operators.author
+    unless @author
+      @author = Author.new
+      @author.supply_default
+    end
+    @author.boosts 'post'
+    @author_form = Locmare::Bucket.factory @author.item_name, @author, true, true, @operators
+    @artist = @operators.artist
+    unless @artist
+      @artist = Artist.new
+      @artist.supply_default
+    end
+    @artist.boosts 'post'
+    @artist_form = Locmare::Bucket.factory @artist.item_name, @artist, true, true, @operators
   end
   
   def create_token
-    if @user.create_token
+    if @operators.user.create_token
       respond_to do |format|
         flash[:notice] = I18n.t('flash.notice.created', :model => User.human_attribute_name(:authentication_token))
         format.html { redirect_to({:action => :configure}) }
@@ -29,7 +46,7 @@ class HomeController < ApplicationController
   end
   
   def delete_token
-    if @user.delete_token
+    if @operators.user.delete_token
       respond_to do |format|
         flash[:notice] = I18n.t('flash.notice.destroyed', :model => User.human_attribute_name(:authentication_token))
         format.html { redirect_to :action => :configure}
@@ -40,92 +57,128 @@ class HomeController < ApplicationController
     end
   end
   
-  def comic
-    @page = Author.page params[:page]
-    @page_size = Author.comic_page_size params[:page_size]
-    @comics = Comic.mylist(@author, @page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @comics.to_json(Comic.list_json_opt) }
-    end
+  def scrolls
+    filer_list
   end
   
-  def story
-    @page = Author.page params[:page]
-    @page_size = Author.story_page_size params[:page_size]
-    @stories = Story.mylist(@author, @page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render text: Story.list_as_json_text(@stories) }
-    end
+  def scroll_panels
+    filer_list
   end
   
-  def panel
-    @page = Author.page params[:page]
-    @page_size = Author.panel_page_size params[:page_size]
-    @panels = Panel.mylist(@author, @page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render text: Panel.list_as_json_text(@panels) }
-    end
+  def comics
+    filer_list
   end
   
-  def panel_picture
-    @page = Author.page params[:page]
-    @page_size = Author.panel_picture_page_size params[:page_size]
-    @panel_pictures = PanelPicture.mylist(@author, @page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @panel_pictures.to_json(PanelPicture.list_json_opt) }
-    end
+  def comic_stories
+    filer_list
   end
   
-  def panel_color
-    @page = Author.page params[:page]
-    @page_size = Author.panel_page_size params[:page_size]
-    @panel_colors = PanelColor.mylist(@author, @page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @panel_colors.to_json(PanelColor.list_json_opt) }
-    end
+  def stories
+    filer_list
   end
   
-  def ground_picture
-    @page = Author.page params[:page]
-    @page_size = Author.panel_page_size params[:page_size]
-    @ground_pictures = GroundPicture.mylist(@author, @page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @ground_pictures.to_json(GroundPicture.list_json_opt) }
-    end
+  def story_sheets
+    filer_list
   end
   
-  def ground_color
-    @page = Author.page params[:page]
-    @page_size = Author.panel_page_size params[:page_size]
-    @ground_colors = GroundColor.mylist(@author, @page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @ground_colors.to_json(GroundColor.list_json_opt) }
-    end
+  def sheets
+    filer_list
   end
   
-  def resource_picture
-    @page = Author.page params[:page]
-    @page_size = Author.panel_page_size params[:page_size]
-    @resource_pictures = ResourcePicture.mylist(@author, @page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
-    end
+  def sheet_panels
+    filer_list
+  end
+  
+  def panels
+    filer_list
+  end
+  
+  def panel_pictures
+    filer_list
+  end
+  
+  def speech_balloons
+    filer_list
+  end
+  
+  def balloons
+    filer_list
+  end
+  
+  def speeches
+    filer_list
+  end
+  
+  def ground_pictures
+    filer_list
+  end
+  
+  def ground_colors
+    filer_list
+  end
+  
+  def resource_pictures
+    filer_list
+  end
+  
+  def scrolls_count
+    list_count
+  end
+  
+  def scroll_panels_count
+    list_count
+  end
+  
+  def comics_count
+    list_count
+  end
+  
+  def comic_stories_count
+    list_count
+  end
+  
+  def stories_count
+    list_count
+  end
+  
+  def story_sheets_count
+    list_count
+  end
+  
+  def sheets_count
+    list_count
+  end
+  
+  def sheet_panels_count
+    list_count
+  end
+  
+  def panels_count
+    list_count
+  end
+  
+  def panel_pictures_count
+    list_count
+  end
+  
+  def balloons_count
+    list_count
+  end
+  
+  def speeches_count
+    list_count
+  end
+  
+  def ground_pictures_count
+    list_count
+  end
+  
+  def ground_colors_count
+    list_count
+  end
+  
+  def resource_pictures_count
+    list_count
   end
   
 end