{"action":"created","comment":{"url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/comments/29092664","id":29092664,"diff_hunk":"@@ -122,29 +92,61 @@ def checkout_email(self, item):\n \r\n         EmailMessage(subject, message, to=to, from_email=from_email).send()\r\n \t\r\n-\r\n-    def save(self, *args, item_pk, performed_by, **kwargs):\r\n+    \r\n+    def clean(self):\r\n+    \r\n+        # require note field on action of OTHER\r\n+        cleaned_data = super().clean()\r\n+        action_choice = cleaned_data.get(\"action_choice\")\r\n+        note = cleaned_data.get(\"note\")\r\n+        first_name = cleaned_data.get(\"first_name\")\r\n+        last_name = cleaned_data.get(\"last_name\")\r\n+        email = cleaned_data.get(\"email\")\r\n         \r\n-        user_first_name = self.cleaned_data['first_name']\r\n-        user_last_name = self.cleaned_data['last_name']\r\n-        user_email = self.cleaned_data['email']\r\n+        if (str(action_choice.machine_name) == Action.RETURNED) and not first_name:\r\n+            self.add_error(\"first_name\", \"First name is required when returning item.\")\r\n         \r\n-        try:\r\n-            returned_user = User.objects.get(first_name=user_first_name, last_name=user_last_name, email=user_email)\r\n-        except User.DoesNotExist:\r\n-            returned_user = create_user(user_first_name, user_last_name, user_email)\r\n-               \r\n-        returned_item = Item.objects.get(pk=item_pk)\r\n-        returned_item.returned_to = returned_user\r\n-        returned_item.save()\r\n+        if (str(action_choice.machine_name) == Action.RETURNED) and not last_name:\r\n+            self.add_error(\"last_name\", \"Last name is required when returning item.\")\r\n+            \r\n+        if (str(action_choice.machine_name) == Action.RETURNED) and not email:\r\n+            self.add_error(\"email\", \"Email is required when returning item.\")\r\n         \r\n-        new_action = Action.objects.get(machine_name=Action.RETURNED)\r\n-        new_status = Status(item=returned_item, action_taken=new_action, performed_by=performed_by, note=\"Returned to owner\").save()\r\n+        if str(action_choice) == 'Other' and not note:\r","path":"its/items/forms.py","position":106,"original_position":106,"commit_id":"7edbc9bd0d26e41c69f4fdb36639466bf31434fa","original_commit_id":"7edbc9bd0d26e41c69f4fdb36639466bf31434fa","user":{"login":"mdj2","id":3181148,"avatar_url":"https://avatars.githubusercontent.com/u/3181148?v=3","gravatar_id":"","url":"https://api.github.com/users/mdj2","html_url":"https://github.com/mdj2","followers_url":"https://api.github.com/users/mdj2/followers","following_url":"https://api.github.com/users/mdj2/following{/other_user}","gists_url":"https://api.github.com/users/mdj2/gists{/gist_id}","starred_url":"https://api.github.com/users/mdj2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdj2/subscriptions","organizations_url":"https://api.github.com/users/mdj2/orgs","repos_url":"https://api.github.com/users/mdj2/repos","events_url":"https://api.github.com/users/mdj2/events{/privacy}","received_events_url":"https://api.github.com/users/mdj2/received_events","type":"User","site_admin":false},"body":"It looks like `Other` is a good candidate to turn into a machine name. Also, action_choice.machine_name is already a string, so you don't need the extra `str(action_choice.machine_name)` stuff everywhere.","created_at":"2015-04-24T23:01:43Z","updated_at":"2015-04-24T23:01:43Z","html_url":"https://github.com/PSU-OIT-ARC/ITS/pull/19#discussion_r29092664","pull_request_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/comments/29092664"},"html":{"href":"https://github.com/PSU-OIT-ARC/ITS/pull/19#discussion_r29092664"},"pull_request":{"href":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/19","id":33486723,"html_url":"https://github.com/PSU-OIT-ARC/ITS/pull/19","diff_url":"https://github.com/PSU-OIT-ARC/ITS/pull/19.diff","patch_url":"https://github.com/PSU-OIT-ARC/ITS/pull/19.patch","issue_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/issues/19","number":19,"state":"open","locked":false,"title":"Modified AdminActionForm to include return functionality, removed ItemReturnForm and Checkout view.","user":{"login":"pault2k14","id":9485547,"avatar_url":"https://avatars.githubusercontent.com/u/9485547?v=3","gravatar_id":"","url":"https://api.github.com/users/pault2k14","html_url":"https://github.com/pault2k14","followers_url":"https://api.github.com/users/pault2k14/followers","following_url":"https://api.github.com/users/pault2k14/following{/other_user}","gists_url":"https://api.github.com/users/pault2k14/gists{/gist_id}","starred_url":"https://api.github.com/users/pault2k14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pault2k14/subscriptions","organizations_url":"https://api.github.com/users/pault2k14/orgs","repos_url":"https://api.github.com/users/pault2k14/repos","events_url":"https://api.github.com/users/pault2k14/events{/privacy}","received_events_url":"https://api.github.com/users/pault2k14/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-16T19:58:15Z","updated_at":"2015-04-24T23:01:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8375e10b261b30e16f64199987bf69b4737e8f36","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/19/commits","review_comments_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/19/comments","review_comment_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/issues/19/comments","statuses_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/statuses/7edbc9bd0d26e41c69f4fdb36639466bf31434fa","head":{"label":"pault2k14:master","ref":"master","sha":"7edbc9bd0d26e41c69f4fdb36639466bf31434fa","user":{"login":"pault2k14","id":9485547,"avatar_url":"https://avatars.githubusercontent.com/u/9485547?v=3","gravatar_id":"","url":"https://api.github.com/users/pault2k14","html_url":"https://github.com/pault2k14","followers_url":"https://api.github.com/users/pault2k14/followers","following_url":"https://api.github.com/users/pault2k14/following{/other_user}","gists_url":"https://api.github.com/users/pault2k14/gists{/gist_id}","starred_url":"https://api.github.com/users/pault2k14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pault2k14/subscriptions","organizations_url":"https://api.github.com/users/pault2k14/orgs","repos_url":"https://api.github.com/users/pault2k14/repos","events_url":"https://api.github.com/users/pault2k14/events{/privacy}","received_events_url":"https://api.github.com/users/pault2k14/received_events","type":"User","site_admin":false},"repo":{"id":29315063,"name":"ITS","full_name":"pault2k14/ITS","owner":{"login":"pault2k14","id":9485547,"avatar_url":"https://avatars.githubusercontent.com/u/9485547?v=3","gravatar_id":"","url":"https://api.github.com/users/pault2k14","html_url":"https://github.com/pault2k14","followers_url":"https://api.github.com/users/pault2k14/followers","following_url":"https://api.github.com/users/pault2k14/following{/other_user}","gists_url":"https://api.github.com/users/pault2k14/gists{/gist_id}","starred_url":"https://api.github.com/users/pault2k14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pault2k14/subscriptions","organizations_url":"https://api.github.com/users/pault2k14/orgs","repos_url":"https://api.github.com/users/pault2k14/repos","events_url":"https://api.github.com/users/pault2k14/events{/privacy}","received_events_url":"https://api.github.com/users/pault2k14/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pault2k14/ITS","description":"ITS Lost and Found","fork":true,"url":"https://api.github.com/repos/pault2k14/ITS","forks_url":"https://api.github.com/repos/pault2k14/ITS/forks","keys_url":"https://api.github.com/repos/pault2k14/ITS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pault2k14/ITS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pault2k14/ITS/teams","hooks_url":"https://api.github.com/repos/pault2k14/ITS/hooks","issue_events_url":"https://api.github.com/repos/pault2k14/ITS/issues/events{/number}","events_url":"https://api.github.com/repos/pault2k14/ITS/events","assignees_url":"https://api.github.com/repos/pault2k14/ITS/assignees{/user}","branches_url":"https://api.github.com/repos/pault2k14/ITS/branches{/branch}","tags_url":"https://api.github.com/repos/pault2k14/ITS/tags","blobs_url":"https://api.github.com/repos/pault2k14/ITS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pault2k14/ITS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pault2k14/ITS/git/refs{/sha}","trees_url":"https://api.github.com/repos/pault2k14/ITS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pault2k14/ITS/statuses/{sha}","languages_url":"https://api.github.com/repos/pault2k14/ITS/languages","stargazers_url":"https://api.github.com/repos/pault2k14/ITS/stargazers","contributors_url":"https://api.github.com/repos/pault2k14/ITS/contributors","subscribers_url":"https://api.github.com/repos/pault2k14/ITS/subscribers","subscription_url":"https://api.github.com/repos/pault2k14/ITS/subscription","commits_url":"https://api.github.com/repos/pault2k14/ITS/commits{/sha}","git_commits_url":"https://api.github.com/repos/pault2k14/ITS/git/commits{/sha}","comments_url":"https://api.github.com/repos/pault2k14/ITS/comments{/number}","issue_comment_url":"https://api.github.com/repos/pault2k14/ITS/issues/comments{/number}","contents_url":"https://api.github.com/repos/pault2k14/ITS/contents/{+path}","compare_url":"https://api.github.com/repos/pault2k14/ITS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pault2k14/ITS/merges","archive_url":"https://api.github.com/repos/pault2k14/ITS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pault2k14/ITS/downloads","issues_url":"https://api.github.com/repos/pault2k14/ITS/issues{/number}","pulls_url":"https://api.github.com/repos/pault2k14/ITS/pulls{/number}","milestones_url":"https://api.github.com/repos/pault2k14/ITS/milestones{/number}","notifications_url":"https://api.github.com/repos/pault2k14/ITS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pault2k14/ITS/labels{/name}","releases_url":"https://api.github.com/repos/pault2k14/ITS/releases{/id}","created_at":"2015-01-15T19:49:50Z","updated_at":"2015-04-23T19:38:35Z","pushed_at":"2015-04-23T19:38:35Z","git_url":"git://github.com/pault2k14/ITS.git","ssh_url":"git@github.com:pault2k14/ITS.git","clone_url":"https://github.com/pault2k14/ITS.git","svn_url":"https://github.com/pault2k14/ITS","homepage":null,"size":452,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"PSU-OIT-ARC:master","ref":"master","sha":"5f213932b1cb2abdbd01506883f708111f363ae2","user":{"login":"PSU-OIT-ARC","id":4128706,"avatar_url":"https://avatars.githubusercontent.com/u/4128706?v=3","gravatar_id":"","url":"https://api.github.com/users/PSU-OIT-ARC","html_url":"https://github.com/PSU-OIT-ARC","followers_url":"https://api.github.com/users/PSU-OIT-ARC/followers","following_url":"https://api.github.com/users/PSU-OIT-ARC/following{/other_user}","gists_url":"https://api.github.com/users/PSU-OIT-ARC/gists{/gist_id}","starred_url":"https://api.github.com/users/PSU-OIT-ARC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PSU-OIT-ARC/subscriptions","organizations_url":"https://api.github.com/users/PSU-OIT-ARC/orgs","repos_url":"https://api.github.com/users/PSU-OIT-ARC/repos","events_url":"https://api.github.com/users/PSU-OIT-ARC/events{/privacy}","received_events_url":"https://api.github.com/users/PSU-OIT-ARC/received_events","type":"Organization","site_admin":false},"repo":{"id":27938821,"name":"ITS","full_name":"PSU-OIT-ARC/ITS","owner":{"login":"PSU-OIT-ARC","id":4128706,"avatar_url":"https://avatars.githubusercontent.com/u/4128706?v=3","gravatar_id":"","url":"https://api.github.com/users/PSU-OIT-ARC","html_url":"https://github.com/PSU-OIT-ARC","followers_url":"https://api.github.com/users/PSU-OIT-ARC/followers","following_url":"https://api.github.com/users/PSU-OIT-ARC/following{/other_user}","gists_url":"https://api.github.com/users/PSU-OIT-ARC/gists{/gist_id}","starred_url":"https://api.github.com/users/PSU-OIT-ARC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PSU-OIT-ARC/subscriptions","organizations_url":"https://api.github.com/users/PSU-OIT-ARC/orgs","repos_url":"https://api.github.com/users/PSU-OIT-ARC/repos","events_url":"https://api.github.com/users/PSU-OIT-ARC/events{/privacy}","received_events_url":"https://api.github.com/users/PSU-OIT-ARC/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PSU-OIT-ARC/ITS","description":"ITS Lost and Found","fork":false,"url":"https://api.github.com/repos/PSU-OIT-ARC/ITS","forks_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/forks","keys_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/teams","hooks_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/hooks","issue_events_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/issues/events{/number}","events_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/events","assignees_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/assignees{/user}","branches_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/branches{/branch}","tags_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/tags","blobs_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/git/refs{/sha}","trees_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/statuses/{sha}","languages_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/languages","stargazers_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/stargazers","contributors_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/contributors","subscribers_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/subscribers","subscription_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/subscription","commits_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/commits{/sha}","git_commits_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/git/commits{/sha}","comments_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/comments{/number}","issue_comment_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/issues/comments{/number}","contents_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/contents/{+path}","compare_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/merges","archive_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/downloads","issues_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/issues{/number}","pulls_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls{/number}","milestones_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/milestones{/number}","notifications_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/labels{/name}","releases_url":"https://api.github.com/repos/PSU-OIT-ARC/ITS/releases{/id}","created_at":"2014-12-12T21:27:03Z","updated_at":"2015-04-13T16:33:16Z","pushed_at":"2015-04-23T19:38:35Z","git_url":"git://github.com/PSU-OIT-ARC/ITS.git","ssh_url":"git@github.com:PSU-OIT-ARC/ITS.git","clone_url":"https://github.com/PSU-OIT-ARC/ITS.git","svn_url":"https://github.com/PSU-OIT-ARC/ITS","homepage":null,"size":754,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/19"},"html":{"href":"https://github.com/PSU-OIT-ARC/ITS/pull/19"},"issue":{"href":"https://api.github.com/repos/PSU-OIT-ARC/ITS/issues/19"},"comments":{"href":"https://api.github.com/repos/PSU-OIT-ARC/ITS/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PSU-OIT-ARC/ITS/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/PSU-OIT-ARC/ITS/statuses/7edbc9bd0d26e41c69f4fdb36639466bf31434fa"}}}}