Project

General

Profile

Download (1.47 KB) Statistics
| Branch: | Tag: | Revision:
b689e231 Marc Dequènes (Duck)
class Admin::ArtworksController < Admin::AdminController
simple_rest_support

before_filter :load_form_data, :only => [:new, :create, :edit, :update]

bf16d414 Marc Dequènes (Duck)
SELECTION_ACTION_LIST = [[_('Associate with Tag'), 'associate_with_tag'], [_('Delete'), 'delete']]

def index
@selection_action_list = SELECTION_ACTION_LIST
end

4ca83ea1 Marc Dequènes (Duck)
def artworks_selection
bf16d414 Marc Dequènes (Duck)
if Hash[SELECTION_ACTION_LIST].values.include? params['artworks_selection_action']
@action = "selection_" + params['artworks_selection_action']
4ca83ea1 Marc Dequènes (Duck)
bf16d414 Marc Dequènes (Duck)
artworks_ids = params['artworks_selection_ids'].collect {|x| x.to_i }
@selection = Artwork.find(artworks_ids)

render :action => @action
4ca83ea1 Marc Dequènes (Duck)
else
render_404
end
end

bf16d414 Marc Dequènes (Duck)
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

b689e231 Marc Dequènes (Duck)
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")
70e65017 Marc Dequènes (Duck)
@artwork_supports = ArtworkSupport.find(:all, :order => "name ASC")
2a4e5c89 Marc Dequènes (Duck)
@tags = Tag.find(:all, :order => "name ASC")
b689e231 Marc Dequènes (Duck)
end
end