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-31 21:55:56 +00:00
|
|
|
#before_filter :check_global_access
|
2011-11-16 18:45:01 +00:00
|
|
|
|
|
|
|
authorize_resource
|
2011-10-27 14:04:03 +01:00
|
|
|
|
|
|
|
def show
|
2011-11-15 20:05:08 +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
|
2011-11-01 13:22:41 +00:00
|
|
|
|
|
|
|
@urpmi_commands = @repository.platform.urpmi_list(request.host)
|
2011-10-27 14:04:03 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def change_visibility
|
2011-11-15 20:05:08 +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-11-15 20:05:08 +00:00
|
|
|
#can_perform? @repository if @repository
|
2011-10-27 14:04:03 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def add_project
|
2011-11-15 20:05:08 +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])
|
2011-11-02 21:37:00 +00:00
|
|
|
# params[:project_id] = nil
|
|
|
|
unless @repository.projects.find_by_unixname(@project.unixname)
|
2011-10-27 14:04:03 +01:00
|
|
|
@repository.projects << @project
|
2011-11-02 21:37:00 +00:00
|
|
|
flash[:notice] = t('flash.repository.project_added')
|
2011-10-27 14:04:03 +01:00
|
|
|
else
|
|
|
|
flash[:error] = t('flash.repository.project_not_added')
|
|
|
|
end
|
2011-11-02 21:37:00 +00:00
|
|
|
redirect_to personal_repository_path(@repository)
|
2011-10-27 14:04:03 +01:00
|
|
|
else
|
|
|
|
@projects = Project.addable_to_repository(@repository.id).paginate(:page => params[:project_page])
|
|
|
|
render 'projects_list'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_project
|
2011-11-15 20:05:08 +00:00
|
|
|
#can_perform? @repository if @repository
|
2011-11-02 21:37:00 +00:00
|
|
|
@project = Project.find(params[:project_id])
|
|
|
|
ProjectToRepository.where(:project_id => @project.id, :repository_id => @repository.id).destroy_all
|
|
|
|
redirect_to personal_repository_path(@repository), :notice => t('flash.repository.project_removed')
|
2011-10-27 14:04:03 +01:00
|
|
|
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
|