rosa-build/app/controllers/platforms_controller.rb

63 lines
1.3 KiB
Ruby
Raw Normal View History

2011-03-09 19:27:51 +00:00
class PlatformsController < ApplicationController
before_filter :authenticate_user!
2011-03-17 14:47:16 +00:00
before_filter :find_platform, :only => [:freeze, :unfreeze]
2011-03-09 19:27:51 +00:00
def index
@platforms = Platform.all
end
def show
@platform = Platform.find params[:id], :include => :repositories
@repositories = @platform.repositories
2011-03-09 19:27:51 +00:00
end
def new
2011-03-10 13:38:50 +00:00
@platforms = Platform.all
2011-03-09 19:27:51 +00:00
@platform = Platform.new
end
def create
@platform = Platform.new params[:platform]
if @platform.save
flash[:notice] = I18n.t("flash.platform.saved")
2011-03-09 19:27:51 +00:00
redirect_to @platform
else
flash[:error] = I18n.t("flash.platform.saved_error")
2011-03-09 19:27:51 +00:00
render :action => :new
end
end
2011-03-17 14:47:16 +00:00
def freeze
@platform.released = true
if @platform.save
flash[:notice] = I18n.t("flash.platform.freezed")
else
flash[:notice] = I18n.t("flash.platform.freeze_error")
end
2011-03-17 14:47:16 +00:00
redirect_to @platform
end
def unfreeze
@platform.released = false
if @platform.save
flash[:notice] = I18n.t("flash.platform.unfreezed")
else
flash[:notice] = I18n.t("flash.platform.unfreeze_error")
end
redirect_to @platform
end
2011-03-09 19:27:51 +00:00
def destroy
Platform.destroy params[:id]
redirect_to root_path
end
2011-03-17 14:47:16 +00:00
protected
def find_platform
@platform = Platform.find params[:id]
end
2011-03-09 19:27:51 +00:00
end