{"action":"created","comment":{"url":"https://api.github.com/repos/divio/django-filer/pulls/comments/55754048","id":55754048,"diff_hunk":"@@ -54,3 +59,55 @@ def userperms_for_request(item, request):\n             if x:\n                 r.append(p)\n     return r\n+\n+\n+def popup_status(request):\n+    return (IS_POPUP_VAR in request.GET or 'pop' in request.GET or\n+            IS_POPUP_VAR in request.POST or 'pop' in request.POST)\n+\n+\n+def popup_pick_type(request):\n+    # very important to limit the pick_types because the result is marked safe.\n+    # (injection attacks)\n+    pick_type = request.GET.get('_pick', request.POST.get('_pick', None))\n+    if pick_type in ALLOWED_PICK_TYPES:\n+        return pick_type\n+    return None\n+\n+\n+def admin_url_params(request):\n+    \"\"\"\n+    given a request, looks at GET and POST values to determine which params\n+    should be added. Is used to keep the context of popup and picker mode.\n+    \"\"\"\n+    # FIXME: put this code in a better location\n+    params = {}\n+    if popup_status(request):\n+        params[IS_POPUP_VAR] = '1'\n+    pick_type = popup_pick_type(request)\n+    if pick_type:\n+        params['_pick'] = pick_type\n+    return params\n+\n+\n+def admin_url_params_encoded(request, first_separator='?'):\n+    # sorted to make testing easier\n+    params = urlencode(sorted(admin_url_params(request).items()))\n+    if not params:\n+        return ''\n+    return '{}{}'.format(first_separator, params)","path":"filer/admin/tools.py","position":55,"original_position":55,"commit_id":"48a5bd81702a351ba7441129cd67cc589776b273","original_commit_id":"48a5bd81702a351ba7441129cd67cc589776b273","user":{"login":"mkoistinen","id":615759,"avatar_url":"https://avatars.githubusercontent.com/u/615759?v=3","gravatar_id":"","url":"https://api.github.com/users/mkoistinen","html_url":"https://github.com/mkoistinen","followers_url":"https://api.github.com/users/mkoistinen/followers","following_url":"https://api.github.com/users/mkoistinen/following{/other_user}","gists_url":"https://api.github.com/users/mkoistinen/gists{/gist_id}","starred_url":"https://api.github.com/users/mkoistinen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkoistinen/subscriptions","organizations_url":"https://api.github.com/users/mkoistinen/orgs","repos_url":"https://api.github.com/users/mkoistinen/repos","events_url":"https://api.github.com/users/mkoistinen/events{/privacy}","received_events_url":"https://api.github.com/users/mkoistinen/received_events","type":"User","site_admin":false},"body":"[see previous note]","created_at":"2016-03-10T21:39:49Z","updated_at":"2016-03-10T21:39:49Z","html_url":"https://github.com/divio/django-filer/pull/772#discussion_r55754048","pull_request_url":"https://api.github.com/repos/divio/django-filer/pulls/772","_links":{"self":{"href":"https://api.github.com/repos/divio/django-filer/pulls/comments/55754048"},"html":{"href":"https://github.com/divio/django-filer/pull/772#discussion_r55754048"},"pull_request":{"href":"https://api.github.com/repos/divio/django-filer/pulls/772"}}},"pull_request":{"url":"https://api.github.com/repos/divio/django-filer/pulls/772","id":62149555,"html_url":"https://github.com/divio/django-filer/pull/772","diff_url":"https://github.com/divio/django-filer/pull/772.diff","patch_url":"https://github.com/divio/django-filer/pull/772.patch","issue_url":"https://api.github.com/repos/divio/django-filer/issues/772","number":772,"state":"open","locked":false,"title":"popup context cleanup","user":{"login":"stefanfoulis","id":14330,"avatar_url":"https://avatars.githubusercontent.com/u/14330?v=3","gravatar_id":"","url":"https://api.github.com/users/stefanfoulis","html_url":"https://github.com/stefanfoulis","followers_url":"https://api.github.com/users/stefanfoulis/followers","following_url":"https://api.github.com/users/stefanfoulis/following{/other_user}","gists_url":"https://api.github.com/users/stefanfoulis/gists{/gist_id}","starred_url":"https://api.github.com/users/stefanfoulis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefanfoulis/subscriptions","organizations_url":"https://api.github.com/users/stefanfoulis/orgs","repos_url":"https://api.github.com/users/stefanfoulis/repos","events_url":"https://api.github.com/users/stefanfoulis/events{/privacy}","received_events_url":"https://api.github.com/users/stefanfoulis/received_events","type":"User","site_admin":false},"body":"> WIP! DO NOT MERGE\r\n\r\n![10mcp2](https://cloud.githubusercontent.com/assets/14330/13684226/125614e0-e70b-11e5-92e2-f91b768ce0e9.jpg)\r\n*(in size. not necessarily in usefulness)* I'm sorry.\r\n\r\nOriginally I set out to fix popup handling for Django 1.8+, since the popups would sometimes just close. To fix it in a way that would work on Django 1.6 through to 1.9, the popup handling needed a cleanup. \r\n\r\nEasier ``GET`` parameters for file and folder picker popup:\r\n- ``_popup=1`` as before to stay compatible with django admin\r\n- replace ``select_folder=1`` with ``_pick=folder`` or ``_pick=file``\r\n- helper templatetags and a special context variable to make templates simpler\r\n- tests for that stuff\r\n\r\nAs I wrote tests, a lot of little regressions popped up in the existing code. I ended up doing some related changes:\r\n\r\n- dropped official Django 1.5 support, as it seems it has not actually been working for a few releases\r\n- cleanup testrunner. remove unnecessary tests. Cleaner matrix structure. Don't test for python 3.3 anymore.\r\n- Image model customisation seems broken. see #778 \r\n- removed dead code and templates\r\n- moved admin views from ``filer/views`` to ``filer/admin/views``\r\n- use relative imports\r\n\r\n### Todo\r\n- [x] basic replacement of ``select_folder`` with ``pick=folder`` and ``pick=file``\r\n- fix handling of popup state (#738)\r\n  - [x] file save\r\n  - [x] image save\r\n  - [x] folder save\r\n  - [x] file delete\r\n  - [x] image delete\r\n  - [x] folder delete\r\n- [ ] correct escaping of ``&`` as ``&amp;`` in ``href`` \r\n- testcases\r\n  - [x] keeps picker context when deleting folder\r\n  - [x] keeps picker context when deleting file\r\n  - [x] keeps picker context when editing file/image\r\n  - [x] keeps picker context when editing folder\r\n  - ~~django raw-id native popup mode works~~ this did not work in any previous version either\r\n- manual testing (general, file picker, image picker, folder picker, raw-id file/folder/image picker)\r\n  - [ ] Django 1.6 with djangocms-admin-style\r\n  - [ ] Django 1.6 without djangocms-admin-style\r\n  - [ ] Django 1.9 with djangocms-admin-style\r\n  - [ ] Django 1.9 without djangocms-admin-style\r\n- [x] flake8\r\n- [x] re-organise/cleanup\r\n- [x] ~~fix Django 1.5 support (if it is simple. otherwise drop support).~~ **Dropped it**.\r\n- [ ] rename ``filer.admin.tools.AdminUrlParams`` to something better","created_at":"2016-03-08T22:41:46Z","updated_at":"2016-03-10T21:39:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ff26303eb91870f62297faa724d7236412ece3d","assignee":{"login":"stefanfoulis","id":14330,"avatar_url":"https://avatars.githubusercontent.com/u/14330?v=3","gravatar_id":"","url":"https://api.github.com/users/stefanfoulis","html_url":"https://github.com/stefanfoulis","followers_url":"https://api.github.com/users/stefanfoulis/followers","following_url":"https://api.github.com/users/stefanfoulis/following{/other_user}","gists_url":"https://api.github.com/users/stefanfoulis/gists{/gist_id}","starred_url":"https://api.github.com/users/stefanfoulis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefanfoulis/subscriptions","organizations_url":"https://api.github.com/users/stefanfoulis/orgs","repos_url":"https://api.github.com/users/stefanfoulis/repos","events_url":"https://api.github.com/users/stefanfoulis/events{/privacy}","received_events_url":"https://api.github.com/users/stefanfoulis/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/divio/django-filer/milestones/16","html_url":"https://github.com/divio/django-filer/milestones/1.2.0","labels_url":"https://api.github.com/repos/divio/django-filer/milestones/16/labels","id":1599647,"number":16,"title":"1.2.0","description":"* Django 1.9 compatibility\r\n* fix regressions\r\n","creator":{"login":"stefanfoulis","id":14330,"avatar_url":"https://avatars.githubusercontent.com/u/14330?v=3","gravatar_id":"","url":"https://api.github.com/users/stefanfoulis","html_url":"https://github.com/stefanfoulis","followers_url":"https://api.github.com/users/stefanfoulis/followers","following_url":"https://api.github.com/users/stefanfoulis/following{/other_user}","gists_url":"https://api.github.com/users/stefanfoulis/gists{/gist_id}","starred_url":"https://api.github.com/users/stefanfoulis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefanfoulis/subscriptions","organizations_url":"https://api.github.com/users/stefanfoulis/orgs","repos_url":"https://api.github.com/users/stefanfoulis/repos","events_url":"https://api.github.com/users/stefanfoulis/events{/privacy}","received_events_url":"https://api.github.com/users/stefanfoulis/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":16,"state":"open","created_at":"2016-02-23T13:42:58Z","updated_at":"2016-03-09T08:19:22Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/divio/django-filer/pulls/772/commits","review_comments_url":"https://api.github.com/repos/divio/django-filer/pulls/772/comments","review_comment_url":"https://api.github.com/repos/divio/django-filer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/divio/django-filer/issues/772/comments","statuses_url":"https://api.github.com/repos/divio/django-filer/statuses/48a5bd81702a351ba7441129cd67cc589776b273","head":{"label":"divio:feature/popup-context-cleanup","ref":"feature/popup-context-cleanup","sha":"48a5bd81702a351ba7441129cd67cc589776b273","user":{"login":"divio","id":117904,"avatar_url":"https://avatars.githubusercontent.com/u/117904?v=3","gravatar_id":"","url":"https://api.github.com/users/divio","html_url":"https://github.com/divio","followers_url":"https://api.github.com/users/divio/followers","following_url":"https://api.github.com/users/divio/following{/other_user}","gists_url":"https://api.github.com/users/divio/gists{/gist_id}","starred_url":"https://api.github.com/users/divio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/divio/subscriptions","organizations_url":"https://api.github.com/users/divio/orgs","repos_url":"https://api.github.com/users/divio/repos","events_url":"https://api.github.com/users/divio/events{/privacy}","received_events_url":"https://api.github.com/users/divio/received_events","type":"Organization","site_admin":false},"repo":{"id":286516,"name":"django-filer","full_name":"divio/django-filer","owner":{"login":"divio","id":117904,"avatar_url":"https://avatars.githubusercontent.com/u/117904?v=3","gravatar_id":"","url":"https://api.github.com/users/divio","html_url":"https://github.com/divio","followers_url":"https://api.github.com/users/divio/followers","following_url":"https://api.github.com/users/divio/following{/other_user}","gists_url":"https://api.github.com/users/divio/gists{/gist_id}","starred_url":"https://api.github.com/users/divio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/divio/subscriptions","organizations_url":"https://api.github.com/users/divio/orgs","repos_url":"https://api.github.com/users/divio/repos","events_url":"https://api.github.com/users/divio/events{/privacy}","received_events_url":"https://api.github.com/users/divio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/divio/django-filer","description":"File and Image Management Application for django","fork":false,"url":"https://api.github.com/repos/divio/django-filer","forks_url":"https://api.github.com/repos/divio/django-filer/forks","keys_url":"https://api.github.com/repos/divio/django-filer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/divio/django-filer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/divio/django-filer/teams","hooks_url":"https://api.github.com/repos/divio/django-filer/hooks","issue_events_url":"https://api.github.com/repos/divio/django-filer/issues/events{/number}","events_url":"https://api.github.com/repos/divio/django-filer/events","assignees_url":"https://api.github.com/repos/divio/django-filer/assignees{/user}","branches_url":"https://api.github.com/repos/divio/django-filer/branches{/branch}","tags_url":"https://api.github.com/repos/divio/django-filer/tags","blobs_url":"https://api.github.com/repos/divio/django-filer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/divio/django-filer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/divio/django-filer/git/refs{/sha}","trees_url":"https://api.github.com/repos/divio/django-filer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/divio/django-filer/statuses/{sha}","languages_url":"https://api.github.com/repos/divio/django-filer/languages","stargazers_url":"https://api.github.com/repos/divio/django-filer/stargazers","contributors_url":"https://api.github.com/repos/divio/django-filer/contributors","subscribers_url":"https://api.github.com/repos/divio/django-filer/subscribers","subscription_url":"https://api.github.com/repos/divio/django-filer/subscription","commits_url":"https://api.github.com/repos/divio/django-filer/commits{/sha}","git_commits_url":"https://api.github.com/repos/divio/django-filer/git/commits{/sha}","comments_url":"https://api.github.com/repos/divio/django-filer/comments{/number}","issue_comment_url":"https://api.github.com/repos/divio/django-filer/issues/comments{/number}","contents_url":"https://api.github.com/repos/divio/django-filer/contents/{+path}","compare_url":"https://api.github.com/repos/divio/django-filer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/divio/django-filer/merges","archive_url":"https://api.github.com/repos/divio/django-filer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/divio/django-filer/downloads","issues_url":"https://api.github.com/repos/divio/django-filer/issues{/number}","pulls_url":"https://api.github.com/repos/divio/django-filer/pulls{/number}","milestones_url":"https://api.github.com/repos/divio/django-filer/milestones{/number}","notifications_url":"https://api.github.com/repos/divio/django-filer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/divio/django-filer/labels{/name}","releases_url":"https://api.github.com/repos/divio/django-filer/releases{/id}","deployments_url":"https://api.github.com/repos/divio/django-filer/deployments","created_at":"2009-08-24T13:49:42Z","updated_at":"2016-03-10T15:32:08Z","pushed_at":"2016-03-10T21:31:07Z","git_url":"git://github.com/divio/django-filer.git","ssh_url":"git@github.com:divio/django-filer.git","clone_url":"https://github.com/divio/django-filer.git","svn_url":"https://github.com/divio/django-filer","homepage":"https://github.com/divio/django-filer/wiki","size":6519,"stargazers_count":605,"watchers_count":605,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":267,"mirror_url":null,"open_issues_count":148,"forks":267,"open_issues":148,"watchers":605,"default_branch":"develop"}},"base":{"label":"divio:develop","ref":"develop","sha":"1089ca1ba901e12c8c09f4596c6d726b89812cd4","user":{"login":"divio","id":117904,"avatar_url":"https://avatars.githubusercontent.com/u/117904?v=3","gravatar_id":"","url":"https://api.github.com/users/divio","html_url":"https://github.com/divio","followers_url":"https://api.github.com/users/divio/followers","following_url":"https://api.github.com/users/divio/following{/other_user}","gists_url":"https://api.github.com/users/divio/gists{/gist_id}","starred_url":"https://api.github.com/users/divio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/divio/subscriptions","organizations_url":"https://api.github.com/users/divio/orgs","repos_url":"https://api.github.com/users/divio/repos","events_url":"https://api.github.com/users/divio/events{/privacy}","received_events_url":"https://api.github.com/users/divio/received_events","type":"Organization","site_admin":false},"repo":{"id":286516,"name":"django-filer","full_name":"divio/django-filer","owner":{"login":"divio","id":117904,"avatar_url":"https://avatars.githubusercontent.com/u/117904?v=3","gravatar_id":"","url":"https://api.github.com/users/divio","html_url":"https://github.com/divio","followers_url":"https://api.github.com/users/divio/followers","following_url":"https://api.github.com/users/divio/following{/other_user}","gists_url":"https://api.github.com/users/divio/gists{/gist_id}","starred_url":"https://api.github.com/users/divio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/divio/subscriptions","organizations_url":"https://api.github.com/users/divio/orgs","repos_url":"https://api.github.com/users/divio/repos","events_url":"https://api.github.com/users/divio/events{/privacy}","received_events_url":"https://api.github.com/users/divio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/divio/django-filer","description":"File and Image Management Application for django","fork":false,"url":"https://api.github.com/repos/divio/django-filer","forks_url":"https://api.github.com/repos/divio/django-filer/forks","keys_url":"https://api.github.com/repos/divio/django-filer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/divio/django-filer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/divio/django-filer/teams","hooks_url":"https://api.github.com/repos/divio/django-filer/hooks","issue_events_url":"https://api.github.com/repos/divio/django-filer/issues/events{/number}","events_url":"https://api.github.com/repos/divio/django-filer/events","assignees_url":"https://api.github.com/repos/divio/django-filer/assignees{/user}","branches_url":"https://api.github.com/repos/divio/django-filer/branches{/branch}","tags_url":"https://api.github.com/repos/divio/django-filer/tags","blobs_url":"https://api.github.com/repos/divio/django-filer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/divio/django-filer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/divio/django-filer/git/refs{/sha}","trees_url":"https://api.github.com/repos/divio/django-filer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/divio/django-filer/statuses/{sha}","languages_url":"https://api.github.com/repos/divio/django-filer/languages","stargazers_url":"https://api.github.com/repos/divio/django-filer/stargazers","contributors_url":"https://api.github.com/repos/divio/django-filer/contributors","subscribers_url":"https://api.github.com/repos/divio/django-filer/subscribers","subscription_url":"https://api.github.com/repos/divio/django-filer/subscription","commits_url":"https://api.github.com/repos/divio/django-filer/commits{/sha}","git_commits_url":"https://api.github.com/repos/divio/django-filer/git/commits{/sha}","comments_url":"https://api.github.com/repos/divio/django-filer/comments{/number}","issue_comment_url":"https://api.github.com/repos/divio/django-filer/issues/comments{/number}","contents_url":"https://api.github.com/repos/divio/django-filer/contents/{+path}","compare_url":"https://api.github.com/repos/divio/django-filer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/divio/django-filer/merges","archive_url":"https://api.github.com/repos/divio/django-filer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/divio/django-filer/downloads","issues_url":"https://api.github.com/repos/divio/django-filer/issues{/number}","pulls_url":"https://api.github.com/repos/divio/django-filer/pulls{/number}","milestones_url":"https://api.github.com/repos/divio/django-filer/milestones{/number}","notifications_url":"https://api.github.com/repos/divio/django-filer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/divio/django-filer/labels{/name}","releases_url":"https://api.github.com/repos/divio/django-filer/releases{/id}","deployments_url":"https://api.github.com/repos/divio/django-filer/deployments","created_at":"2009-08-24T13:49:42Z","updated_at":"2016-03-10T15:32:08Z","pushed_at":"2016-03-10T21:31:07Z","git_url":"git://github.com/divio/django-filer.git","ssh_url":"git@github.com:divio/django-filer.git","clone_url":"https://github.com/divio/django-filer.git","svn_url":"https://github.com/divio/django-filer","homepage":"https://github.com/divio/django-filer/wiki","size":6519,"stargazers_count":605,"watchers_count":605,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":267,"mirror_url":null,"open_issues_count":148,"forks":267,"open_issues":148,"watchers":605,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/divio/django-filer/pulls/772"},"html":{"href":"https://github.com/divio/django-filer/pull/772"},"issue":{"href":"https://api.github.com/repos/divio/django-filer/issues/772"},"comments":{"href":"https://api.github.com/repos/divio/django-filer/issues/772/comments"},"review_comments":{"href":"https://api.github.com/repos/divio/django-filer/pulls/772/comments"},"review_comment":{"href":"https://api.github.com/repos/divio/django-filer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/divio/django-filer/pulls/772/commits"},"statuses":{"href":"https://api.github.com/repos/divio/django-filer/statuses/48a5bd81702a351ba7441129cd67cc589776b273"}}}}