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
+ 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
]
- before_filter :authenticate_artist, :only => [:picture]
+ before_filter :authenticate_author, :only => [:comic, :story, :panel, :panel_picture, :panel_color, :ground_picture, :ground_color]
+ before_filter :authenticate_artist, :only => [:resource_picture]
def index
end
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 @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}
- end
- end
-
- def step2
- 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
- end
-
- def step3
- end
-
- def save_step3
- if @author.artist?
- redirect_to :action => :index
- else
- @artist = Artist.new params[:artist]
+ if @user.delete_token
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
+ 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
end
end
- def panel
+ def story
@page = Author.page params[:page]
- @page_size = Author.panel_page_size params[:page_size]
- @panels = Panel.mylist(@author, @page, @page_size)
+ @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: Panel.list_as_json_text(@panels) }
+ format.json { render text: Story.list_as_json_text(@stories) }
end
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)
+ 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 json: @original_pictures.to_json(OriginalPicture.list_json_opt) }
+ format.json { render text: Panel.list_as_json_text(@panels) }
end
end
def panel_color
@page = Author.page params[:page]
- @page_size = Author.panel_page_size params[:page_size]
+ @page_size = Author.panel_color_page_size params[:page_size]
@panel_colors = PanelColor.mylist(@author, @page, @page_size)
respond_to do |format|
def ground_picture
@page = Author.page params[:page]
- @page_size = Author.panel_page_size params[:page_size]
+ @page_size = Author.ground_picture_page_size params[:page_size]
@ground_pictures = GroundPicture.mylist(@author, @page, @page_size)
respond_to do |format|
def ground_color
@page = Author.page params[:page]
- @page_size = Author.panel_page_size params[:page_size]
+ @page_size = Author.ground_color_page_size params[:page_size]
@ground_colors = GroundColor.mylist(@author, @page, @page_size)
respond_to do |format|
end
end
+ def resource_picture
+ @page = Author.page params[:page]
+ @page_size = Author.resource_picture_page_size params[:page_size]
+ @resource_pictures = ResourcePicture.mylist(@artist, @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
+ end
+
end