Commit 75dd7042940cc6fe7532d42612e1b0db0729a86d
1 parent
d188adfd
Exists in
master
and in
4 other branches
Send update instructions after project namespace id changed or namespace path changed
Showing
5 changed files
with
47 additions
and
2 deletions
Show diff stats
app/mailers/notify.rb
... | ... | @@ -102,6 +102,12 @@ class Notify < ActionMailer::Base |
102 | 102 | end |
103 | 103 | |
104 | 104 | |
105 | + def project_was_moved_email(user_project_id) | |
106 | + @users_project = UsersProject.find user_project_id | |
107 | + @project = @users_project.project | |
108 | + mail(to: @users_project.user.email, | |
109 | + subject: subject("project was moved")) | |
110 | + end | |
105 | 111 | |
106 | 112 | # |
107 | 113 | # User | ... | ... |
app/models/namespace.rb
... | ... | @@ -59,7 +59,10 @@ class Namespace < ActiveRecord::Base |
59 | 59 | if File.exists?(new_path) |
60 | 60 | raise "Already exists" |
61 | 61 | end |
62 | - system("mv #{old_path} #{new_path}") | |
62 | + | |
63 | + if system("mv #{old_path} #{new_path}") | |
64 | + send_update_instructions | |
65 | + end | |
63 | 66 | end |
64 | 67 | end |
65 | 68 | |
... | ... | @@ -67,4 +70,8 @@ class Namespace < ActiveRecord::Base |
67 | 70 | dir_path = File.join(Gitlab.config.gitolite.repos_path, path) |
68 | 71 | system("rm -rf #{dir_path}") |
69 | 72 | end |
73 | + | |
74 | + def send_update_instructions | |
75 | + projects.each(&:send_move_instructions) | |
76 | + end | |
70 | 77 | end | ... | ... |
app/models/project.rb
app/observers/project_observer.rb
... | ... | @@ -0,0 +1,25 @@ |
1 | +%td.content{align: "left", style: "font-family: Helvetica, Arial, sans-serif; padding: 20px 0 0;", valign: "top", width: "600"} | |
2 | + %table{border: "0", cellpadding: "0", cellspacing: "0", style: "color: #555; font: normal 11px Helvetica, Arial, sans-serif; margin: 0; padding: 0;", width: "600"} | |
3 | + %tr | |
4 | + %td{width: "21"} | |
5 | + %td | |
6 | + %h3 | |
7 | + = "Project was moved in another location" | |
8 | + %td{width: "21"} | |
9 | + %tr | |
10 | + %td{width: "21"} | |
11 | + %td | |
12 | + %p | |
13 | + Project is now accessible via next link | |
14 | + = link_to project_url(@project) do | |
15 | + = @project.name_with_namespace | |
16 | + %p | |
17 | + You may want to update your local repository with new remote: | |
18 | + %br | |
19 | + %table{border: "0", cellpadding: "0", cellspacing: "0", width: "558"} | |
20 | + %tr | |
21 | + %td{valign: "top"} | |
22 | + %p{ style: "background:#f5f5f5; padding:10px; border:1px solid #ddd" } | |
23 | + git remote set-url origin #{@project.ssh_url_to_repo} | |
24 | + %br | |
25 | + %td{ width: "21"} | ... | ... |