OSDN Git Service

fix: omniauth twitter
[pettanr/pettanr.git] / app / controllers / story_sheets_controller.rb
1 class StorySheetsController < ApplicationController
2   if Manifest.manifest.magic_numbers['run_mode'] == 0
3     before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
4     before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
5   else
6     before_action :authenticate_reader, :only => [
7       :index, :show, :by_story, :by_sheet, :by_author
8     ]
9     before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
10     before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
11   end
12   
13   def index
14     filer_list
15   end
16   
17   def by_story
18     filer_list param: params[:id]
19   end
20   
21   def by_sheet
22     filer_list param: params[:id]
23   end
24   
25   def by_author
26     filer_list param: params[:id]
27   end
28   
29   def show
30     set_show
31     respond_to do |format|
32       show_prof_format format
33       show_json_format format
34     end
35   end
36   
37   def new
38     form_new
39   end
40   
41   def edit
42     form_edit
43   end
44   
45   def create
46     set_model
47     @item = @my_model_class.new
48     @item.supply_default
49     @item.attributes = @item.permit_params params
50     @item.overwrite @operators
51     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
52     @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id
53     
54     leaf_render_create play_story_path(@binder)
55   end
56   
57   def update
58     set_model
59     @item = @my_model_class.edit(params[:id], @operators)
60     ot = @item.t
61     @item.attributes = @item.permit_params params
62     @item.overwrite @operators
63     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
64     # no check permission for destination
65     # swapable hidden panel
66     #@panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id
67     
68     leaf_render_update ot, play_story_path(@binder)
69   end
70   
71   def destroy
72     set_model
73     @item = @my_model_class.edit(params[:id], @operators)
74     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
75     render_destroy play_story_path(@binder)
76   end
77   
78 end