Class: IshManager::GalleriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::GalleriesController
- Defined in:
- app/controllers/ish_manager/galleries_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
alphabetized! : ).
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #j_show ⇒ Object
- #new ⇒ Object
- #shared_with_me ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
alphabetized! : )
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/ish_manager/galleries_controller.rb', line 8 def create params[:gallery][:shared_profiles] ||= [] params[:gallery][:shared_profiles].delete('') params[:gallery][:shared_profiles] = Ish::UserProfile.find params[:gallery][:shared_profiles] @gallery = Gallery.new params[:gallery].permit! @gallery.user_profile = @current_profile :create, @gallery if @gallery.save ::IshManager::ApplicationMailer.shared_galleries( params[:gallery][:shared_profiles], @gallery ).deliver flash[:notice] = 'Success' redirect_to edit_gallery_path(@gallery) else puts! @gallery.errors. flash[:alert] = "Cannot create the gallery: #{@gallery.errors.}" render :action => 'new' end end |
#destroy ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/controllers/ish_manager/galleries_controller.rb', line 27 def destroy :destroy, @gallery @gallery.is_trash = true @gallery.save flash[:notice] = 'Logically deleted gallery.' redirect_to galleries_path end |
#edit ⇒ Object
35 36 37 |
# File 'app/controllers/ish_manager/galleries_controller.rb', line 35 def edit :edit, @gallery end |
#index ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/ish_manager/galleries_controller.rb', line 39 def index :index, Gallery @page_title = 'Galleries' @galleries = Gallery.unscoped.where( ## This must be so for role `guy`. _vp_ 2022-10-03 :is_done.in => [false, nil], :is_trash.in => [false, nil], :user_profile => @current_profile, ).order_by( :created_at => :desc ) if params[:q] @galleries = @galleries.where({ :name => /#{params[:q]}/i }) # @galleries.selector.delete('is_done') end @galleries = @galleries.page( params[:galleries_page] ).per( 10 ) render params[:render_type] end |
#j_show ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/ish_manager/galleries_controller.rb', line 57 def j_show :show, @gallery respond_to do |format| format.json do jjj = {} jjj[:photos] = @gallery.photos.map do |ph| { :thumbnail_url => ph.photo.url( :thumb ), :delete_type => 'DELETE', :delete_url => photo_path(ph) } end render :json => jjj end end end |
#new ⇒ Object
72 73 74 75 76 |
# File 'app/controllers/ish_manager/galleries_controller.rb', line 72 def new @gallery = Gallery.new @page_title = 'New Gallery' :new, @gallery end |
#shared_with_me ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'app/controllers/ish_manager/galleries_controller.rb', line 78 def shared_with_me :index, Gallery @page_title = 'Galleries Shared With Me' @galleries = @current_profile.shared_galleries.unscoped.where( :is_trash => false ).order_by( :created_at => :desc ).page( params[:shared_galleries_page] ).per( 10 ) render params[:render_type] end |
#show ⇒ Object
87 88 89 90 91 |
# File 'app/controllers/ish_manager/galleries_controller.rb', line 87 def show :show, @gallery @photos = @gallery.photos.unscoped.where({ :is_trash => false }) @deleted_photos = @gallery.photos.unscoped.where({ :is_trash => true }) end |
#update ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/controllers/ish_manager/galleries_controller.rb', line 93 def update old_shared_profile_ids = @gallery.shared_profiles.map(&:id) :update, @gallery params[:gallery][:shared_profiles].delete('') params[:gallery][:shared_profile_ids] = params[:gallery][:shared_profiles] params[:gallery].delete :shared_profiles if @gallery.update_attributes( params[:gallery].permit! ) new_shared_profiles = Ish::UserProfile.find( params[:gallery][:shared_profile_ids] ).select { |p| !old_shared_profile_ids.include?( p.id ) } ::IshManager::ApplicationMailer.shared_galleries( new_shared_profiles, @gallery ).deliver flash[:notice] = 'Success.' redirect_to edit_gallery_path(@gallery) else puts! @gallery.errors., 'cannot save gallery' flash[:alert] = 'No Luck. ' + @gallery.errors..to_s render :action => :edit end end |