[refs #2161] Change logic and output of urpmi commands
This commit is contained in:
parent
910446954c
commit
f4c3bafb6d
|
@ -4,8 +4,6 @@ class PrivateUsersController < ApplicationController
|
|||
before_filter :find_platform_and_private_users
|
||||
|
||||
def index
|
||||
@private_users = PrivateUser.where(:platform_id => params[:platform_id]).paginate :page => params[:page]
|
||||
@platform = Platform.find(params[:platform_id])
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -13,9 +11,10 @@ class PrivateUsersController < ApplicationController
|
|||
old_pair.destroy if old_pair
|
||||
|
||||
@pair = PrivateUser.generate_pair(params[:platform_id], current_user.id)
|
||||
@urpmi_list = @platform.urpmi_list(request.host, @pair).join(' / ')
|
||||
@urpmi_list = @platform.urpmi_list(request.host, @pair)
|
||||
#redirect_to platform_private_users_path(params[:platform_id]), :notice => "Логин: #{ @pair[:login] } Пароль: #{ @pair[:pass] }"
|
||||
flash[:notice] = "Логин: #{ @pair[:login] } Пароль: #{ @pair[:pass] }"
|
||||
|
||||
render :action => 'index'
|
||||
end
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ class Platform < ActiveRecord::Base
|
|||
after_create lambda { add_downloads_symlink unless self.hidden? }
|
||||
|
||||
scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}}
|
||||
scope :open, where(:visibility => 'open')
|
||||
scope :hidden, where(:visibility => 'hidden')
|
||||
scope :main, where(:platform_type => 'main')
|
||||
scope :personal, where(:platform_type => 'personal')
|
||||
|
||||
|
@ -36,16 +38,20 @@ class Platform < ActiveRecord::Base
|
|||
|
||||
|
||||
def urpmi_list(host, pair = nil)
|
||||
pair = {:login => 'login', :pass => 'password'} if pair.blank?
|
||||
blank_pair = {:login => 'login', :pass => 'password'}
|
||||
pair = blank_pair if pair.blank?
|
||||
urpmi_commands = []
|
||||
if self.hidden?
|
||||
Platform.main.each do |pl|
|
||||
urpmi_commands << "urpmi.addmedia http://#{ pair[:login] }@#{ pair[:pass] }:#{ host }/private/#{ self.name }/repository/#{ pl.name }/$ARCH/main/release"
|
||||
end
|
||||
else
|
||||
Platform.main.each do |pl|
|
||||
urpmi_commands << "urpmi.addmedia http://#{ host }/downloads/#{ self.name }/repository/#{ pl.name }/$ARCH/main/release"
|
||||
end
|
||||
|
||||
pls = Platform.main.open
|
||||
pls << self
|
||||
pls.each do |pl|
|
||||
local_pair = pl.id != self.id ? blank_pair : pair
|
||||
tail = (pl.id != self.id && pl.distrib_type == APP_CONFIG['distr_types'].first) ? "/$ARCH/main/release" : ""
|
||||
head = pl.hidden? ? "http://#{ local_pair[:login] }@#{ local_pair[:pass] }:#{ host }/private/" : "http://#{ host }/downloads/"
|
||||
urpmi_commands << [
|
||||
"urpmi.addmedia #{ head }#{ pl.owner.try(:uname) }/repository/#{ pl.name }#{ tail }",
|
||||
pl.name
|
||||
]
|
||||
end
|
||||
|
||||
return urpmi_commands
|
||||
|
|
|
@ -12,11 +12,7 @@
|
|||
\:
|
||||
= link_to @repository.owner.name, url_for(@repository.owner)
|
||||
|
||||
%br
|
||||
.group
|
||||
- @urpmi_commands.each do |urpmi_command|
|
||||
%span= urpmi_command
|
||||
%br
|
||||
= render 'shared/urpmi_list', :urpmi_commands => @urpmi_commands
|
||||
.wat-cf
|
||||
=# link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete")
|
||||
|
||||
|
|
|
@ -18,11 +18,7 @@
|
|||
= link_to @platform.name, platform_path(@platform)
|
||||
|
||||
- if @urpmi_list
|
||||
%br
|
||||
.group
|
||||
- @urpmi_list.each do |urpmi_command|
|
||||
%span= urpmi_command
|
||||
%br
|
||||
= render 'shared/urpmi_list', :urpmi_commands => @urpmi_list
|
||||
.wat-cf
|
||||
=# link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_repository_path(@platform, @repository), :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete")
|
||||
%br
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
.group
|
||||
%span Данные для подключения:
|
||||
.group{:style => 'padding-left: 10px'}
|
||||
- urpmi_commands.each do |urpmi_command|
|
||||
= urpmi_command[1] + ":"
|
||||
.group{:style => 'padding-left: 20px'}
|
||||
%span= urpmi_command[0]
|
||||
%br
|
||||
%br
|
Loading…
Reference in New Issue