|
class Admin::ArtworksController < Admin::AdminController
|
|
simple_rest_support
|
|
|
|
before_filter :load_form_data, :only => [:new, :create, :edit, :update]
|
|
|
|
SELECTION_ACTION_LIST = [[_('Associate with Tag'), 'associate_with_tag'], [_('Delete'), 'delete']]
|
|
|
|
def index
|
|
@selection_action_list = SELECTION_ACTION_LIST
|
|
end
|
|
|
|
def artworks_selection
|
|
if Hash[SELECTION_ACTION_LIST].values.include? params['artworks_selection_action']
|
|
@action = "selection_" + params['artworks_selection_action']
|
|
|
|
artworks_ids = params['artworks_selection_ids'].collect {|x| x.to_i }
|
|
@selection = Artwork.find(artworks_ids)
|
|
|
|
render :action => @action
|
|
else
|
|
render_404
|
|
end
|
|
end
|
|
|
|
def selection_associate_with_tag
|
|
artwork_list = params['artworks_selection_ids'].collect {|x| Artwork.find(x.to_i) }
|
|
tag_list = params['tags_selection_ids'].collect {|x| Tag.find(x.to_i) }
|
|
|
|
artwork_list.each do |artwork|
|
|
artwork.tags += tag_list
|
|
end
|
|
|
|
redirect_to :action => "index"
|
|
end
|
|
|
|
protected
|
|
|
|
private
|
|
|
|
def load_form_data
|
|
@artwork_sets = ArtworkSet.find(:all, :order => "name ASC")
|
|
@artwork_materials = ArtworkMaterial.find(:all, :order => "name ASC")
|
|
@artwork_conditions = ArtworkCondition.find(:all, :order => "position ASC")
|
|
@artwork_placement_reasons = ArtworkPlacementReason.find(:all, :order => "name ASC")
|
|
@artwork_supports = ArtworkSupport.find(:all, :order => "name ASC")
|
|
@tags = Tag.find(:all, :order => "name ASC")
|
|
end
|
|
end
|