{"action":"created","comment":{"url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/comments/88027560","pull_request_review_id":8610284,"id":88027560,"diff_hunk":"@@ -10,85 +10,90 @@\n \n \n class DateWidget(Widget):\n-    def _get_days(self, selected_day):\n-        if selected_day:\n-            selected_day = int(selected_day)\n-\n-        days = []\n-        for day in range(1, 32):\n-            days.append(ObjectFromDict({\n-                'type': 'text',\n-                'value': day,\n-                'text': day,\n-                'selected': (selected_day == day),\n-                'disabled': False,\n-            }))\n-        return days\n-\n-    def _get_months(self, selected_month):\n-        if selected_month:\n-            selected_month = int(selected_month)\n-\n-        months = []\n-        for month in range(1, 13):\n-            months.append(ObjectFromDict({\n-                'value': month,\n-                'text': calendar.month_name[month],\n-                'selected': (selected_month == month),\n-                'disabled': False,\n-            }))\n-        return months\n \n     def render(self, answer_state):\n+\n         if answer_state.input:\n             parts = answer_state.input.split('/')\n         else:\n             parts = [None, None, '']\n \n-        widget_params = {\n-            'legend': answer_state.schema_item.label,\n-            'fields': {\n-                'day': {\n-                  'label': {\n-                    'for': self.name + '-day',\n-                    'text': 'Day',\n+        widget_params = {}\n+        widget_params['legend'] = answer_state.schema_item.label\n+        widget_params['fields'] = self._get_date_fields(parts)\n+\n+        return render_template('partials/widgets/date_widget.html', **widget_params)\n+\n+    def _get_date_fields(self, parts):\n+\n+        fields = {}\n+        fields['day'] = self._get_day_field(parts[0])\n+        fields['month'] = self._get_month_field(parts[1])\n+        fields['year'] = self._get_year_field(parts[2])\n+\n+        return fields\n+\n+    def _get_day_field(self, day):\n+        day = {\n+              'label': {\n+                  'for': self.name + '-day',\n+                  'text': 'Day',\n                   },\n-                  'input': {\n-                    'type': 'text',\n-                    'value': parts[0],\n-                    'placeholder': 'DD',\n-                    'name': self.name + '-day',\n-                    'id': self.name + '-day',\n+              'input': {\n+                  'type': 'text',\n+                  'value': day,\n+                  'placeholder': 'DD',\n+                  'name': self.name + '-day',\n+                  'id': self.name + '-day',\n                   },\n-                },\n-                'month': {\n-                  'label': {\n+                }\n+        return day\n+\n+    def _get_month_field(self, month):\n+\n+        month = {\n+                'label': {\n                     'for': self.name + '-month',\n                     'text': 'Month',\n-                  },\n-                  'select': {\n-                    'options': self._get_months(parts[1]),\n+                },\n+                'select': {\n+                    'options': self._get_months(month),\n                     'name': self.name + '-month',\n                     'id': self.name + '-month',\n                   },\n-                },\n-                'year': {\n-                  'label': {\n+                }\n+        return month\n+\n+    def _get_year_field(self, year):\n+        year = {\n+                'label': {\n                     'for': self.name + '-year',\n                     'text': 'Year',\n-                  },\n-                  'input': {\n+                },\n+                'input': {\n+                    'value': year,\n                     'type': 'text',\n-                    'value': parts[2],\n                     'placeholder': 'YYYY',\n                     'name': self.name + '-year',\n                     'id': self.name + '-year',\n                   },\n-                },\n-            },\n-        }\n+                }\n+        return year\n \n-        return render_template('partials/widgets/date_widget.html', **widget_params)\n+    @staticmethod\n+    def _get_months(selected_month):\n+        if selected_month:","path":"app/schema/widgets/date_widget.py","position":133,"original_position":133,"commit_id":"17a4e618f9db395cfb805be35d5a4225e08ccb77","original_commit_id":"17a4e618f9db395cfb805be35d5a4225e08ccb77","user":{"login":"benjefferies","id":15050019,"avatar_url":"https://avatars.githubusercontent.com/u/15050019?v=3","gravatar_id":"","url":"https://api.github.com/users/benjefferies","html_url":"https://github.com/benjefferies","followers_url":"https://api.github.com/users/benjefferies/followers","following_url":"https://api.github.com/users/benjefferies/following{/other_user}","gists_url":"https://api.github.com/users/benjefferies/gists{/gist_id}","starred_url":"https://api.github.com/users/benjefferies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjefferies/subscriptions","organizations_url":"https://api.github.com/users/benjefferies/orgs","repos_url":"https://api.github.com/users/benjefferies/repos","events_url":"https://api.github.com/users/benjefferies/events{/privacy}","received_events_url":"https://api.github.com/users/benjefferies/received_events","type":"User","site_admin":false},"body":"How will the widget handle it if the selected month isn't selected? Should there always be a selected month?","created_at":"2016-11-15T14:34:20Z","updated_at":"2016-11-15T14:36:31Z","html_url":"https://github.com/ONSdigital/eq-survey-runner/pull/562#discussion_r88027560","pull_request_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/562","_links":{"self":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/comments/88027560"},"html":{"href":"https://github.com/ONSdigital/eq-survey-runner/pull/562#discussion_r88027560"},"pull_request":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/562"}}},"pull_request":{"url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/562","id":93561462,"html_url":"https://github.com/ONSdigital/eq-survey-runner/pull/562","diff_url":"https://github.com/ONSdigital/eq-survey-runner/pull/562.diff","patch_url":"https://github.com/ONSdigital/eq-survey-runner/pull/562.patch","issue_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/562","number":562,"state":"open","locked":false,"title":"Add new date type(Month/Year) and update tests","user":{"login":"LJBabbage","id":14179817,"avatar_url":"https://avatars.githubusercontent.com/u/14179817?v=3","gravatar_id":"","url":"https://api.github.com/users/LJBabbage","html_url":"https://github.com/LJBabbage","followers_url":"https://api.github.com/users/LJBabbage/followers","following_url":"https://api.github.com/users/LJBabbage/following{/other_user}","gists_url":"https://api.github.com/users/LJBabbage/gists{/gist_id}","starred_url":"https://api.github.com/users/LJBabbage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LJBabbage/subscriptions","organizations_url":"https://api.github.com/users/LJBabbage/orgs","repos_url":"https://api.github.com/users/LJBabbage/repos","events_url":"https://api.github.com/users/LJBabbage/events{/privacy}","received_events_url":"https://api.github.com/users/LJBabbage/received_events","type":"User","site_admin":false},"body":"### What is the context of this PR?\r\nTo add in the month/year answer type \"mm/yyyy\". A new widget has been introduced to deal with the alternative format and the summary . A test schema has also been set up to handle all dates \r\n\r\n### How to review \r\nUsing dev, open up the test_dates.json and make sure it shows both the date range and the new format above. Add  invalid data into each and make sure the right messages are shown. Correct the errors and make sure the summary page is correct.\r\n\r\n(N.B there is a malfunctioning test_date.json file as well and an associated selenium test already in master. This needs removing/fixing, but this is outside the scope of this story and will be done in EQ-718 date of birth)","created_at":"2016-11-14T12:54:53Z","updated_at":"2016-11-15T14:36:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7a3fc97a1beddc91ee568a9b2cbbd2d630422df","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/562/commits","review_comments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/562/comments","review_comment_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/562/comments","statuses_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/statuses/17a4e618f9db395cfb805be35d5a4225e08ccb77","head":{"label":"ONSdigital:eq-676-enable-alternative-date-inputs","ref":"eq-676-enable-alternative-date-inputs","sha":"17a4e618f9db395cfb805be35d5a4225e08ccb77","user":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars.githubusercontent.com/u/6865137?v=3","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"repo":{"id":49205589,"name":"eq-survey-runner","full_name":"ONSdigital/eq-survey-runner","owner":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars.githubusercontent.com/u/6865137?v=3","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ONSdigital/eq-survey-runner","description":"eQ Survey Runner","fork":false,"url":"https://api.github.com/repos/ONSdigital/eq-survey-runner","forks_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/forks","keys_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/teams","hooks_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/hooks","issue_events_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/events{/number}","events_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/events","assignees_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/assignees{/user}","branches_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/branches{/branch}","tags_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/tags","blobs_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/refs{/sha}","trees_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/statuses/{sha}","languages_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/languages","stargazers_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/stargazers","contributors_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/contributors","subscribers_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/subscribers","subscription_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/subscription","commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/commits{/sha}","git_commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/commits{/sha}","comments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/comments{/number}","issue_comment_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/comments{/number}","contents_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/contents/{+path}","compare_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/merges","archive_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/downloads","issues_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues{/number}","pulls_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls{/number}","milestones_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/milestones{/number}","notifications_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/labels{/name}","releases_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/releases{/id}","deployments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/deployments","created_at":"2016-01-07T13:15:26Z","updated_at":"2016-11-10T09:21:31Z","pushed_at":"2016-11-15T14:17:02Z","git_url":"git://github.com/ONSdigital/eq-survey-runner.git","ssh_url":"git@github.com:ONSdigital/eq-survey-runner.git","clone_url":"https://github.com/ONSdigital/eq-survey-runner.git","svn_url":"https://github.com/ONSdigital/eq-survey-runner","homepage":null,"size":8129,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":12,"forks":2,"open_issues":12,"watchers":5,"default_branch":"master"}},"base":{"label":"ONSdigital:master","ref":"master","sha":"d8ba8cafc34b3a1799903ed09dbcce5b0b7f4e06","user":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars.githubusercontent.com/u/6865137?v=3","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"repo":{"id":49205589,"name":"eq-survey-runner","full_name":"ONSdigital/eq-survey-runner","owner":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars.githubusercontent.com/u/6865137?v=3","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ONSdigital/eq-survey-runner","description":"eQ Survey Runner","fork":false,"url":"https://api.github.com/repos/ONSdigital/eq-survey-runner","forks_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/forks","keys_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/teams","hooks_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/hooks","issue_events_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/events{/number}","events_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/events","assignees_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/assignees{/user}","branches_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/branches{/branch}","tags_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/tags","blobs_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/refs{/sha}","trees_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/statuses/{sha}","languages_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/languages","stargazers_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/stargazers","contributors_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/contributors","subscribers_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/subscribers","subscription_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/subscription","commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/commits{/sha}","git_commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/commits{/sha}","comments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/comments{/number}","issue_comment_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/comments{/number}","contents_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/contents/{+path}","compare_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/merges","archive_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/downloads","issues_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues{/number}","pulls_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls{/number}","milestones_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/milestones{/number}","notifications_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/labels{/name}","releases_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/releases{/id}","deployments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/deployments","created_at":"2016-01-07T13:15:26Z","updated_at":"2016-11-10T09:21:31Z","pushed_at":"2016-11-15T14:17:02Z","git_url":"git://github.com/ONSdigital/eq-survey-runner.git","ssh_url":"git@github.com:ONSdigital/eq-survey-runner.git","clone_url":"https://github.com/ONSdigital/eq-survey-runner.git","svn_url":"https://github.com/ONSdigital/eq-survey-runner","homepage":null,"size":8129,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":12,"forks":2,"open_issues":12,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/562"},"html":{"href":"https://github.com/ONSdigital/eq-survey-runner/pull/562"},"issue":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/562"},"comments":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/562/comments"},"review_comments":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/562/comments"},"review_comment":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/562/commits"},"statuses":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/statuses/17a4e618f9db395cfb805be35d5a4225e08ccb77"}}}}
{"actor":{"display_login":"benjefferies"}}