{"action":"created","comment":{"url":"https://api.github.com/repos/shuup/shuup/pulls/comments/214739505","pull_request_review_id":151855196,"id":214739505,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNDczOTUwNQ==","diff_hunk":"@@ -213,3 +250,49 @@ def add_resource(context, location, resource):\n     if rc:\n         return bool(rc.add_resource(location, resource))\n     return False\n+\n+\n+def valid_view(context):\n+    \"\"\"\n+    Prevent adding the global snippet in admin views and in editor view\n+    \"\"\"\n+    view_class = getattr(context[\"view\"], \"__class__\", None) if context.get(\"view\") else None\n+    if not view_class or not context.get(\"request\"):\n+        return False\n+\n+    request = context.get(\"request\")\n+    if request:\n+        match = request.resolver_match\n+        if match and match.app_name == \"shuup_admin\":\n+            return False\n+\n+    view_name = getattr(view_class, \"__name__\", \"\")\n+    if view_name == \"EditorView\":\n+        return False\n+\n+    return True\n+\n+\n+def inject_global_snippet(context, content):\n+    if not valid_view(context):\n+        return\n+\n+    from shuup.xtheme import get_current_theme\n+    from shuup.xtheme.models import Snippet, SnippetType\n+    shop = get_shop(context[\"request\"])\n+\n+    for snippet in Snippet.objects.filter(shop=shop):","path":"shuup/xtheme/resources.py","position":127,"original_position":127,"commit_id":"edc8da810645d838b09b9a1d7498989704d55baf","original_commit_id":"edc8da810645d838b09b9a1d7498989704d55baf","user":{"login":"tulimaki","id":4940349,"node_id":"MDQ6VXNlcjQ5NDAzNDk=","avatar_url":"https://avatars1.githubusercontent.com/u/4940349?v=4","gravatar_id":"","url":"https://api.github.com/users/tulimaki","html_url":"https://github.com/tulimaki","followers_url":"https://api.github.com/users/tulimaki/followers","following_url":"https://api.github.com/users/tulimaki/following{/other_user}","gists_url":"https://api.github.com/users/tulimaki/gists{/gist_id}","starred_url":"https://api.github.com/users/tulimaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tulimaki/subscriptions","organizations_url":"https://api.github.com/users/tulimaki/orgs","repos_url":"https://api.github.com/users/tulimaki/repos","events_url":"https://api.github.com/users/tulimaki/events{/privacy}","received_events_url":"https://api.github.com/users/tulimaki/received_events","type":"User","site_admin":false},"body":"This likely needs to be cached. We can't loop over snippets on every page load.","created_at":"2018-09-03T17:33:47Z","updated_at":"2018-09-03T17:39:25Z","html_url":"https://github.com/shuup/shuup/pull/1461#discussion_r214739505","pull_request_url":"https://api.github.com/repos/shuup/shuup/pulls/1461","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/shuup/shuup/pulls/comments/214739505"},"html":{"href":"https://github.com/shuup/shuup/pull/1461#discussion_r214739505"},"pull_request":{"href":"https://api.github.com/repos/shuup/shuup/pulls/1461"}}},"pull_request":{"url":"https://api.github.com/repos/shuup/shuup/pulls/1461","id":212470331,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyNDcwMzMx","html_url":"https://github.com/shuup/shuup/pull/1461","diff_url":"https://github.com/shuup/shuup/pull/1461.diff","patch_url":"https://github.com/shuup/shuup/pull/1461.patch","issue_url":"https://api.github.com/repos/shuup/shuup/issues/1461","number":1461,"state":"open","locked":false,"title":"Xtheme: add feature to add global snippet injection","user":{"login":"chessbr","id":8770370,"node_id":"MDQ6VXNlcjg3NzAzNzA=","avatar_url":"https://avatars3.githubusercontent.com/u/8770370?v=4","gravatar_id":"","url":"https://api.github.com/users/chessbr","html_url":"https://github.com/chessbr","followers_url":"https://api.github.com/users/chessbr/followers","following_url":"https://api.github.com/users/chessbr/following{/other_user}","gists_url":"https://api.github.com/users/chessbr/gists{/gist_id}","starred_url":"https://api.github.com/users/chessbr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chessbr/subscriptions","organizations_url":"https://api.github.com/users/chessbr/orgs","repos_url":"https://api.github.com/users/chessbr/repos","events_url":"https://api.github.com/users/chessbr/events{/privacy}","received_events_url":"https://api.github.com/users/chessbr/received_events","type":"User","site_admin":false},"body":"Add feature to inject snippet of codes in all or a set of themes.\r\n\r\nAdd widget to enable CoreMirror editor\r\n\r\nRefs POS-2564","created_at":"2018-08-31T19:05:54Z","updated_at":"2018-09-03T17:39:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d13a9749da96dce0b9ce56e39d04257dc395eee","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/shuup/shuup/pulls/1461/commits","review_comments_url":"https://api.github.com/repos/shuup/shuup/pulls/1461/comments","review_comment_url":"https://api.github.com/repos/shuup/shuup/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shuup/shuup/issues/1461/comments","statuses_url":"https://api.github.com/repos/shuup/shuup/statuses/edc8da810645d838b09b9a1d7498989704d55baf","head":{"label":"chessbr:xtheme-snippets","ref":"xtheme-snippets","sha":"edc8da810645d838b09b9a1d7498989704d55baf","user":{"login":"chessbr","id":8770370,"node_id":"MDQ6VXNlcjg3NzAzNzA=","avatar_url":"https://avatars3.githubusercontent.com/u/8770370?v=4","gravatar_id":"","url":"https://api.github.com/users/chessbr","html_url":"https://github.com/chessbr","followers_url":"https://api.github.com/users/chessbr/followers","following_url":"https://api.github.com/users/chessbr/following{/other_user}","gists_url":"https://api.github.com/users/chessbr/gists{/gist_id}","starred_url":"https://api.github.com/users/chessbr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chessbr/subscriptions","organizations_url":"https://api.github.com/users/chessbr/orgs","repos_url":"https://api.github.com/users/chessbr/repos","events_url":"https://api.github.com/users/chessbr/events{/privacy}","received_events_url":"https://api.github.com/users/chessbr/received_events","type":"User","site_admin":false},"repo":{"id":74606275,"node_id":"MDEwOlJlcG9zaXRvcnk3NDYwNjI3NQ==","name":"shuup","full_name":"chessbr/shuup","owner":{"login":"chessbr","id":8770370,"node_id":"MDQ6VXNlcjg3NzAzNzA=","avatar_url":"https://avatars3.githubusercontent.com/u/8770370?v=4","gravatar_id":"","url":"https://api.github.com/users/chessbr","html_url":"https://github.com/chessbr","followers_url":"https://api.github.com/users/chessbr/followers","following_url":"https://api.github.com/users/chessbr/following{/other_user}","gists_url":"https://api.github.com/users/chessbr/gists{/gist_id}","starred_url":"https://api.github.com/users/chessbr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chessbr/subscriptions","organizations_url":"https://api.github.com/users/chessbr/orgs","repos_url":"https://api.github.com/users/chessbr/repos","events_url":"https://api.github.com/users/chessbr/events{/privacy}","received_events_url":"https://api.github.com/users/chessbr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chessbr/shuup","description":"E-Commerce Platform","fork":true,"url":"https://api.github.com/repos/chessbr/shuup","forks_url":"https://api.github.com/repos/chessbr/shuup/forks","keys_url":"https://api.github.com/repos/chessbr/shuup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chessbr/shuup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chessbr/shuup/teams","hooks_url":"https://api.github.com/repos/chessbr/shuup/hooks","issue_events_url":"https://api.github.com/repos/chessbr/shuup/issues/events{/number}","events_url":"https://api.github.com/repos/chessbr/shuup/events","assignees_url":"https://api.github.com/repos/chessbr/shuup/assignees{/user}","branches_url":"https://api.github.com/repos/chessbr/shuup/branches{/branch}","tags_url":"https://api.github.com/repos/chessbr/shuup/tags","blobs_url":"https://api.github.com/repos/chessbr/shuup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chessbr/shuup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chessbr/shuup/git/refs{/sha}","trees_url":"https://api.github.com/repos/chessbr/shuup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chessbr/shuup/statuses/{sha}","languages_url":"https://api.github.com/repos/chessbr/shuup/languages","stargazers_url":"https://api.github.com/repos/chessbr/shuup/stargazers","contributors_url":"https://api.github.com/repos/chessbr/shuup/contributors","subscribers_url":"https://api.github.com/repos/chessbr/shuup/subscribers","subscription_url":"https://api.github.com/repos/chessbr/shuup/subscription","commits_url":"https://api.github.com/repos/chessbr/shuup/commits{/sha}","git_commits_url":"https://api.github.com/repos/chessbr/shuup/git/commits{/sha}","comments_url":"https://api.github.com/repos/chessbr/shuup/comments{/number}","issue_comment_url":"https://api.github.com/repos/chessbr/shuup/issues/comments{/number}","contents_url":"https://api.github.com/repos/chessbr/shuup/contents/{+path}","compare_url":"https://api.github.com/repos/chessbr/shuup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chessbr/shuup/merges","archive_url":"https://api.github.com/repos/chessbr/shuup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chessbr/shuup/downloads","issues_url":"https://api.github.com/repos/chessbr/shuup/issues{/number}","pulls_url":"https://api.github.com/repos/chessbr/shuup/pulls{/number}","milestones_url":"https://api.github.com/repos/chessbr/shuup/milestones{/number}","notifications_url":"https://api.github.com/repos/chessbr/shuup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chessbr/shuup/labels{/name}","releases_url":"https://api.github.com/repos/chessbr/shuup/releases{/id}","deployments_url":"https://api.github.com/repos/chessbr/shuup/deployments","created_at":"2016-11-23T19:08:43Z","updated_at":"2018-09-03T12:10:30Z","pushed_at":"2018-09-03T14:20:53Z","git_url":"git://github.com/chessbr/shuup.git","ssh_url":"git@github.com:chessbr/shuup.git","clone_url":"https://github.com/chessbr/shuup.git","svn_url":"https://github.com/chessbr/shuup","homepage":"https://www.shuup.com","size":20584,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"shuup:master","ref":"master","sha":"f5a8c1abf175674a2365b25ba5fcdc47150bf952","user":{"login":"shuup","id":12714852,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNzE0ODUy","avatar_url":"https://avatars2.githubusercontent.com/u/12714852?v=4","gravatar_id":"","url":"https://api.github.com/users/shuup","html_url":"https://github.com/shuup","followers_url":"https://api.github.com/users/shuup/followers","following_url":"https://api.github.com/users/shuup/following{/other_user}","gists_url":"https://api.github.com/users/shuup/gists{/gist_id}","starred_url":"https://api.github.com/users/shuup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shuup/subscriptions","organizations_url":"https://api.github.com/users/shuup/orgs","repos_url":"https://api.github.com/users/shuup/repos","events_url":"https://api.github.com/users/shuup/events{/privacy}","received_events_url":"https://api.github.com/users/shuup/received_events","type":"Organization","site_admin":false},"repo":{"id":36803364,"node_id":"MDEwOlJlcG9zaXRvcnkzNjgwMzM2NA==","name":"shuup","full_name":"shuup/shuup","owner":{"login":"shuup","id":12714852,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNzE0ODUy","avatar_url":"https://avatars2.githubusercontent.com/u/12714852?v=4","gravatar_id":"","url":"https://api.github.com/users/shuup","html_url":"https://github.com/shuup","followers_url":"https://api.github.com/users/shuup/followers","following_url":"https://api.github.com/users/shuup/following{/other_user}","gists_url":"https://api.github.com/users/shuup/gists{/gist_id}","starred_url":"https://api.github.com/users/shuup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shuup/subscriptions","organizations_url":"https://api.github.com/users/shuup/orgs","repos_url":"https://api.github.com/users/shuup/repos","events_url":"https://api.github.com/users/shuup/events{/privacy}","received_events_url":"https://api.github.com/users/shuup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shuup/shuup","description":"E-Commerce Platform","fork":false,"url":"https://api.github.com/repos/shuup/shuup","forks_url":"https://api.github.com/repos/shuup/shuup/forks","keys_url":"https://api.github.com/repos/shuup/shuup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shuup/shuup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shuup/shuup/teams","hooks_url":"https://api.github.com/repos/shuup/shuup/hooks","issue_events_url":"https://api.github.com/repos/shuup/shuup/issues/events{/number}","events_url":"https://api.github.com/repos/shuup/shuup/events","assignees_url":"https://api.github.com/repos/shuup/shuup/assignees{/user}","branches_url":"https://api.github.com/repos/shuup/shuup/branches{/branch}","tags_url":"https://api.github.com/repos/shuup/shuup/tags","blobs_url":"https://api.github.com/repos/shuup/shuup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shuup/shuup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shuup/shuup/git/refs{/sha}","trees_url":"https://api.github.com/repos/shuup/shuup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shuup/shuup/statuses/{sha}","languages_url":"https://api.github.com/repos/shuup/shuup/languages","stargazers_url":"https://api.github.com/repos/shuup/shuup/stargazers","contributors_url":"https://api.github.com/repos/shuup/shuup/contributors","subscribers_url":"https://api.github.com/repos/shuup/shuup/subscribers","subscription_url":"https://api.github.com/repos/shuup/shuup/subscription","commits_url":"https://api.github.com/repos/shuup/shuup/commits{/sha}","git_commits_url":"https://api.github.com/repos/shuup/shuup/git/commits{/sha}","comments_url":"https://api.github.com/repos/shuup/shuup/comments{/number}","issue_comment_url":"https://api.github.com/repos/shuup/shuup/issues/comments{/number}","contents_url":"https://api.github.com/repos/shuup/shuup/contents/{+path}","compare_url":"https://api.github.com/repos/shuup/shuup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shuup/shuup/merges","archive_url":"https://api.github.com/repos/shuup/shuup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shuup/shuup/downloads","issues_url":"https://api.github.com/repos/shuup/shuup/issues{/number}","pulls_url":"https://api.github.com/repos/shuup/shuup/pulls{/number}","milestones_url":"https://api.github.com/repos/shuup/shuup/milestones{/number}","notifications_url":"https://api.github.com/repos/shuup/shuup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shuup/shuup/labels{/name}","releases_url":"https://api.github.com/repos/shuup/shuup/releases{/id}","deployments_url":"https://api.github.com/repos/shuup/shuup/deployments","created_at":"2015-06-03T12:53:21Z","updated_at":"2018-09-03T07:13:05Z","pushed_at":"2018-09-03T16:08:25Z","git_url":"git://github.com/shuup/shuup.git","ssh_url":"git@github.com:shuup/shuup.git","clone_url":"https://github.com/shuup/shuup.git","svn_url":"https://github.com/shuup/shuup","homepage":"https://www.shuup.com","size":20234,"stargazers_count":755,"watchers_count":755,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":396,"mirror_url":null,"archived":false,"open_issues_count":57,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":396,"open_issues":57,"watchers":755,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/shuup/shuup/pulls/1461"},"html":{"href":"https://github.com/shuup/shuup/pull/1461"},"issue":{"href":"https://api.github.com/repos/shuup/shuup/issues/1461"},"comments":{"href":"https://api.github.com/repos/shuup/shuup/issues/1461/comments"},"review_comments":{"href":"https://api.github.com/repos/shuup/shuup/pulls/1461/comments"},"review_comment":{"href":"https://api.github.com/repos/shuup/shuup/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shuup/shuup/pulls/1461/commits"},"statuses":{"href":"https://api.github.com/repos/shuup/shuup/statuses/edc8da810645d838b09b9a1d7498989704d55baf"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"tulimaki"}}