1 class HomeController < ApplicationController
2 before_filter :authenticate_author!, :only => [
3 :index, :show, :profile, :configure, :create_token, :delete_token, :step2, :save_step2, :step3, :save_step3,
17 @author = current_author
18 respond_to do |format|
19 if @author.create_token
20 format.html { redirect_to({:action => :configure}, {:notice => 'author token was successfully created.'}) }
22 format.html { render action: "auth_token" }
28 current_author.delete_token
29 respond_to do |format|
30 format.html { redirect_to :action => :configure}
35 @author = current_author
39 @author = current_author
40 respond_to do |format|
41 if @author.step2(params[:author][:name])
42 a = if params[:step3].to_i == 1
47 format.html { redirect_to({:action => a}, {:notice => 'your name was successfully updated.'}) }
49 format.html { render action: "step2" }
55 @artist = Artist.new :author_id => current_author.id, :name => current_author.name, :default_lisence_id => 1
59 if current_author.artist?
60 redirect_to :action => :index
62 @artist = Artist.new params[:artist]
63 respond_to do |format|
65 format.html { redirect_to({:action => :index}, {:notice => 'artist was successfully registered.'}) }
67 format.html { render action: "step3" }
74 @comics = Comic.find(:all,
75 :include => :author, :conditions => ['author_id = ?', current_author.id],
76 :order => 'updated_at desc', :limit => 20
79 respond_to do |format|
80 format.html # index.html.erb
81 format.json { render json: @comics }
86 if current_author.artist?
87 @original_pictures = OriginalPicture.find(:all,
88 :include => [:artist, :lisence, :resource_picture], :conditions => ['artist_id = ?', current_author.artist.id],
89 :order => 'updated_at', :limit => 20
92 respond_to do |format|
93 format.html # index.html.erb
94 format.json { render :json => @original_pictures.to_json(
95 :include => [:resource_picture, :artist, :lisence]