X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fartists_controller.rb;h=492e4cedba3b97edae1560074af618d9dd4b4c9b;hb=d6d237012089604cdbc61943856d42c0a0472dc7;hp=098527865bf56b5eb1f3da5784ad9bd4e49dfc6d;hpb=02ea4fc4bbe7a54dd576c1cd700aa9e32710abf8;p=pettanr%2Fpettanr.git diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 09852786..492e4ced 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,134 +1,61 @@ class ArtistsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_artist, :only => [:edit, :update, :destroy] else - before_filter :authenticate_resource_reader, :only => [:index, :show, :resource_pictures] + before_filter :authenticate_resource_reader, :only => [ + :index, :show + ] before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_artist, :only => [:edit, :update, :destroy] end - before_filter :authenticate_admin!, :only => [:list, :browse] - - @@model = Artist + def index - set_filer - - respond_to do |format| - format_filer format - format.json { render json: @items.to_json(@@model.list_json_opt) } - end - end - - def show - @item = Artist.show(params[:id], @operators) - - respond_to do |format| - format.html { - @artist = @item - } - format_prof format - format.json { render :json => @item.to_json(Artist.show_json_opt) } - end - end - - def resource_pictures - @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(@artist, @page, @page_size) - respond_to do |format| - format.html { - @paginate = ResourcePicture.himlist_paginate(@artist, @page, @page_size) - } - format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) } - end + filer_list end - def count - @artist = {:count => Artist.visible_count} - respond_to do |format| - format.json { render json: @artist.to_json } - end + def show_html_format format + format.html { + } end - def list - @artists = Artist.all - - respond_to do |format| - format.html { render layout: 'system' } - format.json { render json: @artists } - end - end - - def browse - @artist = Artist.find(params[:id]) - + def show + set_show respond_to do |format| - format.html { render layout: 'system' } - format.json { render json: @artist } + show_html_format format + show_prof_format format + show_json_format format end end - + def new - @artist = Artist.new - @artist.supply_default - - respond_to do |format| - format.html # new.html.erb - format.js - format.json { render json: @artist.to_json(Artist.show_json_opt) } - end + form_new end - + def edit - @artist = Artist.edit(params[:id], @operators) - respond_to do |format| - format.html - format.js - end + form_edit end - + def create - @artist = Artist.new() - @artist.supply_default - @artist.attributes = params[:artist] - @artist.overwrite @operators - respond_to do |format| - 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: @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: @artist.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 - + def update - @artist = Artist.edit(params[:id], @operators) - @artist.attributes = params[:artist] - @artist.overwrite @operators - - respond_to do |format| - 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: @artist.errors, status: :unprocessable_entity } - end - end + set_edit + @item.attributes = params[@my_model_class.item_name] + @item.overwrite @operators + render_update '/home/configure' end - + def destroy @artist = Artist.edit(params[:id], @operators) @artist.destroy - + respond_to do |format| format.html { redirect_to artists_url } format.json { head :ok }