2011-09-15 18:56:20 +01:00
|
|
|
# coding: UTF-8
|
2011-03-31 03:00:21 +01:00
|
|
|
|
2011-03-09 19:27:51 +00:00
|
|
|
class PlatformsController < ApplicationController
|
|
|
|
before_filter :authenticate_user!
|
|
|
|
|
2011-05-30 10:04:32 +01:00
|
|
|
before_filter :find_platform, :only => [:freeze, :unfreeze, :clone]
|
2011-03-17 14:47:16 +00:00
|
|
|
|
2011-03-09 19:27:51 +00:00
|
|
|
def index
|
2011-10-16 21:50:56 +01:00
|
|
|
@platforms = Platform.paginate(:page => params[:platform_page])
|
2011-03-09 19:27:51 +00:00
|
|
|
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
|
2011-10-16 21:50:56 +01:00
|
|
|
pp params
|
|
|
|
# @platform = Platform.new params[:platform]
|
|
|
|
# if @platform.save
|
|
|
|
# flash[:notice] = I18n.t("flash.platform.saved")
|
|
|
|
# redirect_to @platform
|
|
|
|
# else
|
|
|
|
# flash[:error] = I18n.t("flash.platform.saved_error")
|
|
|
|
# @platforms = Platform.all
|
|
|
|
# render :action => :new
|
|
|
|
# end
|
2011-03-09 19:27:51 +00:00
|
|
|
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-05-30 10:04:32 +01:00
|
|
|
def clone
|
|
|
|
cloned = @platform.clone(@platform.name + "_clone", @platform.unixname + "_clone")
|
|
|
|
if cloned
|
|
|
|
flash[:notice] = 'Клонирование успешно'
|
|
|
|
redirect_to cloned
|
|
|
|
else
|
|
|
|
flash[:notice] = 'Ошибка клонирования'
|
|
|
|
redirect_to @platform
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-09 19:27:51 +00:00
|
|
|
def destroy
|
|
|
|
Platform.destroy params[:id]
|
2011-03-31 03:00:21 +01:00
|
|
|
|
|
|
|
flash[:notice] = t("flash.platform.destroyed")
|
2011-03-09 19:27:51 +00:00
|
|
|
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
|