X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fartists_controller.rb;h=098527865bf56b5eb1f3da5784ad9bd4e49dfc6d;hb=02ea4fc4bbe7a54dd576c1cd700aa9e32710abf8;hp=9db1452ed878e9a551d9b35694852e4c3cbe6bb2;hpb=2bcff4ea2e955de6c21e19239313f00ac323f410;p=pettanr%2Fpettanr.git diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 9db1452e..09852786 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -10,47 +10,45 @@ class ArtistsController < ApplicationController end before_filter :authenticate_admin!, :only => [:list, :browse] - # GET /artists - # GET /artists.json + @@model = Artist def index - @page = Artist.page params[:page] - @page_size = Artist.page_size params[:page_size] - @artists = Artist.list(@page, @page_size) + set_filer respond_to do |format| - format.html # index.html.erb - format.json { render :json => @artists.to_json(Artist.list_json_opt) } + format_filer format + format.json { render json: @items.to_json(@@model.list_json_opt) } end end - # GET /artists/1 - # GET /artists/1.json def show - @ar = Artist.show(params[:id], [@user, @admin, @demand_user]) + @item = Artist.show(params[:id], @operators) respond_to do |format| - format.html # show.html.erb - format.json { render :json => @ar.to_json(Artist.show_json_opt) } + format.html { + @artist = @item + } + format_prof format + format.json { render :json => @item.to_json(Artist.show_json_opt) } end end def resource_pictures - @ar = Artist.show(params[:id], [@user, @admin, @demand_user]) + @artist = Artist.show(params[:id], @operators) @page = Author.page params[:page] @page_size = Author.resource_picture_page_size params[:page_size] - @resource_pictures = ResourcePicture.himlist(@ar, @page, @page_size) + @resource_pictures = ResourcePicture.himlist(@artist, @page, @page_size) respond_to do |format| format.html { - @paginate = ResourcePicture.himlist_paginate(@ar, @page, @page_size) + @paginate = ResourcePicture.himlist_paginate(@artist, @page, @page_size) } format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) } end end def count - @ar = {:count => Artist.visible_count} + @artist = {:count => Artist.visible_count} respond_to do |format| - format.json { render json: @ar.to_json } + format.json { render json: @artist.to_json } end end @@ -64,79 +62,72 @@ class ArtistsController < ApplicationController end def browse - @ar = Artist.find(params[:id]) + @artist = Artist.find(params[:id]) respond_to do |format| format.html { render layout: 'system' } - format.json { render json: @ar } + format.json { render json: @artist } end end - # GET /artists/new - # GET /artists/new.json def new - @ar = Artist.new - @ar.supply_default + @artist = Artist.new + @artist.supply_default respond_to do |format| format.html # new.html.erb format.js - format.json { render json: @ar.to_json(Artist.show_json_opt) } + format.json { render json: @artist.to_json(Artist.show_json_opt) } end end - # GET /artists/1/edit def edit - @ar = Artist.edit(params[:id], @author) + @artist = Artist.edit(params[:id], @operators) respond_to do |format| format.html format.js end end - # POST /artists - # POST /artists.json def create - @ar = Artist.new() - @ar.supply_default - @ar.attributes = params[:artist] - @ar.overwrite @author + @artist = Artist.new() + @artist.supply_default + @artist.attributes = params[:artist] + @artist.overwrite @operators respond_to do |format| - if @ar.save + if @artist.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 } + format.json { render json: @artist.to_json(Artist.show_json_opt), status: :created, location: @artist } else + flash[:notice] = I18n.t('flash.notice.not_created', :model => Artist.model_name.human) format.html { render action: "new" } - format.json { render json: @ar.errors, status: :unprocessable_entity } + format.json { render json: @artist.errors, status: :unprocessable_entity } end end end - # PUT /artists/1 - # PUT /artists/1.json def update - @ar = Artist.edit(params[:id], @author) - @ar.attributes = params[:artist] - @ar.overwrite @author + @artist = Artist.edit(params[:id], @operators) + @artist.attributes = params[:artist] + @artist.overwrite @operators respond_to do |format| - if @ar.save + if @artist.save flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human) format.html { redirect_to '/home/configure' } format.json { head :ok } else + flash[:notice] = I18n.t('flash.notice.not_updated', :model => Artist.model_name.human) format.html { render action: "edit" } - format.json { render json: @ar.errors, status: :unprocessable_entity } + format.json { render json: @artist.errors, status: :unprocessable_entity } end end 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 }