fotogallery

This commit is contained in:
Andreas Stephanides
2013-08-19 20:49:07 +02:00
parent 7ab34fa845
commit d96a694a73
6 changed files with 45 additions and 26 deletions

View File

@@ -44,8 +44,8 @@ class FotosController < ApplicationController
respond_to do |format| respond_to do |format|
if @foto.save if @foto.save
format.html { redirect_to @foto, notice: 'Foto was successfully created.' } format.html { redirect_to gallery_foto_path(@foto.gallery,@foto), notice: 'Foto was successfully created.' }
format.json { render json: @foto, status: :created, location: @foto } format.json { render json: gallery_foto_path(@foto.gallery,@foto), status: :created, location: @foto }
else else
format.html { render action: "new" } format.html { render action: "new" }
format.json { render json: @foto.errors, status: :unprocessable_entity } format.json { render json: @foto.errors, status: :unprocessable_entity }
@@ -60,7 +60,7 @@ class FotosController < ApplicationController
respond_to do |format| respond_to do |format|
if @foto.update_attributes(params[:foto]) if @foto.update_attributes(params[:foto])
format.html { redirect_to @foto, notice: 'Foto was successfully updated.' } format.html { redirect_to gallery_foto_path(@foto.gallery,@foto), notice: 'Foto was successfully updated.' }
format.json { head :no_content } format.json { head :no_content }
else else
format.html { render action: "edit" } format.html { render action: "edit" }

View File

@@ -1,3 +1,6 @@
class Foto < ActiveRecord::Base class Foto < ActiveRecord::Base
attr_accessible :datei, :desc, :gallery_id, :title attr_accessible :datei, :desc, :gallery_id, :title
belongs_to :gallery
mount_uploader :datei, FotoUploader
end end

View File

@@ -1,3 +1,4 @@
class Gallery < ActiveRecord::Base class Gallery < ActiveRecord::Base
attr_accessible :datum, :desc, :name attr_accessible :datum, :desc, :name
has_many :fotos
end end

View File

@@ -1,25 +1,31 @@
<p id="notice"><%= notice %></p>
<p> <div class="container-fluid">
<b>Title:</b>
<%= @foto.title %>
</p>
<p>
<b>Desc:</b>
<%= @foto.desc %>
</p>
<p>
<b>Gallery:</b>
<%= @foto.gallery_id %>
</p>
<p>
<b>Datei:</b>
<%= @foto.datei %>
</p>
<%= link_to 'Edit', edit_foto_path(@foto) %> | <div class="row-fluid">
<%= link_to 'Back', fotos_path %> <div class="span12">
<%= link_to image_tag(@foto.datei.resized.url), gallery_foto_path(@foto.gallery, ((@foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].nil?) ? (@foto.gallery.fotos[0].try(:id).to_i) : @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].try(:id).to_i) ) %>
</div>
</div>
<div class="row-fluid">
<div class="span9">
<h2><%= @foto.title %></h2>
<p><%= @foto.desc %></p>
</div>
<div class="span3">
<p>
<%= link_to 'last' , gallery_foto_path(@foto.gallery, @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)-1].try(:id).to_i) unless @foto.gallery.fotos.index(@foto)==0 %>
<%= link_to 'next' , gallery_foto_path(@foto.gallery, @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].try(:id).to_i) unless @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].nil? %>
<%= link_to 'Edit', edit_foto_path(@foto) %> |
<%= link_to 'Back', gallery_path(@foto.gallery) %>
</p>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<p id="notice"><%= notice %></p>
</div>
</div>
</div>

View File

@@ -14,7 +14,14 @@
<b>Datum:</b> <b>Datum:</b>
<%= @gallery.datum %> <%= @gallery.datum %>
</p> </p>
<% @gallery.fotos.each do |f| %>
<%= link_to image_tag(f.datei.big_thumb.url,{:class=>"img-polaroid"}) , gallery_foto_path(@gallery,f) %>
<% end %>
<%= link_to 'NewFoto' , new_gallery_foto_path(@gallery) %> |
<%= link_to 'Edit', edit_gallery_path(@gallery) %> | <%= link_to 'Edit', edit_gallery_path(@gallery) %> |
<%= link_to 'Back', galleries_path %> <%= link_to 'Back', galleries_path %>

View File

@@ -36,8 +36,10 @@
get 'verwalten/studien', :controller=>:studien, :action=>:verwalten, :as=>'studien_verwalten' get 'verwalten/studien', :controller=>:studien, :action=>:verwalten, :as=>'studien_verwalten'
resources :fetzneditions resources :fetzneditions
resources :fotos resources :fotos, :except=>[:new, :show]
resources :galleries resources :galleries do
resources :fotos, :only=>[:new,:show]
end
resources :memberships resources :memberships
resources :gremien resources :gremien
resources :fetprofiles resources :fetprofiles