Sha256: 04dd518ea387b7372571cec9d8094e21729abeace0f239afb8ef85241b4f8ff3

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

module Spina
  module Admin
    class PhotosController < AdminController
      before_filter :set_breadcrumbs
      
      authorize_resource class: Photo

      layout "spina/admin/media_library"

      def index
        add_breadcrumb "Afbeeldingen", spina.admin_photos_path
        @photos = Photo.sorted
        @photo = Photo.new
      end

      def create
        @photo = Photo.create(photo_params)
      end

      def destroy
        @photo = Photo.find(params[:id])
        @photo.destroy
        redirect_to spina.admin_photos_url
      end

      def enhance
        @photo = Photo.find(params[:id])
        @photo.remote_file_url = params[:new_image]
        @photo.save
      end

      def link
        @photo = Photo.find(params[:id])
      end

      def photo_select
        @photos = Photo.sorted
        @photo = Photo.new
        @selected_photo = Photo.find(params[:selected_photo_id]) if params[:selected_photo_id]
      end

      def photo_collection_select
        @photos = Photo.sorted
        @photo = Photo.new
        @selected_photos = params[:selected_photo_ids] ? Photo.where(id: params[:selected_photo_ids]) : Photo.none
      end

      def insert_photo
        @photo = Photo.find(params[:photo_id]) if params[:photo_id].present?
      end

      def insert_photo_collection
        @photos = Photo.find(params[:photo_ids]) if params[:photo_ids].present?
      end

      def wysihtml5_insert
        @photo = Photo.find(params[:photo_id])
      end

      def wysihtml5_select
        @photos = Photo.sorted
        @photo = Photo.new
      end

      private

      def set_breadcrumbs
        add_breadcrumb "Mediabibliotheek", spina.admin_media_library_path
      end

      def photo_params
        params.require(:photo).permit(:file)
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spina-0.6.12 app/controllers/spina/admin/photos_controller.rb
spina-0.6.11 app/controllers/spina/admin/photos_controller.rb