OSDN Git Service

fix manifest
[pettanr/pettanr.git] / app / controllers / artists_controller.rb
1 class ArtistsController < ApplicationController
2   if Manifest.manifest.magic_numbers['run_mode'] == 0
3     before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
4     before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
5   else
6     before_filter :authenticate_resource_reader, :only => [:index, :show, :resource_pictures]
7     before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
8     before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
9   end
10
11   def self.model
12     Artist
13   end
14   
15   def index
16     filer_list
17   end
18   
19   def show_html_format format
20     format.html {
21       @artist = @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     form_new
40   end
41   
42   def edit
43     form_edit
44   end
45   
46   def create
47     @artist = Artist.new()
48     @artist.supply_default 
49     @artist.attributes = params[:artist]
50     @artist.overwrite @operators
51     respond_to do |format|
52       if @artist.save
53         flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
54         format.html { redirect_to root_path }
55         format.json { render json: @artist.to_json(Artist.show_json_opt), status: :created, location: @artist }
56       else
57         flash[:notice] = I18n.t('flash.notice.not_created', :model => Artist.model_name.human)
58         format.html { render action: "new" }
59         format.json { render json: @artist.errors, status: :unprocessable_entity }
60       end
61     end
62   end
63
64   def update
65     @artist = Artist.edit(params[:id], @operators)
66     @artist.attributes = params[:artist]
67     @artist.overwrite @operators
68
69     respond_to do |format|
70       if @artist.save
71         flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
72         format.html { redirect_to '/home/configure' }
73         format.json { head :ok }
74       else
75         flash[:notice] = I18n.t('flash.notice.not_updated', :model => Artist.model_name.human)
76         format.html { render action: "edit" }
77         format.json { render json: @artist.errors, status: :unprocessable_entity }
78       end
79     end
80   end
81
82   def destroy
83     @artist = Artist.edit(params[:id], @operators)
84     @artist.destroy
85
86     respond_to do |format|
87       format.html { redirect_to artists_url }
88       format.json { head :ok }
89     end
90   end
91 end