From ba9855d4877998e3574907cc542fcab15a9d1353 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Tue, 29 Dec 2015 18:58:38 -0200 Subject: Prevent ldap_blocked users from being unblocked by the Admin UI --- app/controllers/admin/users_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index d7c927d444c..87f4fb455b8 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -40,7 +40,9 @@ class Admin::UsersController < Admin::ApplicationController end def unblock - if user.activate + if user.ldap_blocked? + redirect_back_or_admin_user(alert: "This user cannot be unlocked manually from GitLab") + elsif user.activate redirect_back_or_admin_user(notice: "Successfully unblocked") else redirect_back_or_admin_user(alert: "Error occurred. User was not unblocked") -- cgit v1.2.1 From ec67e9be1d7486199b47e19c766202a8bfdefe93 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Wed, 6 Jan 2016 05:38:52 -0200 Subject: Repair ldap_blocked state when no ldap identity exist anymore --- app/controllers/admin/identities_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb index e383fe38ea6..9ba10487512 100644 --- a/app/controllers/admin/identities_controller.rb +++ b/app/controllers/admin/identities_controller.rb @@ -26,6 +26,7 @@ class Admin::IdentitiesController < Admin::ApplicationController def update if @identity.update_attributes(identity_params) + RepairLdapBlockedUserService.new(@user, @identity).execute redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.' else render :edit @@ -34,6 +35,7 @@ class Admin::IdentitiesController < Admin::ApplicationController def destroy if @identity.destroy + RepairLdapBlockedUserService.new(@user, @identity).execute redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully removed.' else redirect_to admin_user_identities_path(@user), alert: 'Failed to remove user identity.' -- cgit v1.2.1 From 47e4613f4adc2d6ef4b066a87ec772ef8044bdd5 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Thu, 7 Jan 2016 14:01:01 -0200 Subject: Code style fixes and some code simplified --- app/controllers/admin/identities_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb index 9ba10487512..79a53556f0a 100644 --- a/app/controllers/admin/identities_controller.rb +++ b/app/controllers/admin/identities_controller.rb @@ -26,7 +26,7 @@ class Admin::IdentitiesController < Admin::ApplicationController def update if @identity.update_attributes(identity_params) - RepairLdapBlockedUserService.new(@user, @identity).execute + RepairLdapBlockedUserService.new(@user).execute redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.' else render :edit @@ -35,7 +35,7 @@ class Admin::IdentitiesController < Admin::ApplicationController def destroy if @identity.destroy - RepairLdapBlockedUserService.new(@user, @identity).execute + RepairLdapBlockedUserService.new(@user).execute redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully removed.' else redirect_to admin_user_identities_path(@user), alert: 'Failed to remove user identity.' -- cgit v1.2.1 From 58867eff46dc6886b85bfe5a787341f224d09421 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Wed, 9 Dec 2015 11:59:25 +0100 Subject: Unsubscribe from thread through link in email footer --- app/controllers/sent_notifications_controller.rb | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/controllers/sent_notifications_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb new file mode 100644 index 00000000000..93dcc16094f --- /dev/null +++ b/app/controllers/sent_notifications_controller.rb @@ -0,0 +1,25 @@ +class SentNotificationsController < ApplicationController + skip_before_action :authenticate_user! + + def unsubscribe + @sent_notification = SentNotification.for(params[:id]) + return render_404 unless @sent_notification && !@sent_notification.for_commit? + + noteable = @sent_notification.noteable + noteable.unsubscribe(@sent_notification.recipient) + + flash[:notice] = "You have been unsubscribed from this thread." + if current_user + case @sent_notification.noteable + when Issue + redirect_to issue_path(noteable) + when MergeRequest + redirect_to merge_request_path(noteable) + else + redirect_to root_path + end + else + redirect_to new_user_session_path + end + end +end -- cgit v1.2.1 From 26cedc7e0bd83fc488da3a4dc5265d395639215f Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Sat, 9 Jan 2016 19:32:03 +0100 Subject: Minor improvements, unsubscribe from email footer --- app/controllers/sent_notifications_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb index 93dcc16094f..b7008c82bf2 100644 --- a/app/controllers/sent_notifications_controller.rb +++ b/app/controllers/sent_notifications_controller.rb @@ -3,14 +3,14 @@ class SentNotificationsController < ApplicationController def unsubscribe @sent_notification = SentNotification.for(params[:id]) - return render_404 unless @sent_notification && !@sent_notification.for_commit? + return render_404 unless @sent_notification && @sent_notification.can_unsubscribe? noteable = @sent_notification.noteable noteable.unsubscribe(@sent_notification.recipient) flash[:notice] = "You have been unsubscribed from this thread." if current_user - case @sent_notification.noteable + case noteable when Issue redirect_to issue_path(noteable) when MergeRequest -- cgit v1.2.1 From be08490863b76026b8f3ffbc422cb7f5d8b4a6a4 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Mon, 11 Jan 2016 14:23:45 +0100 Subject: #can_unsubscribe? -> #?unsubscribable? --- app/controllers/sent_notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb index b7008c82bf2..7271c933b9b 100644 --- a/app/controllers/sent_notifications_controller.rb +++ b/app/controllers/sent_notifications_controller.rb @@ -3,7 +3,7 @@ class SentNotificationsController < ApplicationController def unsubscribe @sent_notification = SentNotification.for(params[:id]) - return render_404 unless @sent_notification && @sent_notification.can_unsubscribe? + return render_404 unless @sent_notification && @sent_notification.unsubscribable? noteable = @sent_notification.noteable noteable.unsubscribe(@sent_notification.recipient) -- cgit v1.2.1 From da40274fdc60fe17f928b80eb71c211e27523d5e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 12 Jan 2016 20:48:16 -0500 Subject: Block the reported user before destroying the record This is intended to prevent the user from creating new objects while the transaction that removes them is being run, resulting in objects with nil authors which can then not be edited. See https://gitlab.com/gitlab-org/gitlab-ce/issues/7117 --- app/controllers/admin/abuse_reports_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/abuse_reports_controller.rb b/app/controllers/admin/abuse_reports_controller.rb index 38a5a9fca08..2463cfa87be 100644 --- a/app/controllers/admin/abuse_reports_controller.rb +++ b/app/controllers/admin/abuse_reports_controller.rb @@ -6,11 +6,9 @@ class Admin::AbuseReportsController < Admin::ApplicationController def destroy abuse_report = AbuseReport.find(params[:id]) - if params[:remove_user] - abuse_report.user.destroy - end - + abuse_report.remove_user if params[:remove_user] abuse_report.destroy + render nothing: true end end -- cgit v1.2.1 From 9d7f88c12258e27a189e8229090920db0627e88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 12 Jan 2016 18:10:06 +0100 Subject: Show referenced MRs & Issues only when the current viewer can access them --- app/controllers/projects/issues_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index b59b52291fb..f476afb2d92 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -61,7 +61,7 @@ class Projects::IssuesController < Projects::ApplicationController @note = @project.notes.new(noteable: @issue) @notes = @issue.notes.nonawards.with_associations.fresh @noteable = @issue - @merge_requests = @issue.referenced_merge_requests + @merge_requests = @issue.referenced_merge_requests(current_user) respond_with(@issue) end -- cgit v1.2.1 From 23671600150cb022a09a77b8ea56a9465f19a013 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 13 Jan 2016 12:29:48 +0100 Subject: Make the metrics sampler interval configurable --- app/controllers/admin/application_settings_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers') diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 44d06b6a647..91f7d78bd73 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -73,6 +73,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController :metrics_pool_size, :metrics_timeout, :metrics_method_call_threshold, + :metrics_sample_interval, :recaptcha_enabled, :recaptcha_site_key, :recaptcha_private_key, -- cgit v1.2.1 From 6ae39c2cd1edcc845136739d42baf032120e3ddc Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 31 Dec 2015 15:56:15 -0500 Subject: Remove alert_type attribute from BroadcastMessage --- app/controllers/admin/broadcast_messages_controller.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb index 497c34f8f49..bc702c022b6 100644 --- a/app/controllers/admin/broadcast_messages_controller.rb +++ b/app/controllers/admin/broadcast_messages_controller.rb @@ -31,9 +31,12 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController end def broadcast_message_params - params.require(:broadcast_message).permit( - :alert_type, :color, :ends_at, :font, - :message, :starts_at - ) + params.require(:broadcast_message).permit(%i( + color + ends_at + font + message + starts_at + )) end end -- cgit v1.2.1 From 00e8700433b3b1ad11252448af5be58913539d85 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 31 Dec 2015 17:55:14 -0500 Subject: Broadcast Messages can now be edited Closes #3046 --- .../admin/broadcast_messages_controller.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb index bc702c022b6..4735b27c65d 100644 --- a/app/controllers/admin/broadcast_messages_controller.rb +++ b/app/controllers/admin/broadcast_messages_controller.rb @@ -1,8 +1,12 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController - before_action :broadcast_messages + before_action :finder, only: [:edit, :update, :destroy] def index - @broadcast_message = BroadcastMessage.new + @broadcast_messages = BroadcastMessage.reorder("starts_at ASC").page(params[:page]) + @broadcast_message = BroadcastMessage.new + end + + def edit end def create @@ -15,8 +19,16 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController end end + def update + if @broadcast_message.update(broadcast_message_params) + redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully updated.' + else + render :edit + end + end + def destroy - BroadcastMessage.find(params[:id]).destroy + @broadcast_message.destroy respond_to do |format| format.html { redirect_back_or_default(default: { action: 'index' }) } @@ -26,8 +38,8 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController protected - def broadcast_messages - @broadcast_messages ||= BroadcastMessage.order("starts_at DESC").page(params[:page]) + def finder + @broadcast_message = BroadcastMessage.find(params[:id]) end def broadcast_message_params -- cgit v1.2.1 From df8776f480eeb81245f338f85998b93d11f833a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Wed, 13 Jan 2016 17:03:24 -0500 Subject: Consider that URL can end with '/' before redirecting. #7975 --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 81cb1367e2c..bf99b2e777d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -115,7 +115,7 @@ class ApplicationController < ActionController::Base # localhost/group/project # if id =~ /\.git\Z/ - redirect_to request.original_url.gsub(/\.git\Z/, '') and return + redirect_to request.original_url.gsub(/\.git\/?\Z/, '') and return end project_path = "#{namespace}/#{id}" -- cgit v1.2.1 From 79fe18d9e7290fb880f1feb5f2c9f3f96b2d74fe Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 17 Dec 2015 14:24:43 +0100 Subject: Move build artifacts implementation to separate controller --- .../projects/builds/artifacts_controller.rb | 36 ++++++++++++++++++++++ app/controllers/projects/builds_controller.rb | 27 ---------------- 2 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 app/controllers/projects/builds/artifacts_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/projects/builds/artifacts_controller.rb b/app/controllers/projects/builds/artifacts_controller.rb new file mode 100644 index 00000000000..fd2195d2460 --- /dev/null +++ b/app/controllers/projects/builds/artifacts_controller.rb @@ -0,0 +1,36 @@ +class Projects::Builds::ArtifactsController < Projects::ApplicationController + layout 'project' + before_action :authorize_download_build_artifacts! + + def download + unless artifacts_file.file_storage? + return redirect_to artifacts_file.url + end + + unless artifacts_file.exists? + return not_found! + end + + send_file artifacts_file.path, disposition: 'attachment' + end + + private + + def build + @build ||= project.builds.unscoped.find_by!(id: params[:build_id]) + end + + def artifacts_file + @artifacts_file ||= build.artifacts_file + end + + def authorize_download_build_artifacts! + unless can?(current_user, :download_build_artifacts, @project) + if current_user.nil? + return authenticate_user! + else + return render_404 + end + end + end +end diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 39d3ba26ba2..0e965966ffa 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -2,7 +2,6 @@ class Projects::BuildsController < Projects::ApplicationController before_action :build, except: [:index, :cancel_all] before_action :authorize_manage_builds!, except: [:index, :show, :status] - before_action :authorize_download_build_artifacts!, only: [:download] layout "project" @@ -51,18 +50,6 @@ class Projects::BuildsController < Projects::ApplicationController redirect_to build_path(build) end - def download - unless artifacts_file.file_storage? - return redirect_to artifacts_file.url - end - - unless artifacts_file.exists? - return not_found! - end - - send_file artifacts_file.path, disposition: 'attachment' - end - def status render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha) end @@ -79,10 +66,6 @@ class Projects::BuildsController < Projects::ApplicationController @build ||= project.builds.unscoped.find_by!(id: params[:id]) end - def artifacts_file - build.artifacts_file - end - def build_path(build) namespace_project_build_path(build.project.namespace, build.project, build) end @@ -92,14 +75,4 @@ class Projects::BuildsController < Projects::ApplicationController return page_404 end end - - def authorize_download_build_artifacts! - unless can?(current_user, :download_build_artifacts, @project) - if current_user.nil? - return authenticate_user! - else - return render_404 - end - end - end end -- cgit v1.2.1 From a96d45c694bd8fe7d07283d0b46725ca8e4c281b Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 17 Dec 2015 15:17:00 +0100 Subject: Add view action to artifacts controller --- app/controllers/projects/builds/artifacts_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/projects/builds/artifacts_controller.rb b/app/controllers/projects/builds/artifacts_controller.rb index fd2195d2460..bb70d801d8c 100644 --- a/app/controllers/projects/builds/artifacts_controller.rb +++ b/app/controllers/projects/builds/artifacts_controller.rb @@ -14,6 +14,10 @@ class Projects::Builds::ArtifactsController < Projects::ApplicationController send_file artifacts_file.path, disposition: 'attachment' end + def view + @metadata = build.artifacts_metadata + end + private def build -- cgit v1.2.1 From f091272f1982dfe977c9f366e4127fbbe0314f4a Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 18 Dec 2015 08:41:16 +0100 Subject: Move artifacts controller level up This reverts nesting artifacts controller in builds module. --- app/controllers/projects/artifacts_controller.rb | 40 ++++++++++++++++++++++ .../projects/builds/artifacts_controller.rb | 40 ---------------------- 2 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 app/controllers/projects/artifacts_controller.rb delete mode 100644 app/controllers/projects/builds/artifacts_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb new file mode 100644 index 00000000000..ff04e144884 --- /dev/null +++ b/app/controllers/projects/artifacts_controller.rb @@ -0,0 +1,40 @@ +class Projects::ArtifactsController < Projects::ApplicationController + layout 'project' + before_action :authorize_download_build_artifacts! + + def download + unless artifacts_file.file_storage? + return redirect_to artifacts_file.url + end + + unless artifacts_file.exists? + return not_found! + end + + send_file artifacts_file.path, disposition: 'attachment' + end + + def browse + @metadata = build.artifacts_metadata + end + + private + + def build + @build ||= project.builds.unscoped.find_by!(id: params[:build_id]) + end + + def artifacts_file + @artifacts_file ||= build.artifacts_file + end + + def authorize_download_build_artifacts! + unless can?(current_user, :download_build_artifacts, @project) + if current_user.nil? + return authenticate_user! + else + return render_404 + end + end + end +end diff --git a/app/controllers/projects/builds/artifacts_controller.rb b/app/controllers/projects/builds/artifacts_controller.rb deleted file mode 100644 index bb70d801d8c..00000000000 --- a/app/controllers/projects/builds/artifacts_controller.rb +++ /dev/null @@ -1,40 +0,0 @@ -class Projects::Builds::ArtifactsController < Projects::ApplicationController - layout 'project' - before_action :authorize_download_build_artifacts! - - def download - unless artifacts_file.file_storage? - return redirect_to artifacts_file.url - end - - unless artifacts_file.exists? - return not_found! - end - - send_file artifacts_file.path, disposition: 'attachment' - end - - def view - @metadata = build.artifacts_metadata - end - - private - - def build - @build ||= project.builds.unscoped.find_by!(id: params[:build_id]) - end - - def artifacts_file - @artifacts_file ||= build.artifacts_file - end - - def authorize_download_build_artifacts! - unless can?(current_user, :download_build_artifacts, @project) - if current_user.nil? - return authenticate_user! - else - return render_404 - end - end - end -end -- cgit v1.2.1 From 80a71576ba27d84b3406a8b929328359e2edc9da Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 18 Dec 2015 12:55:50 +0100 Subject: Use `Gitlab::StringPath` in CI build artifacts controller --- app/controllers/projects/artifacts_controller.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index ff04e144884..c1f406e3ba5 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -15,7 +15,10 @@ class Projects::ArtifactsController < Projects::ApplicationController end def browse - @metadata = build.artifacts_metadata + path = params[:path].to_s + @paths = artifacts_metadata.map do |_artifact_file| + Gitlab::StringPath.new(path, artifacts_metadata) + end end private @@ -28,6 +31,10 @@ class Projects::ArtifactsController < Projects::ApplicationController @artifacts_file ||= build.artifacts_file end + def artifacts_metadata + @artifacts_metadata ||= build.artifacts_metadata + end + def authorize_download_build_artifacts! unless can?(current_user, :download_build_artifacts, @project) if current_user.nil? -- cgit v1.2.1 From 5a1faf61f6d8bdbdde1842db8cf13521287ed168 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Dec 2015 12:53:31 +0100 Subject: Add artifacts browser This implementation makes it possible to browse artifacts, it depends on artifacts metadata. --- app/controllers/projects/artifacts_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index c1f406e3ba5..4524127e8e5 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -15,10 +15,8 @@ class Projects::ArtifactsController < Projects::ApplicationController end def browse - path = params[:path].to_s - @paths = artifacts_metadata.map do |_artifact_file| - Gitlab::StringPath.new(path, artifacts_metadata) - end + current_path = params[:path] ? "./#{params[:path]}/" : './' + @path = Gitlab::StringPath.new(current_path, artifacts_metadata) end private -- cgit v1.2.1 From ebd69c5fc1296f30238326b901ad73c891d696da Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 28 Dec 2015 10:35:51 +0100 Subject: Remove artifacts metadata column from database --- app/controllers/projects/artifacts_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 4524127e8e5..399aa11fcbe 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -16,6 +16,7 @@ class Projects::ArtifactsController < Projects::ApplicationController def browse current_path = params[:path] ? "./#{params[:path]}/" : './' + artifacts_metadata = build.artifacts_metadata(current_path) @path = Gitlab::StringPath.new(current_path, artifacts_metadata) end @@ -29,10 +30,6 @@ class Projects::ArtifactsController < Projects::ApplicationController @artifacts_file ||= build.artifacts_file end - def artifacts_metadata - @artifacts_metadata ||= build.artifacts_metadata - end - def authorize_download_build_artifacts! unless can?(current_user, :download_build_artifacts, @project) if current_user.nil? -- cgit v1.2.1 From 8eeed761a9c25ea8ccfc347fbd3f5894b5957d9e Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 28 Dec 2015 11:43:15 +0100 Subject: Update specs for CI Build, add `artifacts?` method `artifacts?` method checks if artifacts archive is available. --- app/controllers/projects/artifacts_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 399aa11fcbe..18677fb1e95 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -15,6 +15,8 @@ class Projects::ArtifactsController < Projects::ApplicationController end def browse + return render_404 unless build.artifacts? + current_path = params[:path] ? "./#{params[:path]}/" : './' artifacts_metadata = build.artifacts_metadata(current_path) @path = Gitlab::StringPath.new(current_path, artifacts_metadata) -- cgit v1.2.1 From 662f4b9e1dec8e461c4ea8da3ccc46a259d9d205 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 30 Dec 2015 14:41:44 +0100 Subject: Add artifacts metadata uploader filed Artifacts metadata field will be used to store a filename of gzipped file containing metadata definition for given artifacts archive. --- app/controllers/projects/artifacts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 18677fb1e95..8a1ff383134 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -18,7 +18,7 @@ class Projects::ArtifactsController < Projects::ApplicationController return render_404 unless build.artifacts? current_path = params[:path] ? "./#{params[:path]}/" : './' - artifacts_metadata = build.artifacts_metadata(current_path) + artifacts_metadata = build.artifacts_metadata_for(current_path) @path = Gitlab::StringPath.new(current_path, artifacts_metadata) end -- cgit v1.2.1 From 447f56036e837fc9a9c2bcaf382d38dc513a9733 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 31 Dec 2015 09:25:59 +0100 Subject: Use metadata stored in artifacats metadata file --- app/controllers/projects/artifacts_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 8a1ff383134..3a112587f72 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -18,8 +18,8 @@ class Projects::ArtifactsController < Projects::ApplicationController return render_404 unless build.artifacts? current_path = params[:path] ? "./#{params[:path]}/" : './' - artifacts_metadata = build.artifacts_metadata_for(current_path) - @path = Gitlab::StringPath.new(current_path, artifacts_metadata) + metadata = build.artifacts_metadata_for_path(current_path) + @path = Gitlab::StringPath.new(current_path, metadata) end private -- cgit v1.2.1 From 3de8a4620a70c886c815576dc0a30a745cbb8ccb Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 31 Dec 2015 12:21:56 +0100 Subject: Parse artifacts metadata stored in JSON format --- app/controllers/projects/artifacts_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 3a112587f72..5bd0c8cd780 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -18,8 +18,8 @@ class Projects::ArtifactsController < Projects::ApplicationController return render_404 unless build.artifacts? current_path = params[:path] ? "./#{params[:path]}/" : './' - metadata = build.artifacts_metadata_for_path(current_path) - @path = Gitlab::StringPath.new(current_path, metadata) + paths, metadata = build.artifacts_metadata_for_path(current_path) + @path = Gitlab::StringPath.new(current_path, paths, metadata) end private -- cgit v1.2.1 From a7f99b67a0bf1160f41ebf4dc92c618eb13a7a10 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 4 Jan 2016 13:08:49 +0100 Subject: Extract artifacts metadata implementation to separate class --- app/controllers/projects/artifacts_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 5bd0c8cd780..ee1b1f375dc 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -16,10 +16,7 @@ class Projects::ArtifactsController < Projects::ApplicationController def browse return render_404 unless build.artifacts? - - current_path = params[:path] ? "./#{params[:path]}/" : './' - paths, metadata = build.artifacts_metadata_for_path(current_path) - @path = Gitlab::StringPath.new(current_path, paths, metadata) + @path = build.artifacts_metadata_string_path(params[:path] || './') end private -- cgit v1.2.1 From a5e1905d28e490fb4734bff0e02a1ecff4c7c029 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 4 Jan 2016 14:00:49 +0100 Subject: Render 404 when artifacts path is invalid --- app/controllers/projects/artifacts_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index ee1b1f375dc..d11ae5bd52d 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -17,6 +17,7 @@ class Projects::ArtifactsController < Projects::ApplicationController def browse return render_404 unless build.artifacts? @path = build.artifacts_metadata_string_path(params[:path] || './') + return render_404 if @path.universe.empty? end private -- cgit v1.2.1 From cd3b8bbd2f8e7ad75a453441f83c46aeb1d37353 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 4 Jan 2016 14:18:06 +0100 Subject: Add method that checks if path exists in `StringPath` --- app/controllers/projects/artifacts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index d11ae5bd52d..647bcc31de5 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -17,7 +17,7 @@ class Projects::ArtifactsController < Projects::ApplicationController def browse return render_404 unless build.artifacts? @path = build.artifacts_metadata_string_path(params[:path] || './') - return render_404 if @path.universe.empty? + return render_404 unless @path.exists? end private -- cgit v1.2.1 From 61fb47a43202332fe9ac57847996da929ba42d3f Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Sat, 9 Jan 2016 14:41:43 +0100 Subject: Simplify implementation of build artifacts browser (refactoring) --- app/controllers/projects/artifacts_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 647bcc31de5..9f9861dec79 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -16,10 +16,16 @@ class Projects::ArtifactsController < Projects::ApplicationController def browse return render_404 unless build.artifacts? - @path = build.artifacts_metadata_string_path(params[:path] || './') + @path = build.artifacts_metadata_path(params[:path].to_s) return render_404 unless @path.exists? end + def file + # TODO, check if file exists in metadata + render json: { repository: build.artifacts_file.path, + path: Base64.encode64(params[:path].to_s) } + end + private def build -- cgit v1.2.1 From 09a4a5aff8c53dd5930044ddbb285a95ef177d8a Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 11 Jan 2016 09:57:03 +0100 Subject: Render only valid paths in artifacts metadata In this version we will support only relative paths in artifacts metadata. Support for absolute paths will be introduced later. --- app/controllers/projects/artifacts_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 9f9861dec79..f88d866febc 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -16,7 +16,10 @@ class Projects::ArtifactsController < Projects::ApplicationController def browse return render_404 unless build.artifacts? - @path = build.artifacts_metadata_path(params[:path].to_s) + + directory = params[:path] ? "#{params[:path]}/" : '' + @path = build.artifacts_metadata_path(directory) + return render_404 unless @path.exists? end -- cgit v1.2.1 From e9c2628220ed3a9d82cba31e7c9d2654c20235c8 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 11 Jan 2016 10:01:18 +0100 Subject: Check if file exists in metadata in download action --- app/controllers/projects/artifacts_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index f88d866febc..a1f82ddd9c5 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -24,9 +24,14 @@ class Projects::ArtifactsController < Projects::ApplicationController end def file - # TODO, check if file exists in metadata - render json: { repository: build.artifacts_file.path, - path: Base64.encode64(params[:path].to_s) } + file = build.artifacts_metadata_path(params[:path]) + + if file.exists? + render json: { repository: build.artifacts_file.path, + path: Base64.encode64(file.path) } + else + render json: {}, status: 404 + end end private -- cgit v1.2.1 From 487b0a026f9efe2d8214c19a7b95b391708ba3f4 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 12 Jan 2016 11:02:15 +0100 Subject: Improvements, readability for artifacts browser --- app/controllers/projects/artifacts_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index a1f82ddd9c5..00daac0cb30 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -1,6 +1,6 @@ class Projects::ArtifactsController < Projects::ApplicationController layout 'project' - before_action :authorize_download_build_artifacts! + before_action :authorize_read_build_artifacts! def download unless artifacts_file.file_storage? @@ -24,11 +24,11 @@ class Projects::ArtifactsController < Projects::ApplicationController end def file - file = build.artifacts_metadata_path(params[:path]) + file_path = build.artifacts_metadata_path(params[:path]) - if file.exists? - render json: { repository: build.artifacts_file.path, - path: Base64.encode64(file.path) } + if file_path.exists? + render json: { archive: build.artifacts_file.path, + path: Base64.encode64(file_path.path) } else render json: {}, status: 404 end @@ -44,8 +44,8 @@ class Projects::ArtifactsController < Projects::ApplicationController @artifacts_file ||= build.artifacts_file end - def authorize_download_build_artifacts! - unless can?(current_user, :download_build_artifacts, @project) + def authorize_read_build_artifacts! + unless can?(current_user, :read_build_artifacts, @project) if current_user.nil? return authenticate_user! else -- cgit v1.2.1 From 6b0a43aff36f0bbb9050b3c04155a3ccd9c1a75b Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 13 Jan 2016 21:17:28 +0100 Subject: Improve readability of artifacts browser `Entry` related code --- app/controllers/projects/artifacts_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 00daac0cb30..dff0732bdfe 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -18,17 +18,17 @@ class Projects::ArtifactsController < Projects::ApplicationController return render_404 unless build.artifacts? directory = params[:path] ? "#{params[:path]}/" : '' - @path = build.artifacts_metadata_path(directory) + @entry = build.artifacts_metadata_entry(directory) - return render_404 unless @path.exists? + return render_404 unless @entry.exists? end def file - file_path = build.artifacts_metadata_path(params[:path]) + entry = build.artifacts_metadata_entry(params[:path]) - if file_path.exists? + if entry.exists? render json: { archive: build.artifacts_file.path, - path: Base64.encode64(file_path.path) } + entry: Base64.encode64(entry.path) } else render json: {}, status: 404 end -- cgit v1.2.1 From f7240e03a6045ff64ca8595d9e11e3a1dab86624 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 15 Jan 2016 11:29:53 +0100 Subject: Fix autocomplete for new issues/MRs/snippets --- app/controllers/projects/issues_controller.rb | 2 +- app/controllers/projects/merge_requests_controller.rb | 1 + app/controllers/projects/snippets_controller.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index f476afb2d92..68244883803 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -49,7 +49,7 @@ class Projects::IssuesController < Projects::ApplicationController assignee_id: "" ) - @issue = @project.issues.new(issue_params) + @issue = @noteable = @project.issues.new(issue_params) respond_with(@issue) end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index de948d271c8..a6284a24223 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -90,6 +90,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController def new params[:merge_request] ||= ActionController::Parameters.new(source_project: @project) @merge_request = MergeRequests::BuildService.new(project, current_user, merge_request_params).execute + @noteable = @merge_request @target_branches = if @merge_request.target_project @merge_request.target_project.repository.branch_names diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index 2104c7a7a71..92b0caa2efb 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -25,7 +25,7 @@ class Projects::SnippetsController < Projects::ApplicationController end def new - @snippet = @project.snippets.build + @snippet = @noteable = @project.snippets.build end def create -- cgit v1.2.1 From f66f9e95bf1e67ad13de9958d16103b858b58e72 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 15 Jan 2016 02:29:34 -0800 Subject: Give reporters the ability to download artifacts. Also fix a few places where page_404 should be render_404. --- app/controllers/projects/builds_controller.rb | 4 ++-- app/controllers/projects/commit_controller.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 0e965966ffa..92d9699fe84 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -42,7 +42,7 @@ class Projects::BuildsController < Projects::ApplicationController def retry unless @build.retryable? - return page_404 + return render_404 end build = Ci::Build.retry(@build) @@ -72,7 +72,7 @@ class Projects::BuildsController < Projects::ApplicationController def authorize_manage_builds! unless can?(current_user, :manage_builds, project) - return page_404 + return render_404 end end end diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 0aaba3792bf..870f6795219 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -79,7 +79,7 @@ class Projects::CommitController < Projects::ApplicationController def authorize_manage_builds! unless can?(current_user, :manage_builds, project) - return page_404 + return render_404 end end end -- cgit v1.2.1 From 6b2f38f39a473e6791b39e61645d76638d4bd673 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 15 Jan 2016 13:48:29 +0100 Subject: Fix nonexistent method in artifacts controller --- app/controllers/projects/artifacts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index dff0732bdfe..f159a6d6dc6 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -8,7 +8,7 @@ class Projects::ArtifactsController < Projects::ApplicationController end unless artifacts_file.exists? - return not_found! + return render_404 end send_file artifacts_file.path, disposition: 'attachment' -- cgit v1.2.1 From c70ed7f2cdc0fbecea739a08332529b71325938c Mon Sep 17 00:00:00 2001 From: Josh Frye Date: Tue, 12 Jan 2016 12:36:28 -0500 Subject: Autofill abuse message text with user url. Closes #2838 --- app/controllers/abuse_reports_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers') diff --git a/app/controllers/abuse_reports_controller.rb b/app/controllers/abuse_reports_controller.rb index 38814459f66..2eac0cabf7a 100644 --- a/app/controllers/abuse_reports_controller.rb +++ b/app/controllers/abuse_reports_controller.rb @@ -2,6 +2,7 @@ class AbuseReportsController < ApplicationController def new @abuse_report = AbuseReport.new @abuse_report.user_id = params[:user_id] + @ref_url = params.fetch(:ref_url, '') end def create -- cgit v1.2.1