[refs #2161] Global private users and repos fixes
This commit is contained in:
parent
5c97e89829
commit
e03d711d1b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ ru:
|
|||
|
||||
downloads:
|
||||
title: Статистика закачек пакетов
|
||||
message: Обновляется автоматически каждые 24 часа
|
||||
message: Обновляется автоматически каждые 5 минут
|
||||
refresh_btn: Обновить
|
||||
|
||||
auto_build_lists:
|
||||
|
|
Loading…
Reference in New Issue