summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-20 22:16:51 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-20 22:16:51 +0200
commit75dd7042940cc6fe7532d42612e1b0db0729a86d (patch)
treea82b4952de732c19cf4df421ffb91d19af9cc423 /app
parentd188adfd97417be489df8a1cef2ca3bf986676ee (diff)
downloadgitlab-ce-75dd7042940cc6fe7532d42612e1b0db0729a86d.tar.gz
Send update instructions after project namespace id changed or namespace path changed
Diffstat (limited to 'app')
-rw-r--r--app/mailers/notify.rb6
-rw-r--r--app/models/namespace.rb9
-rw-r--r--app/models/project.rb6
-rw-r--r--app/observers/project_observer.rb3
-rw-r--r--app/views/notify/project_was_moved_email.html.haml25
5 files changed, 47 insertions, 2 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index f954a05c883..ab35677fb64 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -102,6 +102,12 @@ class Notify < ActionMailer::Base
end
+ def project_was_moved_email(user_project_id)
+ @users_project = UsersProject.find user_project_id
+ @project = @users_project.project
+ mail(to: @users_project.user.email,
+ subject: subject("project was moved"))
+ end
#
# User
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 3c087e26c19..8c90f5aee26 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -59,7 +59,10 @@ class Namespace < ActiveRecord::Base
if File.exists?(new_path)
raise "Already exists"
end
- system("mv #{old_path} #{new_path}")
+
+ if system("mv #{old_path} #{new_path}")
+ send_update_instructions
+ end
end
end
@@ -67,4 +70,8 @@ class Namespace < ActiveRecord::Base
dir_path = File.join(Gitlab.config.gitolite.repos_path, path)
system("rm -rf #{dir_path}")
end
+
+ def send_update_instructions
+ projects.each(&:send_move_instructions)
+ end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 6a427fddfac..3e5c912e0b4 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -259,4 +259,10 @@ class Project < ActiveRecord::Base
merge_requests
end
end
+
+ def send_move_instructions
+ self.users_projects.each do |member|
+ Notify.project_was_moved_email(member.id).deliver
+ end
+ end
end
diff --git a/app/observers/project_observer.rb b/app/observers/project_observer.rb
index bd41e51e8e4..b1c694569d7 100644
--- a/app/observers/project_observer.rb
+++ b/app/observers/project_observer.rb
@@ -3,7 +3,8 @@ class ProjectObserver < ActiveRecord::Observer
project.update_repository
end
- def after_save(project)
+ def after_update(project)
+ project.send_move_instructions if project.namespace_id_changed?
end
def after_destroy(project)
diff --git a/app/views/notify/project_was_moved_email.html.haml b/app/views/notify/project_was_moved_email.html.haml
new file mode 100644
index 00000000000..e81ae70ba5a
--- /dev/null
+++ b/app/views/notify/project_was_moved_email.html.haml
@@ -0,0 +1,25 @@
+%td.content{align: "left", style: "font-family: Helvetica, Arial, sans-serif; padding: 20px 0 0;", valign: "top", width: "600"}
+ %table{border: "0", cellpadding: "0", cellspacing: "0", style: "color: #555; font: normal 11px Helvetica, Arial, sans-serif; margin: 0; padding: 0;", width: "600"}
+ %tr
+ %td{width: "21"}
+ %td
+ %h3
+ = "Project was moved in another location"
+ %td{width: "21"}
+ %tr
+ %td{width: "21"}
+ %td
+ %p
+ Project is now accessible via next link
+ = link_to project_url(@project) do
+ = @project.name_with_namespace
+ %p
+ You may want to update your local repository with new remote:
+ %br
+ %table{border: "0", cellpadding: "0", cellspacing: "0", width: "558"}
+ %tr
+ %td{valign: "top"}
+ %p{ style: "background:#f5f5f5; padding:10px; border:1px solid #ddd" }
+ git remote set-url origin #{@project.ssh_url_to_repo}
+ %br
+ %td{ width: "21"}