Sha256: 6b5e749404b5108ca638448cd96e93803a68bf9a03498f37daf649b1c2f6850e
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
class ClassificationsController < FassetsCore::ApplicationController before_filter :authenticate_user! before_filter :find_classification, :only => [:update, :destroy] respond_to :html, :js def create if params[:asset_id] @classification = Classification.new(:asset_id => params[:asset_id],:catalog_id => params[:catalog_id]) @classification.save create_content_labeling(params[:asset_id],params[:catalog_id]) else classification = Classification.new(params[:classification]) classification.save end render :nothing => true end def destroy @classification.destroy render :nothing => true end def update if params[:commit] == "Drop" @classification.destroy() return end @classification.label_ids = params[:labels] flash[:notice] = "Updated Classification" respond_with do |format| format.js format.html {} end end protected def create_content_labeling(asset_id,catalog_id) asset = Asset.find(asset_id) content_facet = Facet.where(:catalog_id => catalog_id, :caption => "Content Type").first unless content_facet content_facet = Facet.create(:caption => "Content Type", :color => "orange", :label_order => "value ASC, caption ASC", :catalog_id => catalog_id) end media_type = asset.content.media_type.capitalize label = Label.where(:facet_id => content_facet.id, :caption => media_type.to_s).first unless label label = Label.new(:facet_id => content_facet.id, :caption => media_type.to_s) label.save end labeling = Labeling.new(:classification_id => @classification.id, :label_id => label.id) labeling.save end def find_classification @classification = Classification.find(params[:id]) end end
Version data entries
4 entries across 4 versions & 1 rubygems