debian-mirror-gitlab/app/controllers/projects/releases_controller.rb

63 lines
1.5 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2015-11-26 14:37:03 +05:30
class Projects::ReleasesController < Projects::ApplicationController
# Authorize
2019-12-26 22:10:19 +05:30
before_action :require_non_empty_project, except: [:index]
before_action :release, only: %i[edit update]
2019-02-15 15:39:39 +05:30
before_action :authorize_read_release!
2019-12-21 20:55:43 +05:30
before_action do
2019-12-26 22:10:19 +05:30
push_frontend_feature_flag(:release_issue_summary, project)
2020-01-01 13:55:28 +05:30
push_frontend_feature_flag(:release_evidence_collection, project)
2019-12-21 20:55:43 +05:30
end
2019-12-26 22:10:19 +05:30
before_action :authorize_update_release!, only: %i[edit update]
2020-01-03 18:37:03 +05:30
before_action :authorize_read_release_evidence!, only: [:evidence]
2015-11-26 14:37:03 +05:30
2019-02-15 15:39:39 +05:30
def index
2019-12-26 22:10:19 +05:30
respond_to do |format|
format.html do
require_non_empty_project
end
format.json { render json: releases }
end
end
2020-01-01 13:55:28 +05:30
def evidence
respond_to do |format|
format.json do
render json: release.evidence_summary
end
end
end
2019-12-26 22:10:19 +05:30
protected
def releases
ReleasesFinder.new(@project, current_user).execute
end
def edit
respond_to do |format|
format.html { render 'edit' }
end
end
private
def authorize_update_release!
access_denied! unless can?(current_user, :update_release, release)
end
2020-01-03 18:37:03 +05:30
def authorize_read_release_evidence!
access_denied! unless Feature.enabled?(:release_evidence, project, default_enabled: true)
access_denied! unless can?(current_user, :read_release_evidence, release)
end
2019-12-26 22:10:19 +05:30
def release
@release ||= project.releases.find_by_tag!(sanitized_tag_name)
end
def sanitized_tag_name
CGI.unescape(params[:tag])
2015-11-26 14:37:03 +05:30
end
end