X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fhome_controller.rb;h=bff64a081a2bc78fbbb9af5bdfbd2a6783891b24;hb=69b61b39006c1951fc8c08746e884e63e50233b3;hp=af11ec46c4e57b58e42ecb49844559fba214f1ee;hpb=c2af7cf1ff49dcf8f3c902a718d6842793af4f39;p=pettanr%2Fpettanr.git diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index af11ec46..bff64a08 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,10 +1,12 @@ class HomeController < ApplicationController - layout 'test' if Pettanr::Application.test_layout - before_filter :authenticate_user!, :only => [ - :index, :show, :profile, :configure, :create_token, :delete_token, :step2, :save_step2, :step3, :save_step3, - :comic, :panel, :picture, :panel_picture, :panel_color, :ground_picture, :ground_color + before_filter :authenticate_user, :only => [ + :index, :show, :profile, :configure, :create_token, :delete_token, + :scrolls, :scroll_panels, :comics, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :resource_pictures, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors ] - before_filter :authenticate_artist, :only => [:picture] + before_filter :authenticate_author, :only => [ + :scrolls, :scroll_panels, :comics, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors + ] + before_filter :authenticate_artist, :only => [:resource_pictures] def index end @@ -13,136 +15,96 @@ 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 - respond_to do |format| - if @user.create_token - format.html { redirect_to({:action => :configure}, {:notice => 'user token was successfully created.'}) } - else - format.html { render action: "auth_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}) } end + else + flash[:notice] = I18n.t('flash.notice.not_created', :model => User.human_attribute_name(:authentication_token)) + format.html { render action: "configure" } end end def delete_token - @user.delete_token - respond_to do |format| - format.html { redirect_to :action => :configure} + 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} + end + else + flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => User.human_attribute_name(:authentication_token)) + format.html { render action: "configure" } end end - def step2 + def scrolls + filer_list end - def save_step2 - respond_to do |format| - if @author.step2(params[:author][:name]) - a = if params[:step3].to_i == 1 - :step3 - else - :index - end - format.html { redirect_to({:action => a}, {:notice => 'your name was successfully updated.'}) } - else - format.html { render action: "step2" } - end - end + def scroll_panels + filer_list end - def step3 + def comics + filer_list end - def save_step3 - if @author.artist? - redirect_to :action => :index - else - @artist = Artist.new params[:artist] - respond_to do |format| - if @artist.save - format.html { redirect_to({:action => :index}, {:notice => 'artist was successfully registered.'}) } - else - format.html { render action: "step3" } - end - end - end + def stories + filer_list 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 story_sheets + 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 sheets + filer_list end - def picture - @page = OriginalPicture.page params[:page] - @page_size = OriginalPicture.page_size params[:page_size] - @original_pictures = OriginalPicture.mylist(@artist.id, @page, @page_size) - - respond_to do |format| - format.html # index.html.erb - format.json { render json: @original_pictures.to_json(OriginalPicture.list_json_opt) } - end + def sheet_panels + 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 panels + 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 panel_pictures + 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 speech_balloons + 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 ground_pictures + filer_list + end + + def ground_colors + filer_list + end + + def resource_pictures + filer_list end end