{"action":"closed","number":1965,"pull_request":{"url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1965","id":53607278,"html_url":"https://github.com/DirectEmployers/MyJobs/pull/1965","diff_url":"https://github.com/DirectEmployers/MyJobs/pull/1965.diff","patch_url":"https://github.com/DirectEmployers/MyJobs/pull/1965.patch","issue_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/1965","number":1965,"state":"closed","locked":false,"title":"[PD-1856] Custom invitation reasons","user":{"login":"aspidites","id":93686,"avatar_url":"https://avatars.githubusercontent.com/u/93686?v=3","gravatar_id":"","url":"https://api.github.com/users/aspidites","html_url":"https://github.com/aspidites","followers_url":"https://api.github.com/users/aspidites/followers","following_url":"https://api.github.com/users/aspidites/following{/other_user}","gists_url":"https://api.github.com/users/aspidites/gists{/gist_id}","starred_url":"https://api.github.com/users/aspidites/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspidites/subscriptions","organizations_url":"https://api.github.com/users/aspidites/orgs","repos_url":"https://api.github.com/users/aspidites/repos","events_url":"https://api.github.com/users/aspidites/events{/privacy}","received_events_url":"https://api.github.com/users/aspidites/received_events","type":"User","site_admin":false},"body":"# Description\r\nAt the moment, we send send specific invitation emails depending on whether or not the invitation is associated with a saved search or a group. This PR abstracts that functionality from the template and moves it to the backend, in addition to allowing for a custom reason to be provided in the email. \r\n\r\n# Key Changes\r\n- `registration.models.Invitation.send` now takes an optional `reason` parameter\r\n- `myjobs.models.User.send_invite` now takes an optional `reason` parameter\r\n- `registration.models.Invitation` no longer automatically sends an email on creation\r\n- Conditional messages inside of the invitation email template has been moved to the `send` method.\r\n- New tests to cover each of these different template use cases. Note that I didn't give the tests a custom failure message as the default was more informative than anything I could have come up with (I tried).\r\n\r\n# Testing\r\nYou can either:\r\n- use the UI to generate the different invitation emails:\r\n    - create a saved search\r\n    - with ROLES_ENABLED set to False, create a company user\r\n    - ~~with ROLES_ENABLED add a user to a role [1]~~\r\n- generate the three conditions from the the './manage.py shell' prompt and call user.send_invite:\r\n    - with a user and company, call user.send_invite\r\n        - with and without a role\r\n        - with and without a reason\r\n    - create an invitation with and without a reason:\r\n        - attach a saved search and call send\r\n        - attach a group and call send\r\n\r\n~~[1] I don't remember if the User Management frontend allows inviting of users yet, so this may not yet be possible from a UI~~","created_at":"2015-12-14T19:06:04Z","updated_at":"2015-12-18T13:42:02Z","closed_at":"2015-12-18T13:42:01Z","merged_at":"2015-12-18T13:42:01Z","merge_commit_sha":"19ef6d7d3868873f9009d575feb0023211795172","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1965/commits","review_comments_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1965/comments","review_comment_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/1965/comments","statuses_url":"https://api.github.com/repos/DirectEmployers/MyJobs/statuses/c225282d9b668eb19b679cbd08ba369f5877bfb2","head":{"label":"DirectEmployers:pd-1856","ref":"pd-1856","sha":"c225282d9b668eb19b679cbd08ba369f5877bfb2","user":{"login":"DirectEmployers","id":381171,"avatar_url":"https://avatars.githubusercontent.com/u/381171?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectEmployers","html_url":"https://github.com/DirectEmployers","followers_url":"https://api.github.com/users/DirectEmployers/followers","following_url":"https://api.github.com/users/DirectEmployers/following{/other_user}","gists_url":"https://api.github.com/users/DirectEmployers/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectEmployers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectEmployers/subscriptions","organizations_url":"https://api.github.com/users/DirectEmployers/orgs","repos_url":"https://api.github.com/users/DirectEmployers/repos","events_url":"https://api.github.com/users/DirectEmployers/events{/privacy}","received_events_url":"https://api.github.com/users/DirectEmployers/received_events","type":"Organization","site_admin":false},"repo":{"id":2867982,"name":"MyJobs","full_name":"DirectEmployers/MyJobs","owner":{"login":"DirectEmployers","id":381171,"avatar_url":"https://avatars.githubusercontent.com/u/381171?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectEmployers","html_url":"https://github.com/DirectEmployers","followers_url":"https://api.github.com/users/DirectEmployers/followers","following_url":"https://api.github.com/users/DirectEmployers/following{/other_user}","gists_url":"https://api.github.com/users/DirectEmployers/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectEmployers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectEmployers/subscriptions","organizations_url":"https://api.github.com/users/DirectEmployers/orgs","repos_url":"https://api.github.com/users/DirectEmployers/repos","events_url":"https://api.github.com/users/DirectEmployers/events{/privacy}","received_events_url":"https://api.github.com/users/DirectEmployers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DirectEmployers/MyJobs","description":"Multi-user website designed to assist job seekers in their search for employment","fork":false,"url":"https://api.github.com/repos/DirectEmployers/MyJobs","forks_url":"https://api.github.com/repos/DirectEmployers/MyJobs/forks","keys_url":"https://api.github.com/repos/DirectEmployers/MyJobs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DirectEmployers/MyJobs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DirectEmployers/MyJobs/teams","hooks_url":"https://api.github.com/repos/DirectEmployers/MyJobs/hooks","issue_events_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/events{/number}","events_url":"https://api.github.com/repos/DirectEmployers/MyJobs/events","assignees_url":"https://api.github.com/repos/DirectEmployers/MyJobs/assignees{/user}","branches_url":"https://api.github.com/repos/DirectEmployers/MyJobs/branches{/branch}","tags_url":"https://api.github.com/repos/DirectEmployers/MyJobs/tags","blobs_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/refs{/sha}","trees_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DirectEmployers/MyJobs/statuses/{sha}","languages_url":"https://api.github.com/repos/DirectEmployers/MyJobs/languages","stargazers_url":"https://api.github.com/repos/DirectEmployers/MyJobs/stargazers","contributors_url":"https://api.github.com/repos/DirectEmployers/MyJobs/contributors","subscribers_url":"https://api.github.com/repos/DirectEmployers/MyJobs/subscribers","subscription_url":"https://api.github.com/repos/DirectEmployers/MyJobs/subscription","commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/commits{/sha}","git_commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/commits{/sha}","comments_url":"https://api.github.com/repos/DirectEmployers/MyJobs/comments{/number}","issue_comment_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/comments{/number}","contents_url":"https://api.github.com/repos/DirectEmployers/MyJobs/contents/{+path}","compare_url":"https://api.github.com/repos/DirectEmployers/MyJobs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DirectEmployers/MyJobs/merges","archive_url":"https://api.github.com/repos/DirectEmployers/MyJobs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DirectEmployers/MyJobs/downloads","issues_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues{/number}","pulls_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls{/number}","milestones_url":"https://api.github.com/repos/DirectEmployers/MyJobs/milestones{/number}","notifications_url":"https://api.github.com/repos/DirectEmployers/MyJobs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DirectEmployers/MyJobs/labels{/name}","releases_url":"https://api.github.com/repos/DirectEmployers/MyJobs/releases{/id}","created_at":"2011-11-28T15:22:36Z","updated_at":"2015-12-02T15:27:22Z","pushed_at":"2015-12-18T13:42:02Z","git_url":"git://github.com/DirectEmployers/MyJobs.git","ssh_url":"git@github.com:DirectEmployers/MyJobs.git","clone_url":"https://github.com/DirectEmployers/MyJobs.git","svn_url":"https://github.com/DirectEmployers/MyJobs","homepage":"http://my.jobs","size":34149,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":4,"forks":10,"open_issues":4,"watchers":6,"default_branch":"quality-control"}},"base":{"label":"DirectEmployers:quality-control","ref":"quality-control","sha":"453fffefb67c98d8e430e0de97af149b1876a6ce","user":{"login":"DirectEmployers","id":381171,"avatar_url":"https://avatars.githubusercontent.com/u/381171?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectEmployers","html_url":"https://github.com/DirectEmployers","followers_url":"https://api.github.com/users/DirectEmployers/followers","following_url":"https://api.github.com/users/DirectEmployers/following{/other_user}","gists_url":"https://api.github.com/users/DirectEmployers/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectEmployers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectEmployers/subscriptions","organizations_url":"https://api.github.com/users/DirectEmployers/orgs","repos_url":"https://api.github.com/users/DirectEmployers/repos","events_url":"https://api.github.com/users/DirectEmployers/events{/privacy}","received_events_url":"https://api.github.com/users/DirectEmployers/received_events","type":"Organization","site_admin":false},"repo":{"id":2867982,"name":"MyJobs","full_name":"DirectEmployers/MyJobs","owner":{"login":"DirectEmployers","id":381171,"avatar_url":"https://avatars.githubusercontent.com/u/381171?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectEmployers","html_url":"https://github.com/DirectEmployers","followers_url":"https://api.github.com/users/DirectEmployers/followers","following_url":"https://api.github.com/users/DirectEmployers/following{/other_user}","gists_url":"https://api.github.com/users/DirectEmployers/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectEmployers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectEmployers/subscriptions","organizations_url":"https://api.github.com/users/DirectEmployers/orgs","repos_url":"https://api.github.com/users/DirectEmployers/repos","events_url":"https://api.github.com/users/DirectEmployers/events{/privacy}","received_events_url":"https://api.github.com/users/DirectEmployers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DirectEmployers/MyJobs","description":"Multi-user website designed to assist job seekers in their search for employment","fork":false,"url":"https://api.github.com/repos/DirectEmployers/MyJobs","forks_url":"https://api.github.com/repos/DirectEmployers/MyJobs/forks","keys_url":"https://api.github.com/repos/DirectEmployers/MyJobs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DirectEmployers/MyJobs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DirectEmployers/MyJobs/teams","hooks_url":"https://api.github.com/repos/DirectEmployers/MyJobs/hooks","issue_events_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/events{/number}","events_url":"https://api.github.com/repos/DirectEmployers/MyJobs/events","assignees_url":"https://api.github.com/repos/DirectEmployers/MyJobs/assignees{/user}","branches_url":"https://api.github.com/repos/DirectEmployers/MyJobs/branches{/branch}","tags_url":"https://api.github.com/repos/DirectEmployers/MyJobs/tags","blobs_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/refs{/sha}","trees_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DirectEmployers/MyJobs/statuses/{sha}","languages_url":"https://api.github.com/repos/DirectEmployers/MyJobs/languages","stargazers_url":"https://api.github.com/repos/DirectEmployers/MyJobs/stargazers","contributors_url":"https://api.github.com/repos/DirectEmployers/MyJobs/contributors","subscribers_url":"https://api.github.com/repos/DirectEmployers/MyJobs/subscribers","subscription_url":"https://api.github.com/repos/DirectEmployers/MyJobs/subscription","commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/commits{/sha}","git_commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/commits{/sha}","comments_url":"https://api.github.com/repos/DirectEmployers/MyJobs/comments{/number}","issue_comment_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/comments{/number}","contents_url":"https://api.github.com/repos/DirectEmployers/MyJobs/contents/{+path}","compare_url":"https://api.github.com/repos/DirectEmployers/MyJobs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DirectEmployers/MyJobs/merges","archive_url":"https://api.github.com/repos/DirectEmployers/MyJobs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DirectEmployers/MyJobs/downloads","issues_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues{/number}","pulls_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls{/number}","milestones_url":"https://api.github.com/repos/DirectEmployers/MyJobs/milestones{/number}","notifications_url":"https://api.github.com/repos/DirectEmployers/MyJobs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DirectEmployers/MyJobs/labels{/name}","releases_url":"https://api.github.com/repos/DirectEmployers/MyJobs/releases{/id}","created_at":"2011-11-28T15:22:36Z","updated_at":"2015-12-02T15:27:22Z","pushed_at":"2015-12-18T13:42:02Z","git_url":"git://github.com/DirectEmployers/MyJobs.git","ssh_url":"git@github.com:DirectEmployers/MyJobs.git","clone_url":"https://github.com/DirectEmployers/MyJobs.git","svn_url":"https://github.com/DirectEmployers/MyJobs","homepage":"http://my.jobs","size":34149,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":4,"forks":10,"open_issues":4,"watchers":6,"default_branch":"quality-control"}},"_links":{"self":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1965"},"html":{"href":"https://github.com/DirectEmployers/MyJobs/pull/1965"},"issue":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/1965"},"comments":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/1965/comments"},"review_comments":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1965/comments"},"review_comment":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1965/commits"},"statuses":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/statuses/c225282d9b668eb19b679cbd08ba369f5877bfb2"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"tdphillips","id":3379265,"avatar_url":"https://avatars.githubusercontent.com/u/3379265?v=3","gravatar_id":"","url":"https://api.github.com/users/tdphillips","html_url":"https://github.com/tdphillips","followers_url":"https://api.github.com/users/tdphillips/followers","following_url":"https://api.github.com/users/tdphillips/following{/other_user}","gists_url":"https://api.github.com/users/tdphillips/gists{/gist_id}","starred_url":"https://api.github.com/users/tdphillips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdphillips/subscriptions","organizations_url":"https://api.github.com/users/tdphillips/orgs","repos_url":"https://api.github.com/users/tdphillips/repos","events_url":"https://api.github.com/users/tdphillips/events{/privacy}","received_events_url":"https://api.github.com/users/tdphillips/received_events","type":"User","site_admin":false},"comments":4,"review_comments":8,"commits":13,"additions":148,"deletions":67,"changed_files":9}}