diff options
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r-- | app/controllers/projects_controller.rb | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index aab86db..8a89ab8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -21,7 +21,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. #++ -class ProjectsController < ApplicationController +class ProjectsController < ApplicationController before_filter :login_required, :only => [:create, :update, :destroy, :new, :edit, :confirm_delete] before_filter :check_if_only_site_admins_can_create, :only => [:new, :create] @@ -31,26 +31,26 @@ class ProjectsController < ApplicationController before_filter :require_user_has_ssh_keys, :only => [:new, :create] renders_in_site_specific_context :only => [:show, :edit, :update, :confirm_delete] renders_in_global_context :except => [:show, :edit, :update, :confirm_delete, :clones] - + def index - @projects = Project.paginate(:all, :order => "projects.created_at desc", + @projects = Project.paginate(:all, :order => "projects.created_at desc", :page => params[:page], :include => [:tags, { :repositories => :project } ]) - + @atom_auto_discovery_url = projects_path(:format => :atom) respond_to do |format| format.html { @active_recently = Project.most_active_recently @active_overall = Project.most_active_overall(@active_recently.size) - @tags = Project.top_tags + @tags = Project.top_tags } format.xml { render :xml => @projects } format.atom { } end end - + def category tags = params[:id].to_s.gsub(/,\ ?/, " ") - @projects = Project.paginate_by_tag(tags, :order => 'created_at desc', + @projects = Project.paginate_by_tag(tags, :order => 'created_at desc', :page => params[:page]) @atom_auto_discovery_url = projects_category_path(params[:id], :format => :atom) respond_to do |format| @@ -62,7 +62,7 @@ class ProjectsController < ApplicationController format.atom { render :action => "index"} end end - + def show @owner = @project @root = @project @@ -86,13 +86,13 @@ class ProjectsController < ApplicationController format.js { render :partial => "repositories" } end end - + def new @project = Project.new @project.owner = current_user @root = Breadcrumb::NewProject.new end - + def create @project = Project.new(params[:project]) @root = Breadcrumb::NewProject.new @@ -103,7 +103,7 @@ class ProjectsController < ApplicationController when "Group" current_user.groups.find(params[:project][:owner_id]) end - + if @project.save @project.create_event(Action::CREATE_PROJECT, @project, current_user) redirect_to new_project_repository_path(@project) @@ -111,12 +111,12 @@ class ProjectsController < ApplicationController render :action => 'new' end end - + def edit - @groups = current_user.groups + @groups = current_user.groups.select{|g| g.admin?(current_user) } @root = Breadcrumb::EditProject.new(@project) end - + def edit_slug @root = Breadcrumb::EditProject.new(@project) if request.put? @@ -128,16 +128,16 @@ class ProjectsController < ApplicationController end end end - + def update - @groups = current_user.groups + @groups = current_user.groups.select{|g| g.admin?(current_user) } @root = Breadcrumb::EditProject.new(@project) - + # change group, if requested unless params[:project][:owner_id].blank? @project.change_owner_to(current_user.groups.find(params[:project][:owner_id])) end - + @project.attributes = params[:project] changed = @project.changed? # Dirty attr tracking is cleared after #save if @project.save && @project.wiki_repository.save @@ -148,7 +148,7 @@ class ProjectsController < ApplicationController render :action => 'edit' end end - + def preview @project = Project.new @project.description = params[:project][:description] @@ -156,11 +156,11 @@ class ProjectsController < ApplicationController wants.js end end - + def confirm_delete @project = Project.find_by_slug!(params[:id]) end - + def destroy @project = Project.find_by_slug!(params[:id]) if @project.can_be_deleted_by?(current_user) @@ -172,19 +172,19 @@ class ProjectsController < ApplicationController end redirect_to projects_path end - + protected def find_project @project = Project.find_by_slug!(params[:id], :include => [:repositories]) end - + def assure_adminship if !@project.admin?(current_user) flash[:error] = I18n.t "projects_controller.update_error" redirect_to(project_path(@project)) and return end end - + def check_if_only_site_admins_can_create if GitoriousConfig["only_site_admins_can_create_projects"] unless current_user.site_admin? |