{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/comments/48008691","id":48008691,"diff_hunk":"@@ -0,0 +1,84 @@\n+from flask import render_template, redirect, url_for, current_app, \\\n+    request, flash\n+from flask_login import login_required\n+\n+from .. import main\n+from ..auth import role_required\n+from ..helpers.communications import file_is_pdf, file_is_zip\n+from ... import data_api_client\n+from . import get_template_data\n+\n+from dmutils import s3\n+\n+\n+def _get_path(framework_slug, path):\n+    return '{}/communications/{}'.format(framework_slug, path)\n+\n+\n+def _get_itt_pack_path(framework_slug):\n+    return '{0}/communications/{0}-itt-pack.zip'.format(framework_slug)\n+\n+\n+@main.route('/communications/<framework_slug>', methods=['GET'])\n+@login_required\n+@role_required('admin')\n+def manage_communications(framework_slug):\n+    communications_bucket = s3.S3(current_app.config['DM_COMMUNICATIONS_BUCKET'])\n+    framework = data_api_client.get_framework(framework_slug)['frameworks']\n+\n+    itt_pack = next(iter(communications_bucket.list(_get_itt_pack_path(framework_slug))), None)\n+    clarification = next(iter(communications_bucket.list(_get_path(framework_slug, 'updates/clarifications'))), None)\n+    communication = next(iter(communications_bucket.list(_get_path(framework_slug, 'updates/communications'))), None)\n+\n+    return render_template(\n+        'manage_communications.html',\n+        itt_pack=itt_pack,\n+        clarification=clarification,\n+        communication=communication,\n+        framework=framework,\n+        **get_template_data()\n+    )\n+\n+\n+@main.route('/communications/<framework_slug>', methods=['POST'])\n+@login_required\n+@role_required('admin')\n+def upload_communication(framework_slug):\n+    communications_bucket = s3.S3(current_app.config['DM_COMMUNICATIONS_BUCKET'])\n+    framework = data_api_client.get_framework(framework_slug)['frameworks']\n+    errors = {}\n+\n+    if 'communication' in request.files and request.files['communication'].filename is not u'':","path":"app/main/views/communications.py","position":51,"original_position":51,"commit_id":"378e300940f2d7758b3741141620d52bde7e6a7d","original_commit_id":"378e300940f2d7758b3741141620d52bde7e6a7d","user":{"login":"robyoung","id":14287,"avatar_url":"https://avatars.githubusercontent.com/u/14287?v=3","gravatar_id":"","url":"https://api.github.com/users/robyoung","html_url":"https://github.com/robyoung","followers_url":"https://api.github.com/users/robyoung/followers","following_url":"https://api.github.com/users/robyoung/following{/other_user}","gists_url":"https://api.github.com/users/robyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/robyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robyoung/subscriptions","organizations_url":"https://api.github.com/users/robyoung/orgs","repos_url":"https://api.github.com/users/robyoung/repos","events_url":"https://api.github.com/users/robyoung/events{/privacy}","received_events_url":"https://api.github.com/users/robyoung/received_events","type":"User","site_admin":false},"body":"This could be `if request.files.get('communication')` as the `FileStorage` object evaluates to `False` if there is no file.","created_at":"2015-12-18T09:37:20Z","updated_at":"2015-12-18T09:37:20Z","html_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend/pull/155#discussion_r48008691","pull_request_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/155","_links":{"self":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/comments/48008691"},"html":{"href":"https://github.com/alphagov/digitalmarketplace-admin-frontend/pull/155#discussion_r48008691"},"pull_request":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/155"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/155","id":53918858,"html_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend/pull/155","diff_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend/pull/155.diff","patch_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend/pull/155.patch","issue_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues/155","number":155,"state":"open","locked":false,"title":"Enable admin to post new files","user":{"login":"tommorris","id":175,"avatar_url":"https://avatars.githubusercontent.com/u/175?v=3","gravatar_id":"","url":"https://api.github.com/users/tommorris","html_url":"https://github.com/tommorris","followers_url":"https://api.github.com/users/tommorris/followers","following_url":"https://api.github.com/users/tommorris/following{/other_user}","gists_url":"https://api.github.com/users/tommorris/gists{/gist_id}","starred_url":"https://api.github.com/users/tommorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommorris/subscriptions","organizations_url":"https://api.github.com/users/tommorris/orgs","repos_url":"https://api.github.com/users/tommorris/repos","events_url":"https://api.github.com/users/tommorris/events{/privacy}","received_events_url":"https://api.github.com/users/tommorris/received_events","type":"User","site_admin":false},"body":"Pivotal: [#107188452](https://www.pivotaltracker.com/story/show/107188452)\r\n\r\nAs an admin user I want to upload new clarification answers in pdf, new ITT packs in zip format and their accompanying email in PDFs from the admin app so that I don't have to get a developer involved each time. ","created_at":"2015-12-17T00:21:59Z","updated_at":"2015-12-18T09:37:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f159ed298c769cf677eeeff7e606595dc4b94912","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/155/commits","review_comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/155/comments","review_comment_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues/155/comments","statuses_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/statuses/378e300940f2d7758b3741141620d52bde7e6a7d","head":{"label":"alphagov:manage-communications","ref":"manage-communications","sha":"378e300940f2d7758b3741141620d52bde7e6a7d","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":31009853,"name":"digitalmarketplace-admin-frontend","full_name":"alphagov/digitalmarketplace-admin-frontend","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend","description":"Frontend administration application for the digital marketplace","fork":false,"url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend","forks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/forks","keys_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/teams","hooks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/hooks","issue_events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/events","assignees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/tags","blobs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/languages","stargazers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/stargazers","contributors_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/contributors","subscribers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/subscribers","subscription_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/subscription","commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/merges","archive_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/downloads","issues_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/releases{/id}","created_at":"2015-02-19T10:09:45Z","updated_at":"2015-10-28T11:13:51Z","pushed_at":"2015-12-17T10:30:40Z","git_url":"git://github.com/alphagov/digitalmarketplace-admin-frontend.git","ssh_url":"git@github.com:alphagov/digitalmarketplace-admin-frontend.git","clone_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend.git","svn_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend","homepage":"","size":654,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"12fb8652dca84212267ce653d2d037aeac331e28","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":31009853,"name":"digitalmarketplace-admin-frontend","full_name":"alphagov/digitalmarketplace-admin-frontend","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend","description":"Frontend administration application for the digital marketplace","fork":false,"url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend","forks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/forks","keys_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/teams","hooks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/hooks","issue_events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/events","assignees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/tags","blobs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/languages","stargazers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/stargazers","contributors_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/contributors","subscribers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/subscribers","subscription_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/subscription","commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/merges","archive_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/downloads","issues_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/releases{/id}","created_at":"2015-02-19T10:09:45Z","updated_at":"2015-10-28T11:13:51Z","pushed_at":"2015-12-17T10:30:40Z","git_url":"git://github.com/alphagov/digitalmarketplace-admin-frontend.git","ssh_url":"git@github.com:alphagov/digitalmarketplace-admin-frontend.git","clone_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend.git","svn_url":"https://github.com/alphagov/digitalmarketplace-admin-frontend","homepage":"","size":654,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/155"},"html":{"href":"https://github.com/alphagov/digitalmarketplace-admin-frontend/pull/155"},"issue":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues/155"},"comments":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/issues/155/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/155/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/pulls/155/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-admin-frontend/statuses/378e300940f2d7758b3741141620d52bde7e6a7d"}}}}