Class: IshLibEngine::Manager::GalleriesController

Inherits:
Manager::ManagerController
  • Object
show all
Defined in:
app/controllers/ish_lib_engine/manager/galleries_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 28

def create
  @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



69
70
71
72
73
74
75
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 69

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

#editObject



47
48
49
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 47

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

#indexObject



6
7
8
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 6

def index
  redirect_to manager_galleries_thumb_path
end

#index_miniObject



18
19
20
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 18

def index_mini
  @galleries = Gallery.all
end

#index_thumbObject



14
15
16
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 14

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

#index_titleObject



10
11
12
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 10

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

#newObject



22
23
24
25
26
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 22

def new
  @gallery = Gallery.new
  @cities_list = City.list
  @tags_list = Tag.list
end

#showObject



64
65
66
67
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 64

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

#updateObject



51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/ish_lib_engine/manager/galleries_controller.rb', line 51

def update
  @gallery = Gallery.unscoped.find params[:id]
  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