2011-10-18 14:47:17 +01:00
|
|
|
class PrivateUsersController < ApplicationController
|
2011-10-24 14:01:15 +01:00
|
|
|
before_filter :authenticate_user!
|
2011-10-31 21:55:56 +00:00
|
|
|
before_filter :check_global_access, :except => [:destroy]
|
2011-11-01 13:22:41 +00:00
|
|
|
before_filter :find_platform_and_private_users
|
2011-10-24 14:01:15 +01:00
|
|
|
|
2011-10-18 14:47:17 +01:00
|
|
|
def index
|
|
|
|
@private_users = PrivateUser.where(:platform_id => params[:platform_id]).paginate :page => params[:page]
|
|
|
|
@platform = Platform.find(params[:platform_id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2011-11-02 10:42:08 +00:00
|
|
|
old_pair = PrivateUser.find_by_platform_id_and_user_id(params[:platform_id], current_user.id)
|
|
|
|
old_pair.destroy if old_pair
|
|
|
|
|
2011-11-01 13:22:41 +00:00
|
|
|
@pair = PrivateUser.generate_pair(params[:platform_id], current_user.id)
|
|
|
|
@urpmi_list = @platform.urpmi_list(request.host, @pair).join(' / ')
|
|
|
|
#redirect_to platform_private_users_path(params[:platform_id]), :notice => "Логин: #{ @pair[:login] } Пароль: #{ @pair[:pass] }"
|
|
|
|
flash[:notice] = "Логин: #{ @pair[:login] } Пароль: #{ @pair[:pass] }"
|
|
|
|
render :action => 'index'
|
2011-10-18 14:47:17 +01:00
|
|
|
end
|
|
|
|
|
2011-11-02 10:42:08 +00:00
|
|
|
#def destroy
|
|
|
|
# user = PrivateUser.find(params[:id])
|
|
|
|
# can_perform? user if user
|
|
|
|
# user.destroy
|
|
|
|
# redirect_to platform_private_users_path(params[:platform_id])
|
|
|
|
#end
|
2011-11-01 13:22:41 +00:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def find_platform_and_private_users
|
|
|
|
@private_users = PrivateUser.where(:platform_id => params[:platform_id]).paginate :page => params[:page]
|
|
|
|
@platform = Platform.find(params[:platform_id])
|
|
|
|
end
|
2011-10-24 14:01:15 +01:00
|
|
|
end
|