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]
|
2020-04-08 14:13:33 +05:30
|
|
|
before_action :release, only: %i[edit show update downloads]
|
2019-02-15 15:39:39 +05:30
|
|
|
before_action :authorize_read_release!
|
2019-12-21 20:55:43 +05:30
|
|
|
before_action do
|
2020-04-08 14:13:33 +05:30
|
|
|
push_frontend_feature_flag(:release_issue_summary, project, default_enabled: true)
|
2020-03-13 15:44:24 +05:30
|
|
|
push_frontend_feature_flag(:release_evidence_collection, project, default_enabled: true)
|
2020-04-08 14:13:33 +05:30
|
|
|
push_frontend_feature_flag(:release_show_page, project, default_enabled: true)
|
2020-04-22 19:07:51 +05:30
|
|
|
push_frontend_feature_flag(:release_asset_link_editing, project, default_enabled: true)
|
2020-06-23 00:09:42 +05:30
|
|
|
push_frontend_feature_flag(:release_asset_link_type, project, default_enabled: true)
|
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-07-28 23:09:34 +05:30
|
|
|
before_action :authorize_create_release!, only: :new
|
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-03-13 15:44:24 +05:30
|
|
|
def show
|
2020-04-08 14:13:33 +05:30
|
|
|
return render_404 unless Feature.enabled?(:release_show_page, project, default_enabled: true)
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
def new
|
2020-10-24 23:57:45 +05:30
|
|
|
unless Feature.enabled?(:new_release_page, project, default_enabled: true)
|
2020-07-28 23:09:34 +05:30
|
|
|
redirect_to(new_project_tag_path(@project))
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
def downloads
|
|
|
|
redirect_to link.url
|
|
|
|
end
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
private
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
def releases
|
|
|
|
ReleasesFinder.new(@project, current_user).execute
|
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_update_release!
|
|
|
|
access_denied! unless can?(current_user, :update_release, release)
|
|
|
|
end
|
|
|
|
|
|
|
|
def release
|
|
|
|
@release ||= project.releases.find_by_tag!(sanitized_tag_name)
|
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
def link
|
|
|
|
release.links.find_by_filepath!(sanitized_filepath)
|
|
|
|
end
|
|
|
|
|
|
|
|
def sanitized_filepath
|
|
|
|
CGI.unescape(params[:filepath])
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
def sanitized_tag_name
|
|
|
|
CGI.unescape(params[:tag])
|
2015-11-26 14:37:03 +05:30
|
|
|
end
|
|
|
|
end
|