OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / controllers / comic_stories_controller.rb
1 class ComicStoriesController < 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_comic, :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_comic
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       format.json { render json: @item.to_json }
34     end
35   end
36   
37   def count_by_author
38     list_count
39   end
40   
41   def new
42     form_new
43   end
44   
45   def edit
46     form_edit
47   end
48   
49   def create
50     set_model
51     @item = @my_model_class.new
52     @item.supply_default
53     @item.attributes = @item.permit_params params
54     @item.overwrite @operators
55     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
56     @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id
57     
58     leaf_render_create play_comic_path(@binder)
59   end
60   
61   def update
62     set_model
63     @item = @my_model_class.edit(params[:id], @operators)
64     ot = @item.t
65     @item.attributes = @item.permit_params params
66     @item.overwrite @operators
67     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
68     # no check permission for destination
69     # swapable hidden panel
70     #@panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id
71     
72     leaf_render_update ot, play_comic_path(@binder)
73   end
74   
75   def destroy
76     set_model
77     @item = @my_model_class.edit(params[:id], @operators)
78     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
79     render_destroy play_comic_path(@binder)
80   end
81   
82 end