GitHub PullRequestReviewCommentEvent at 2014-09-11 15:37:24
Repository: performanceplatform-admin
Actor: jcbashdown
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/comments/17428278","id":17428278,"diff_hunk":"@@ -1,18 +1,94 @@\n from admin import app\n+from admin.forms import DashboardCreationForm\n from admin.helpers import (\n     base_template_context,\n     requires_authentication,\n     requires_permission,\n )\n-from flask import render_template, session\n+from flask import (\n+    flash, redirect, render_template, request,\n+    session, url_for\n+)\n+\n+import json\n+import requests\n+\n \n+DASHBOARD_ROUTE = '/administer-dashboards'\n \n-@app.route('/administer-dashboards', methods=['GET'])\n+\n+@app.route('{0}'.format(DASHBOARD_ROUTE), methods=['GET'])\n @requires_authentication\n-@requires_permission('dashboard-editor')\n+@requires_permission('dashboard')\n def dashboard_admin_index(admin_client):\n     template_context = base_template_context()\n     template_context.update({\n         'user': session['oauth_user'],\n     })\n     return render_template('dashboards/index.html', **template_context)\n+\n+\n+@app.route('{0}/create'.format(DASHBOARD_ROUTE), methods=['GET'])\n+@requires_authentication\n+@requires_permission('dashboard')\n+def dashboard_admin_create(admin_client):\n+    template_context = base_template_context()\n+    template_context.update({\n+        'user': session['oauth_user'],\n+    })\n+\n+    if 'pending_dashboard' in session:\n+        form = DashboardCreationForm(data=session['pending_dashboard'])\n+    else:\n+        form = DashboardCreationForm(request.form)\n+\n+    return render_template('dashboards/create.html',\n+                           form=form,\n+                           **template_context)\n+\n+\n+@app.route('{0}/create'.format(DASHBOARD_ROUTE), methods=['POST'])\n+@requires_authentication\n+@requires_permission('dashboard')\n+def dashboard_admin_create_post(admin_client):\n+    form = DashboardCreationForm(request.form)\n+\n+    access_token = session['oauth_token']['access_token']\n+    dashboard_url = \"{0}/dashboard\".format(app.config['STAGECRAFT_HOST'])\n+    data = {\n+        'published': False,\n+        'page-type': 'dashboard',\n+        'dashboard-type': form.dashboard_type.data,\n+        'slug': form.slug.data,\n+        'title': form.title.data,\n+        'description': form.description.data,\n+        'customer_type': form.customer_type.data,\n+        'business_model': form.business_model.data,\n+        'strapline': form.strapline.data,\n+        'links': [{\n+            'title': form.transaction_title.data,\n+            'url': form.transaction_link.data,\n+            'type': 'transaction',\n+        }]\n+    }\n+    headers = {\n+        'Authorization': 'Bearer {0}'.format(access_token),\n+        'Content-type': 'application/json',\n+    }\n+\n+    create_dashboard = requests.post(dashboard_url,\n+                                     data=json.dumps(data),\n+                                     headers=headers)\n+\n+    if create_dashboard.status_code == 200:\n+        if 'pending_dashboard' in session:\n+            del session['pending_dashboard']\n+        flash('Created the {0} dashboard'.format(form.slug.data), 'success')\n+        return redirect(url_for('dashboard_admin_index'))\n+    else:\n+        session['pending_dashboard'] = request.form\n+        stagecraft_message = create_dashboard.json()['message']\n+        errors = ['{0}: {1}'.format(err, ', '.join(stagecraft_message[err]))","path":"admin/dashboards.py","position":94,"original_position":94,"commit_id":"5af52129d1337f6565d45d99977e43a9d30e0913","original_commit_id":"5af52129d1337f6565d45d99977e43a9d30e0913","user":{"login":"jcbashdown","id":677893,"avatar_url":"https://avatars.githubusercontent.com/u/677893?v=2","gravatar_id":"6dca9a54fa48c13b620f1f0c2dccc751","url":"https://api.github.com/users/jcbashdown","html_url":"https://github.com/jcbashdown","followers_url":"https://api.github.com/users/jcbashdown/followers","following_url":"https://api.github.com/users/jcbashdown/following{/other_user}","gists_url":"https://api.github.com/users/jcbashdown/gists{/gist_id}","starred_url":"https://api.github.com/users/jcbashdown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcbashdown/subscriptions","organizations_url":"https://api.github.com/users/jcbashdown/orgs","repos_url":"https://api.github.com/users/jcbashdown/repos","events_url":"https://api.github.com/users/jcbashdown/events{/privacy}","received_events_url":"https://api.github.com/users/jcbashdown/received_events","type":"User","site_admin":false},"body":"Is this definitely a list? It looks like it's generally a string and sometimes a dict:\r\n\r\nhttps://github.com/alphagov/stagecraft/blob/master/stagecraft/apps/dashboards/views/dashboard.py#L104","created_at":"2014-09-11T15:37:24Z","updated_at":"2014-09-11T15:37:24Z","html_url":"https://github.com/alphagov/performanceplatform-admin/pull/53#discussion_r17428278","pull_request_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/comments/17428278"},"html":{"href":"https://github.com/alphagov/performanceplatform-admin/pull/53#discussion_r17428278"},"pull_request":{"href":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/53","id":21014900,"html_url":"https://github.com/alphagov/performanceplatform-admin/pull/53","diff_url":"https://github.com/alphagov/performanceplatform-admin/pull/53.diff","patch_url":"https://github.com/alphagov/performanceplatform-admin/pull/53.patch","issue_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues/53","number":53,"state":"open","locked":false,"title":"[#73958524] Create dashboard form","user":{"login":"alexmuller","id":121219,"avatar_url":"https://avatars.githubusercontent.com/u/121219?v=2","gravatar_id":"9aa68f61d27cc8a33b6efef5279a0702","url":"https://api.github.com/users/alexmuller","html_url":"https://github.com/alexmuller","followers_url":"https://api.github.com/users/alexmuller/followers","following_url":"https://api.github.com/users/alexmuller/following{/other_user}","gists_url":"https://api.github.com/users/alexmuller/gists{/gist_id}","starred_url":"https://api.github.com/users/alexmuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexmuller/subscriptions","organizations_url":"https://api.github.com/users/alexmuller/orgs","repos_url":"https://api.github.com/users/alexmuller/repos","events_url":"https://api.github.com/users/alexmuller/events{/privacy}","received_events_url":"https://api.github.com/users/alexmuller/received_events","type":"User","site_admin":false},"body":"I would appreciate feedback on:\r\n\r\n1. How to make the tests less verbose\r\n2. Our discrepancy between the `dashboard` and `dashboard-editor` permission\r\n3. Anything else that is broken\r\n","created_at":"2014-09-10T11:39:56Z","updated_at":"2014-09-11T15:37:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"04690d243eed50ac1b9ae14791d655cfe09523df","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/53/commits","review_comments_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/53/comments","review_comment_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/comments/{number}","comments_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues/53/comments","statuses_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/statuses/5af52129d1337f6565d45d99977e43a9d30e0913","head":{"label":"alphagov:73958524-create-dashboard-form","ref":"73958524-create-dashboard-form","sha":"5af52129d1337f6565d45d99977e43a9d30e0913","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=2","gravatar_id":"5618b843830194a2475a6e48823f7455","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":21730553,"name":"performanceplatform-admin","full_name":"alphagov/performanceplatform-admin","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=2","gravatar_id":"5618b843830194a2475a6e48823f7455","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/performanceplatform-admin","description":"A Flask app to let authorised users update performance data on GOV.UK","fork":false,"url":"https://api.github.com/repos/alphagov/performanceplatform-admin","forks_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/forks","keys_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/teams","hooks_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/hooks","issue_events_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/events","assignees_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/tags","blobs_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/languages","stargazers_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/stargazers","contributors_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/contributors","subscribers_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/subscribers","subscription_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/subscription","commits_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues/comments/{number}","contents_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/merges","archive_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/downloads","issues_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/releases{/id}","created_at":"2014-07-11T09:33:07Z","updated_at":"2014-09-05T14:36:12Z","pushed_at":"2014-09-11T11:46:05Z","git_url":"git://github.com/alphagov/performanceplatform-admin.git","ssh_url":"git@github.com:alphagov/performanceplatform-admin.git","clone_url":"https://github.com/alphagov/performanceplatform-admin.git","svn_url":"https://github.com/alphagov/performanceplatform-admin","homepage":null,"size":3485,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"4a5dd467bbcc97ca973c34e3d8e18d52fff9c679","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=2","gravatar_id":"5618b843830194a2475a6e48823f7455","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":21730553,"name":"performanceplatform-admin","full_name":"alphagov/performanceplatform-admin","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=2","gravatar_id":"5618b843830194a2475a6e48823f7455","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/performanceplatform-admin","description":"A Flask app to let authorised users update performance data on GOV.UK","fork":false,"url":"https://api.github.com/repos/alphagov/performanceplatform-admin","forks_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/forks","keys_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/teams","hooks_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/hooks","issue_events_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/events","assignees_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/tags","blobs_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/languages","stargazers_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/stargazers","contributors_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/contributors","subscribers_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/subscribers","subscription_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/subscription","commits_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues/comments/{number}","contents_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/merges","archive_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/downloads","issues_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/performanceplatform-admin/releases{/id}","created_at":"2014-07-11T09:33:07Z","updated_at":"2014-09-05T14:36:12Z","pushed_at":"2014-09-11T11:46:05Z","git_url":"git://github.com/alphagov/performanceplatform-admin.git","ssh_url":"git@github.com:alphagov/performanceplatform-admin.git","clone_url":"https://github.com/alphagov/performanceplatform-admin.git","svn_url":"https://github.com/alphagov/performanceplatform-admin","homepage":null,"size":3485,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/53"},"html":{"href":"https://github.com/alphagov/performanceplatform-admin/pull/53"},"issue":{"href":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues/53"},"comments":{"href":"https://api.github.com/repos/alphagov/performanceplatform-admin/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/alphagov/performanceplatform-admin/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/performanceplatform-admin/statuses/5af52129d1337f6565d45d99977e43a9d30e0913"}}}}