{"action":"created","comment":{"url":"https://api.github.com/repos/coreyadkins/codeguild/pulls/comments/77916724","id":77916724,"diff_hunk":"@@ -0,0 +1,167 @@\n+\"\"\"flutter Logic.\"\"\"\n+\n+from . import models\n+from django.contrib.auth import authenticate, login\n+from django.contrib.auth.models import User\n+import datetime\n+from django.test import client\n+from django.contrib.auth import logout\n+\n+\n+def create_and_save_flutt(username, body, time, user_id):\n+    \"\"\"Creates a new Flutt object and saves to the database.\n+\n+    >>> create_and_save_flutt('adkinsbass', 'Radical!', datetime.datetime(2016, 9, 2, 10, 28, 34), 0)\n+    >>> models.Flutt.objects.get(author='adkinsbass', body='Radical!')\n+    Flutt(author='adkinsbass', body='Radical!', timestamp=2016-09-02 10:28:34+00:00, author_id=0)\n+    \"\"\"\n+    if not body:\n+        raise ValueError('Empty body')\n+    else:\n+        new_flutt = models.Flutt(author=username, body=body, timestamp=time, author_id=user_id)\n+        new_flutt.save()\n+\n+\n+def get_current_time():\n+    \"\"\"Returns the server time at moment of access.\"\"\"\n+    return datetime.datetime.now()\n+\n+\n+def get_all_flutts():\n+    \"\"\"Returns all posted Flutts.\n+\n+    >>> models.Flutt(author='Fred', body='2', timestamp=datetime.datetime(2016, 9, 2, 10, 28, 34), author_id=0).save()\n+    >>> list(get_all_flutts())\n+    [Flutt(author='Fred', body='2', timestamp=2016-09-02 10:28:34+00:00, author_id=0)]\n+    \"\"\"\n+    return models.Flutt.objects.all()\n+\n+\n+def sort_flutts_by_most_recent(flutts_list):\n+    \"\"\"Takes a list of Flutts, returns them sorted by most recent.\n+\n+    >>> sort_flutts_by_most_recent([models.Flutt(author='Fred', body='2', timestamp=datetime.datetime\\\n+    (2016, 9, 2, 10, 28, 34), author_id=0), models.Flutt(author='Bob', body='1', timestamp=datetime.datetime\\\n+    (2016, 9, 2, 10, 28, 35), author_id=1)])\n+    [Flutt(author='Bob', body='1', timestamp=2016-09-02 10:28:35, author_id=1), Flutt(author='Fred', body='2', timestam\\\n+p=2016-09-02 10:28:34, author_id=0)]\n+    \"\"\"\n+    return sorted(flutts_list, key=lambda Flutt: Flutt.timestamp, reverse=True)\n+\n+\n+def get_matches_by_search_text(search_text):\n+    \"\"\"Takes a search text, searches through all posted Flutts for Flutts that contain that text, returns a list of\n+    Flutts that match.\n+\n+    >>> models.Flutt(author='Fred', body='2', timestamp=datetime.datetime(2016, 9, 2, 10, 28, 34), author_id=0).save()\n+    >>> get_matches_by_search_text(2)\n+    <QuerySet [Flutt(author='Fred', body='2', timestamp=2016-09-02 10:28:34+00:00, author_id=0)]>\n+    >>> get_matches_by_search_text(3)\n+    Traceback (most recent call last):\n+    ...\n+    LookupError: No matches\n+    \"\"\"\n+    matches = models.Flutt.objects.filter(body__contains=search_text)\n+    if not matches:\n+        raise LookupError('No matches')","path":"practice/flutter/flutter/logic.py","position":66,"original_position":66,"commit_id":"018864e9380fa042a9ddba2bfc6fa0e5ee27b456","original_commit_id":"018864e9380fa042a9ddba2bfc6fa0e5ee27b456","user":{"login":"selassid","id":921669,"avatar_url":"https://avatars.githubusercontent.com/u/921669?v=3","gravatar_id":"","url":"https://api.github.com/users/selassid","html_url":"https://github.com/selassid","followers_url":"https://api.github.com/users/selassid/followers","following_url":"https://api.github.com/users/selassid/following{/other_user}","gists_url":"https://api.github.com/users/selassid/gists{/gist_id}","starred_url":"https://api.github.com/users/selassid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selassid/subscriptions","organizations_url":"https://api.github.com/users/selassid/orgs","repos_url":"https://api.github.com/users/selassid/repos","events_url":"https://api.github.com/users/selassid/events{/privacy}","received_events_url":"https://api.github.com/users/selassid/received_events","type":"User","site_admin":false},"body":"Same comment here about the empty list being a totally great return value.","created_at":"2016-09-07T22:32:13Z","updated_at":"2016-09-07T22:32:13Z","html_url":"https://github.com/coreyadkins/codeguild/pull/18#discussion_r77916724","pull_request_url":"https://api.github.com/repos/coreyadkins/codeguild/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/coreyadkins/codeguild/pulls/comments/77916724"},"html":{"href":"https://github.com/coreyadkins/codeguild/pull/18#discussion_r77916724"},"pull_request":{"href":"https://api.github.com/repos/coreyadkins/codeguild/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/coreyadkins/codeguild/pulls/18","id":83872276,"html_url":"https://github.com/coreyadkins/codeguild/pull/18","diff_url":"https://github.com/coreyadkins/codeguild/pull/18.diff","patch_url":"https://github.com/coreyadkins/codeguild/pull/18.patch","issue_url":"https://api.github.com/repos/coreyadkins/codeguild/issues/18","number":18,"state":"open","locked":false,"title":"Flutter","user":{"login":"coreyadkins","id":20361332,"avatar_url":"https://avatars.githubusercontent.com/u/20361332?v=3","gravatar_id":"","url":"https://api.github.com/users/coreyadkins","html_url":"https://github.com/coreyadkins","followers_url":"https://api.github.com/users/coreyadkins/followers","following_url":"https://api.github.com/users/coreyadkins/following{/other_user}","gists_url":"https://api.github.com/users/coreyadkins/gists{/gist_id}","starred_url":"https://api.github.com/users/coreyadkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreyadkins/subscriptions","organizations_url":"https://api.github.com/users/coreyadkins/orgs","repos_url":"https://api.github.com/users/coreyadkins/repos","events_url":"https://api.github.com/users/coreyadkins/events{/privacy}","received_events_url":"https://api.github.com/users/coreyadkins/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-02T22:22:24Z","updated_at":"2016-09-07T22:32:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3554c3747dc721049ba4cbbc03ede119642337f1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/coreyadkins/codeguild/pulls/18/commits","review_comments_url":"https://api.github.com/repos/coreyadkins/codeguild/pulls/18/comments","review_comment_url":"https://api.github.com/repos/coreyadkins/codeguild/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreyadkins/codeguild/issues/18/comments","statuses_url":"https://api.github.com/repos/coreyadkins/codeguild/statuses/018864e9380fa042a9ddba2bfc6fa0e5ee27b456","head":{"label":"coreyadkins:flutter","ref":"flutter","sha":"018864e9380fa042a9ddba2bfc6fa0e5ee27b456","user":{"login":"coreyadkins","id":20361332,"avatar_url":"https://avatars.githubusercontent.com/u/20361332?v=3","gravatar_id":"","url":"https://api.github.com/users/coreyadkins","html_url":"https://github.com/coreyadkins","followers_url":"https://api.github.com/users/coreyadkins/followers","following_url":"https://api.github.com/users/coreyadkins/following{/other_user}","gists_url":"https://api.github.com/users/coreyadkins/gists{/gist_id}","starred_url":"https://api.github.com/users/coreyadkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreyadkins/subscriptions","organizations_url":"https://api.github.com/users/coreyadkins/orgs","repos_url":"https://api.github.com/users/coreyadkins/repos","events_url":"https://api.github.com/users/coreyadkins/events{/privacy}","received_events_url":"https://api.github.com/users/coreyadkins/received_events","type":"User","site_admin":false},"repo":{"id":62911448,"name":"codeguild","full_name":"coreyadkins/codeguild","owner":{"login":"coreyadkins","id":20361332,"avatar_url":"https://avatars.githubusercontent.com/u/20361332?v=3","gravatar_id":"","url":"https://api.github.com/users/coreyadkins","html_url":"https://github.com/coreyadkins","followers_url":"https://api.github.com/users/coreyadkins/followers","following_url":"https://api.github.com/users/coreyadkins/following{/other_user}","gists_url":"https://api.github.com/users/coreyadkins/gists{/gist_id}","starred_url":"https://api.github.com/users/coreyadkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreyadkins/subscriptions","organizations_url":"https://api.github.com/users/coreyadkins/orgs","repos_url":"https://api.github.com/users/coreyadkins/repos","events_url":"https://api.github.com/users/coreyadkins/events{/privacy}","received_events_url":"https://api.github.com/users/coreyadkins/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/coreyadkins/codeguild","description":null,"fork":false,"url":"https://api.github.com/repos/coreyadkins/codeguild","forks_url":"https://api.github.com/repos/coreyadkins/codeguild/forks","keys_url":"https://api.github.com/repos/coreyadkins/codeguild/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreyadkins/codeguild/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreyadkins/codeguild/teams","hooks_url":"https://api.github.com/repos/coreyadkins/codeguild/hooks","issue_events_url":"https://api.github.com/repos/coreyadkins/codeguild/issues/events{/number}","events_url":"https://api.github.com/repos/coreyadkins/codeguild/events","assignees_url":"https://api.github.com/repos/coreyadkins/codeguild/assignees{/user}","branches_url":"https://api.github.com/repos/coreyadkins/codeguild/branches{/branch}","tags_url":"https://api.github.com/repos/coreyadkins/codeguild/tags","blobs_url":"https://api.github.com/repos/coreyadkins/codeguild/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreyadkins/codeguild/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreyadkins/codeguild/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreyadkins/codeguild/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreyadkins/codeguild/statuses/{sha}","languages_url":"https://api.github.com/repos/coreyadkins/codeguild/languages","stargazers_url":"https://api.github.com/repos/coreyadkins/codeguild/stargazers","contributors_url":"https://api.github.com/repos/coreyadkins/codeguild/contributors","subscribers_url":"https://api.github.com/repos/coreyadkins/codeguild/subscribers","subscription_url":"https://api.github.com/repos/coreyadkins/codeguild/subscription","commits_url":"https://api.github.com/repos/coreyadkins/codeguild/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreyadkins/codeguild/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreyadkins/codeguild/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreyadkins/codeguild/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreyadkins/codeguild/contents/{+path}","compare_url":"https://api.github.com/repos/coreyadkins/codeguild/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreyadkins/codeguild/merges","archive_url":"https://api.github.com/repos/coreyadkins/codeguild/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreyadkins/codeguild/downloads","issues_url":"https://api.github.com/repos/coreyadkins/codeguild/issues{/number}","pulls_url":"https://api.github.com/repos/coreyadkins/codeguild/pulls{/number}","milestones_url":"https://api.github.com/repos/coreyadkins/codeguild/milestones{/number}","notifications_url":"https://api.github.com/repos/coreyadkins/codeguild/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreyadkins/codeguild/labels{/name}","releases_url":"https://api.github.com/repos/coreyadkins/codeguild/releases{/id}","deployments_url":"https://api.github.com/repos/coreyadkins/codeguild/deployments","created_at":"2016-07-08T19:09:37Z","updated_at":"2016-07-08T19:11:28Z","pushed_at":"2016-09-06T19:11:44Z","git_url":"git://github.com/coreyadkins/codeguild.git","ssh_url":"git@github.com:coreyadkins/codeguild.git","clone_url":"https://github.com/coreyadkins/codeguild.git","svn_url":"https://github.com/coreyadkins/codeguild","homepage":null,"size":7383,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"coreyadkins:master","ref":"master","sha":"1c2293a3ac38a53ff2b6f1a79e92b562879f5e54","user":{"login":"coreyadkins","id":20361332,"avatar_url":"https://avatars.githubusercontent.com/u/20361332?v=3","gravatar_id":"","url":"https://api.github.com/users/coreyadkins","html_url":"https://github.com/coreyadkins","followers_url":"https://api.github.com/users/coreyadkins/followers","following_url":"https://api.github.com/users/coreyadkins/following{/other_user}","gists_url":"https://api.github.com/users/coreyadkins/gists{/gist_id}","starred_url":"https://api.github.com/users/coreyadkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreyadkins/subscriptions","organizations_url":"https://api.github.com/users/coreyadkins/orgs","repos_url":"https://api.github.com/users/coreyadkins/repos","events_url":"https://api.github.com/users/coreyadkins/events{/privacy}","received_events_url":"https://api.github.com/users/coreyadkins/received_events","type":"User","site_admin":false},"repo":{"id":62911448,"name":"codeguild","full_name":"coreyadkins/codeguild","owner":{"login":"coreyadkins","id":20361332,"avatar_url":"https://avatars.githubusercontent.com/u/20361332?v=3","gravatar_id":"","url":"https://api.github.com/users/coreyadkins","html_url":"https://github.com/coreyadkins","followers_url":"https://api.github.com/users/coreyadkins/followers","following_url":"https://api.github.com/users/coreyadkins/following{/other_user}","gists_url":"https://api.github.com/users/coreyadkins/gists{/gist_id}","starred_url":"https://api.github.com/users/coreyadkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreyadkins/subscriptions","organizations_url":"https://api.github.com/users/coreyadkins/orgs","repos_url":"https://api.github.com/users/coreyadkins/repos","events_url":"https://api.github.com/users/coreyadkins/events{/privacy}","received_events_url":"https://api.github.com/users/coreyadkins/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/coreyadkins/codeguild","description":null,"fork":false,"url":"https://api.github.com/repos/coreyadkins/codeguild","forks_url":"https://api.github.com/repos/coreyadkins/codeguild/forks","keys_url":"https://api.github.com/repos/coreyadkins/codeguild/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreyadkins/codeguild/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreyadkins/codeguild/teams","hooks_url":"https://api.github.com/repos/coreyadkins/codeguild/hooks","issue_events_url":"https://api.github.com/repos/coreyadkins/codeguild/issues/events{/number}","events_url":"https://api.github.com/repos/coreyadkins/codeguild/events","assignees_url":"https://api.github.com/repos/coreyadkins/codeguild/assignees{/user}","branches_url":"https://api.github.com/repos/coreyadkins/codeguild/branches{/branch}","tags_url":"https://api.github.com/repos/coreyadkins/codeguild/tags","blobs_url":"https://api.github.com/repos/coreyadkins/codeguild/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreyadkins/codeguild/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreyadkins/codeguild/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreyadkins/codeguild/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreyadkins/codeguild/statuses/{sha}","languages_url":"https://api.github.com/repos/coreyadkins/codeguild/languages","stargazers_url":"https://api.github.com/repos/coreyadkins/codeguild/stargazers","contributors_url":"https://api.github.com/repos/coreyadkins/codeguild/contributors","subscribers_url":"https://api.github.com/repos/coreyadkins/codeguild/subscribers","subscription_url":"https://api.github.com/repos/coreyadkins/codeguild/subscription","commits_url":"https://api.github.com/repos/coreyadkins/codeguild/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreyadkins/codeguild/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreyadkins/codeguild/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreyadkins/codeguild/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreyadkins/codeguild/contents/{+path}","compare_url":"https://api.github.com/repos/coreyadkins/codeguild/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreyadkins/codeguild/merges","archive_url":"https://api.github.com/repos/coreyadkins/codeguild/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreyadkins/codeguild/downloads","issues_url":"https://api.github.com/repos/coreyadkins/codeguild/issues{/number}","pulls_url":"https://api.github.com/repos/coreyadkins/codeguild/pulls{/number}","milestones_url":"https://api.github.com/repos/coreyadkins/codeguild/milestones{/number}","notifications_url":"https://api.github.com/repos/coreyadkins/codeguild/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreyadkins/codeguild/labels{/name}","releases_url":"https://api.github.com/repos/coreyadkins/codeguild/releases{/id}","deployments_url":"https://api.github.com/repos/coreyadkins/codeguild/deployments","created_at":"2016-07-08T19:09:37Z","updated_at":"2016-07-08T19:11:28Z","pushed_at":"2016-09-06T19:11:44Z","git_url":"git://github.com/coreyadkins/codeguild.git","ssh_url":"git@github.com:coreyadkins/codeguild.git","clone_url":"https://github.com/coreyadkins/codeguild.git","svn_url":"https://github.com/coreyadkins/codeguild","homepage":null,"size":7383,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreyadkins/codeguild/pulls/18"},"html":{"href":"https://github.com/coreyadkins/codeguild/pull/18"},"issue":{"href":"https://api.github.com/repos/coreyadkins/codeguild/issues/18"},"comments":{"href":"https://api.github.com/repos/coreyadkins/codeguild/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/coreyadkins/codeguild/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/coreyadkins/codeguild/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreyadkins/codeguild/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/coreyadkins/codeguild/statuses/018864e9380fa042a9ddba2bfc6fa0e5ee27b456"}}}}
{"actor":{"display_login":"selassid"}}