see photos by tag. search photos show albums
This commit is contained in:
parent
a887a5e67d
commit
467eff11ba
12 changed files with 55 additions and 18 deletions
|
@ -19,6 +19,7 @@ class AlbumsController < ApplicationController
|
|||
|
||||
def untouched
|
||||
@albums = Album.untouched()
|
||||
@albums.ea
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render :json => @albums }
|
||||
|
|
|
@ -3,7 +3,9 @@ class PhotosController < ApplicationController
|
|||
before_filter :require_role_admin, :only => [:untouched, :upload, :new, :create, :edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
if params[:tag_id]
|
||||
if params[:tag_id] && params[:album_id]
|
||||
@photos = Tag.find_by_title( params[:tag_id] ).photos.find(:all, :conditions => ['photos.album_id = :album', {:album => Album.find(params[:album_id] ) } ], :order => "photos.id ASC")
|
||||
elsif params[:tag_id]
|
||||
@photos = Tag.find_by_title( params[:tag_id] ).photos.find(:all, :order => "photos.id ASC")
|
||||
elsif params[:album_id]
|
||||
@photos = Album.find( params[:album_id]).photos.find(:all, :order => "photos.id ASC")
|
||||
|
@ -83,7 +85,7 @@ class PhotosController < ApplicationController
|
|||
@photo = Photo.find( params[:id])
|
||||
@tags = Tag.find(:all).map { |tag| tag.title }.join('\',\'')
|
||||
end
|
||||
|
||||
|
||||
def edit_multiple
|
||||
if params[:album_id]
|
||||
@album = Album.find( params[:album_id] )
|
||||
|
@ -107,9 +109,13 @@ class PhotosController < ApplicationController
|
|||
@photos = params[:photos][:photo]
|
||||
@photos.each do |photo_item|
|
||||
photo = Photo.find( photo_item[0] )
|
||||
photo.title = photo_item[1][:title]
|
||||
photo.tag_list = photo_item[1][:tags]
|
||||
photo.save
|
||||
if photo_item[1][:_delete] == "1"
|
||||
photo.destroy
|
||||
else
|
||||
photo.title = photo_item[1][:title]
|
||||
photo.tag_list = photo_item[1][:tags]
|
||||
photo.save
|
||||
end
|
||||
end
|
||||
flash[:notice] = "Updated photos!"
|
||||
redirect_to photos_path
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
<%= f.submit "Update" %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% content_for :action_links do %>
|
||||
<% if has_role?("admin") %>
|
||||
<br /><%= link_to("Delete album", { :action => "destroy", :id => @album },
|
||||
:confirm => "Are you sure you want to delete this album?",
|
||||
:method => :delete) %>
|
||||
|
||||
<br /><%= link_to "All albums", albums_path %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,4 +1,19 @@
|
|||
<h1>Albums</h1>
|
||||
<%= render :partial => @albums %>
|
||||
<% for album in @albums %>
|
||||
<div class="row">
|
||||
<div class="title">
|
||||
<%= render :partial => "photos/thumb", :locals => {:photo => album.photos.first } unless album.photos.empty? %>
|
||||
<p><%= link_to album.title, album %></p>
|
||||
</div>
|
||||
<div class="image">
|
||||
<%= render :partial => "photos/thumb", :collection => album.photos.find(:all, :limit => 5, :offset => 1), :as => :photo %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<br /><%= link_to "New Album", new_album_path %>
|
||||
<% content_for :action_links do %>
|
||||
<%= link_to "Show just the photos tagged with #{params[:q]}", photos_path(:q => params[:q]) if params[:q] %>
|
||||
<% if has_role?("admin") %>
|
||||
<%= " | " if params[:q] %>
|
||||
<%= link_to "New album", new_album_path() %>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -5,5 +5,4 @@
|
|||
<%= render :partial => "form", :object => f %>
|
||||
<%= f.submit "Create" %>
|
||||
<% end %>
|
||||
|
||||
<br /><%= link_to "All albums", albums_path %>
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
</div>
|
||||
|
||||
<p><%= @album.description %></p>
|
||||
<p>Tagged with: <%= @album.tags.map {|tag| (link_to tag.title, tag_photos_path(tag) ) + " " } unless @album.tags.nil? %></p>
|
||||
<p>Tagged with: <%= @album.tags.map {|tag| (link_to tag.title, album_tag_photos_path(@album, tag) ) + " " } unless @album.tags.nil? %></p>
|
||||
|
||||
<% if has_role?("admin") %>
|
||||
<p><%= @album.address %></p>
|
||||
|
@ -27,6 +27,7 @@
|
|||
<%= link_to "PDF", album_path(@album, :format => 'pdf') %> |
|
||||
<%= link_to "Edit album", edit_album_path(@album) %> |
|
||||
<%= link_to "Edit all photos", edit_multiple_album_photos_path(@album) %> |
|
||||
<%= link_to "Edit untouched photos", untouched_album_photos_path(@album) %> |
|
||||
<%= link_to "Add photos", upload_album_photos_path(@album) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -7,5 +7,8 @@
|
|||
<br />
|
||||
<%= form.label :tag_list %><br />
|
||||
<%= form.text_field :tag_list, { :autocomplete => "off", :class => 'tag_list'} %><br />
|
||||
<br />
|
||||
<%= form.label :description %><br />
|
||||
<%= form.text_area :description %><br />
|
||||
<br/>
|
||||
<p>On disk: ~/<%= @photo.path %></p>
|
|
@ -1,10 +1,11 @@
|
|||
<% form_for :photos, :url => update_multiple_photos_path, :html => { :method => :put } do |f| %>
|
||||
<% for photo in @photos %>
|
||||
<p>
|
||||
<% f.fields_for photo do |p|%>
|
||||
<% f.fields_for photo, :index => photo.id do |p|%>
|
||||
<%= p.check_box :_delete %>
|
||||
<%= render :partial => "photos/thumb", :locals => {:photo => photo } %>
|
||||
<%= p.text_field :title, :index => photo.id %>
|
||||
<%= p.text_field :tags, :index => photo.id, :value => photo.tag_list %>
|
||||
<%= p.text_field :title %>
|
||||
<%= p.text_field :tags, :value => photo.tag_list %>
|
||||
<% end%>
|
||||
</p>
|
||||
<% end%>
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
<ul><%= render :partial => 'photos/thumb',:collection => @photos, :as => :photo %></ul>
|
||||
<ul><%= render :partial => 'photos/thumb',:collection => @photos, :as => :photo %></ul>
|
||||
|
||||
<% content_for :action_links do %>
|
||||
<%= link_to "Show albums containing photos tagged with #{params[:q]}", albums_path(:q => params[:q]) if params[:q] %>
|
||||
<% end %>
|
|
@ -2,6 +2,7 @@
|
|||
<% for photo in @photos %>
|
||||
<p>
|
||||
<% f.fields_for photo do |p|%>
|
||||
<%= render :partial => "photos/thumb", :locals => {:photo => photo } %>
|
||||
<%= p.text_field :title, :index => photo.id %>
|
||||
<%= p.text_field :tags, :index => photo.id, :value => photo.tag_list %>
|
||||
<% end%>
|
||||
|
|
|
@ -3,7 +3,7 @@ development:
|
|||
database: gallery_development
|
||||
username: gallery
|
||||
password: changeme
|
||||
production:
|
||||
production:
|
||||
adapter: mysql
|
||||
encoding: utf8
|
||||
username: photogallery
|
||||
|
|
|
@ -6,6 +6,9 @@ ActionController::Routing::Routes.draw do |map|
|
|||
|
||||
map.resources :photos, :collection => { :untouched => :get, :edit_multiple => :post, :update_multiple => :put, :upload => :get }
|
||||
map.resources :albums, :collection => { :untouched => :get, } do |album|
|
||||
album.resources :tags do |tag|
|
||||
tag.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }
|
||||
end
|
||||
album.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }
|
||||
end
|
||||
map.resources :collections do |collection|
|
||||
|
|
Loading…
Reference in a new issue