{"action":"created","comment":{"url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/comments/30173207","id":30173207,"diff_hunk":"@@ -0,0 +1,341 @@\n+__author__ = 'Mohamed Morsy'\n+from django.forms import ModelForm\n+from django import forms\n+from crispy_forms.layout import *\n+from crispy_forms.bootstrap import *\n+from models import *\n+from hs_core.forms import BaseFormHelper\n+\n+#SWATmodelParameters element forms\n+class ModelOutputFormHelper(BaseFormHelper):\n+    def __init__(self, allow_edit=True, res_short_id=None, element_id=None, element_name=None,  *args, **kwargs):\n+\n+        # the order in which the model fields are listed for the FieldSet is the order these fields will be displayed\n+        field_width = 'form-control input-sm'\n+        layout = Layout(\n+                        Field('includes_output', css_class=field_width),\n+                 )\n+        kwargs['element_name_label'] = 'Includes output files?'\n+        super(ModelOutputFormHelper, self).__init__(allow_edit, res_short_id, element_id, element_name, layout,  *args, **kwargs)\n+\n+\n+class ModelOutputForm(ModelForm):\n+    includes_output = forms.TypedChoiceField(choices=((True, 'Yes'), (False, 'No')), widget=forms.RadioSelect)\n+    def __init__(self, allow_edit=True, res_short_id=None, element_id=None, *args, **kwargs):\n+        super(ModelOutputForm, self).__init__(*args, **kwargs)\n+        self.helper = ModelOutputFormHelper(allow_edit, res_short_id, element_id, element_name='ModelOutput')\n+        self.fields['includes_output'].widget.attrs['style'] = \"width:auto;margin-top:-5px\"\n+\n+    class Meta:\n+        model = ModelOutput\n+        fields = ['includes_output']\n+        exclude = ['content_object']\n+\n+class ModelOutputValidationForm(forms.Form):\n+    includes_output = forms.TypedChoiceField(choices=((True, 'Yes'), (False, 'No')))\n+\n+    def clean_includes_output(self):\n+        data = self.cleaned_data['includes_output']\n+        if data == u'False':\n+            return False\n+        else:\n+            return True\n+\n+class ExecutedByFormHelper(BaseFormHelper):\n+    def __init__(self, allow_edit=True, res_short_id=None, element_id=None, element_name=None,  *args, **kwargs):\n+\n+        # the order in which the model fields are listed for the FieldSet is the order these fields will be displayed\n+        field_width = 'form-control input-sm'\n+        layout = Layout(\n+                        Field('name', css_class=field_width),\n+                 )\n+\n+        kwargs['element_name_label'] = 'Model Program used for execution'\n+        super(ExecutedByFormHelper, self).__init__(allow_edit, res_short_id, element_id, element_name, layout,  *args, **kwargs)\n+\n+\n+class ExecutedByForm(ModelForm):\n+    def __init__(self, allow_edit=True, res_short_id=None, element_id=None, *args, **kwargs):\n+        super(ExecutedByForm, self).__init__(*args, **kwargs)\n+        self.helper = ExecutedByFormHelper(allow_edit, res_short_id, element_id, element_name='ExecutedBy')\n+\n+    class Meta:\n+        model = ExecutedBy\n+        fields = ['name']\n+        exclude = ['content_object']\n+\n+class ExecutedByValidationForm(forms.Form):\n+    name = forms.CharField(max_length=200)\n+\n+\n+class ModelObjectiveFormHelper(BaseFormHelper):\n+    def __init__(self, allow_edit=True, res_short_id=None, element_id=None, element_name=None,  *args, **kwargs):\n+\n+        # the order in which the model fields are listed for the FieldSet is the order these fields will be displayed\n+        field_width = 'form-control input-sm'\n+        layout = Layout(\n+                        Field('swat_model_objective', css_class=field_width),\n+                        Field('other_objectives', css_class=field_width),\n+                 )\n+        kwargs['element_name_label'] = 'Model objective'\n+        super(ModelObjectiveFormHelper, self).__init__(allow_edit, res_short_id, element_id, element_name, layout,  *args, **kwargs)\n+\n+class ModelObjectiveForm(ModelForm):\n+    def __init__(self, allow_edit=True, res_short_id=None, element_id=None, *args, **kwargs):\n+        objective_choices = tuple([('Choose an objective', 'Choose an objective'), ('Hydrology', 'Hydrology'),\\","path":"hs_swat_modelinstance/forms.py","position":85,"original_position":85,"commit_id":"87a8744aecd617b4e6cb85d0c04c82de76750f8d","original_commit_id":"87a8744aecd617b4e6cb85d0c04c82de76750f8d","user":{"login":"mohamedmorsy","id":5543781,"avatar_url":"https://avatars.githubusercontent.com/u/5543781?v=3","gravatar_id":"","url":"https://api.github.com/users/mohamedmorsy","html_url":"https://github.com/mohamedmorsy","followers_url":"https://api.github.com/users/mohamedmorsy/followers","following_url":"https://api.github.com/users/mohamedmorsy/following{/other_user}","gists_url":"https://api.github.com/users/mohamedmorsy/gists{/gist_id}","starred_url":"https://api.github.com/users/mohamedmorsy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohamedmorsy/subscriptions","organizations_url":"https://api.github.com/users/mohamedmorsy/orgs","repos_url":"https://api.github.com/users/mohamedmorsy/repos","events_url":"https://api.github.com/users/mohamedmorsy/events{/privacy}","received_events_url":"https://api.github.com/users/mohamedmorsy/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2015-05-12T19:53:46Z","updated_at":"2015-05-12T19:53:46Z","html_url":"https://github.com/hydroshare/hydroshare/pull/368#discussion_r30173207","pull_request_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/368","_links":{"self":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/comments/30173207"},"html":{"href":"https://github.com/hydroshare/hydroshare/pull/368#discussion_r30173207"},"pull_request":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/368"}}},"pull_request":{"url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/368","id":35160331,"html_url":"https://github.com/hydroshare/hydroshare/pull/368","diff_url":"https://github.com/hydroshare/hydroshare/pull/368.diff","patch_url":"https://github.com/hydroshare/hydroshare/pull/368.patch","issue_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/368","number":368,"state":"open","locked":false,"title":"303 swat model instance","user":{"login":"mohamedmorsy","id":5543781,"avatar_url":"https://avatars.githubusercontent.com/u/5543781?v=3","gravatar_id":"","url":"https://api.github.com/users/mohamedmorsy","html_url":"https://github.com/mohamedmorsy","followers_url":"https://api.github.com/users/mohamedmorsy/followers","following_url":"https://api.github.com/users/mohamedmorsy/following{/other_user}","gists_url":"https://api.github.com/users/mohamedmorsy/gists{/gist_id}","starred_url":"https://api.github.com/users/mohamedmorsy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohamedmorsy/subscriptions","organizations_url":"https://api.github.com/users/mohamedmorsy/orgs","repos_url":"https://api.github.com/users/mohamedmorsy/repos","events_url":"https://api.github.com/users/mohamedmorsy/events{/privacy}","received_events_url":"https://api.github.com/users/mohamedmorsy/received_events","type":"User","site_admin":false},"body":"This is the first phase of implementing SWAT Model Instance resource type. This phase does not include the link between SWAT Model Instance resource type and Model Program resource type.","created_at":"2015-05-11T19:27:52Z","updated_at":"2015-05-12T19:53:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f9bf95564ad6a19b1949200be60945a9d323ff02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/368/commits","review_comments_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/368/comments","review_comment_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/368/comments","statuses_url":"https://api.github.com/repos/hydroshare/hydroshare/statuses/87a8744aecd617b4e6cb85d0c04c82de76750f8d","head":{"label":"hydroshare:303-SWATModelInstance","ref":"303-SWATModelInstance","sha":"87a8744aecd617b4e6cb85d0c04c82de76750f8d","user":{"login":"hydroshare","id":3444493,"avatar_url":"https://avatars.githubusercontent.com/u/3444493?v=3","gravatar_id":"","url":"https://api.github.com/users/hydroshare","html_url":"https://github.com/hydroshare","followers_url":"https://api.github.com/users/hydroshare/followers","following_url":"https://api.github.com/users/hydroshare/following{/other_user}","gists_url":"https://api.github.com/users/hydroshare/gists{/gist_id}","starred_url":"https://api.github.com/users/hydroshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hydroshare/subscriptions","organizations_url":"https://api.github.com/users/hydroshare/orgs","repos_url":"https://api.github.com/users/hydroshare/repos","events_url":"https://api.github.com/users/hydroshare/events{/privacy}","received_events_url":"https://api.github.com/users/hydroshare/received_events","type":"Organization","site_admin":false},"repo":{"id":24703136,"name":"hydroshare","full_name":"hydroshare/hydroshare","owner":{"login":"hydroshare","id":3444493,"avatar_url":"https://avatars.githubusercontent.com/u/3444493?v=3","gravatar_id":"","url":"https://api.github.com/users/hydroshare","html_url":"https://github.com/hydroshare","followers_url":"https://api.github.com/users/hydroshare/followers","following_url":"https://api.github.com/users/hydroshare/following{/other_user}","gists_url":"https://api.github.com/users/hydroshare/gists{/gist_id}","starred_url":"https://api.github.com/users/hydroshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hydroshare/subscriptions","organizations_url":"https://api.github.com/users/hydroshare/orgs","repos_url":"https://api.github.com/users/hydroshare/repos","events_url":"https://api.github.com/users/hydroshare/events{/privacy}","received_events_url":"https://api.github.com/users/hydroshare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hydroshare/hydroshare","description":"HydroShare is a collaborative website being developed for better access to data and models in the hydrologic sciences. ","fork":false,"url":"https://api.github.com/repos/hydroshare/hydroshare","forks_url":"https://api.github.com/repos/hydroshare/hydroshare/forks","keys_url":"https://api.github.com/repos/hydroshare/hydroshare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hydroshare/hydroshare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hydroshare/hydroshare/teams","hooks_url":"https://api.github.com/repos/hydroshare/hydroshare/hooks","issue_events_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/events{/number}","events_url":"https://api.github.com/repos/hydroshare/hydroshare/events","assignees_url":"https://api.github.com/repos/hydroshare/hydroshare/assignees{/user}","branches_url":"https://api.github.com/repos/hydroshare/hydroshare/branches{/branch}","tags_url":"https://api.github.com/repos/hydroshare/hydroshare/tags","blobs_url":"https://api.github.com/repos/hydroshare/hydroshare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hydroshare/hydroshare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hydroshare/hydroshare/git/refs{/sha}","trees_url":"https://api.github.com/repos/hydroshare/hydroshare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hydroshare/hydroshare/statuses/{sha}","languages_url":"https://api.github.com/repos/hydroshare/hydroshare/languages","stargazers_url":"https://api.github.com/repos/hydroshare/hydroshare/stargazers","contributors_url":"https://api.github.com/repos/hydroshare/hydroshare/contributors","subscribers_url":"https://api.github.com/repos/hydroshare/hydroshare/subscribers","subscription_url":"https://api.github.com/repos/hydroshare/hydroshare/subscription","commits_url":"https://api.github.com/repos/hydroshare/hydroshare/commits{/sha}","git_commits_url":"https://api.github.com/repos/hydroshare/hydroshare/git/commits{/sha}","comments_url":"https://api.github.com/repos/hydroshare/hydroshare/comments{/number}","issue_comment_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/comments{/number}","contents_url":"https://api.github.com/repos/hydroshare/hydroshare/contents/{+path}","compare_url":"https://api.github.com/repos/hydroshare/hydroshare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hydroshare/hydroshare/merges","archive_url":"https://api.github.com/repos/hydroshare/hydroshare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hydroshare/hydroshare/downloads","issues_url":"https://api.github.com/repos/hydroshare/hydroshare/issues{/number}","pulls_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls{/number}","milestones_url":"https://api.github.com/repos/hydroshare/hydroshare/milestones{/number}","notifications_url":"https://api.github.com/repos/hydroshare/hydroshare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hydroshare/hydroshare/labels{/name}","releases_url":"https://api.github.com/repos/hydroshare/hydroshare/releases{/id}","created_at":"2014-10-02T02:19:41Z","updated_at":"2015-04-01T15:17:27Z","pushed_at":"2015-05-12T19:40:15Z","git_url":"git://github.com/hydroshare/hydroshare.git","ssh_url":"git@github.com:hydroshare/hydroshare.git","clone_url":"https://github.com/hydroshare/hydroshare.git","svn_url":"https://github.com/hydroshare/hydroshare","homepage":"https://www.cuahsi.org/hydroshare","size":62457,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":130,"forks":1,"open_issues":130,"watchers":9,"default_branch":"master"}},"base":{"label":"hydroshare:develop","ref":"develop","sha":"977c2014c97ccdd9ba823e23a5a47e831bfa0b96","user":{"login":"hydroshare","id":3444493,"avatar_url":"https://avatars.githubusercontent.com/u/3444493?v=3","gravatar_id":"","url":"https://api.github.com/users/hydroshare","html_url":"https://github.com/hydroshare","followers_url":"https://api.github.com/users/hydroshare/followers","following_url":"https://api.github.com/users/hydroshare/following{/other_user}","gists_url":"https://api.github.com/users/hydroshare/gists{/gist_id}","starred_url":"https://api.github.com/users/hydroshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hydroshare/subscriptions","organizations_url":"https://api.github.com/users/hydroshare/orgs","repos_url":"https://api.github.com/users/hydroshare/repos","events_url":"https://api.github.com/users/hydroshare/events{/privacy}","received_events_url":"https://api.github.com/users/hydroshare/received_events","type":"Organization","site_admin":false},"repo":{"id":24703136,"name":"hydroshare","full_name":"hydroshare/hydroshare","owner":{"login":"hydroshare","id":3444493,"avatar_url":"https://avatars.githubusercontent.com/u/3444493?v=3","gravatar_id":"","url":"https://api.github.com/users/hydroshare","html_url":"https://github.com/hydroshare","followers_url":"https://api.github.com/users/hydroshare/followers","following_url":"https://api.github.com/users/hydroshare/following{/other_user}","gists_url":"https://api.github.com/users/hydroshare/gists{/gist_id}","starred_url":"https://api.github.com/users/hydroshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hydroshare/subscriptions","organizations_url":"https://api.github.com/users/hydroshare/orgs","repos_url":"https://api.github.com/users/hydroshare/repos","events_url":"https://api.github.com/users/hydroshare/events{/privacy}","received_events_url":"https://api.github.com/users/hydroshare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hydroshare/hydroshare","description":"HydroShare is a collaborative website being developed for better access to data and models in the hydrologic sciences. ","fork":false,"url":"https://api.github.com/repos/hydroshare/hydroshare","forks_url":"https://api.github.com/repos/hydroshare/hydroshare/forks","keys_url":"https://api.github.com/repos/hydroshare/hydroshare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hydroshare/hydroshare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hydroshare/hydroshare/teams","hooks_url":"https://api.github.com/repos/hydroshare/hydroshare/hooks","issue_events_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/events{/number}","events_url":"https://api.github.com/repos/hydroshare/hydroshare/events","assignees_url":"https://api.github.com/repos/hydroshare/hydroshare/assignees{/user}","branches_url":"https://api.github.com/repos/hydroshare/hydroshare/branches{/branch}","tags_url":"https://api.github.com/repos/hydroshare/hydroshare/tags","blobs_url":"https://api.github.com/repos/hydroshare/hydroshare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hydroshare/hydroshare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hydroshare/hydroshare/git/refs{/sha}","trees_url":"https://api.github.com/repos/hydroshare/hydroshare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hydroshare/hydroshare/statuses/{sha}","languages_url":"https://api.github.com/repos/hydroshare/hydroshare/languages","stargazers_url":"https://api.github.com/repos/hydroshare/hydroshare/stargazers","contributors_url":"https://api.github.com/repos/hydroshare/hydroshare/contributors","subscribers_url":"https://api.github.com/repos/hydroshare/hydroshare/subscribers","subscription_url":"https://api.github.com/repos/hydroshare/hydroshare/subscription","commits_url":"https://api.github.com/repos/hydroshare/hydroshare/commits{/sha}","git_commits_url":"https://api.github.com/repos/hydroshare/hydroshare/git/commits{/sha}","comments_url":"https://api.github.com/repos/hydroshare/hydroshare/comments{/number}","issue_comment_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/comments{/number}","contents_url":"https://api.github.com/repos/hydroshare/hydroshare/contents/{+path}","compare_url":"https://api.github.com/repos/hydroshare/hydroshare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hydroshare/hydroshare/merges","archive_url":"https://api.github.com/repos/hydroshare/hydroshare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hydroshare/hydroshare/downloads","issues_url":"https://api.github.com/repos/hydroshare/hydroshare/issues{/number}","pulls_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls{/number}","milestones_url":"https://api.github.com/repos/hydroshare/hydroshare/milestones{/number}","notifications_url":"https://api.github.com/repos/hydroshare/hydroshare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hydroshare/hydroshare/labels{/name}","releases_url":"https://api.github.com/repos/hydroshare/hydroshare/releases{/id}","created_at":"2014-10-02T02:19:41Z","updated_at":"2015-04-01T15:17:27Z","pushed_at":"2015-05-12T19:40:15Z","git_url":"git://github.com/hydroshare/hydroshare.git","ssh_url":"git@github.com:hydroshare/hydroshare.git","clone_url":"https://github.com/hydroshare/hydroshare.git","svn_url":"https://github.com/hydroshare/hydroshare","homepage":"https://www.cuahsi.org/hydroshare","size":62457,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":130,"forks":1,"open_issues":130,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/368"},"html":{"href":"https://github.com/hydroshare/hydroshare/pull/368"},"issue":{"href":"https://api.github.com/repos/hydroshare/hydroshare/issues/368"},"comments":{"href":"https://api.github.com/repos/hydroshare/hydroshare/issues/368/comments"},"review_comments":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/368/comments"},"review_comment":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/368/commits"},"statuses":{"href":"https://api.github.com/repos/hydroshare/hydroshare/statuses/87a8744aecd617b4e6cb85d0c04c82de76750f8d"}}}}