2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-11-05 05:16:41 -05:00
|
|
|
class Projects::ReleasesController < Projects::ApplicationController
|
|
|
|
# Authorize
|
2019-10-28 17:06:24 -04:00
|
|
|
before_action :require_non_empty_project, except: [:index]
|
2019-10-31 23:06:26 -04:00
|
|
|
before_action :release, only: %i[edit update]
|
2018-12-13 06:08:53 -05:00
|
|
|
before_action :authorize_read_release!
|
2019-10-15 20:06:16 -04:00
|
|
|
before_action do
|
2019-11-08 07:06:32 -05:00
|
|
|
push_frontend_feature_flag(:release_issue_summary, project)
|
2019-11-22 04:06:20 -05:00
|
|
|
push_frontend_feature_flag(:release_evidence_collection, project)
|
2019-10-15 20:06:16 -04:00
|
|
|
end
|
2019-10-31 23:06:26 -04:00
|
|
|
before_action :authorize_update_release!, only: %i[edit update]
|
2020-01-02 16:07:38 -05:00
|
|
|
before_action :authorize_read_release_evidence!, only: [:evidence]
|
2018-12-10 07:03:00 -05:00
|
|
|
|
|
|
|
def index
|
2019-10-28 17:06:24 -04:00
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
|
|
|
require_non_empty_project
|
|
|
|
end
|
|
|
|
format.json { render json: releases }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-11-19 04:06:16 -05:00
|
|
|
def evidence
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render json: release.evidence_summary
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-28 17:06:24 -04:00
|
|
|
protected
|
|
|
|
|
|
|
|
def releases
|
|
|
|
ReleasesFinder.new(@project, current_user).execute
|
2018-12-10 07:03:00 -05:00
|
|
|
end
|
2019-10-31 23:06:26 -04:00
|
|
|
|
|
|
|
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-02 16:07:38 -05:00
|
|
|
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-10-31 23:06:26 -04:00
|
|
|
def release
|
|
|
|
@release ||= project.releases.find_by_tag!(sanitized_tag_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def sanitized_tag_name
|
|
|
|
CGI.unescape(params[:tag])
|
|
|
|
end
|
2015-11-05 05:16:41 -05:00
|
|
|
end
|