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

39 lines
910 B
Ruby
Raw Normal View History

2015-11-26 14:37:03 +05:30
class Projects::ReleasesController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
before_action :authorize_download_code!
before_action :authorize_push_code!
before_action :tag
before_action :release
def edit
end
def update
2017-08-17 22:00:37 +05:30
# Release belongs to Tag which is not active record object,
# it exists only to save a description to each Tag.
# If description is empty we should destroy the existing record.
if release_params[:description].present?
2018-11-18 11:00:15 +05:30
release.update(release_params)
2017-08-17 22:00:37 +05:30
else
release.destroy
end
2015-11-26 14:37:03 +05:30
2017-09-10 17:25:29 +05:30
redirect_to project_tag_path(@project, @tag.name)
2015-11-26 14:37:03 +05:30
end
private
def tag
@tag ||= @repository.find_tag(params[:tag_id])
end
def release
@release ||= @project.releases.find_or_initialize_by(tag: @tag.name)
end
def release_params
params.require(:release).permit(:description)
end
end