forked from bofh/fetsite
Merge branch 'testgallery'
This commit is contained in:
@@ -87,10 +87,11 @@ class FotosController < ApplicationController
|
||||
# DELETE /fotos/1.json
|
||||
def destroy
|
||||
@foto = Foto.find(params[:id])
|
||||
gallery = @foto.gallery_id
|
||||
@foto.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to galleries_url }
|
||||
format.html { redirect_to gallery_path(gallery) }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,23 +18,42 @@ class GalleriesController < ApplicationController
|
||||
# GET /galleries/1.json
|
||||
def show
|
||||
@gallery = Gallery.find(params[:id])
|
||||
|
||||
@pppage_array = [ 25 , 50 , 100 ] #defines number & size of picture chunks
|
||||
|
||||
@pppage_array = [ 25 , 50 , 100, "all"] #defines number & size of picture chunks
|
||||
@pppage = 0 #starting index of pppage_array
|
||||
|
||||
if params[:pppage].to_i <= 2 && params[:pppage].to_i >= 0
|
||||
|
||||
if !params[:pppage].nil? && params[:pppage].to_i <= 3 && params[:pppage].to_i >= 0
|
||||
@pppage = params[:pppage].to_i
|
||||
end
|
||||
|
||||
|
||||
@page = params[:page].nil? ? 1 : params[:page].to_i
|
||||
# @fotos = Foto.where(:gallery_id => params[:id]).limit(@pppage_array[@pppage]).offset(@pppage_array[@pppage]*(@page-1))
|
||||
# @fotos = Foto.where(:gallery_id => params[:id]).limit(@pppage_array[@pppage]).offset(@pppage_array[@pppage]*(@page-1))
|
||||
@fotos = Foto.where(:gallery_id => params[:id])
|
||||
@pages = (Foto.where(:gallery_id => params[:id]).count/(@pppage_array[@pppage])+1)
|
||||
@showind=[]
|
||||
@showind.fill(0,@pppage_array[@pppage]){ |i| i+ @pppage_array[@pppage]*(@page-1)} # Hier ausrechnen welche angezeigt werden sollen
|
||||
if @fotos.nil? || @fotos.empty?
|
||||
@fotos_p = []
|
||||
@fotos_n = []
|
||||
@pages = 1
|
||||
|
||||
else
|
||||
if @pppage_array[@pppage] != "all"
|
||||
@fotos_p = @fotos.page(@page).per(@pppage_array[@pppage])
|
||||
|
||||
@fotos_n = @fotos- @fotos_p
|
||||
@foto_ind = @fotos.find_index(@fotos_p.first)
|
||||
@fotos_n = @fotos_n.rotate(@foto_ind)
|
||||
@pages = (Foto.where(:gallery_id => params[:id]).count/(@pppage_array[@pppage])+1)
|
||||
else
|
||||
@fotos_p = @fotos
|
||||
@fotos_n = []
|
||||
@pages = 1
|
||||
end
|
||||
end
|
||||
|
||||
# Hier ausrechnen welche angezeigt werden sollen
|
||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('fotos.new-fotos'), :path=>new_gallery_foto_path(@gallery)}
|
||||
@toolbar_elements << {:hicon=>'icon-pencil', :text => I18n.t('common.edit'), :path=>edit_gallery_path(@gallery)}
|
||||
@toolbar_elements << {:hicon=>'icon-arrow-left', :text=>I18n.t('common.back'), :path=>galleries_path()}
|
||||
@toolbar_elements << {:hicon => 'icon-remove-circle', :text => I18n.t('common.delete'), :path => gallery_path(@gallery),:confirm=>'Sure?', :method=>:delete} if can? :delete, Gallery
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
@@ -56,6 +75,7 @@ class GalleriesController < ApplicationController
|
||||
# GET /galleries/1/edit
|
||||
def edit
|
||||
@gallery = Gallery.find(params[:id])
|
||||
@fotos_old = @gallery.fotos
|
||||
end
|
||||
|
||||
# POST /galleries
|
||||
@@ -81,6 +101,10 @@ class GalleriesController < ApplicationController
|
||||
@foto = Foto.new
|
||||
respond_to do |format|
|
||||
if @gallery.update_attributes(params[:gallery])
|
||||
|
||||
Foto.where(:gallery_id=>nil).each do |tbd|
|
||||
tbd.destroy
|
||||
end
|
||||
format.html { redirect_to @gallery, notice: 'Gallery was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
|
||||
@@ -2,8 +2,12 @@ class HomeController < ApplicationController
|
||||
def index
|
||||
@beispiele = Beispiel.last([Beispiel.count, 3].min)
|
||||
@neuigkeiten = Neuigkeit.recent
|
||||
if Thema.count>0
|
||||
t=YAML.load_file("#{::Rails.root.to_s}/config/start_topic.yml")
|
||||
@starttopic= @themen = Thema.where(:id=>t).first
|
||||
else
|
||||
@starttopic=@themen = nil
|
||||
end
|
||||
end
|
||||
def dev
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
class NeuigkeitenController < ApplicationController
|
||||
|
||||
before_filter :load_toolbar_elements, :only=>[:show,:find_link]
|
||||
before_filter :load_toolbar_elements_edit, :only=>[:edit]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user