This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/panel/announcements_controller.rb

50 lines
1.2 KiB
Ruby

class Panel::AnnouncementsController < ApplicationController
before_filter :require_entry_name, :only => [:index, :new]
layout "admin"
def index
@announcements = Announcement.all( :conditions => { :entry_name => params[:entry_name] })
end
def new
@announcement = Announcement.new
@announcement.entry_name = params[:entry_name]
end
def edit
@announcement = Announcement.find(params[:id])
end
def create
@announcement = Announcement.new(params[:announcement])
if @announcement.save
flash[:notice] = 'Announcement was successfully created.'
redirect_to panel_announcements_path( :entry_name => @announcement.entry_name )
else
render :action => "new"
end
end
def update
@announcement = Announcement.find(params[:id])
if @announcement.update_attributes(params[:announcement])
flash[:notice] = 'Announcement was successfully updated.'
redirect_to panel_announcements_path( :entry_name => @announcement.entry_name )
else
render :action => "edit"
end
end
def destroy
@announcement = Announcement.find(params[:id])
@announcement.destroy
redirect_to panel_announcements_path( :entry_name => @announcement.entry_name )
end
end