Ejemplo n.º 1
0
 def get(self):
     rfidb = yield RFIDB.get_global()
     users = yield rfidb.list_users()
     exhibitperms = yield ExhibitPermissions.get_global()
     for user in users:
         userid = user['id']
         user['permissions'] = yield exhibitperms.get_permissions(userid)
     return self.api_response(users)
Ejemplo n.º 2
0
    def get(self):
        showid = self.get_argument('showtime_id')
        shares = self.get_arguments('share')
        passphrase = self.get_argument('passphrase', None)
        reprocess = bool(self.get_argument('reprocess', None) is not None)
        ticket_api = CONFIG.get('ticket_api')

        # we could also just pass the raw arguments, but this is more explicit
        # and 'self documenting'
        params = [('showtime_id', showid)]
        if passphrase:
            params += [('passphrase', passphrase)]
        elif shares:
            params += [('share', s) for s in shares]
        url = url_concat(ticket_api + '/api/showtimes/access_tokens', params)
        show_data_raw = yield httpclient.fetch(url, request_timeout=180)
        if show_data_raw.code != 200:
            return self.error(show_data_raw.code, show_data_raw.body)
        exhibitperms = yield ExhibitPermissions.get_global()
        show_data = json.loads(show_data_raw.body)
        show_date = show_data['data']['date']
        users_added = []
        for user_data in show_data['data']['users']:
            userid = user_data.pop('id')
            perms = yield exhibitperms.get_permissions(userid)
            if perms and not reprocess:
                users_added.append({'userid': userid,
                                    'permissions': perms,
                                    'process': False})
            publickey = user_data['publickey']
            privatekey = user_data.get('privatekey')
            meta = user_data.get('meta') or {}
            meta.update({'showid': showid, 'permissions': perms,
                         'showdate': show_date})
            user = User(userid, publickey, services=user_data['services'],
                        privatekey_pem=privatekey, meta=meta)
            users_added.append({'userid': userid, 'process': True})
            ioloop.IOLoop.current().add_callback(partial(userprocess, user))
        return self.api_response(users_added)