debian-mirror-gitlab/app/controllers/groups/milestones_controller.rb

56 lines
1.3 KiB
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
class Groups::MilestonesController < Groups::ApplicationController
2015-11-26 14:37:03 +05:30
include GlobalMilestones
before_action :projects
before_action :milestones, only: [:index]
before_action :milestone, only: [:show, :update]
before_action :authorize_group_milestone!, only: [:create, :update]
2014-09-02 18:07:02 +05:30
def index
end
2015-11-26 14:37:03 +05:30
def new
@milestone = Milestone.new
2014-09-02 18:07:02 +05:30
end
2015-11-26 14:37:03 +05:30
def create
project_ids = params[:milestone][:project_ids]
title = milestone_params[:title]
2014-09-02 18:07:02 +05:30
2015-11-26 14:37:03 +05:30
@group.projects.where(id: project_ids).each do |project|
Milestones::CreateService.new(project, current_user, milestone_params).execute
2014-09-02 18:07:02 +05:30
end
2015-11-26 14:37:03 +05:30
redirect_to milestone_path(title)
end
def show
end
def update
@milestone.milestones.each do |milestone|
Milestones::UpdateService.new(milestone.project, current_user, milestone_params).execute(milestone)
2014-09-02 18:07:02 +05:30
end
2015-11-26 14:37:03 +05:30
redirect_back_or_default(default: milestone_path(@milestone.title))
2014-09-02 18:07:02 +05:30
end
private
2015-11-26 14:37:03 +05:30
def authorize_group_milestone!
return render_404 unless can?(current_user, :admin_milestones, group)
2014-09-02 18:07:02 +05:30
end
2015-11-26 14:37:03 +05:30
def milestone_params
params.require(:milestone).permit(:title, :description, :due_date, :state_event)
2014-09-02 18:07:02 +05:30
end
2015-11-26 14:37:03 +05:30
def milestone_path(title)
2015-12-23 02:04:40 +05:30
group_milestone_path(@group, title.to_slug.to_s, title: title)
2014-09-02 18:07:02 +05:30
end
2015-11-26 14:37:03 +05:30
def projects
@projects ||= @group.projects
2014-09-02 18:07:02 +05:30
end
end