From 7a109402a866db1c84ef9af1c14e148ec944aa22 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 20 Jan 2017 21:57:01 +0800 Subject: Prefer service object over after_save hook Closes #26921 --- app/controllers/admin/runners_controller.rb | 6 +++--- app/controllers/projects/runners_controller.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb index 7345c91f67d..348641e5ecb 100644 --- a/app/controllers/admin/runners_controller.rb +++ b/app/controllers/admin/runners_controller.rb @@ -13,7 +13,7 @@ class Admin::RunnersController < Admin::ApplicationController end def update - if @runner.update_attributes(runner_params) + if Ci::UpdateRunnerService.new(@runner).update(runner_params) respond_to do |format| format.js format.html { redirect_to admin_runner_path(@runner) } @@ -31,7 +31,7 @@ class Admin::RunnersController < Admin::ApplicationController end def resume - if @runner.update_attributes(active: true) + if Ci::UpdateRunnerService.new(@runner).update(active: true) redirect_to admin_runners_path, notice: 'Runner was successfully updated.' else redirect_to admin_runners_path, alert: 'Runner was not updated.' @@ -39,7 +39,7 @@ class Admin::RunnersController < Admin::ApplicationController end def pause - if @runner.update_attributes(active: false) + if Ci::UpdateRunnerService.new(@runner).update(active: false) redirect_to admin_runners_path, notice: 'Runner was successfully updated.' else redirect_to admin_runners_path, alert: 'Runner was not updated.' diff --git a/app/controllers/projects/runners_controller.rb b/app/controllers/projects/runners_controller.rb index 53c36635efe..ff75c408beb 100644 --- a/app/controllers/projects/runners_controller.rb +++ b/app/controllers/projects/runners_controller.rb @@ -16,7 +16,7 @@ class Projects::RunnersController < Projects::ApplicationController end def update - if @runner.update_attributes(runner_params) + if Ci::UpdateRunnerService.new(@runner).update(runner_params) redirect_to runner_path(@runner), notice: 'Runner was successfully updated.' else render 'edit' @@ -32,7 +32,7 @@ class Projects::RunnersController < Projects::ApplicationController end def resume - if @runner.update_attributes(active: true) + if Ci::UpdateRunnerService.new(@runner).update(active: true) redirect_to runner_path(@runner), notice: 'Runner was successfully updated.' else redirect_to runner_path(@runner), alert: 'Runner was not updated.' @@ -40,7 +40,7 @@ class Projects::RunnersController < Projects::ApplicationController end def pause - if @runner.update_attributes(active: false) + if Ci::UpdateRunnerService.new(@runner).update(active: false) redirect_to runner_path(@runner), notice: 'Runner was successfully updated.' else redirect_to runner_path(@runner), alert: 'Runner was not updated.' -- cgit v1.2.1 From 3c4dc4338484acc8736c347b5b64029450836c03 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Tue, 14 Feb 2017 13:39:11 -0500 Subject: Dispatch needed JS when creating a new MR in diff view --- app/controllers/projects/application_controller.rb | 1 - app/controllers/projects/merge_requests_controller.rb | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index db33b60b229..e2f81b09adc 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -83,7 +83,6 @@ class Projects::ApplicationController < ApplicationController end def apply_diff_view_cookie! - @show_changes_tab = params[:view].present? cookies.permanent[:diff_view] = params.delete(:view) if params[:view].present? end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index c3e1760f168..4c981fe4e7e 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -245,6 +245,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController respond_to do |format| format.html do define_new_vars + @show_changes_tab = true render "new" end format.json do @@ -613,6 +614,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController @labels = LabelsFinder.new(current_user, project_id: @project.id).execute + @show_changes_tab = params[:show_changes].present? + define_pipelines_vars end -- cgit v1.2.1 From 0667d1aa7f251f5bf11dd121fe2f696107d8103e Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Gray Date: Mon, 13 Feb 2017 11:38:53 -0600 Subject: Drop theme ID from users table --- app/controllers/admin/users_controller.rb | 1 - app/controllers/profiles/preferences_controller.rb | 1 - 2 files changed, 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 1cd50852e89..7ffde71c3b1 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -194,7 +194,6 @@ class Admin::UsersController < Admin::ApplicationController :provider, :remember_me, :skype, - :theme_id, :twitter, :username, :website_url diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb index a9a06ecc808..0d891ef4004 100644 --- a/app/controllers/profiles/preferences_controller.rb +++ b/app/controllers/profiles/preferences_controller.rb @@ -34,7 +34,6 @@ class Profiles::PreferencesController < Profiles::ApplicationController :layout, :dashboard, :project_view, - :theme_id ) end end -- cgit v1.2.1 From 204a0865e0e69d740abcaa85a689218140678a49 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 17 Feb 2017 07:09:24 +1100 Subject: Add merge request count to each issue on issues list --- app/controllers/concerns/issuable_collections.rb | 20 ++++++++++++++------ app/controllers/projects/issues_controller.rb | 2 +- .../projects/merge_requests_controller.rb | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index a6e158ebae6..d7d781cbe72 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -9,24 +9,32 @@ module IssuableCollections private - def issuable_meta_data(issuable_collection) + def issuable_meta_data(issuable_collection, collection_type) # map has to be used here since using pluck or select will # throw an error when ordering issuables by priority which inserts # a new order into the collection. # We cannot use reorder to not mess up the paginated collection. - issuable_ids = issuable_collection.map(&:id) - issuable_note_count = Note.count_for_collection(issuable_ids, @collection_type) + issuable_ids = issuable_collection.map(&:id) + issuable_note_count = Note.count_for_collection(issuable_ids, @collection_type) issuable_votes_count = AwardEmoji.votes_for_collection(issuable_ids, @collection_type) + issuable_merge_requests_count = + if collection_type == 'Issue' + MergeRequestsClosingIssues.count_for_collection(issuable_ids) + else + [] + end issuable_ids.each_with_object({}) do |id, issuable_meta| downvotes = issuable_votes_count.find { |votes| votes.awardable_id == id && votes.downvote? } - upvotes = issuable_votes_count.find { |votes| votes.awardable_id == id && votes.upvote? } - notes = issuable_note_count.find { |notes| notes.noteable_id == id } + upvotes = issuable_votes_count.find { |votes| votes.awardable_id == id && votes.upvote? } + notes = issuable_note_count.find { |notes| notes.noteable_id == id } + merge_requests = issuable_merge_requests_count.find { |mr| mr.issue_id == id } issuable_meta[id] = Issuable::IssuableMeta.new( upvotes.try(:count).to_i, downvotes.try(:count).to_i, - notes.try(:count).to_i + notes.try(:count).to_i, + merge_requests.try(:count).to_i ) end end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 744a4af1c51..05056ad046a 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -26,7 +26,7 @@ class Projects::IssuesController < Projects::ApplicationController @collection_type = "Issue" @issues = issues_collection @issues = @issues.page(params[:page]) - @issuable_meta_data = issuable_meta_data(@issues) + @issuable_meta_data = issuable_meta_data(@issues, @collection_type) if @issues.out_of_range? && @issues.total_pages != 0 return redirect_to url_for(params.merge(page: @issues.total_pages)) diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 63b5bcbb586..1d286ca62e5 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -39,7 +39,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController @collection_type = "MergeRequest" @merge_requests = merge_requests_collection @merge_requests = @merge_requests.page(params[:page]) - @issuable_meta_data = issuable_meta_data(@merge_requests) + @issuable_meta_data = issuable_meta_data(@merge_requests, @collection_type) if @merge_requests.out_of_range? && @merge_requests.total_pages != 0 return redirect_to url_for(params.merge(page: @merge_requests.total_pages)) -- cgit v1.2.1 From ffd3583486f4772c8aec58b2750619d889d18d1b Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 17 Feb 2017 08:30:00 +1100 Subject: Added second parameter to @issuable_meta_data variables --- app/controllers/concerns/issues_action.rb | 2 +- app/controllers/concerns/merge_requests_action.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/concerns/issues_action.rb b/app/controllers/concerns/issues_action.rb index fb5edb34370..b17c138d5c7 100644 --- a/app/controllers/concerns/issues_action.rb +++ b/app/controllers/concerns/issues_action.rb @@ -10,7 +10,7 @@ module IssuesAction .page(params[:page]) @collection_type = "Issue" - @issuable_meta_data = issuable_meta_data(@issues) + @issuable_meta_data = issuable_meta_data(@issues, @collection_type) respond_to do |format| format.html diff --git a/app/controllers/concerns/merge_requests_action.rb b/app/controllers/concerns/merge_requests_action.rb index 6229759dcf1..d3c8e4888bc 100644 --- a/app/controllers/concerns/merge_requests_action.rb +++ b/app/controllers/concerns/merge_requests_action.rb @@ -9,7 +9,7 @@ module MergeRequestsAction .page(params[:page]) @collection_type = "MergeRequest" - @issuable_meta_data = issuable_meta_data(@merge_requests) + @issuable_meta_data = issuable_meta_data(@merge_requests, @collection_type) end private -- cgit v1.2.1 From 4a8a28eb9e9dffb03a8c8be413aa341f452ce113 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 17 Feb 2017 12:46:21 -0600 Subject: Fix issue where files on a fork could not be edited --- app/controllers/concerns/creates_commit.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb index 6286d67d30c..88d180fcc2e 100644 --- a/app/controllers/concerns/creates_commit.rb +++ b/app/controllers/concerns/creates_commit.rb @@ -104,23 +104,15 @@ module CreatesCommit if can?(current_user, :push_code, @project) # Edit file in this project @mr_source_project = @project - - if @project.forked? - # Merge request from this project to fork origin - @mr_target_project = @project.forked_from_project - @mr_target_branch = @mr_target_project.repository.root_ref - else - # Merge request to this project - @mr_target_project = @project - @mr_target_branch = @ref || @target_branch - end else # Merge request from fork to this project @mr_source_project = current_user.fork_of(@project) - @mr_target_project = @project - @mr_target_branch = @ref || @target_branch end + # Merge request to this project + @mr_target_project = @project + @mr_target_branch = @ref || @target_branch + @mr_source_branch = guess_mr_source_branch end -- cgit v1.2.1 From 26160459b56019f445a7d29abc0b72f591e1d2a9 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Mon, 16 Jan 2017 14:11:08 +0100 Subject: Todo done clicking is kind of unusable. The Done button will change to an Undo button and the line item will be greyed out. Bold links will be unbolded. The user can undo the task by clicking the Undo button. --- app/controllers/dashboard/todos_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index e3933e3d7b1..4e61b0886d8 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -29,6 +29,12 @@ class Dashboard::TodosController < Dashboard::ApplicationController end end + def restore + TodoService.new.mark_todos_as_pending_by_ids([params[:id]], current_user) + + render json: todos_counts + end + private def find_todos -- cgit v1.2.1 From d3afb752385e41bed583391b678cb0e49e5a04cc Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Feb 2017 09:39:49 +0000 Subject: exclude rpc_pipefs from system disc info --- app/controllers/admin/system_info_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers') diff --git a/app/controllers/admin/system_info_controller.rb b/app/controllers/admin/system_info_controller.rb index ca04a17caa1..1330399a836 100644 --- a/app/controllers/admin/system_info_controller.rb +++ b/app/controllers/admin/system_info_controller.rb @@ -21,6 +21,7 @@ class Admin::SystemInfoController < Admin::ApplicationController 'mqueue', 'proc', 'pstore', + 'rpc_pipefs', 'securityfs', 'sysfs', 'tmpfs', -- cgit v1.2.1 From a29fbc213ca192af9994f61b67990172b9640855 Mon Sep 17 00:00:00 2001 From: wendy0402 Date: Sun, 19 Feb 2017 15:15:30 +0700 Subject: fix incorrect sidekiq concurrency count in admin background page --- app/controllers/admin/background_jobs_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers') diff --git a/app/controllers/admin/background_jobs_controller.rb b/app/controllers/admin/background_jobs_controller.rb index 338496013a0..c09095b9849 100644 --- a/app/controllers/admin/background_jobs_controller.rb +++ b/app/controllers/admin/background_jobs_controller.rb @@ -2,5 +2,6 @@ class Admin::BackgroundJobsController < Admin::ApplicationController def show ps_output, _ = Gitlab::Popen.popen(%W(ps -U #{Gitlab.config.gitlab.user} -o pid,pcpu,pmem,stat,start,command)) @sidekiq_processes = ps_output.split("\n").grep(/sidekiq/) + @concurrency = Sidekiq.options[:concurrency] end end -- cgit v1.2.1 From c9d687d6fed8ee9d0b9dfd1ebb55ddbb30b39fe2 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Mon, 6 Feb 2017 16:04:00 +0100 Subject: Download snippets with LF line-endings by default --- app/controllers/concerns/snippets_actions.rb | 21 +++++++++++++++++++++ app/controllers/projects/snippets_controller.rb | 13 +------------ app/controllers/snippets_controller.rb | 15 ++------------- 3 files changed, 24 insertions(+), 25 deletions(-) create mode 100644 app/controllers/concerns/snippets_actions.rb (limited to 'app/controllers') diff --git a/app/controllers/concerns/snippets_actions.rb b/app/controllers/concerns/snippets_actions.rb new file mode 100644 index 00000000000..ca6dffe1cc5 --- /dev/null +++ b/app/controllers/concerns/snippets_actions.rb @@ -0,0 +1,21 @@ +module SnippetsActions + extend ActiveSupport::Concern + + def edit + end + + def raw + send_data( + convert_line_endings(@snippet.content), + type: 'text/plain; charset=utf-8', + disposition: 'inline', + filename: @snippet.sanitized_file_name + ) + end + + private + + def convert_line_endings(content) + params[:line_ending] == 'raw' ? content : content.gsub(/\r\n/, "\n") + end +end diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index 5d193f26a8e..ef5d3d242eb 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -1,6 +1,7 @@ class Projects::SnippetsController < Projects::ApplicationController include ToggleAwardEmoji include SpammableActions + include SnippetsActions before_action :module_enabled before_action :snippet, only: [:show, :edit, :destroy, :update, :raw, :toggle_award_emoji, :mark_as_spam] @@ -49,9 +50,6 @@ class Projects::SnippetsController < Projects::ApplicationController end end - def edit - end - def update UpdateSnippetService.new(project, current_user, @snippet, snippet_params).execute @@ -74,15 +72,6 @@ class Projects::SnippetsController < Projects::ApplicationController redirect_to namespace_project_snippets_path(@project.namespace, @project) end - def raw - send_data( - @snippet.content, - type: 'text/plain; charset=utf-8', - disposition: 'inline', - filename: @snippet.sanitized_file_name - ) - end - protected def snippet diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index b169d993688..366804ab17e 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,6 +1,7 @@ class SnippetsController < ApplicationController include ToggleAwardEmoji include SpammableActions + include SnippetsActions before_action :snippet, only: [:show, :edit, :destroy, :update, :raw, :download] @@ -47,9 +48,6 @@ class SnippetsController < ApplicationController respond_with @snippet.becomes(Snippet) end - def edit - end - def update UpdateSnippetService.new(nil, current_user, @snippet, snippet_params).execute @@ -67,18 +65,9 @@ class SnippetsController < ApplicationController redirect_to snippets_path end - def raw - send_data( - @snippet.content, - type: 'text/plain; charset=utf-8', - disposition: 'inline', - filename: @snippet.sanitized_file_name - ) - end - def download send_data( - @snippet.content, + convert_line_endings(@snippet.content), type: 'text/plain; charset=utf-8', filename: @snippet.sanitized_file_name ) -- cgit v1.2.1 From beb887748e8aa3bc42376656f28b689aad91dab7 Mon Sep 17 00:00:00 2001 From: Alexandros Keramidas Date: Fri, 6 Jan 2017 21:07:27 +0200 Subject: Added support for Authentiq Back-Channel Logout --- app/controllers/omniauth_callbacks_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index f54c79c2e37..3ab7e6e0658 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -78,6 +78,13 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController handle_omniauth end + def authentiq + if params['sid'] + handle_service_ticket oauth['provider'], params['sid'] + end + handle_omniauth + end + private def handle_omniauth -- cgit v1.2.1 From 1eb72a71f54da310b2277e5890dce27c15e11036 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Tue, 21 Feb 2017 12:45:08 +1100 Subject: Refactored count_for_collection() for using pluck instead of select --- app/controllers/concerns/issuable_collections.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index d7d781cbe72..85ae4985e58 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -28,13 +28,13 @@ module IssuableCollections downvotes = issuable_votes_count.find { |votes| votes.awardable_id == id && votes.downvote? } upvotes = issuable_votes_count.find { |votes| votes.awardable_id == id && votes.upvote? } notes = issuable_note_count.find { |notes| notes.noteable_id == id } - merge_requests = issuable_merge_requests_count.find { |mr| mr.issue_id == id } + merge_requests = issuable_merge_requests_count.find { |mr| mr.first == id } issuable_meta[id] = Issuable::IssuableMeta.new( upvotes.try(:count).to_i, downvotes.try(:count).to_i, notes.try(:count).to_i, - merge_requests.try(:count).to_i + merge_requests.try(:last).to_i ) end end -- cgit v1.2.1 From 2ace39f2420abf018ceef6aaad52e4917bcbab7d Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Tue, 14 Feb 2017 17:07:11 -0200 Subject: Spam check and reCAPTCHA improvements --- app/controllers/concerns/spammable_actions.rb | 30 +++++++++++++++++----- app/controllers/projects/issues_controller.rb | 34 +++++++------------------ app/controllers/projects/snippets_controller.rb | 21 ++++++--------- app/controllers/snippets_controller.rb | 13 ++++++---- 4 files changed, 49 insertions(+), 49 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/concerns/spammable_actions.rb b/app/controllers/concerns/spammable_actions.rb index a6891149bfa..da225d8f1c7 100644 --- a/app/controllers/concerns/spammable_actions.rb +++ b/app/controllers/concerns/spammable_actions.rb @@ -17,13 +17,31 @@ module SpammableActions private - def recaptcha_params - return {} unless params[:recaptcha_verification] && Gitlab::Recaptcha.load_configurations! && verify_recaptcha + def recaptcha_check_with_fallback(&fallback) + if spammable.valid? + redirect_to spammable + elsif render_recaptcha? + if params[:recaptcha_verification] + flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.' + end + + render :verify + else + fallback.call + end + end + + def spammable_params + default_params = { request: request } + + recaptcha_check = params[:recaptcha_verification] && + Gitlab::Recaptcha.load_configurations! && + verify_recaptcha + + return default_params unless recaptcha_check - { - recaptcha_verified: true, - spam_log_id: params[:spam_log_id] - } + { recaptcha_verified: true, + spam_log_id: params[:spam_log_id] }.merge(default_params) end def spammable diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 744a4af1c51..6ef36771ac1 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -94,15 +94,15 @@ class Projects::IssuesController < Projects::ApplicationController end def create - extra_params = { request: request, - merge_request_for_resolving_discussions: merge_request_for_resolving_discussions } - extra_params.merge!(recaptcha_params) + create_params = issue_params + .merge(merge_request_for_resolving_discussions: merge_request_for_resolving_discussions) + .merge(spammable_params) - @issue = Issues::CreateService.new(project, current_user, issue_params.merge(extra_params)).execute + @issue = Issues::CreateService.new(project, current_user, create_params).execute respond_to do |format| format.html do - html_response_create + recaptcha_check_with_fallback { render :new } end format.js do @link = @issue.attachment.url.to_js @@ -111,7 +111,9 @@ class Projects::IssuesController < Projects::ApplicationController end def update - @issue = Issues::UpdateService.new(project, current_user, issue_params).execute(issue) + update_params = issue_params.merge(spammable_params) + + @issue = Issues::UpdateService.new(project, current_user, update_params).execute(issue) if params[:move_to_project_id].to_i > 0 new_project = Project.find(params[:move_to_project_id]) @@ -123,11 +125,7 @@ class Projects::IssuesController < Projects::ApplicationController respond_to do |format| format.html do - if @issue.valid? - redirect_to issue_path(@issue) - else - render :edit - end + recaptcha_check_with_fallback { render :edit } end format.json do @@ -179,20 +177,6 @@ class Projects::IssuesController < Projects::ApplicationController protected - def html_response_create - if @issue.valid? - redirect_to issue_path(@issue) - elsif render_recaptcha? - if params[:recaptcha_verification] - flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.' - end - - render :verify - else - render :new - end - end - def issue # The Sortable default scope causes performance issues when used with find_by @noteable = @issue ||= @project.issues.where(iid: params[:id]).reorder(nil).take || redirect_old diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index ef5d3d242eb..ea1a97b7cf0 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -38,24 +38,19 @@ class Projects::SnippetsController < Projects::ApplicationController end def create - create_params = snippet_params.merge(request: request) + create_params = snippet_params.merge(spammable_params) + @snippet = CreateSnippetService.new(@project, current_user, create_params).execute - if @snippet.valid? - respond_with(@snippet, - location: namespace_project_snippet_path(@project.namespace, - @project, @snippet)) - else - render :new - end + recaptcha_check_with_fallback { render :new } end def update - UpdateSnippetService.new(project, current_user, @snippet, - snippet_params).execute - respond_with(@snippet, - location: namespace_project_snippet_path(@project.namespace, - @project, @snippet)) + update_params = snippet_params.merge(spammable_params) + + UpdateSnippetService.new(project, current_user, @snippet, update_params).execute + + recaptcha_check_with_fallback { render :edit } end def show diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 366804ab17e..a632c36cfb8 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -42,16 +42,19 @@ class SnippetsController < ApplicationController end def create - create_params = snippet_params.merge(request: request) + create_params = snippet_params.merge(spammable_params) + @snippet = CreateSnippetService.new(nil, current_user, create_params).execute - respond_with @snippet.becomes(Snippet) + recaptcha_check_with_fallback { render :new } end def update - UpdateSnippetService.new(nil, current_user, @snippet, - snippet_params).execute - respond_with @snippet.becomes(Snippet) + update_params = snippet_params.merge(spammable_params) + + UpdateSnippetService.new(nil, current_user, @snippet, update_params).execute + + recaptcha_check_with_fallback { render :edit } end def show -- cgit v1.2.1 From 649c095a671f9fcf6f09449c96b145761a2d6817 Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Wed, 15 Feb 2017 16:13:53 -0600 Subject: Add filtered search to MR page --- app/controllers/projects/merge_requests_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 2bf3542d089..75971faa93e 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -50,6 +50,17 @@ class Projects::MergeRequestsController < Projects::ApplicationController @labels = LabelsFinder.new(current_user, labels_params).execute end + @users = [] + if params[:assignee_id].present? + assignee = User.find_by_id(params[:assignee_id]) + @users.push(assignee) if assignee + end + + if params[:author_id].present? + author = User.find_by_id(params[:author_id]) + @users.push(author) if author + end + respond_to do |format| format.html format.json do -- cgit v1.2.1 From 0a53a3d9664187cbd8c72c24666a8ff03f3dccec Mon Sep 17 00:00:00 2001 From: mhasbini Date: Tue, 21 Feb 2017 21:21:49 +0200 Subject: change todos counter position & format ( for large counts ) --- app/controllers/dashboard/todos_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 4e61b0886d8..ee2358b986d 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -35,6 +35,11 @@ class Dashboard::TodosController < Dashboard::ApplicationController render json: todos_counts end + # Used in TodosHelper also + def self.todos_count_format(count) + count >= 100 ? '99+' : count + end + private def find_todos -- cgit v1.2.1 From f40716f48a25809d197ba2abf32ce150b7b73efa Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Feb 2017 16:31:14 -0600 Subject: No more and/or --- app/controllers/application_controller.rb | 8 ++++---- app/controllers/import/fogbugz_controller.rb | 2 +- app/controllers/import/google_code_controller.rb | 4 ++-- app/controllers/invites_controller.rb | 4 +--- app/controllers/omniauth_callbacks_controller.rb | 2 +- app/controllers/profiles/keys_controller.rb | 4 ++-- app/controllers/projects/blob_controller.rb | 2 +- app/controllers/projects/tree_controller.rb | 4 ++-- app/controllers/snippets_controller.rb | 2 +- 9 files changed, 15 insertions(+), 17 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bf6be3d516b..5e7af3bff0d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -74,7 +74,7 @@ class ApplicationController < ActionController::Base def authenticate_user!(*args) if redirect_to_home_page_url? - redirect_to current_application_settings.home_page_url and return + return redirect_to current_application_settings.home_page_url end super(*args) @@ -131,7 +131,7 @@ class ApplicationController < ActionController::Base headers['X-UA-Compatible'] = 'IE=edge' headers['X-Content-Type-Options'] = 'nosniff' # Enabling HSTS for non-standard ports would send clients to the wrong port - if Gitlab.config.gitlab.https and Gitlab.config.gitlab.port == 443 + if Gitlab.config.gitlab.https && Gitlab.config.gitlab.port == 443 headers['Strict-Transport-Security'] = 'max-age=31536000' end end @@ -152,7 +152,7 @@ class ApplicationController < ActionController::Base def check_password_expiration if current_user && current_user.password_expires_at && current_user.password_expires_at < Time.now && !current_user.ldap_user? - redirect_to new_profile_password_path and return + return redirect_to new_profile_password_path end end @@ -218,7 +218,7 @@ class ApplicationController < ActionController::Base def require_email if current_user && current_user.temp_oauth_email? && session[:impersonator_id].nil? - redirect_to profile_path, notice: 'Please complete your profile with email address' and return + return redirect_to profile_path, notice: 'Please complete your profile with email address' end end diff --git a/app/controllers/import/fogbugz_controller.rb b/app/controllers/import/fogbugz_controller.rb index 99b10b2f9b3..5df6bd34185 100644 --- a/app/controllers/import/fogbugz_controller.rb +++ b/app/controllers/import/fogbugz_controller.rb @@ -29,7 +29,7 @@ class Import::FogbugzController < Import::BaseController unless user_map.is_a?(Hash) && user_map.all? { |k, v| !v[:name].blank? } flash.now[:alert] = 'All users must have a name.' - render 'new_user_map' and return + return render 'new_user_map' end session[:fogbugz_user_map] = user_map diff --git a/app/controllers/import/google_code_controller.rb b/app/controllers/import/google_code_controller.rb index 8d0de158f98..7d7f13ce5d5 100644 --- a/app/controllers/import/google_code_controller.rb +++ b/app/controllers/import/google_code_controller.rb @@ -44,13 +44,13 @@ class Import::GoogleCodeController < Import::BaseController rescue flash.now[:alert] = "The entered user map is not a valid JSON user map." - render "new_user_map" and return + return render "new_user_map" end unless user_map.is_a?(Hash) && user_map.all? { |k, v| k.is_a?(String) && v.is_a?(String) } flash.now[:alert] = "The entered user map is not a valid JSON user map." - render "new_user_map" and return + return render "new_user_map" end # This is the default, so let's not save it into the database. diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 58964a0e65d..7625187c7be 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -42,9 +42,7 @@ class InvitesController < ApplicationController @token = params[:id] @member = Member.find_by_invite_token(@token) - unless @member - render_404 and return - end + return render_404 unless @member @member end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 3ab7e6e0658..58d50ad647b 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -122,7 +122,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController else error_message = @user.errors.full_messages.to_sentence - redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return + return redirect_to omniauth_error_path(oauth['provider'], error: error_message) end end diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index 830e0b9591b..c8663a3c38e 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -45,13 +45,13 @@ class Profiles::KeysController < Profiles::ApplicationController if user.present? render text: user.all_ssh_keys.join("\n"), content_type: "text/plain" else - render_404 and return + return render_404 end rescue => e render text: e.message end else - render_404 and return + return render_404 end end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index a1db856dcfb..39ba815cfca 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -95,7 +95,7 @@ class Projects::BlobController < Projects::ApplicationController else if tree = @repository.tree(@commit.id, @path) if tree.entries.any? - redirect_to namespace_project_tree_path(@project.namespace, @project, File.join(@ref, @path)) and return + return redirect_to namespace_project_tree_path(@project.namespace, @project, File.join(@ref, @path)) end end diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index cb3ed0f6f9c..4f094146348 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -15,10 +15,10 @@ class Projects::TreeController < Projects::ApplicationController if tree.entries.empty? if @repository.blob_at(@commit.id, @path) - redirect_to( + return redirect_to( namespace_project_blob_path(@project.namespace, @project, File.join(@ref, @path)) - ) and return + ) elsif @path.present? return render_404 end diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 366804ab17e..445898a2e9e 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -23,7 +23,7 @@ class SnippetsController < ApplicationController if params[:username].present? @user = User.find_by(username: params[:username]) - render_404 and return unless @user + return render_404 unless @user @snippets = SnippetsFinder.new.execute(current_user, { filter: :by_user, -- cgit v1.2.1 From e6c0c334e9596a90c21a614de047e4a3652fb763 Mon Sep 17 00:00:00 2001 From: Nur Rony Date: Wed, 22 Feb 2017 13:19:09 +0600 Subject: fixes delimiter removes when todo marked as done --- app/controllers/dashboard/todos_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index ee2358b986d..5848ca62777 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -1,4 +1,6 @@ class Dashboard::TodosController < Dashboard::ApplicationController + include ActionView::Helpers::NumberHelper + before_action :find_todos, only: [:index, :destroy_all] def index @@ -48,8 +50,8 @@ class Dashboard::TodosController < Dashboard::ApplicationController def todos_counts { - count: current_user.todos_pending_count, - done_count: current_user.todos_done_count + count: number_with_delimiter(current_user.todos_pending_count), + done_count: number_with_delimiter(current_user.todos_done_count) } end end -- cgit v1.2.1