diff --git a/app/controllers/personal_repositories_controller.rb b/app/controllers/personal_repositories_controller.rb index c59c9b61d..93812372e 100644 --- a/app/controllers/personal_repositories_controller.rb +++ b/app/controllers/personal_repositories_controller.rb @@ -11,9 +11,10 @@ class PersonalRepositoriesController < ApplicationController else @projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30 end + + @urpmi_commands = @repository.platform.urpmi_list(request.host) end - #TODO: Add git repo move into private repos path. def change_visibility can_perform? @repository if @repository @repository.platform.change_visibility @@ -23,11 +24,6 @@ class PersonalRepositoriesController < ApplicationController def settings can_perform? @repository if @repository - if @repository.platform.hidden? - @urmpi_command = "urpmi -add http://login@password:#{ request.host }/privates/#{ @repository.platform.name }/main/" - else - @urmpi_command = "urpmi -add http://#{ request.host }/downloads/#{ @repository.platform.name }/main/" - end end def add_project diff --git a/app/controllers/private_users_controller.rb b/app/controllers/private_users_controller.rb index c3bc533b7..c456f4a37 100644 --- a/app/controllers/private_users_controller.rb +++ b/app/controllers/private_users_controller.rb @@ -1,6 +1,7 @@ class PrivateUsersController < ApplicationController before_filter :authenticate_user! before_filter :check_global_access, :except => [:destroy] + before_filter :find_platform_and_private_users def index @private_users = PrivateUser.where(:platform_id => params[:platform_id]).paginate :page => params[:page] @@ -8,9 +9,11 @@ class PrivateUsersController < ApplicationController end def create - pair = PrivateUser.generate_pair(params[:platform_id], current_user.id) - redirect_to platform_private_users_path(params[:platform_id]), - :notice => "Логин: #{ pair[:login] } Пароль: #{ pair[:pass] }" + @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' end def destroy @@ -18,4 +21,11 @@ class PrivateUsersController < ApplicationController can_perform? user if user redirect_to platform_private_users_path(params[:platform_id]) end + + 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 end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 6ab432bc7..78bafcb9e 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -64,7 +64,11 @@ class RepositoriesController < ApplicationController redirect_to url_for(:action => :add_project) end else - @projects = Project.addable_to_repository(@repository.id).paginate(:page => params[:project_page]) + @projects = Project.scoped + @projects = @projects.addable_to_repository(@repository.id) + @projects = @projects.by_visibilities(['open']) if @repository.platform.platform_type == 'main' + @projects.paginate(:page => params[:project_page]) + #@projects = Project.addable_to_repository(@repository.id).paginate(:page => params[:project_page]) render 'projects_list' end end diff --git a/app/models/platform.rb b/app/models/platform.rb index a3679a9e6..b12992c93 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -35,6 +35,22 @@ class Platform < ActiveRecord::Base #attr_accessible :visibility + def urpmi_list(host, pair = nil) + pair = {:login => 'login', :pass => 'password'} 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 }/#{ pl.name }/main/" + end + else + Platform.main.each do |pl| + urpmi_commands << "urpmi.addmedia http://#{ host }/downloads/#{ self.name }/repository/#{ pl.name }/main/" + end + end + + return urpmi_commands + end + def path build_path(unixname) end diff --git a/app/models/project.rb b/app/models/project.rb index 983d266ae..bfddd54c6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -28,7 +28,7 @@ class Project < ActiveRecord::Base # scope :by_name, lambda { |name| {:conditions => ['name like ?', '%' + name + '%']} } scope :by_name, lambda { |name| where('name like ?', '%' + name + '%') } scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}} - scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id != #{ repository_id }))") } + scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id = #{ repository_id }))") } scope :automateable, where("projects.id NOT IN (SELECT auto_build_lists.project_id FROM auto_build_lists)") # before_save :add_owner_rel diff --git a/app/views/downloads/index.html.haml b/app/views/downloads/index.html.haml index 39341955d..1602e498d 100644 --- a/app/views/downloads/index.html.haml +++ b/app/views/downloads/index.html.haml @@ -3,7 +3,6 @@ %h2.title = t("layout.downloads.title") %h3= t("layout.downloads.message") - = link_to t("layout.downloads.refresh_btn"), downloads_refresh_path() .inner %table.table %tr diff --git a/app/views/personal_repositories/settings.html.haml b/app/views/personal_repositories/settings.html.haml index 13363cccb..00382f766 100644 --- a/app/views/personal_repositories/settings.html.haml +++ b/app/views/personal_repositories/settings.html.haml @@ -14,8 +14,4 @@ .group = link_to t("layout.personal_repositories.change_visibility_from_#{ @repository.platform.visibility }"), change_visibility_personal_repository_path(@repository) - %br - .group - %span= @urmpi_command - -# content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/personal_repositories/show.html.haml b/app/views/personal_repositories/show.html.haml index a78d62d8d..afc3ca502 100644 --- a/app/views/personal_repositories/show.html.haml +++ b/app/views/personal_repositories/show.html.haml @@ -11,6 +11,12 @@ = t("activerecord.attributes.repository.owner") \: = link_to @repository.owner.name, url_for(@repository.owner) + + %br + .group + - @urpmi_commands.each do |urpmi_command| + %span= urpmi_command + %br .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") diff --git a/app/views/private_users/index.html.haml b/app/views/private_users/index.html.haml index 719f7174f..b9ba95110 100644 --- a/app/views/private_users/index.html.haml +++ b/app/views/private_users/index.html.haml @@ -16,6 +16,13 @@ = t("activerecord.attributes.repository.platform") \: = link_to @platform.name, platform_path(@platform) + + - if @urpmi_list + %br + .group + - @urpmi_list.each do |urpmi_command| + %span= urpmi_command + %br .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") diff --git a/app/views/repositories/projects_list.html.haml b/app/views/repositories/projects_list.html.haml index 97b192af7..80c9e55cf 100644 --- a/app/views/repositories/projects_list.html.haml +++ b/app/views/repositories/projects_list.html.haml @@ -26,11 +26,6 @@ = t("activerecord.attributes.repository.owner") \: = link_to @repository.owner.try(:name), url_for(@repository.owner) - %p - %b - = t("activerecord.attributes.repository.platform") - \: - = link_to @repository.platform.name, platform_path(@platform) .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") diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 70e73c0d6..dc28101e4 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -32,7 +32,7 @@ ru: downloads: title: Статистика закачек пакетов - message: Обновляется автоматически каждые 24 часа + message: Обновляется автоматически каждые 5 минут refresh_btn: Обновить auto_build_lists: