summaryrefslogtreecommitdiff
path: root/app/controllers/groups
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-13 16:07:27 +0100
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-16 14:07:38 +0100
commit05335a3c8584c48a9317bd0919eccee6948de742 (patch)
tree9f3e533c6fc1fa1169d3e5a0a965d4103f37f19c /app/controllers/groups
parent1328e4b504773ff98d716fd561dbc50fd7652a36 (diff)
downloadgitlab-ce-05335a3c8584c48a9317bd0919eccee6948de742.tar.gz
Create milestones in the group
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/groups')
-rw-r--r--app/controllers/groups/milestones_controller.rb36
1 files changed, 31 insertions, 5 deletions
diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb
index 669f7f3126d..8779376d93c 100644
--- a/app/controllers/groups/milestones_controller.rb
+++ b/app/controllers/groups/milestones_controller.rb
@@ -1,16 +1,34 @@
class Groups::MilestonesController < Groups::ApplicationController
before_action :authorize_group_milestone!, only: :update
+ before_action :group
def index
- project_milestones = case params[:state]
- when 'all'; state
- when 'closed'; state('closed')
- else state('active')
- end
+ project_milestones =
+ case params[:state]
+ when 'all'; state
+ when 'closed'; state('closed')
+ else state('active')
+ end
+
@group_milestones = Milestones::GroupService.new(project_milestones).execute
@group_milestones = Kaminari.paginate_array(@group_milestones).page(params[:page]).per(PER_PAGE)
end
+ def new
+ @group_milestone = OpenStruct.new(title: nil, description: nil)
+ end
+
+ def create
+ project_ids = params[:milestone][:project_ids]
+ title = milestone_params[:title]
+
+ @group.projects.where(id: project_ids).each do |project|
+ Milestones::CreateService.new(project, current_user, milestone_params).execute
+ end
+
+ redirect_to group_milestone_path(@group, title.parameterize, title: title)
+ end
+
def show
project_milestones = Milestone.where(project_id: group.projects).order("due_date ASC")
@group_milestone = Milestones::GroupService.new(project_milestones).milestone(title)
@@ -51,4 +69,12 @@ class Groups::MilestonesController < Groups::ApplicationController
def authorize_group_milestone!
return render_404 unless can?(current_user, :admin_group, group)
end
+
+ def milestone_params
+ params.require(:milestone).permit(
+ :title,
+ :description,
+ :due_date
+ )
+ end
end