{"action":"created","comment":{"url":"https://api.github.com/repos/18F/tock/pulls/comments/89853669","pull_request_review_id":10385550,"id":89853669,"diff_hunk":"@@ -327,6 +338,43 @@ def get_object(self, queryset=None):\n             user_id=self.request.user.id)\n         return obj\n \n+    def get(self, request, *args, **kwargs):\n+        \"\"\"Get timecard form only for last N reporting periods or if\n+        unsubmitted timecards.\"\"\"\n+        # Get reporting period object.\n+        self.object = self.get_object()\n+        selected_rp = ReportingPeriod.objects.get(\n+            id=self.object.__dict__['reporting_period_id']\n+        )\n+\n+        # Get most recent reporting period objects.\n+        max_rps = ReportingPeriod.objects.all().order_by('-start_date')[:3]\n+\n+        # Determine increment and number of reporting periods in list.\n+        if datetime.date.today() < max_rps[0].start_date:\n+            increment = 2\n+        else:\n+            increment = 1\n+        last_rps = max_rps[:increment]\n+\n+        # If the reporting period is in the reporting period list or if the\n+        # timecard has not been submitted, return the timecard form. If not,\n+        # return the non-editable report view of the timecard.\n+        if selected_rp in last_rps or \\\n+        self.object.__dict__['submitted'] == False:\n+            context = self.get_context_data(object=self.object)\n+            return self.render_to_response(context)\n+        else:\n+            return redirect(\n+                reverse(","path":"tock/hours/views.py","position":67,"original_position":67,"commit_id":"9159e351b066eaec031300c9c2af6622397f24f8","original_commit_id":"9159e351b066eaec031300c9c2af6622397f24f8","user":{"login":"batemapf","id":7645362,"avatar_url":"https://avatars.githubusercontent.com/u/7645362?v=3","gravatar_id":"","url":"https://api.github.com/users/batemapf","html_url":"https://github.com/batemapf","followers_url":"https://api.github.com/users/batemapf/followers","following_url":"https://api.github.com/users/batemapf/following{/other_user}","gists_url":"https://api.github.com/users/batemapf/gists{/gist_id}","starred_url":"https://api.github.com/users/batemapf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/batemapf/subscriptions","organizations_url":"https://api.github.com/users/batemapf/orgs","repos_url":"https://api.github.com/users/batemapf/repos","events_url":"https://api.github.com/users/batemapf/events{/privacy}","received_events_url":"https://api.github.com/users/batemapf/received_events","type":"User","site_admin":false},"body":"TODO: Check that redirect occurs and that destination is correct.","created_at":"2016-11-28T19:01:01Z","updated_at":"2016-11-28T19:01:01Z","html_url":"https://github.com/18F/tock/pull/580#discussion_r89853669","pull_request_url":"https://api.github.com/repos/18F/tock/pulls/580","_links":{"self":{"href":"https://api.github.com/repos/18F/tock/pulls/comments/89853669"},"html":{"href":"https://github.com/18F/tock/pull/580#discussion_r89853669"},"pull_request":{"href":"https://api.github.com/repos/18F/tock/pulls/580"}}},"pull_request":{"url":"https://api.github.com/repos/18F/tock/pulls/580","id":95340241,"html_url":"https://github.com/18F/tock/pull/580","diff_url":"https://github.com/18F/tock/pull/580.diff","patch_url":"https://github.com/18F/tock/pull/580.patch","issue_url":"https://api.github.com/repos/18F/tock/issues/580","number":580,"state":"open","locked":false,"title":"[WIP] Allow edit access to prior reporting period","user":{"login":"batemapf","id":7645362,"avatar_url":"https://avatars.githubusercontent.com/u/7645362?v=3","gravatar_id":"","url":"https://api.github.com/users/batemapf","html_url":"https://github.com/batemapf","followers_url":"https://api.github.com/users/batemapf/followers","following_url":"https://api.github.com/users/batemapf/following{/other_user}","gists_url":"https://api.github.com/users/batemapf/gists{/gist_id}","starred_url":"https://api.github.com/users/batemapf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/batemapf/subscriptions","organizations_url":"https://api.github.com/users/batemapf/orgs","repos_url":"https://api.github.com/users/batemapf/repos","events_url":"https://api.github.com/users/batemapf/events{/privacy}","received_events_url":"https://api.github.com/users/batemapf/received_events","type":"User","site_admin":false},"body":"## Description\r\n\r\nGives the user access to a limited number of previously submitted timecards for editing (requested in #572). Typically, only one previously submitted timecard will be available; however, when a new reporting period has been created but has not yet begun, the user has access to the \"current\" reporting period, as well as the prior week. The objective is to ensure the user always has access to the current week's timecard for editing, as well as the prior week's. \r\n\r\nIn addition, this change addresses #401 by limiting access to the timecard form based on the reporting period. A user who tries to access the timecard form for a reporting period that is earlier than the previous reporting period will be redirected to their submitted data. The exception is if the user never submitted a timecard for that period. In that case, the user will be directed to their form for submission. This should only happen in instances where the user is at least two weeks late in submitting their time.\r\n\r\nFurther tweaks were made to the user's initial view, including adding in links to previous timecards (view-only) and displaying a notification that the user is up to date if all available timecard forms have been filed.\r\n\r\n## Additional information\r\n\r\nScreen shot of changes:\r\n\r\n----\r\n\r\n<img width=\"997\" alt=\"screen shot 2016-11-25 at 1 48 33 pm\" src=\"https://cloud.githubusercontent.com/assets/7645362/20633621/d6cb0af6-b316-11e6-954f-673233a2ad97.png\">\r\n\r\n","created_at":"2016-11-25T18:58:38Z","updated_at":"2016-11-28T19:01:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"63b60cb624c7618d1db6f330104039102007ff00","assignee":{"login":"batemapf","id":7645362,"avatar_url":"https://avatars.githubusercontent.com/u/7645362?v=3","gravatar_id":"","url":"https://api.github.com/users/batemapf","html_url":"https://github.com/batemapf","followers_url":"https://api.github.com/users/batemapf/followers","following_url":"https://api.github.com/users/batemapf/following{/other_user}","gists_url":"https://api.github.com/users/batemapf/gists{/gist_id}","starred_url":"https://api.github.com/users/batemapf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/batemapf/subscriptions","organizations_url":"https://api.github.com/users/batemapf/orgs","repos_url":"https://api.github.com/users/batemapf/repos","events_url":"https://api.github.com/users/batemapf/events{/privacy}","received_events_url":"https://api.github.com/users/batemapf/received_events","type":"User","site_admin":false},"assignees":[{"login":"batemapf","id":7645362,"avatar_url":"https://avatars.githubusercontent.com/u/7645362?v=3","gravatar_id":"","url":"https://api.github.com/users/batemapf","html_url":"https://github.com/batemapf","followers_url":"https://api.github.com/users/batemapf/followers","following_url":"https://api.github.com/users/batemapf/following{/other_user}","gists_url":"https://api.github.com/users/batemapf/gists{/gist_id}","starred_url":"https://api.github.com/users/batemapf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/batemapf/subscriptions","organizations_url":"https://api.github.com/users/batemapf/orgs","repos_url":"https://api.github.com/users/batemapf/repos","events_url":"https://api.github.com/users/batemapf/events{/privacy}","received_events_url":"https://api.github.com/users/batemapf/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/18F/tock/pulls/580/commits","review_comments_url":"https://api.github.com/repos/18F/tock/pulls/580/comments","review_comment_url":"https://api.github.com/repos/18F/tock/pulls/comments{/number}","comments_url":"https://api.github.com/repos/18F/tock/issues/580/comments","statuses_url":"https://api.github.com/repos/18F/tock/statuses/9159e351b066eaec031300c9c2af6622397f24f8","head":{"label":"18F:previous-timecard-updates","ref":"previous-timecard-updates","sha":"9159e351b066eaec031300c9c2af6622397f24f8","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":30162008,"name":"tock","full_name":"18F/tock","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/tock","description":"We use Tock to track and report our time at 18F","fork":false,"url":"https://api.github.com/repos/18F/tock","forks_url":"https://api.github.com/repos/18F/tock/forks","keys_url":"https://api.github.com/repos/18F/tock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/tock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/tock/teams","hooks_url":"https://api.github.com/repos/18F/tock/hooks","issue_events_url":"https://api.github.com/repos/18F/tock/issues/events{/number}","events_url":"https://api.github.com/repos/18F/tock/events","assignees_url":"https://api.github.com/repos/18F/tock/assignees{/user}","branches_url":"https://api.github.com/repos/18F/tock/branches{/branch}","tags_url":"https://api.github.com/repos/18F/tock/tags","blobs_url":"https://api.github.com/repos/18F/tock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/tock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/tock/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/tock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/tock/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/tock/languages","stargazers_url":"https://api.github.com/repos/18F/tock/stargazers","contributors_url":"https://api.github.com/repos/18F/tock/contributors","subscribers_url":"https://api.github.com/repos/18F/tock/subscribers","subscription_url":"https://api.github.com/repos/18F/tock/subscription","commits_url":"https://api.github.com/repos/18F/tock/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/tock/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/tock/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/tock/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/tock/contents/{+path}","compare_url":"https://api.github.com/repos/18F/tock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/tock/merges","archive_url":"https://api.github.com/repos/18F/tock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/tock/downloads","issues_url":"https://api.github.com/repos/18F/tock/issues{/number}","pulls_url":"https://api.github.com/repos/18F/tock/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/tock/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/tock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/tock/labels{/name}","releases_url":"https://api.github.com/repos/18F/tock/releases{/id}","deployments_url":"https://api.github.com/repos/18F/tock/deployments","created_at":"2015-02-01T22:19:32Z","updated_at":"2016-11-27T05:03:19Z","pushed_at":"2016-11-28T17:08:25Z","git_url":"git://github.com/18F/tock.git","ssh_url":"git@github.com:18F/tock.git","clone_url":"https://github.com/18F/tock.git","svn_url":"https://github.com/18F/tock","homepage":"https://18f.gsa.gov/2015/05/21/TockingTime/","size":3036,"stargazers_count":88,"watchers_count":88,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":73,"forks":32,"open_issues":73,"watchers":88,"default_branch":"master"}},"base":{"label":"18F:master","ref":"master","sha":"8833090251e6193c61002f29816c8793ebf939e1","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":30162008,"name":"tock","full_name":"18F/tock","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/tock","description":"We use Tock to track and report our time at 18F","fork":false,"url":"https://api.github.com/repos/18F/tock","forks_url":"https://api.github.com/repos/18F/tock/forks","keys_url":"https://api.github.com/repos/18F/tock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/tock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/tock/teams","hooks_url":"https://api.github.com/repos/18F/tock/hooks","issue_events_url":"https://api.github.com/repos/18F/tock/issues/events{/number}","events_url":"https://api.github.com/repos/18F/tock/events","assignees_url":"https://api.github.com/repos/18F/tock/assignees{/user}","branches_url":"https://api.github.com/repos/18F/tock/branches{/branch}","tags_url":"https://api.github.com/repos/18F/tock/tags","blobs_url":"https://api.github.com/repos/18F/tock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/tock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/tock/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/tock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/tock/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/tock/languages","stargazers_url":"https://api.github.com/repos/18F/tock/stargazers","contributors_url":"https://api.github.com/repos/18F/tock/contributors","subscribers_url":"https://api.github.com/repos/18F/tock/subscribers","subscription_url":"https://api.github.com/repos/18F/tock/subscription","commits_url":"https://api.github.com/repos/18F/tock/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/tock/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/tock/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/tock/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/tock/contents/{+path}","compare_url":"https://api.github.com/repos/18F/tock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/tock/merges","archive_url":"https://api.github.com/repos/18F/tock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/tock/downloads","issues_url":"https://api.github.com/repos/18F/tock/issues{/number}","pulls_url":"https://api.github.com/repos/18F/tock/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/tock/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/tock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/tock/labels{/name}","releases_url":"https://api.github.com/repos/18F/tock/releases{/id}","deployments_url":"https://api.github.com/repos/18F/tock/deployments","created_at":"2015-02-01T22:19:32Z","updated_at":"2016-11-27T05:03:19Z","pushed_at":"2016-11-28T17:08:25Z","git_url":"git://github.com/18F/tock.git","ssh_url":"git@github.com:18F/tock.git","clone_url":"https://github.com/18F/tock.git","svn_url":"https://github.com/18F/tock","homepage":"https://18f.gsa.gov/2015/05/21/TockingTime/","size":3036,"stargazers_count":88,"watchers_count":88,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":73,"forks":32,"open_issues":73,"watchers":88,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/18F/tock/pulls/580"},"html":{"href":"https://github.com/18F/tock/pull/580"},"issue":{"href":"https://api.github.com/repos/18F/tock/issues/580"},"comments":{"href":"https://api.github.com/repos/18F/tock/issues/580/comments"},"review_comments":{"href":"https://api.github.com/repos/18F/tock/pulls/580/comments"},"review_comment":{"href":"https://api.github.com/repos/18F/tock/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/18F/tock/pulls/580/commits"},"statuses":{"href":"https://api.github.com/repos/18F/tock/statuses/9159e351b066eaec031300c9c2af6622397f24f8"}}}}
{"actor":{"display_login":"batemapf"}}