Class: IshLibManager::GalleriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ish_lib_manager/galleries_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#set_lists

Instance Method Details

#createObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 33

def create
  authorize! :create, Gallery
  @gallery = Gallery.new(params[:gallery].permit(:name, :city, :tag, :is_public, :is_done, :is_feature))
  @gallery.user = current_user
  @gallery.site = @site
  authorize! :create, @gallery

  if @gallery.save
    # expire_page :controller => 'galleries', :action => 'index', :domainname => @site.domain
    # expire_page :controller => 'sites', :action => 'show', :domainname => @site.domain
    flash[:notice] = 'Success'
    redirect_to manager_galleries_path
  else
    flash[:error] = 'No Luck. ' + @gallery.errors.inspect
    @cities_list = City.list
    @tags_list = Tag.list
    render :action => 'new'
  end
end

#destroyObject



79
80
81
82
83
84
85
86
87
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 79

def destroy
  @gallery = Gallery.unscoped.find params[:id]
  authorize! :destroy, @gallery
  
  @gallery.is_trash = true
  @gallery.save
  flash[:notice] = 'Logically deleted gallery.'
  redirect_to manager_galleries_title_path
end

#editObject



53
54
55
56
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 53

def edit
  @gallery = Gallery.unscoped.find params[:id]
  authorize! :edit, @gallery
end

#indexObject



6
7
8
9
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 6

def index
  authorize! :index, Gallery
  redirect_to galleries_thumb_path
end

#index_miniObject



21
22
23
24
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 21

def index_mini
  authorize! :index, Gallery
  @galleries = Gallery.all
end

#index_thumbObject



16
17
18
19
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 16

def index_thumb
  authorize! :index, Gallery
  @galleries = Gallery.unscoped.where( :is_trash => false ).order_by( :created_at => :desc ).page( params[:galleries_page] ).per( 10 )
end

#index_titleObject



11
12
13
14
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 11

def index_title
  authorize! :index, Gallery
  @galleries = Gallery.unscoped.where( :is_trash => false ).order_by( :created_at => :desc )
end

#newObject



26
27
28
29
30
31
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 26

def new
  authorize! :new, Gallery
  @gallery = Gallery.new
  @cities_list = City.list
  @tags_list = Tag.list
end

#showObject



73
74
75
76
77
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 73

def show
  @gallery = Gallery.unscoped.find params[:id]
  authorize! :show, @gallery
  @photos = @gallery.photos.unscoped.where({ :is_trash => false })
end

#updateObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/ish_lib_manager/galleries_controller.rb', line 58

def update
  @gallery = Gallery.unscoped.find params[:id]
  authorize! :update, @gallery
  
  if @gallery.update_attributes( params[:gallery].permit( :username, :name, :galleryname, :subhead, :descr, :lang,
                                                          :is_trash, :is_public, :is_done, :is_feature,
                                                          :tag_id, :city_id, :venue_id, :site_id, :user_id, :site_id ) )
    flash[:notice] = 'Success.'
    redirect_to manager_galleries_path
  else
    flash[:error] = 'No Luck. ' + @gallery.errors
    render :action => :edit
  end
end