From c1de46dbc7ea1afc89f059bdc87a5b717bc322c9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Sep 2015 17:14:55 +0200 Subject: [PATCH] Fix project pages for authorized user --- app/assets/stylesheets/ci/application.scss | 4 ++++ app/controllers/ci/application_controller.rb | 5 ++--- app/controllers/ci/runners_controller.rb | 4 +++- app/views/ci/builds/show.html.haml | 4 ++-- app/views/layouts/ci/project.html.haml | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/ci/application.scss b/app/assets/stylesheets/ci/application.scss index 7a124ae87d9..2f2928f7054 100644 --- a/app/assets/stylesheets/ci/application.scss +++ b/app/assets/stylesheets/ci/application.scss @@ -52,4 +52,8 @@ $nprogress-color: #9BC; body { padding-top: 0 !important; + + a { + color: #3084bb; + } } diff --git a/app/controllers/ci/application_controller.rb b/app/controllers/ci/application_controller.rb index e5c99066a68..9a32efaee7d 100644 --- a/app/controllers/ci/application_controller.rb +++ b/app/controllers/ci/application_controller.rb @@ -8,7 +8,6 @@ module Ci rescue_from Ci::Network::UnauthorizedError, with: :invalid_token before_filter :default_headers - #before_filter :check_config helper_method :gl_project protect_from_forgery @@ -38,7 +37,7 @@ module Ci end def authorize_manage_builds! - unless can?(current_user, :manage_builds, gl_project) + unless can?(current_user, :admin_project, gl_project) return page_404 end end @@ -48,7 +47,7 @@ module Ci end def authorize_manage_project! - unless can?(current_user, :manage_project, gl_project) + unless can?(current_user, :admin_project, gl_project) return page_404 end end diff --git a/app/controllers/ci/runners_controller.rb b/app/controllers/ci/runners_controller.rb index 0ef32ce928f..0e9d576a15b 100644 --- a/app/controllers/ci/runners_controller.rb +++ b/app/controllers/ci/runners_controller.rb @@ -10,7 +10,9 @@ module Ci def index @runners = @project.runners.order('id DESC') - @specific_runners = current_user.authorized_runners. + @specific_runners = + Ci::Runner.specific.includes(:runner_projects). + where(Ci::RunnerProject.table_name => { project_id: current_user.authorized_projects } ). where.not(id: @runners).order("#{Ci::Runner.table_name}.id DESC").page(params[:page]).per(20) @shared_runners = Ci::Runner.shared.active @shared_runners_count = @shared_runners.count(:all) diff --git a/app/views/ci/builds/show.html.haml b/app/views/ci/builds/show.html.haml index a698176c3ed..db8926e30d3 100644 --- a/app/views/ci/builds/show.html.haml +++ b/app/views/ci/builds/show.html.haml @@ -2,7 +2,7 @@ = link_to ci_project_path(@project) @ = @commit.short_sha - + %p = link_to ci_project_ref_commits_path(@project, @commit.ref, @commit.sha) do ← Back to project commit @@ -104,7 +104,7 @@ #{time_ago_in_words(@build.finished_at)} ago %p %span.attr-name Runner: - - if @build.runner && current_user && current_user.is_admin + - if @build.runner && current_user && current_user.admin \#{link_to "##{@build.runner.id}", ci_admin_runner_path(@build.runner.id)} - elsif @build.runner \##{@build.runner.id} diff --git a/app/views/layouts/ci/project.html.haml b/app/views/layouts/ci/project.html.haml index f78d749e592..88c21211a57 100644 --- a/app/views/layouts/ci/project.html.haml +++ b/app/views/layouts/ci/project.html.haml @@ -17,7 +17,7 @@ %hr .container.container-body .content - - if current_user && can?(current_user, :manage_project, gl_project) + - if current_user && can?(current_user, :admin_project, gl_project) .row .col-md-2.append-bottom-20 = render 'layouts/ci/nav_project'