mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-15 20:54:03 +00:00
parent
a8b94c13f3
commit
22cc5e4f14
12 changed files with 190 additions and 13 deletions
65
app/controllers/admin/photos_controller.rb
Normal file
65
app/controllers/admin/photos_controller.rb
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
module Admin
|
||||
class PhotosController < ApplicationController
|
||||
before_action :set_conference
|
||||
before_action :set_photo, only: [:edit, :update, :destroy]
|
||||
|
||||
# GET /admin/photos
|
||||
def index
|
||||
@photos = @conference.photos.all
|
||||
end
|
||||
|
||||
# GET /admin/photos/new
|
||||
def new
|
||||
@photo = @conference.photos.build
|
||||
end
|
||||
|
||||
# GET /admin/photos/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /admin/photos
|
||||
def create
|
||||
@photo = @conference.photos.build(photo_params)
|
||||
if @photo.save
|
||||
redirect_to admin_conference_photos_path, notice: 'Photo was successfully created.'
|
||||
else
|
||||
flash[:alert] = "A error prohibited this Photo from being saved: #{@photo.errors.full_messages.join('. ')}."
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /admin/photos/1
|
||||
def update
|
||||
if @photo.update(photo_params)
|
||||
redirect_to admin_conference_photos_path, notice: 'Photo was successfully updated.'
|
||||
else
|
||||
flash[:alert] = "A error prohibited this Photo from being saved: #{@photo.errors.full_messages.join('. ')}."
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /admin/photos/1
|
||||
def destroy
|
||||
@photo.destroy
|
||||
redirect_to admin_conference_photos_path, notice: 'Photo was successfully destroyed.'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_conference
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
end
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_photo
|
||||
@photo = Photo.find_by(id: params[:id])
|
||||
end
|
||||
|
||||
# Only allow a trusted parameter "white list" through.
|
||||
def photo_params
|
||||
params[:photo]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue