2011-10-27 14:04:03 +01:00
|
|
|
class PersonalRepositoriesController < ApplicationController
|
|
|
|
before_filter :authenticate_user!
|
|
|
|
before_filter :find_repository#, :only => [:show, :destroy, :add_project, :remove_project, :make_private, :settings]
|
2011-10-28 15:28:45 +01:00
|
|
|
before_filter :check_repository
|
2011-10-28 18:55:40 +01:00
|
|
|
before_filter :check_global_access
|
2011-10-27 14:04:03 +01:00
|
|
|
|
|
|
|
def show
|
2011-10-31 18:14:25 +00:00
|
|
|
can_perform? @repository if @repository
|
2011-10-27 14:04:03 +01:00
|
|
|
if params[:query]
|
|
|
|
@projects = @repository.projects.recent.by_name(params[:query]).paginate :page => params[:project_page], :per_page => 30
|
|
|
|
else
|
|
|
|
@projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#TODO: Add git repo move into private repos path.
|
|
|
|
def change_visibility
|
2011-10-31 18:14:25 +00:00
|
|
|
can_perform? @repository if @repository
|
2011-10-28 08:20:13 +01:00
|
|
|
@repository.platform.change_visibility
|
2011-10-27 14:04:03 +01:00
|
|
|
|
|
|
|
redirect_to settings_personal_repository_path(@repository)
|
|
|
|
end
|
|
|
|
|
|
|
|
def settings
|
2011-10-31 18:14:25 +00:00
|
|
|
can_perform? @repository if @repository
|
2011-10-28 08:20:13 +01:00
|
|
|
if @repository.platform.hidden?
|
2011-10-27 14:04:03 +01:00
|
|
|
@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
|
2011-10-31 18:14:25 +00:00
|
|
|
can_perform? @repository if @repository
|
2011-10-27 14:04:03 +01:00
|
|
|
if params[:project_id]
|
|
|
|
@project = Project.find(params[:project_id])
|
|
|
|
params[:project_id] = nil
|
|
|
|
unless @repository.projects.include? @project
|
|
|
|
@repository.projects << @project
|
|
|
|
flash[:notice] = t('flash.repository.project_added')
|
|
|
|
redirect_to platform_repository_path(@repository.platform, @repository)
|
|
|
|
else
|
|
|
|
flash[:error] = t('flash.repository.project_not_added')
|
|
|
|
redirect_to url_for(:action => :add_project)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
@projects = Project.addable_to_repository(@repository.id).paginate(:page => params[:project_page])
|
|
|
|
render 'projects_list'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_project
|
2011-10-31 18:14:25 +00:00
|
|
|
can_perform? @repository if @repository
|
2011-10-27 14:04:03 +01:00
|
|
|
if params[:project_id]
|
|
|
|
@project = Project.find(params[:project_id])
|
|
|
|
params[:project_id] = nil
|
|
|
|
if @repository.projects.include? @project
|
|
|
|
@repository.projects.delete @project
|
|
|
|
flash[:notice] = t('flash.repository.project_removed')
|
|
|
|
redirect_to platform_repository_path(@repository.platform, @repository)
|
|
|
|
else
|
|
|
|
redirect_to url_for(:action => :remove_project)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
redirect_to platform_repository_path(@repository.platform, @repository)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def find_repository
|
|
|
|
@repository = Repository.find(params[:id])
|
|
|
|
end
|
2011-10-28 15:28:45 +01:00
|
|
|
|
|
|
|
def check_repository
|
|
|
|
redirect_to root_path if !@repository.platform.personal?
|
|
|
|
end
|
2011-10-27 14:04:03 +01:00
|
|
|
end
|