X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fartists_controller.rb;h=82145f1263ce8c875272bd432ab3c4817b358f6a;hb=665761e56525215946e2547a70c82c603d5047af;hp=ae96dd99957bcda61e6712d8f7d7d7b6e6a8250b;hpb=ef9a33979c325f99b16263c4275379f4885f30ee;p=pettanr%2Fpettanr.git diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index ae96dd99..82145f12 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,112 +1,63 @@ class ArtistsController < ApplicationController -layout 'test' - before_filter :authenticate_user!, :only => [:index, :show, :create, :update, :destroy] - before_filter :authenticate_admin!, :only => [:list, :browse] - - # GET /artists - # GET /artists.json + 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_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 + 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 - @artist = Artist.show(params[:id]) - + set_show respond_to do |format| - format.html # show.html.erb - format.json { render :json => @artist.to_json(Artist.list_json_opt) } + show_html_format format + show_prof_format format + show_json_format format end end - + def count - @artist = {:count => Artist.visible_count} - respond_to do |format| - format.json { render json: @artist.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 - @artist = Artist.find(params[:id]) - - respond_to do |format| - format.html { render layout: 'system' } - format.json { render json: @artist } - end - end - - # GET /artists/new - # GET /artists/new.json def new - @artist = Artist.new - - respond_to do |format| - format.html # new.html.erb - format.js - format.json { render json: @artist } - end + form_new end - - # GET /artists/1/edit + def edit - @artist = Artist.find(params[:id]) + form_edit end - - # POST /artists - # POST /artists.json + def create - @artist = Artist.new(params[:artist]) - @artist.author_id = @author.id - respond_to do |format| - if @artist.save - format.html { redirect_to @artist, notice: 'Artist was successfully created.' } - format.json { render json: @artist, status: :created, location: @artist } - else - 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 - - # PUT /artists/1 - # PUT /artists/1.json + def update - @artist = Artist.find(params[:id]) - - respond_to do |format| - if @artist.update_attributes(params[:artist]) - format.html { redirect_to @artist, notice: 'Artist was successfully updated.' } - format.json { head :ok } - else - 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 - - # DELETE /artists/1 - # DELETE /artists/1.json + def destroy - @artist = Artist.find(params[:id]) + @artist = Artist.edit(params[:id], @operators) @artist.destroy - + respond_to do |format| format.html { redirect_to artists_url } format.json { head :ok }