{"action":"created","comment":{"url":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/comments/50325366","id":50325366,"diff_hunk":"@@ -0,0 +1,69 @@\n+from django import forms\n+from django.core.exceptions import ValidationError\n+from django.forms import ModelForm\n+from django.utils.timezone import now\n+from exdb.models import Experience\n+\n+\n+class ExperienceSaveForm(ModelForm):\n+\n+    class Meta:\n+        model = Experience\n+        fields = ['name', 'description', 'planners', 'start_datetime', 'end_datetime', 'type',\n+                  'sub_type', 'recognition', 'audience', 'attendance', 'keywords', 'goal', 'guest',\n+                  'guest_office']\n+        \n+        widgets = {\n+            'description': forms.Textarea(attrs={'cols': 40, 'rows': 4}),\n+            'goal': forms.Textarea(attrs={'cols': 40, 'rows': 4}),\n+            'start_datetime': forms.SelectDateWidget(),\n+            'end_datetime': forms.SelectDateWidget(),\n+        }\n+\n+        labels = {\n+            'start_datetime': 'Start Time',\n+            'end_datetime': 'End Time',\n+        }\n+\n+    def __init__(self, *args, **kwargs):\n+        self.when = kwargs.pop('when', now())\n+        return super(ExperienceSaveForm, self).__init__(*args, **kwargs)\n+\n+\n+class ExperienceSubmitForm(ExperienceSaveForm):\n+    def clean(self):\n+\n+        if not self.cleaned_data.get('end_datetime'):\n+            raise ValidationError(\"Need a end date!\")\n+\n+        if not self.cleaned_data.get('start_datetime'):\n+            raise ValidationError(\"Need a start time!\")\n+\n+        if not self.cleaned_data.get('sub_type'):\n+            raise ValidationError(\"Need a subType\")\n+\n+        if not self.cleaned_data.get('type'):\n+            raise ValidationError(\"Need a subType\")\n+\n+        if self.cleaned_data.get('start_datetime') >= self.cleaned_data.get('end_datetime'):\n+            raise ValidationError(\"Start date must be before end date\")\n+\n+        if not self.cleaned_data.get('type').needs_verification and self.cleaned_data.get('start_datetime') > self.when:\n+            raise ValidationError(\"Spontaneous experiences must have happened in the past\")\n+\n+        if self.cleaned_data.get('type').needs_verification and self.cleaned_data.get('start_datetime') < self.when:\n+            raise ValidationError(\"Only Spontaneous events can happen in the past\")\n+\n+        if not self.cleaned_data.get('type').needs_verification and not self.cleaned_data.get('attendance'):\n+            raise ValidationError(\"Spontaneous events must have an attendance\")\n+\n+        if not self.cleaned_data.get('type').needs_verification and not self.cleaned_data.get('audience'):\n+            raise ValidationError(\"Spontaneous events must have an attendance\")\n+\n+        if not self.cleaned_data.get('type').needs_verification and self.cleaned_data.get('attendance') and self.cleaned_data.get('attendance') < 1:\n+            raise ValidationError(\"Spontaneous events must have an attendance greater than 0\")\n+\n+        if self.cleaned_data.get('type').needs_verification and self.cleaned_data.get('attendance'):\n+            raise ValidationError(\"Future events cannot have an attendance\")\n+\n+        return self.cleaned_data","path":"exdb/forms.py","position":69,"original_position":69,"commit_id":"c1e2d4c4690e287b9595e1d243ce9b47a281f65f","original_commit_id":"c1e2d4c4690e287b9595e1d243ce9b47a281f65f","user":{"login":"shaneallgeier","id":1827786,"avatar_url":"https://avatars.githubusercontent.com/u/1827786?v=3","gravatar_id":"","url":"https://api.github.com/users/shaneallgeier","html_url":"https://github.com/shaneallgeier","followers_url":"https://api.github.com/users/shaneallgeier/followers","following_url":"https://api.github.com/users/shaneallgeier/following{/other_user}","gists_url":"https://api.github.com/users/shaneallgeier/gists{/gist_id}","starred_url":"https://api.github.com/users/shaneallgeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaneallgeier/subscriptions","organizations_url":"https://api.github.com/users/shaneallgeier/orgs","repos_url":"https://api.github.com/users/shaneallgeier/repos","events_url":"https://api.github.com/users/shaneallgeier/events{/privacy}","received_events_url":"https://api.github.com/users/shaneallgeier/received_events","type":"User","site_admin":false},"body":"Every instance of \"spontaneous\" should be replaced with `self.cleaned_data.get('type').name`. You might also consider creating a local variable set to `self.cleaned_data.get('type')` and use that instead since `self.cleaned_data.get('type')` is repeated so often.","created_at":"2016-01-20T21:53:33Z","updated_at":"2016-01-20T21:53:33Z","html_url":"https://github.com/mostateresnet/exdbproject/pull/8#discussion_r50325366","pull_request_url":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/comments/50325366"},"html":{"href":"https://github.com/mostateresnet/exdbproject/pull/8#discussion_r50325366"},"pull_request":{"href":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/8","id":56205474,"html_url":"https://github.com/mostateresnet/exdbproject/pull/8","diff_url":"https://github.com/mostateresnet/exdbproject/pull/8.diff","patch_url":"https://github.com/mostateresnet/exdbproject/pull/8.patch","issue_url":"https://api.github.com/repos/mostateresnet/exdbproject/issues/8","number":8,"state":"open","locked":false,"title":"6 create experience view","user":{"login":"enki211","id":11928681,"avatar_url":"https://avatars.githubusercontent.com/u/11928681?v=3","gravatar_id":"","url":"https://api.github.com/users/enki211","html_url":"https://github.com/enki211","followers_url":"https://api.github.com/users/enki211/followers","following_url":"https://api.github.com/users/enki211/following{/other_user}","gists_url":"https://api.github.com/users/enki211/gists{/gist_id}","starred_url":"https://api.github.com/users/enki211/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enki211/subscriptions","organizations_url":"https://api.github.com/users/enki211/orgs","repos_url":"https://api.github.com/users/enki211/repos","events_url":"https://api.github.com/users/enki211/events{/privacy}","received_events_url":"https://api.github.com/users/enki211/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-15T18:42:18Z","updated_at":"2016-01-20T21:53:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06d1ea30330b39c7616e05085765e9adc7902ef2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/8/commits","review_comments_url":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/8/comments","review_comment_url":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mostateresnet/exdbproject/issues/8/comments","statuses_url":"https://api.github.com/repos/mostateresnet/exdbproject/statuses/c1e2d4c4690e287b9595e1d243ce9b47a281f65f","head":{"label":"mostateresnet:6-create-experience-view","ref":"6-create-experience-view","sha":"c1e2d4c4690e287b9595e1d243ce9b47a281f65f","user":{"login":"mostateresnet","id":1827779,"avatar_url":"https://avatars.githubusercontent.com/u/1827779?v=3","gravatar_id":"","url":"https://api.github.com/users/mostateresnet","html_url":"https://github.com/mostateresnet","followers_url":"https://api.github.com/users/mostateresnet/followers","following_url":"https://api.github.com/users/mostateresnet/following{/other_user}","gists_url":"https://api.github.com/users/mostateresnet/gists{/gist_id}","starred_url":"https://api.github.com/users/mostateresnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mostateresnet/subscriptions","organizations_url":"https://api.github.com/users/mostateresnet/orgs","repos_url":"https://api.github.com/users/mostateresnet/repos","events_url":"https://api.github.com/users/mostateresnet/events{/privacy}","received_events_url":"https://api.github.com/users/mostateresnet/received_events","type":"Organization","site_admin":false},"repo":{"id":44201056,"name":"exdbproject","full_name":"mostateresnet/exdbproject","owner":{"login":"mostateresnet","id":1827779,"avatar_url":"https://avatars.githubusercontent.com/u/1827779?v=3","gravatar_id":"","url":"https://api.github.com/users/mostateresnet","html_url":"https://github.com/mostateresnet","followers_url":"https://api.github.com/users/mostateresnet/followers","following_url":"https://api.github.com/users/mostateresnet/following{/other_user}","gists_url":"https://api.github.com/users/mostateresnet/gists{/gist_id}","starred_url":"https://api.github.com/users/mostateresnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mostateresnet/subscriptions","organizations_url":"https://api.github.com/users/mostateresnet/orgs","repos_url":"https://api.github.com/users/mostateresnet/repos","events_url":"https://api.github.com/users/mostateresnet/events{/privacy}","received_events_url":"https://api.github.com/users/mostateresnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mostateresnet/exdbproject","description":"","fork":false,"url":"https://api.github.com/repos/mostateresnet/exdbproject","forks_url":"https://api.github.com/repos/mostateresnet/exdbproject/forks","keys_url":"https://api.github.com/repos/mostateresnet/exdbproject/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mostateresnet/exdbproject/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mostateresnet/exdbproject/teams","hooks_url":"https://api.github.com/repos/mostateresnet/exdbproject/hooks","issue_events_url":"https://api.github.com/repos/mostateresnet/exdbproject/issues/events{/number}","events_url":"https://api.github.com/repos/mostateresnet/exdbproject/events","assignees_url":"https://api.github.com/repos/mostateresnet/exdbproject/assignees{/user}","branches_url":"https://api.github.com/repos/mostateresnet/exdbproject/branches{/branch}","tags_url":"https://api.github.com/repos/mostateresnet/exdbproject/tags","blobs_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/refs{/sha}","trees_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mostateresnet/exdbproject/statuses/{sha}","languages_url":"https://api.github.com/repos/mostateresnet/exdbproject/languages","stargazers_url":"https://api.github.com/repos/mostateresnet/exdbproject/stargazers","contributors_url":"https://api.github.com/repos/mostateresnet/exdbproject/contributors","subscribers_url":"https://api.github.com/repos/mostateresnet/exdbproject/subscribers","subscription_url":"https://api.github.com/repos/mostateresnet/exdbproject/subscription","commits_url":"https://api.github.com/repos/mostateresnet/exdbproject/commits{/sha}","git_commits_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/commits{/sha}","comments_url":"https://api.github.com/repos/mostateresnet/exdbproject/comments{/number}","issue_comment_url":"https://api.github.com/repos/mostateresnet/exdbproject/issues/comments{/number}","contents_url":"https://api.github.com/repos/mostateresnet/exdbproject/contents/{+path}","compare_url":"https://api.github.com/repos/mostateresnet/exdbproject/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mostateresnet/exdbproject/merges","archive_url":"https://api.github.com/repos/mostateresnet/exdbproject/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mostateresnet/exdbproject/downloads","issues_url":"https://api.github.com/repos/mostateresnet/exdbproject/issues{/number}","pulls_url":"https://api.github.com/repos/mostateresnet/exdbproject/pulls{/number}","milestones_url":"https://api.github.com/repos/mostateresnet/exdbproject/milestones{/number}","notifications_url":"https://api.github.com/repos/mostateresnet/exdbproject/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mostateresnet/exdbproject/labels{/name}","releases_url":"https://api.github.com/repos/mostateresnet/exdbproject/releases{/id}","created_at":"2015-10-13T19:55:07Z","updated_at":"2016-01-15T16:52:15Z","pushed_at":"2016-01-19T19:33:25Z","git_url":"git://github.com/mostateresnet/exdbproject.git","ssh_url":"git@github.com:mostateresnet/exdbproject.git","clone_url":"https://github.com/mostateresnet/exdbproject.git","svn_url":"https://github.com/mostateresnet/exdbproject","homepage":null,"size":140,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"mostateresnet:master","ref":"master","sha":"7b26bf15bfaf66e64eb3415151c514c757e90f48","user":{"login":"mostateresnet","id":1827779,"avatar_url":"https://avatars.githubusercontent.com/u/1827779?v=3","gravatar_id":"","url":"https://api.github.com/users/mostateresnet","html_url":"https://github.com/mostateresnet","followers_url":"https://api.github.com/users/mostateresnet/followers","following_url":"https://api.github.com/users/mostateresnet/following{/other_user}","gists_url":"https://api.github.com/users/mostateresnet/gists{/gist_id}","starred_url":"https://api.github.com/users/mostateresnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mostateresnet/subscriptions","organizations_url":"https://api.github.com/users/mostateresnet/orgs","repos_url":"https://api.github.com/users/mostateresnet/repos","events_url":"https://api.github.com/users/mostateresnet/events{/privacy}","received_events_url":"https://api.github.com/users/mostateresnet/received_events","type":"Organization","site_admin":false},"repo":{"id":44201056,"name":"exdbproject","full_name":"mostateresnet/exdbproject","owner":{"login":"mostateresnet","id":1827779,"avatar_url":"https://avatars.githubusercontent.com/u/1827779?v=3","gravatar_id":"","url":"https://api.github.com/users/mostateresnet","html_url":"https://github.com/mostateresnet","followers_url":"https://api.github.com/users/mostateresnet/followers","following_url":"https://api.github.com/users/mostateresnet/following{/other_user}","gists_url":"https://api.github.com/users/mostateresnet/gists{/gist_id}","starred_url":"https://api.github.com/users/mostateresnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mostateresnet/subscriptions","organizations_url":"https://api.github.com/users/mostateresnet/orgs","repos_url":"https://api.github.com/users/mostateresnet/repos","events_url":"https://api.github.com/users/mostateresnet/events{/privacy}","received_events_url":"https://api.github.com/users/mostateresnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mostateresnet/exdbproject","description":"","fork":false,"url":"https://api.github.com/repos/mostateresnet/exdbproject","forks_url":"https://api.github.com/repos/mostateresnet/exdbproject/forks","keys_url":"https://api.github.com/repos/mostateresnet/exdbproject/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mostateresnet/exdbproject/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mostateresnet/exdbproject/teams","hooks_url":"https://api.github.com/repos/mostateresnet/exdbproject/hooks","issue_events_url":"https://api.github.com/repos/mostateresnet/exdbproject/issues/events{/number}","events_url":"https://api.github.com/repos/mostateresnet/exdbproject/events","assignees_url":"https://api.github.com/repos/mostateresnet/exdbproject/assignees{/user}","branches_url":"https://api.github.com/repos/mostateresnet/exdbproject/branches{/branch}","tags_url":"https://api.github.com/repos/mostateresnet/exdbproject/tags","blobs_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/refs{/sha}","trees_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mostateresnet/exdbproject/statuses/{sha}","languages_url":"https://api.github.com/repos/mostateresnet/exdbproject/languages","stargazers_url":"https://api.github.com/repos/mostateresnet/exdbproject/stargazers","contributors_url":"https://api.github.com/repos/mostateresnet/exdbproject/contributors","subscribers_url":"https://api.github.com/repos/mostateresnet/exdbproject/subscribers","subscription_url":"https://api.github.com/repos/mostateresnet/exdbproject/subscription","commits_url":"https://api.github.com/repos/mostateresnet/exdbproject/commits{/sha}","git_commits_url":"https://api.github.com/repos/mostateresnet/exdbproject/git/commits{/sha}","comments_url":"https://api.github.com/repos/mostateresnet/exdbproject/comments{/number}","issue_comment_url":"https://api.github.com/repos/mostateresnet/exdbproject/issues/comments{/number}","contents_url":"https://api.github.com/repos/mostateresnet/exdbproject/contents/{+path}","compare_url":"https://api.github.com/repos/mostateresnet/exdbproject/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mostateresnet/exdbproject/merges","archive_url":"https://api.github.com/repos/mostateresnet/exdbproject/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mostateresnet/exdbproject/downloads","issues_url":"https://api.github.com/repos/mostateresnet/exdbproject/issues{/number}","pulls_url":"https://api.github.com/repos/mostateresnet/exdbproject/pulls{/number}","milestones_url":"https://api.github.com/repos/mostateresnet/exdbproject/milestones{/number}","notifications_url":"https://api.github.com/repos/mostateresnet/exdbproject/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mostateresnet/exdbproject/labels{/name}","releases_url":"https://api.github.com/repos/mostateresnet/exdbproject/releases{/id}","created_at":"2015-10-13T19:55:07Z","updated_at":"2016-01-15T16:52:15Z","pushed_at":"2016-01-19T19:33:25Z","git_url":"git://github.com/mostateresnet/exdbproject.git","ssh_url":"git@github.com:mostateresnet/exdbproject.git","clone_url":"https://github.com/mostateresnet/exdbproject.git","svn_url":"https://github.com/mostateresnet/exdbproject","homepage":null,"size":140,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/8"},"html":{"href":"https://github.com/mostateresnet/exdbproject/pull/8"},"issue":{"href":"https://api.github.com/repos/mostateresnet/exdbproject/issues/8"},"comments":{"href":"https://api.github.com/repos/mostateresnet/exdbproject/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mostateresnet/exdbproject/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/mostateresnet/exdbproject/statuses/c1e2d4c4690e287b9595e1d243ce9b47a281f65f"}}}}