OSDN Git Service

mrg
[pettanr/pettanr.git] / app / controllers / artists_controller.rb
index 850f045..917f7dc 100644 (file)
 class ArtistsController < ApplicationController
-  layout 'test' if MagicNumber['test_layout']
-  if MagicNumber['run_mode'] == 0
-    before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+  if Manifest.manifest.magic_numbers['run_mode'] == 0
+    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_filter :authenticate_artist, :only => [:edit, :update, :destroy]
   else
-    before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
+    before_filter :authenticate_resource_reader, :only => [:index, :show, :resource_pictures]
+    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_filter :authenticate_artist, :only => [:edit, :update, :destroy]
   end
-  before_filter :authenticate_admin!, :only => [:list, :browse]
 
-  # GET /artists
-  # GET /artists.json
+  def self.model
+    Artist
+  end
+  
   def index
-    @page = Artist.page params[:page]
-    @page_size = Artist.page_size params[:page_size]
-    @artists = Artist.list(@page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render :json => @artists.to_json(Artist.list_json_opt) }
-    end
+    filer_list
   end
-
-  # GET /artists/1
-  # GET /artists/1.json
+  
+  def show_html_format format
+    format.html {
+    }
+  end
+  
   def show
-    @ar = Artist.show(params[:id], @author)
-
+    set_show
     respond_to do |format|
-      format.html # show.html.erb
-      format.json { render :json => @ar.to_json(Artist.show_json_opt) }
+      show_html_format format
+      show_prof_format format
+      show_json_format format
     end
   end
-
+  
   def count
-    @ar = {:count => Artist.visible_count}
-    respond_to do |format|
-      format.json { render json: @ar.to_json }
-    end
+    list_count
   end
   
-  def list
-    @artists = Artist.all
-
-    respond_to do |format|
-      format.html { render layout: 'system' }
-      format.json { render json: @artists }
-    end
-  end
-
-  def browse
-    @ar = Artist.find(params[:id])
-
-    respond_to do |format|
-      format.html { render layout: 'system' }
-      format.json { render json: @ar }
-    end
-  end
-
-  # GET /artists/new
-  # GET /artists/new.json
   def new
-    @ar = Artist.new
-    @ar.supply_default 
-
-    respond_to do |format|
-      format.html # new.html.erb
-      format.js
-      format.json { render json: @ar.to_json(Artist.show_json_opt) }
-    end
+    form_new
   end
-
-  # GET /artists/1/edit
+  
   def edit
-    @ar = Artist.edit(params[:id], @author)
-    respond_to do |format|
-      format.html 
-      format.js
-    end
+    form_edit
   end
-
-  # POST /artists
-  # POST /artists.json
+  
   def create
-    @ar = Artist.new()
-    @ar.supply_default 
-    @ar.attributes = params[:artist]
-    @ar.overwrite @author
-    respond_to do |format|
-      if @ar.save
-        flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
-        format.html { redirect_to root_path }
-        format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
-      else
-        format.html { render action: "new" }
-        format.json { render json: @ar.errors, status: :unprocessable_entity }
-      end
-    end
+    set_model
+    @item = @my_model_class.new
+    @item.supply_default 
+    @item.attributes = params[@my_model_class.item_name]
+    @item.overwrite @operators
+    render_create root_path
   end
-
-  # PUT /artists/1
-  # PUT /artists/1.json
+  
   def update
-    @ar = Artist.edit(params[:id], @author)
-    @ar.attributes = params[:artist]
-    @ar.overwrite @author
-
-    respond_to do |format|
-      if @ar.save
-        flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
-        format.html { redirect_to '/home/configure' }
-        format.json { head :ok }
-      else
-        format.html { render action: "edit" }
-        format.json { render json: @ar.errors, status: :unprocessable_entity }
-      end
-    end
+    set_edit
+    @item.attributes = params[@my_model_class.item_name]
+    @item.overwrite @operators
+    render_update '/home/configure'
   end
-
-  # DELETE /artists/1
-  # DELETE /artists/1.json
+  
   def destroy
-    @ar = Artist.edit(params[:id], @author)
-    @ar.destroy
-
+    @artist = Artist.edit(params[:id], @operators)
+    @artist.destroy
+    
     respond_to do |format|
       format.html { redirect_to artists_url }
       format.json { head :ok }