Sha256: bdbe0808805a1bfc1b324d22e8d5f86923dea3ab8d1a826d124468e232c6703f

Contents?: true

Size: 1.89 KB

Versions: 3

Compression:

Stored size: 1.89 KB

Contents

module Tim
  class ProviderImagesController < Tim::ApplicationController
    respond_to :json, :only => :update

    before_filter :factory_keys, :only => :update

    def index
      @provider_images = Tim::ProviderImage.all unless defined? @provider_images
      respond_with @provider_images
    end

    def show
      @provider_image = Tim::ProviderImage.find(params[:id]) unless defined? @provider_image
      respond_with @provider_image
    end

    def new
      @provider_image = Tim::ProviderImage.new
      respond_with @provider_image
    end

    def edit
      @provider_image = Tim::ProviderImage.find(params[:id]) unless defined? @provider_image
      respond_with @provider_image
    end

    def create
      @provider_image = ProviderImage.new(params[:provider_image]) unless defined? @provider_image
      if @provider_image.save
        flash[:notice] = 'Image version was successfully created.'
      end
      respond_with @provider_image
    end

    def update
      @provider_image = Tim::ProviderImage.find(params[:id]) unless defined? @provider_image
      if @provider_image.update_attributes(params[:provider_image])
        flash[:notice] = 'Provider image was successfully updated.'
      end
      respond_with @provider_image
    end

    def destroy
      @provider_image = Tim::ProviderImage.find(params[:id]) unless defined? @provider_image
      @provider_image.destroy
      respond_with @provider_image
    end

    private
    # TODO Add factory permission check
    def factory_keys
      if params[:provider_image][:percent_complete] && params[:provider_image][:status_detail][:activity]
        params[:provider_image] = { :progress => params[:provider_image][:percent_complete],
                                    :status_detail => params[:provider_image][:status_detail][:activity],
                                    :status => params[:provider_image][:status] }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tim-0.1.2 app/controllers/tim/provider_images_controller.rb
tim-0.1.1 app/controllers/tim/provider_images_controller.rb
tim-0.0.1 app/controllers/tim/provider_images_controller.rb