diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-02-13 12:01:28 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-02-13 12:02:58 +0100 |
commit | 9b917b4a73ddd7607cd19847e89381fda0ec65d5 (patch) | |
tree | 8f571ab7587c79de29cb0640422931b333f75db1 | |
parent | 522efa43fe9ff5828838a5d5ed49db23bfd88c95 (diff) | |
download | gitlab-ce-9b917b4a73ddd7607cd19847e89381fda0ec65d5.tar.gz |
Add "User created project Namespace / Project" event
-rw-r--r-- | app/models/event.rb | 12 | ||||
-rw-r--r-- | app/models/members/project_member.rb | 8 | ||||
-rw-r--r-- | app/services/event_create_service.rb | 4 | ||||
-rw-r--r-- | app/services/projects/create_service.rb | 12 |
4 files changed, 26 insertions, 10 deletions
diff --git a/app/models/event.rb b/app/models/event.rb index 87be24e31a8..cae7f0be85b 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -61,6 +61,8 @@ class Event < ActiveRecord::Base true elsif membership_changed? true + elsif created_project? + true else (issue? || merge_request? || note? || milestone?) && target end @@ -114,6 +116,14 @@ class Event < ActiveRecord::Base joined? || left? end + def created_project? + created? && !target + end + + def created_target? + created? && target + end + def milestone? target_type == "Milestone" end @@ -165,6 +175,8 @@ class Event < ActiveRecord::Base 'left' elsif commented? "commented on" + elsif created_project? + "created" else "opened" end diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb index ff05ab1590f..e4791d0f0aa 100644 --- a/app/models/members/project_member.rb +++ b/app/models/members/project_member.rb @@ -114,9 +114,11 @@ class ProjectMember < Member end def post_create_hook - - event_service.join_project(self.project, self.user) - notification_service.new_team_member(self) unless owner? + unless owner? + event_service.join_project(self.project, self.user) + notification_service.new_team_member(self) + end + system_hook_service.execute_hooks_for(self, :create) end diff --git a/app/services/event_create_service.rb b/app/services/event_create_service.rb index bb3c37023a0..ba9547b9242 100644 --- a/app/services/event_create_service.rb +++ b/app/services/event_create_service.rb @@ -58,6 +58,10 @@ class EventCreateService create_event(project, current_user, Event::LEFT) end + def create_project(project, current_user) + create_event(project, current_user, Event::CREATED) + end + def push_ref(project, current_user, ref, action = 'add', prefix = 'refs/heads') commit = project.repository.commit(ref.target) diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 139de70114b..4fe790b98f1 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -52,13 +52,7 @@ module Projects end end - if @project.persisted? - if @project.wiki_enabled? - @project.create_wiki - end - - after_create_actions - end + after_create_actions if @project.persisted? @project rescue => ex @@ -79,6 +73,10 @@ module Projects def after_create_actions log_info("#{@project.owner.name} created a new project \"#{@project.name_with_namespace}\"") + + @project.create_wiki if @project.wiki_enabled? + + event_service.create_project(@project, current_user) system_hook_service.execute_hooks_for(@project, :create) unless @project.group |