Welcome to mirror list, hosted at ThFree Co, Russian Federation.

update_service.rb « plan_limits « admin « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a71d1f141125703684244dae85fc11f42efa73b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

module Admin
  module PlanLimits
    class UpdateService < ::BaseService
      def initialize(params = {}, current_user:, plan:)
        @current_user = current_user
        @params = params
        @plan = plan
      end

      def execute
        return error(_('Access denied'), :forbidden) unless can_update?

        if plan.actual_limits.update(parsed_params)
          success
        else
          error(plan.actual_limits.errors.full_messages, :bad_request)
        end
      end

      private

      attr_accessor :current_user, :params, :plan

      def can_update?
        current_user.can_admin_all_resources?
      end

      # Overridden in EE
      def parsed_params
        params
      end
    end
  end
end

Admin::PlanLimits::UpdateService.prepend_mod_with('Admin::PlanLimits::UpdateService')