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,
+ :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
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
+ if @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 scrolls
+ @page = Author.page params[:page]
+ @page_size = Author.scroll_page_size params[:page_size]
+ @scrolls = Scroll.mylist(@author, @page, @page_size)
+
respond_to do |format|
- format.html { redirect_to :action => :configure}
+ format.html {
+ @paginate = Scroll.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @scrolls, :model => Scroll,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render json: @scrolls.to_json(Scroll.list_json_opt) }
end
end
- def step2
+ def scroll_panels
+ @page = Author.page params[:page]
+ @page_size = Author.scroll_panel_page_size params[:page_size]
+ @scroll_panels = ScrollPanel.mylist(@author, @page, @page_size)
+
+ respond_to do |format|
+ format.html {
+ @paginate = ScrollPanel.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @scroll_panels, :model => ScrollPanel,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render json: @scroll_panels.to_json(ScrollPanel.list_json_opt) }
+ end
end
- def save_step2
+ def comics
+ @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|
- 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
+ format.html {
+ @paginate = Comic.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @comics, :model => Comic,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render json: @comics.to_json(Comic.list_json_opt) }
end
end
- def step3
+ def stories
+ @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 {
+ @paginate = Story.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @stories, :model => Story,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render json: @stories.to_json(Story.list_json_opt) }
+ end
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
+ def story_sheets
+ @page = Author.page params[:page]
+ @page_size = Author.story_sheet_page_size params[:page_size]
+ @story_sheets = StorySheet.mylist(@author, @page, @page_size)
+
+ respond_to do |format|
+ format.html {
+ @paginate = StorySheet.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @story_sheets, :model => StorySheet,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render json: @story_sheets.to_json(StorySheet.list_json_opt) }
end
end
- def comic
+ def sheets
@page = Author.page params[:page]
- @page_size = Author.comic_page_size params[:page_size]
- @comics = Comic.mylist(@author, @page, @page_size)
+ @page_size = Author.sheet_page_size params[:page_size]
+ @sheets = Sheet.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) }
+ format.html {
+ @paginate = Sheet.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @sheets, :model => Sheet,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render json: @sheets.to_json(Sheet.list_json_opt) }
end
end
- def panel
+ def sheet_panels
@page = Author.page params[:page]
- @page_size = Author.panel_page_size params[:page_size]
- @panels = Panel.mylist(@author, @page, @page_size)
+ @page_size = Author.sheet_panel_page_size params[:page_size]
+ @sheet_panels = SheetPanel.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.html {
+ @paginate = SheetPanel.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @sheet_panels, :model => SheetPanel,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render json: @sheet_panels.to_json(SheetPanel.list_json_opt) }
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 panels
+ @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.html {
+ @paginate = Panel.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @panels, :model => Panel,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render text: Panel.list_as_json_text(@panels) }
end
end
- def panel_picture
+ def panel_pictures
@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.html {
+ @paginate = PanelPicture.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @panel_pictures, :model => PanelPicture,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
format.json { render json: @panel_pictures.to_json(PanelPicture.list_json_opt) }
end
end
- def panel_color
+ def speech_balloons
@page = Author.page params[:page]
- @page_size = Author.panel_page_size params[:page_size]
- @panel_colors = PanelColor.mylist(@author, @page, @page_size)
+ @page_size = Author.speech_balloon_page_size params[:page_size]
+ @speech_balloons = SpeechBalloon.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) }
+ format.html {
+ @paginate = SpeechBalloon.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @speech_balloons, :model => SpeechBalloon,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render json: @speech_balloons.to_json(SpeechBalloon.list_json_opt) }
end
end
- def ground_picture
+ def ground_pictures
@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|
- format.html # index.html.erb
+ format.html {
+ @paginate = GroundPicture.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @ground_pictures, :model => GroundPicture,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
format.json { render json: @ground_pictures.to_json(GroundPicture.list_json_opt) }
end
end
- def ground_color
+ def ground_colors
@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|
- format.html # index.html.erb
+ format.html {
+ @paginate = GroundColor.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @ground_colors, :model => GroundColor,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
format.json { render json: @ground_colors.to_json(GroundColor.list_json_opt) }
end
end
+ def resource_pictures
+ @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 {
+ @paginate = ResourcePicture.mylist_paginate(@author, @page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @resource_pictures, :model => ResourcePicture,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
+ format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
+ end
+ end
+
end