{"action":"created","comment":{"url":"https://api.github.com/repos/indico/indico/pulls/comments/41511784","id":41511784,"diff_hunk":"@@ -0,0 +1,147 @@\n+# This file is part of Indico.\n+# Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).\n+#\n+# Indico is free software; you can redistribute it and/or\n+# modify it under the terms of the GNU General Public License as\n+# published by the Free Software Foundation; either version 3 of the\n+# License, or (at your option) any later version.\n+#\n+# Indico is distributed in the hope that it will be useful, but\n+# WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+# General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with Indico; if not, see <http://www.gnu.org/licenses/>.\n+\n+from __future__ import unicode_literals\n+\n+import itertools\n+import json\n+from uuid import uuid4\n+\n+from flask import session, request, redirect, jsonify\n+from sqlalchemy.orm import joinedload\n+\n+from indico.core.db import db\n+from indico.modules.events.registration.controllers.management import RHManageRegFormBase, RHManageRegistrationBase\n+from indico.modules.events.registration.models.items import RegistrationFormItemType, RegistrationFormItem\n+from indico.modules.events.registration.models.registrations import Registration, RegistrationData\n+from indico.modules.events.registration.models.form_fields import RegistrationFormFieldData\n+from indico.modules.events.registration.views import WPManageRegistration\n+from indico.web.flask.templating import get_template_module\n+from indico.web.flask.util import url_for\n+from indico.web.util import jsonify_data\n+from MaKaC.common.cache import GenericCache\n+\n+\n+cache = GenericCache('reglist-config')\n+\n+\n+def _get_filters_from_request(regform):\n+    filters = {}\n+    for field in regform.form_items:\n+        if field.is_field and field.input_type in ['radio', 'country']:\n+            radioitems = request.form.getlist('radiogroup_{}'.format(field.id))\n+            if radioitems:\n+                filters[field.id] = radioitems\n+    return filters\n+\n+\n+def _filter_registration(query, filters):\n+    if not filters:\n+        return query\n+\n+    criteria = [db.and_(RegistrationFormFieldData.field_id == field_id,\n+                        RegistrationData.data.op('#>>')('{}').in_(data_list))\n+                for field_id, data_list in filters.iteritems()]\n+    subquery = (RegistrationData.query\n+                .with_entities(db.func.count(RegistrationData.registration_id))\n+                .join(RegistrationData.field_data)\n+                .filter(RegistrationData.registration_id == Registration.id)\n+                .filter(db.or_(*criteria))\n+                .correlate(Registration)\n+                .as_scalar())\n+    return query.filter(subquery == len(filters))\n+\n+\n+def _query_registrations(regform, filters):\n+    query = (Registration.query\n+             .with_parent(regform)\n+             .options(joinedload('data').joinedload('field_data').joinedload('field')))\n+    return _filter_registration(query, filters)\n+\n+\n+class RHRegistrationsListManage(RHManageRegFormBase):\n+    \"\"\"List all registrations of a specific registration form of an event\"\"\"\n+\n+    def _process(self):\n+        session_key = 'reg_list_config_{}'.format(self.regform.id)\n+        report_config_uuid = request.args.get('config')\n+        if report_config_uuid:\n+            configuration = cache.get(report_config_uuid)","path":"indico/modules/events/registration/controllers/management/reglists.py","position":82,"original_position":82,"commit_id":"529fe1a93041a8b7017783d3fe1faf146bbcb714","original_commit_id":"529fe1a93041a8b7017783d3fe1faf146bbcb714","user":{"login":"ThiefMaster","id":179599,"avatar_url":"https://avatars.githubusercontent.com/u/179599?v=3","gravatar_id":"","url":"https://api.github.com/users/ThiefMaster","html_url":"https://github.com/ThiefMaster","followers_url":"https://api.github.com/users/ThiefMaster/followers","following_url":"https://api.github.com/users/ThiefMaster/following{/other_user}","gists_url":"https://api.github.com/users/ThiefMaster/gists{/gist_id}","starred_url":"https://api.github.com/users/ThiefMaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThiefMaster/subscriptions","organizations_url":"https://api.github.com/users/ThiefMaster/orgs","repos_url":"https://api.github.com/users/ThiefMaster/repos","events_url":"https://api.github.com/users/ThiefMaster/events{/privacy}","received_events_url":"https://api.github.com/users/ThiefMaster/received_events","type":"User","site_admin":false},"body":"IIRC. we wanted to include the regform it in the data stored in the cache to avoid loading another regform's config (which would probably not work or even cause errors)","created_at":"2015-10-08T13:27:22Z","updated_at":"2015-10-08T13:27:22Z","html_url":"https://github.com/indico/indico/pull/2085#discussion_r41511784","pull_request_url":"https://api.github.com/repos/indico/indico/pulls/2085","_links":{"self":{"href":"https://api.github.com/repos/indico/indico/pulls/comments/41511784"},"html":{"href":"https://github.com/indico/indico/pull/2085#discussion_r41511784"},"pull_request":{"href":"https://api.github.com/repos/indico/indico/pulls/2085"}}},"pull_request":{"url":"https://api.github.com/repos/indico/indico/pulls/2085","id":47004760,"html_url":"https://github.com/indico/indico/pull/2085","diff_url":"https://github.com/indico/indico/pull/2085.diff","patch_url":"https://github.com/indico/indico/pull/2085.patch","issue_url":"https://api.github.com/repos/indico/indico/issues/2085","number":2085,"state":"open","locked":false,"title":"Registration list","user":{"login":"nop33","id":1579899,"avatar_url":"https://avatars.githubusercontent.com/u/1579899?v=3","gravatar_id":"","url":"https://api.github.com/users/nop33","html_url":"https://github.com/nop33","followers_url":"https://api.github.com/users/nop33/followers","following_url":"https://api.github.com/users/nop33/following{/other_user}","gists_url":"https://api.github.com/users/nop33/gists{/gist_id}","starred_url":"https://api.github.com/users/nop33/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nop33/subscriptions","organizations_url":"https://api.github.com/users/nop33/orgs","repos_url":"https://api.github.com/users/nop33/repos","events_url":"https://api.github.com/users/nop33/events{/privacy}","received_events_url":"https://api.github.com/users/nop33/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-07T09:30:56Z","updated_at":"2015-10-08T13:27:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"87b819ee93b3d50550879eb47bd74532bf0c4940","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/indico/indico/pulls/2085/commits","review_comments_url":"https://api.github.com/repos/indico/indico/pulls/2085/comments","review_comment_url":"https://api.github.com/repos/indico/indico/pulls/comments{/number}","comments_url":"https://api.github.com/repos/indico/indico/issues/2085/comments","statuses_url":"https://api.github.com/repos/indico/indico/statuses/529fe1a93041a8b7017783d3fe1faf146bbcb714","head":{"label":"nop33:wip/registration","ref":"wip/registration","sha":"529fe1a93041a8b7017783d3fe1faf146bbcb714","user":{"login":"nop33","id":1579899,"avatar_url":"https://avatars.githubusercontent.com/u/1579899?v=3","gravatar_id":"","url":"https://api.github.com/users/nop33","html_url":"https://github.com/nop33","followers_url":"https://api.github.com/users/nop33/followers","following_url":"https://api.github.com/users/nop33/following{/other_user}","gists_url":"https://api.github.com/users/nop33/gists{/gist_id}","starred_url":"https://api.github.com/users/nop33/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nop33/subscriptions","organizations_url":"https://api.github.com/users/nop33/orgs","repos_url":"https://api.github.com/users/nop33/repos","events_url":"https://api.github.com/users/nop33/events{/privacy}","received_events_url":"https://api.github.com/users/nop33/received_events","type":"User","site_admin":false},"repo":{"id":22684703,"name":"indico","full_name":"nop33/indico","owner":{"login":"nop33","id":1579899,"avatar_url":"https://avatars.githubusercontent.com/u/1579899?v=3","gravatar_id":"","url":"https://api.github.com/users/nop33","html_url":"https://github.com/nop33","followers_url":"https://api.github.com/users/nop33/followers","following_url":"https://api.github.com/users/nop33/following{/other_user}","gists_url":"https://api.github.com/users/nop33/gists{/gist_id}","starred_url":"https://api.github.com/users/nop33/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nop33/subscriptions","organizations_url":"https://api.github.com/users/nop33/orgs","repos_url":"https://api.github.com/users/nop33/repos","events_url":"https://api.github.com/users/nop33/events{/privacy}","received_events_url":"https://api.github.com/users/nop33/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nop33/indico","description":"The Indico Project (mirror)","fork":true,"url":"https://api.github.com/repos/nop33/indico","forks_url":"https://api.github.com/repos/nop33/indico/forks","keys_url":"https://api.github.com/repos/nop33/indico/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nop33/indico/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nop33/indico/teams","hooks_url":"https://api.github.com/repos/nop33/indico/hooks","issue_events_url":"https://api.github.com/repos/nop33/indico/issues/events{/number}","events_url":"https://api.github.com/repos/nop33/indico/events","assignees_url":"https://api.github.com/repos/nop33/indico/assignees{/user}","branches_url":"https://api.github.com/repos/nop33/indico/branches{/branch}","tags_url":"https://api.github.com/repos/nop33/indico/tags","blobs_url":"https://api.github.com/repos/nop33/indico/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nop33/indico/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nop33/indico/git/refs{/sha}","trees_url":"https://api.github.com/repos/nop33/indico/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nop33/indico/statuses/{sha}","languages_url":"https://api.github.com/repos/nop33/indico/languages","stargazers_url":"https://api.github.com/repos/nop33/indico/stargazers","contributors_url":"https://api.github.com/repos/nop33/indico/contributors","subscribers_url":"https://api.github.com/repos/nop33/indico/subscribers","subscription_url":"https://api.github.com/repos/nop33/indico/subscription","commits_url":"https://api.github.com/repos/nop33/indico/commits{/sha}","git_commits_url":"https://api.github.com/repos/nop33/indico/git/commits{/sha}","comments_url":"https://api.github.com/repos/nop33/indico/comments{/number}","issue_comment_url":"https://api.github.com/repos/nop33/indico/issues/comments{/number}","contents_url":"https://api.github.com/repos/nop33/indico/contents/{+path}","compare_url":"https://api.github.com/repos/nop33/indico/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nop33/indico/merges","archive_url":"https://api.github.com/repos/nop33/indico/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nop33/indico/downloads","issues_url":"https://api.github.com/repos/nop33/indico/issues{/number}","pulls_url":"https://api.github.com/repos/nop33/indico/pulls{/number}","milestones_url":"https://api.github.com/repos/nop33/indico/milestones{/number}","notifications_url":"https://api.github.com/repos/nop33/indico/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nop33/indico/labels{/name}","releases_url":"https://api.github.com/repos/nop33/indico/releases{/id}","created_at":"2014-08-06T14:02:24Z","updated_at":"2015-09-07T15:17:59Z","pushed_at":"2015-10-08T12:56:32Z","git_url":"git://github.com/nop33/indico.git","ssh_url":"git@github.com:nop33/indico.git","clone_url":"https://github.com/nop33/indico.git","svn_url":"https://github.com/nop33/indico","homepage":"http://indico-software.org","size":186735,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"indico:wip/registration","ref":"wip/registration","sha":"eaa6912dfd32f7f12e1088c569be0f5966ea3c4d","user":{"login":"indico","id":715236,"avatar_url":"https://avatars.githubusercontent.com/u/715236?v=3","gravatar_id":"","url":"https://api.github.com/users/indico","html_url":"https://github.com/indico","followers_url":"https://api.github.com/users/indico/followers","following_url":"https://api.github.com/users/indico/following{/other_user}","gists_url":"https://api.github.com/users/indico/gists{/gist_id}","starred_url":"https://api.github.com/users/indico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indico/subscriptions","organizations_url":"https://api.github.com/users/indico/orgs","repos_url":"https://api.github.com/users/indico/repos","events_url":"https://api.github.com/users/indico/events{/privacy}","received_events_url":"https://api.github.com/users/indico/received_events","type":"Organization","site_admin":false},"repo":{"id":2113067,"name":"indico","full_name":"indico/indico","owner":{"login":"indico","id":715236,"avatar_url":"https://avatars.githubusercontent.com/u/715236?v=3","gravatar_id":"","url":"https://api.github.com/users/indico","html_url":"https://github.com/indico","followers_url":"https://api.github.com/users/indico/followers","following_url":"https://api.github.com/users/indico/following{/other_user}","gists_url":"https://api.github.com/users/indico/gists{/gist_id}","starred_url":"https://api.github.com/users/indico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indico/subscriptions","organizations_url":"https://api.github.com/users/indico/orgs","repos_url":"https://api.github.com/users/indico/repos","events_url":"https://api.github.com/users/indico/events{/privacy}","received_events_url":"https://api.github.com/users/indico/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/indico/indico","description":"The Indico Project","fork":false,"url":"https://api.github.com/repos/indico/indico","forks_url":"https://api.github.com/repos/indico/indico/forks","keys_url":"https://api.github.com/repos/indico/indico/keys{/key_id}","collaborators_url":"https://api.github.com/repos/indico/indico/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/indico/indico/teams","hooks_url":"https://api.github.com/repos/indico/indico/hooks","issue_events_url":"https://api.github.com/repos/indico/indico/issues/events{/number}","events_url":"https://api.github.com/repos/indico/indico/events","assignees_url":"https://api.github.com/repos/indico/indico/assignees{/user}","branches_url":"https://api.github.com/repos/indico/indico/branches{/branch}","tags_url":"https://api.github.com/repos/indico/indico/tags","blobs_url":"https://api.github.com/repos/indico/indico/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/indico/indico/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/indico/indico/git/refs{/sha}","trees_url":"https://api.github.com/repos/indico/indico/git/trees{/sha}","statuses_url":"https://api.github.com/repos/indico/indico/statuses/{sha}","languages_url":"https://api.github.com/repos/indico/indico/languages","stargazers_url":"https://api.github.com/repos/indico/indico/stargazers","contributors_url":"https://api.github.com/repos/indico/indico/contributors","subscribers_url":"https://api.github.com/repos/indico/indico/subscribers","subscription_url":"https://api.github.com/repos/indico/indico/subscription","commits_url":"https://api.github.com/repos/indico/indico/commits{/sha}","git_commits_url":"https://api.github.com/repos/indico/indico/git/commits{/sha}","comments_url":"https://api.github.com/repos/indico/indico/comments{/number}","issue_comment_url":"https://api.github.com/repos/indico/indico/issues/comments{/number}","contents_url":"https://api.github.com/repos/indico/indico/contents/{+path}","compare_url":"https://api.github.com/repos/indico/indico/compare/{base}...{head}","merges_url":"https://api.github.com/repos/indico/indico/merges","archive_url":"https://api.github.com/repos/indico/indico/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/indico/indico/downloads","issues_url":"https://api.github.com/repos/indico/indico/issues{/number}","pulls_url":"https://api.github.com/repos/indico/indico/pulls{/number}","milestones_url":"https://api.github.com/repos/indico/indico/milestones{/number}","notifications_url":"https://api.github.com/repos/indico/indico/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/indico/indico/labels{/name}","releases_url":"https://api.github.com/repos/indico/indico/releases{/id}","created_at":"2011-07-27T13:56:30Z","updated_at":"2015-10-08T08:45:20Z","pushed_at":"2015-10-08T12:56:33Z","git_url":"git://github.com/indico/indico.git","ssh_url":"git@github.com:indico/indico.git","clone_url":"https://github.com/indico/indico.git","svn_url":"https://github.com/indico/indico","homepage":"http://indico-software.org","size":212281,"stargazers_count":107,"watchers_count":107,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":59,"mirror_url":null,"open_issues_count":534,"forks":59,"open_issues":534,"watchers":107,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/indico/indico/pulls/2085"},"html":{"href":"https://github.com/indico/indico/pull/2085"},"issue":{"href":"https://api.github.com/repos/indico/indico/issues/2085"},"comments":{"href":"https://api.github.com/repos/indico/indico/issues/2085/comments"},"review_comments":{"href":"https://api.github.com/repos/indico/indico/pulls/2085/comments"},"review_comment":{"href":"https://api.github.com/repos/indico/indico/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/indico/indico/pulls/2085/commits"},"statuses":{"href":"https://api.github.com/repos/indico/indico/statuses/529fe1a93041a8b7017783d3fe1faf146bbcb714"}}}}