{"action":"created","comment":{"url":"https://api.github.com/repos/eciis/web/pulls/comments/145186935","pull_request_review_id":69948973,"id":145186935,"diff_hunk":"@@ -0,0 +1,60 @@\n+\"\"\"Survey Post Model.\"\"\"\n+from models.post import Post\n+from google.appengine.ext import ndb\n+from utils import Utils\n+import datetime\n+\n+\n+class SurveyPost(Post):\n+    \"\"\"Model of survey post.\"\"\"\n+\n+    options = ndb.JsonProperty()\n+\n+    # Type of survey.\n+    type_survey = ndb.StringProperty(choices=set([\n+        'multiple_choice',\n+        'binary']))\n+\n+    # Date and time limit that survey will receive answers\n+    deadline = ndb.DateTimeProperty(required=True)\n+\n+    @staticmethod\n+    def create(data, author_key, institution_key):\n+        \"\"\"Create a post and check required fields.\"\"\"\n+        survey_post = SurveyPost()\n+        survey_post.options = Utils.toJson(data.get(\"options\"))\n+        survey_post.deadline = datetime.datetime.strptime(\n+            data.get('deadline'), \"%Y-%m-%dT%H:%M:%S\")\n+\n+        survey_post = Post.create(\n+            data, survey_post, author_key, institution_key)\n+\n+        return survey_post\n+\n+    def add_vote(self, author_key, option_id):\n+        \"\"\"Add a vote to the survey post.\"\"\"\n+        if(datetime.today() > self.deadline):\n+            raise Exception(\"Deadline for receive answers has passed.\")\n+\n+        option = self.options[option_id]\n+        if(author_key in option.voters):\n+            raise Exception(\"The user already voted for this option\")\n+        option.number_votes += 1","path":"backend/models/survey_post.py","position":42,"original_position":42,"commit_id":"53379d9520c35cc8c44a426ff406b27da00631f2","original_commit_id":"53379d9520c35cc8c44a426ff406b27da00631f2","user":{"login":"andreldsa","id":2967288,"avatar_url":"https://avatars2.githubusercontent.com/u/2967288?v=4","gravatar_id":"","url":"https://api.github.com/users/andreldsa","html_url":"https://github.com/andreldsa","followers_url":"https://api.github.com/users/andreldsa/followers","following_url":"https://api.github.com/users/andreldsa/following{/other_user}","gists_url":"https://api.github.com/users/andreldsa/gists{/gist_id}","starred_url":"https://api.github.com/users/andreldsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreldsa/subscriptions","organizations_url":"https://api.github.com/users/andreldsa/orgs","repos_url":"https://api.github.com/users/andreldsa/repos","events_url":"https://api.github.com/users/andreldsa/events{/privacy}","received_events_url":"https://api.github.com/users/andreldsa/received_events","type":"User","site_admin":false},"body":"e quando a resposta não for um +1? É preciso pensar de forma mais genérica para que seja possível extender para outros problemas.","created_at":"2017-10-17T16:41:56Z","updated_at":"2017-10-17T16:42:34Z","html_url":"https://github.com/eciis/web/pull/431#discussion_r145186935","pull_request_url":"https://api.github.com/repos/eciis/web/pulls/431","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/eciis/web/pulls/comments/145186935"},"html":{"href":"https://github.com/eciis/web/pull/431#discussion_r145186935"},"pull_request":{"href":"https://api.github.com/repos/eciis/web/pulls/431"}}},"pull_request":{"url":"https://api.github.com/repos/eciis/web/pulls/431","id":147070452,"html_url":"https://github.com/eciis/web/pull/431","diff_url":"https://github.com/eciis/web/pull/431.diff","patch_url":"https://github.com/eciis/web/pull/431.patch","issue_url":"https://api.github.com/repos/eciis/web/issues/431","number":431,"state":"open","locked":false,"title":"Survey post model server","user":{"login":"MaianaB","id":18709274,"avatar_url":"https://avatars1.githubusercontent.com/u/18709274?v=4","gravatar_id":"","url":"https://api.github.com/users/MaianaB","html_url":"https://github.com/MaianaB","followers_url":"https://api.github.com/users/MaianaB/followers","following_url":"https://api.github.com/users/MaianaB/following{/other_user}","gists_url":"https://api.github.com/users/MaianaB/gists{/gist_id}","starred_url":"https://api.github.com/users/MaianaB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaianaB/subscriptions","organizations_url":"https://api.github.com/users/MaianaB/orgs","repos_url":"https://api.github.com/users/MaianaB/repos","events_url":"https://api.github.com/users/MaianaB/events{/privacy}","received_events_url":"https://api.github.com/users/MaianaB/received_events","type":"User","site_admin":false},"body":"<p><b>Feature/Bug description:</b> Model of survey post in backend.</p>\r\n\r\n<p><b>Solution:</b> The entity is heritage of model Post with addition some attributes like 'options' and 'deadline'.</p>\r\n\r\n<p><b>TODO/FIXME:</b> Model of option\r\n{* attributes of post *,\r\n'number_votes' = 0,\r\n'voters' = []}</p>\r\n","created_at":"2017-10-17T15:16:46Z","updated_at":"2017-10-17T16:42:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b07442e0ccad08cb00996fc1d2e3a703d7987f5","assignee":{"login":"MaianaB","id":18709274,"avatar_url":"https://avatars1.githubusercontent.com/u/18709274?v=4","gravatar_id":"","url":"https://api.github.com/users/MaianaB","html_url":"https://github.com/MaianaB","followers_url":"https://api.github.com/users/MaianaB/followers","following_url":"https://api.github.com/users/MaianaB/following{/other_user}","gists_url":"https://api.github.com/users/MaianaB/gists{/gist_id}","starred_url":"https://api.github.com/users/MaianaB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaianaB/subscriptions","organizations_url":"https://api.github.com/users/MaianaB/orgs","repos_url":"https://api.github.com/users/MaianaB/repos","events_url":"https://api.github.com/users/MaianaB/events{/privacy}","received_events_url":"https://api.github.com/users/MaianaB/received_events","type":"User","site_admin":false},"assignees":[{"login":"MaianaB","id":18709274,"avatar_url":"https://avatars1.githubusercontent.com/u/18709274?v=4","gravatar_id":"","url":"https://api.github.com/users/MaianaB","html_url":"https://github.com/MaianaB","followers_url":"https://api.github.com/users/MaianaB/followers","following_url":"https://api.github.com/users/MaianaB/following{/other_user}","gists_url":"https://api.github.com/users/MaianaB/gists{/gist_id}","starred_url":"https://api.github.com/users/MaianaB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaianaB/subscriptions","organizations_url":"https://api.github.com/users/MaianaB/orgs","repos_url":"https://api.github.com/users/MaianaB/repos","events_url":"https://api.github.com/users/MaianaB/events{/privacy}","received_events_url":"https://api.github.com/users/MaianaB/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"mayzabeel","id":6525725,"avatar_url":"https://avatars3.githubusercontent.com/u/6525725?v=4","gravatar_id":"","url":"https://api.github.com/users/mayzabeel","html_url":"https://github.com/mayzabeel","followers_url":"https://api.github.com/users/mayzabeel/followers","following_url":"https://api.github.com/users/mayzabeel/following{/other_user}","gists_url":"https://api.github.com/users/mayzabeel/gists{/gist_id}","starred_url":"https://api.github.com/users/mayzabeel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mayzabeel/subscriptions","organizations_url":"https://api.github.com/users/mayzabeel/orgs","repos_url":"https://api.github.com/users/mayzabeel/repos","events_url":"https://api.github.com/users/mayzabeel/events{/privacy}","received_events_url":"https://api.github.com/users/mayzabeel/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/eciis/web/milestones/4","html_url":"https://github.com/eciis/web/milestone/4","labels_url":"https://api.github.com/repos/eciis/web/milestones/4/labels","id":2807021,"number":4,"title":"MT 4","description":"","creator":{"login":"andreldsa","id":2967288,"avatar_url":"https://avatars2.githubusercontent.com/u/2967288?v=4","gravatar_id":"","url":"https://api.github.com/users/andreldsa","html_url":"https://github.com/andreldsa","followers_url":"https://api.github.com/users/andreldsa/followers","following_url":"https://api.github.com/users/andreldsa/following{/other_user}","gists_url":"https://api.github.com/users/andreldsa/gists{/gist_id}","starred_url":"https://api.github.com/users/andreldsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreldsa/subscriptions","organizations_url":"https://api.github.com/users/andreldsa/orgs","repos_url":"https://api.github.com/users/andreldsa/repos","events_url":"https://api.github.com/users/andreldsa/events{/privacy}","received_events_url":"https://api.github.com/users/andreldsa/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":27,"state":"open","created_at":"2017-10-02T12:17:28Z","updated_at":"2017-10-17T15:16:46Z","due_on":"2017-11-25T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/eciis/web/pulls/431/commits","review_comments_url":"https://api.github.com/repos/eciis/web/pulls/431/comments","review_comment_url":"https://api.github.com/repos/eciis/web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eciis/web/issues/431/comments","statuses_url":"https://api.github.com/repos/eciis/web/statuses/53379d9520c35cc8c44a426ff406b27da00631f2","head":{"label":"eciis:survey-post-model-server","ref":"survey-post-model-server","sha":"53379d9520c35cc8c44a426ff406b27da00631f2","user":{"login":"eciis","id":28706805,"avatar_url":"https://avatars3.githubusercontent.com/u/28706805?v=4","gravatar_id":"","url":"https://api.github.com/users/eciis","html_url":"https://github.com/eciis","followers_url":"https://api.github.com/users/eciis/followers","following_url":"https://api.github.com/users/eciis/following{/other_user}","gists_url":"https://api.github.com/users/eciis/gists{/gist_id}","starred_url":"https://api.github.com/users/eciis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eciis/subscriptions","organizations_url":"https://api.github.com/users/eciis/orgs","repos_url":"https://api.github.com/users/eciis/repos","events_url":"https://api.github.com/users/eciis/events{/privacy}","received_events_url":"https://api.github.com/users/eciis/received_events","type":"Organization","site_admin":false},"repo":{"id":91336041,"name":"web","full_name":"eciis/web","owner":{"login":"eciis","id":28706805,"avatar_url":"https://avatars3.githubusercontent.com/u/28706805?v=4","gravatar_id":"","url":"https://api.github.com/users/eciis","html_url":"https://github.com/eciis","followers_url":"https://api.github.com/users/eciis/followers","following_url":"https://api.github.com/users/eciis/following{/other_user}","gists_url":"https://api.github.com/users/eciis/gists{/gist_id}","starred_url":"https://api.github.com/users/eciis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eciis/subscriptions","organizations_url":"https://api.github.com/users/eciis/orgs","repos_url":"https://api.github.com/users/eciis/repos","events_url":"https://api.github.com/users/eciis/events{/privacy}","received_events_url":"https://api.github.com/users/eciis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eciis/web","description":"AngularJS Frontend with Appengine Python Backend","fork":false,"url":"https://api.github.com/repos/eciis/web","forks_url":"https://api.github.com/repos/eciis/web/forks","keys_url":"https://api.github.com/repos/eciis/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eciis/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eciis/web/teams","hooks_url":"https://api.github.com/repos/eciis/web/hooks","issue_events_url":"https://api.github.com/repos/eciis/web/issues/events{/number}","events_url":"https://api.github.com/repos/eciis/web/events","assignees_url":"https://api.github.com/repos/eciis/web/assignees{/user}","branches_url":"https://api.github.com/repos/eciis/web/branches{/branch}","tags_url":"https://api.github.com/repos/eciis/web/tags","blobs_url":"https://api.github.com/repos/eciis/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eciis/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eciis/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/eciis/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eciis/web/statuses/{sha}","languages_url":"https://api.github.com/repos/eciis/web/languages","stargazers_url":"https://api.github.com/repos/eciis/web/stargazers","contributors_url":"https://api.github.com/repos/eciis/web/contributors","subscribers_url":"https://api.github.com/repos/eciis/web/subscribers","subscription_url":"https://api.github.com/repos/eciis/web/subscription","commits_url":"https://api.github.com/repos/eciis/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/eciis/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/eciis/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/eciis/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/eciis/web/contents/{+path}","compare_url":"https://api.github.com/repos/eciis/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eciis/web/merges","archive_url":"https://api.github.com/repos/eciis/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eciis/web/downloads","issues_url":"https://api.github.com/repos/eciis/web/issues{/number}","pulls_url":"https://api.github.com/repos/eciis/web/pulls{/number}","milestones_url":"https://api.github.com/repos/eciis/web/milestones{/number}","notifications_url":"https://api.github.com/repos/eciis/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eciis/web/labels{/name}","releases_url":"https://api.github.com/repos/eciis/web/releases{/id}","deployments_url":"https://api.github.com/repos/eciis/web/deployments","created_at":"2017-05-15T12:37:06Z","updated_at":"2017-09-22T21:03:47Z","pushed_at":"2017-10-17T15:50:31Z","git_url":"git://github.com/eciis/web.git","ssh_url":"git@github.com:eciis/web.git","clone_url":"https://github.com/eciis/web.git","svn_url":"https://github.com/eciis/web","homepage":"","size":5409,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"base":{"label":"eciis:master","ref":"master","sha":"2db668413961c2cdd933bf520b99d3037e6c46cd","user":{"login":"eciis","id":28706805,"avatar_url":"https://avatars3.githubusercontent.com/u/28706805?v=4","gravatar_id":"","url":"https://api.github.com/users/eciis","html_url":"https://github.com/eciis","followers_url":"https://api.github.com/users/eciis/followers","following_url":"https://api.github.com/users/eciis/following{/other_user}","gists_url":"https://api.github.com/users/eciis/gists{/gist_id}","starred_url":"https://api.github.com/users/eciis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eciis/subscriptions","organizations_url":"https://api.github.com/users/eciis/orgs","repos_url":"https://api.github.com/users/eciis/repos","events_url":"https://api.github.com/users/eciis/events{/privacy}","received_events_url":"https://api.github.com/users/eciis/received_events","type":"Organization","site_admin":false},"repo":{"id":91336041,"name":"web","full_name":"eciis/web","owner":{"login":"eciis","id":28706805,"avatar_url":"https://avatars3.githubusercontent.com/u/28706805?v=4","gravatar_id":"","url":"https://api.github.com/users/eciis","html_url":"https://github.com/eciis","followers_url":"https://api.github.com/users/eciis/followers","following_url":"https://api.github.com/users/eciis/following{/other_user}","gists_url":"https://api.github.com/users/eciis/gists{/gist_id}","starred_url":"https://api.github.com/users/eciis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eciis/subscriptions","organizations_url":"https://api.github.com/users/eciis/orgs","repos_url":"https://api.github.com/users/eciis/repos","events_url":"https://api.github.com/users/eciis/events{/privacy}","received_events_url":"https://api.github.com/users/eciis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eciis/web","description":"AngularJS Frontend with Appengine Python Backend","fork":false,"url":"https://api.github.com/repos/eciis/web","forks_url":"https://api.github.com/repos/eciis/web/forks","keys_url":"https://api.github.com/repos/eciis/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eciis/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eciis/web/teams","hooks_url":"https://api.github.com/repos/eciis/web/hooks","issue_events_url":"https://api.github.com/repos/eciis/web/issues/events{/number}","events_url":"https://api.github.com/repos/eciis/web/events","assignees_url":"https://api.github.com/repos/eciis/web/assignees{/user}","branches_url":"https://api.github.com/repos/eciis/web/branches{/branch}","tags_url":"https://api.github.com/repos/eciis/web/tags","blobs_url":"https://api.github.com/repos/eciis/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eciis/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eciis/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/eciis/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eciis/web/statuses/{sha}","languages_url":"https://api.github.com/repos/eciis/web/languages","stargazers_url":"https://api.github.com/repos/eciis/web/stargazers","contributors_url":"https://api.github.com/repos/eciis/web/contributors","subscribers_url":"https://api.github.com/repos/eciis/web/subscribers","subscription_url":"https://api.github.com/repos/eciis/web/subscription","commits_url":"https://api.github.com/repos/eciis/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/eciis/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/eciis/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/eciis/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/eciis/web/contents/{+path}","compare_url":"https://api.github.com/repos/eciis/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eciis/web/merges","archive_url":"https://api.github.com/repos/eciis/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eciis/web/downloads","issues_url":"https://api.github.com/repos/eciis/web/issues{/number}","pulls_url":"https://api.github.com/repos/eciis/web/pulls{/number}","milestones_url":"https://api.github.com/repos/eciis/web/milestones{/number}","notifications_url":"https://api.github.com/repos/eciis/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eciis/web/labels{/name}","releases_url":"https://api.github.com/repos/eciis/web/releases{/id}","deployments_url":"https://api.github.com/repos/eciis/web/deployments","created_at":"2017-05-15T12:37:06Z","updated_at":"2017-09-22T21:03:47Z","pushed_at":"2017-10-17T15:50:31Z","git_url":"git://github.com/eciis/web.git","ssh_url":"git@github.com:eciis/web.git","clone_url":"https://github.com/eciis/web.git","svn_url":"https://github.com/eciis/web","homepage":"","size":5409,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eciis/web/pulls/431"},"html":{"href":"https://github.com/eciis/web/pull/431"},"issue":{"href":"https://api.github.com/repos/eciis/web/issues/431"},"comments":{"href":"https://api.github.com/repos/eciis/web/issues/431/comments"},"review_comments":{"href":"https://api.github.com/repos/eciis/web/pulls/431/comments"},"review_comment":{"href":"https://api.github.com/repos/eciis/web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eciis/web/pulls/431/commits"},"statuses":{"href":"https://api.github.com/repos/eciis/web/statuses/53379d9520c35cc8c44a426ff406b27da00631f2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"andreldsa"}}