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
|
2011-03-11 16:08:41 +00:00
|
|
|
@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
|
2011-03-17 12:35:42 +00:00
|
|
|
flash[:notice] = I18n.t("flash.platform.saved")
|
2011-03-09 19:27:51 +00:00
|
|
|
redirect_to @platform
|
|
|
|
else
|
2011-03-17 12:35:42 +00:00
|
|
|
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 12:35:42 +00:00
|
|
|
|
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-17 12:35:42 +00:00
|
|
|
|
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
|