OSDN Git Service

manifest view profiler
[pettanr/pettanr.git] / app / controllers / authors_controller.rb
1 class AuthorsController < ApplicationController
2   if Manifest.manifest.magic_numbers['run_mode'] == 0
3     before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
4     before_filter :authenticate_author, :only => [:edit, :update]
5   else
6     before_filter :authenticate_reader, :only => [:index, :show, :count]
7     before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
8     before_filter :authenticate_author, :only => [:edit, :update]
9   end
10
11   def self.model
12     Author
13   end
14   
15   def index
16     filer_list
17   end
18   
19   def show_html_format format
20     format.html {
21       @author = @item
22     }
23   end
24   
25   def show
26     set_show
27     respond_to do |format|
28       show_html_format format
29       show_prof_format format
30       show_json_format format
31     end
32   end
33   
34   def count
35     list_count
36   end
37   
38   def new
39     @author = Author.new
40     @author.supply_default 
41
42     respond_to do |format|
43       format.html
44       format.js
45       format.json { render json: @au.to_json(Author.show_json_opt) }
46     end
47   end
48
49   def edit
50     @author = Author.edit(params[:id], @operators)
51   end
52
53   def create
54     @author = Author.new()
55     @author.supply_default 
56     @author.attributes = params[:author]
57     @author.overwrite @operators
58     respond_to do |format|
59       if @author.save
60         flash[:notice] = I18n.t('flash.notice.created', :model => Author.model_name.human)
61         format.html { redirect_to root_path }
62         format.json { render json: @author.to_json(Author.show_json_opt), status: :created }
63       else
64         flash[:notice] = I18n.t('flash.notice.not_created', :model => Author.model_name.human)
65         format.html { render action: "new" }
66         format.json { render json: @au.errors, status: :unprocessable_entity }
67       end
68     end
69   end
70
71   def update
72     @author = Author.edit(params[:id], @operators)
73     @author.attributes = params[:author]
74     @author.overwrite @operators
75
76     respond_to do |format|
77       if @author.save
78         flash[:notice] = I18n.t('flash.notice.updated', :model => Author.model_name.human)
79         format.html { redirect_to '/home/configure' }
80         format.json { head :ok }
81       else
82         flash[:notice] = I18n.t('flash.notice.not_updated', :model => Author.model_name.human)
83         format.html { render action: "edit" }
84         format.json { render json: @author.errors, status: :unprocessable_entity }
85       end
86     end
87   end
88 end