2013-07-16 20:12:52 +00:00
|
|
|
class Projects::TagsController < Projects::ApplicationController
|
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_read_project!
|
|
|
|
before_filter :require_non_empty_project
|
|
|
|
|
2013-07-17 05:26:00 +00:00
|
|
|
before_filter :authorize_code_access!
|
|
|
|
before_filter :authorize_push!, only: [:create]
|
|
|
|
before_filter :authorize_admin_project!, only: [:destroy]
|
2013-07-16 20:12:52 +00:00
|
|
|
|
|
|
|
def index
|
2014-04-14 16:39:24 +00:00
|
|
|
sorted = VersionSorter.rsort(@repository.tag_names)
|
|
|
|
@tags = Kaminari.paginate_array(sorted).page(params[:page]).per(30)
|
2013-07-16 20:12:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2014-07-27 17:56:33 +00:00
|
|
|
result = CreateTagService.new.execute(@project, params[:tag_name],
|
2014-06-24 01:35:36 +00:00
|
|
|
params[:ref], params[:message],
|
|
|
|
current_user)
|
2014-07-27 17:56:33 +00:00
|
|
|
if result[:status] == :success
|
|
|
|
@tag = result[:tag]
|
|
|
|
redirect_to project_tags_path(@project)
|
|
|
|
else
|
|
|
|
@error = result[:message]
|
|
|
|
render action: 'new'
|
|
|
|
end
|
2013-07-16 20:12:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2013-07-17 12:11:03 +00:00
|
|
|
tag = @repository.find_tag(params[:id])
|
2013-07-16 20:12:52 +00:00
|
|
|
|
2013-07-17 12:11:03 +00:00
|
|
|
if tag && @repository.rm_tag(tag.name)
|
|
|
|
Event.create_ref_event(@project, current_user, tag, 'rm', 'refs/tags')
|
2013-07-16 20:12:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to project_tags_path }
|
|
|
|
format.js { render nothing: true }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|