10: def channel
11: @gallery = Gallery.new
12:
13: if params[:id]
14: @channel = Category.find(params[:id])
15: elsif params[:channel]
16: if @dept = Department.find_by_label(params[:channel])
17: @channel = @gallery.department_channel(@dept)
18: end
19: end
20:
21: if @channel
22: @title = @channel.name
23:
24:
25: @albums = Album.published.tagged_with(@channel.tags.private.collect {|t| t.name_es}).paginate :page => params[:p], :per_page => 6,
26: :conditions => "album_photos_count>0",
27: :order => "featured DESC, created_at DESC"
28:
29: @featured_album = @albums.first
30: @featured_photos = @featured_album.photos.ordered_by_title.paginate :page => params[:page], :per_page => 6,
31: :conditions => ["cover_photo=?", false] if @featured_album
32:
33: respond_to do |format|
34: format.html
35: format.js {
36: render :update do |page|
37: if params[:page]
38: page.replace 'thumbnails', :partial => '/albums/thumbnails', :locals => {:photos => @featured_photos}
39: elsif params[:p]
40: page.replace "channel_#{@channel.id}", :partial => "/gallery/channel_albums", :locals => {:albums => @albums, :channel => @channel}
41: end
42: end
43: }
44: end
45:
46: else
47: flash[:notice] = t('gallery.does_not_exist')
48: redirect_to gallery_path and return
49: end
50:
51: end