BigW Consortium Gitlab

projects.rb 1.3 KB
Newer Older
1 2 3 4 5
module Emails
  module Projects
    def project_access_granted_email(user_project_id)
      @users_project = UsersProject.find user_project_id
      @project = @users_project.project
6
      @target_url = project_url(@project)
7
      mail(to: @users_project.user.email,
8
           subject: subject("Access to project was granted"))
9 10
    end

11 12 13
    def project_was_moved_email(project_id, user_id)
      @user = User.find user_id
      @project = Project.find project_id
14
      @target_url = project_url(@project)
15
      mail(to: @user.email,
16
           subject: subject("Project was moved"))
17
    end
18

19 20 21
    def repository_push_email(project_id, recipient, author_id, branch, compare)
      @project = Project.find(project_id)
      @author  = User.find(author_id)
22
      @compare = compare
23
      @commits = Commit.decorate(compare.commits)
24 25
      @diffs   = compare.diffs
      @branch  = branch
26 27
      if @commits.length > 1
        @target_url = project_compare_url(@project, from: @commits.first, to: @commits.last)
28
        @subject = "#{@commits.length} new commits pushed to repository"
29
      else
30
        @target_url = project_commit_url(@project, @commits.first)
31
        @subject = @commits.first.title
32
      end
33

34
      mail(from: sender(author_id),
35
           to: recipient,
36
           subject: subject(@subject))
37
    end
38 39
  end
end