Example #1
0
def get_base_ical_parameters(user, event, detail, session_=None):
    """Returns a dict of all parameters expected by iCal template"""

    from indico.web.http_api.util import generate_public_auth_request

    api_mode = api_settings.get('security_mode')
    persistent_allowed = api_settings.get('allow_persistent')
    api_key = user.api_key if user else None
    persistent_user_enabled = api_key.is_persistent_allowed if api_key else None
    tpl = get_template_module('api/_messages.html')
    persistent_agreement = tpl.get_ical_persistent_msg()
    if session_:
        path = '/export/event/{0}/session/{1}.ics'.format(event.id, session_.id)
    else:
        path = '/export/event/{0}.ics'.format(event.id)
    top_urls = generate_public_auth_request(api_key, path)
    urls = generate_public_auth_request(api_key, path, {'detail': detail})
    request_urls = {
        'publicRequestURL': top_urls['publicRequestURL'],
        'authRequestURL': top_urls['authRequestURL'],
        'publicRequestDetailedURL': urls['publicRequestURL'],
        'authRequestDetailedURL': urls['authRequestURL']
    }

    return {'api_mode': api_mode, 'api_key': api_key, 'persistent_allowed': persistent_allowed,
            'persistent_user_enabled': persistent_user_enabled, 'api_active': api_key is not None,
            'api_key_user_agreement': tpl.get_ical_api_key_msg(), 'api_persistent_user_agreement': persistent_agreement,
            'user_logged': user is not None, 'request_urls': request_urls}
Example #2
0
 def _process(self):
     urls = {}
     api_key = session.user.api_key if session.user else None
     url_format = '/export/event/{0}/{1}/{2}.ics'
     if isinstance(self.object, Contribution):
         event = self.object.event
         urls = generate_public_auth_request(
             api_key,
             url_format.format(event.id, 'contribution', self.object.id))
     elif isinstance(self.object, Session):
         event = self.object.event
         urls = generate_public_auth_request(
             api_key, url_format.format(event.id, 'session',
                                        self.object.id))
     elif isinstance(self.object, Category):
         urls = generate_public_auth_request(
             api_key, f'/export/categ/{self.object.id}.ics',
             {'from': '-31d'})
     elif isinstance(self.object, Event):
         urls = generate_public_auth_request(
             api_key, f'/export/event/{self.object.id}.ics')
         event_urls = generate_public_auth_request(
             api_key, f'/export/event/{self.object.id}.ics',
             {'detail': 'contribution'})
         urls['publicRequestDetailedURL'] = event_urls['publicRequestURL']
         urls['authRequestDetailedURL'] = event_urls['authRequestURL']
     return jsonify_data(flash=False, urls=urls)
Example #3
0
    def getVars( self ):
        from indico.web.http_api.util import generate_public_auth_request

        vars = WHeader.getVars( self )
        vars["categurl"] = self._conf.as_event.category.url

        vars["conf"] = vars["target"] = self._conf

        vars["imgLogo"] = Config.getInstance().getSystemIconURL("miniLogo")
        vars["MaKaCHomeURL"] = self._conf.as_event.category.url

        # Default values to avoid NameError while executing the template
        styles = theme_settings.get_themes_for("conference")

        vars["viewoptions"] = [{'id': theme_id, 'name': data['title']}
                               for theme_id, data in sorted(styles.viewitems(), key=lambda x: x[1]['title'])]
        vars["SelectedStyle"] = ""
        vars["pdfURL"] = ""
        vars["displayURL"] = str(urlHandlers.UHConferenceOtherViews.getURL(self._conf))

        # Setting the buttons that will be displayed in the header menu
        vars["showFilterButton"] = False
        vars["showMoreButton"] = True
        vars["showExportToICal"] = True
        vars["showExportToPDF"] = False
        vars["showDLMaterial"] = True
        vars["showLayout"] = True

        vars["displayNavigationBar"] = layout_settings.get(self._conf, 'show_nav_bar')

        # This is basically the same WICalExportBase, but we need some extra
        # logic in order to have the detailed URLs
        apiMode = api_settings.get('security_mode')

        vars["icsIconURL"] = str(Config.getInstance().getSystemIconURL("ical_grey"))
        vars["apiMode"] = apiMode
        vars["signingEnabled"] = apiMode in {APIMode.SIGNED, APIMode.ONLYKEY_SIGNED, APIMode.ALL_SIGNED}
        vars["persistentAllowed"] = api_settings.get('allow_persistent')
        user = self._aw.getUser()
        apiKey = user.api_key if user else None

        topURLs = generate_public_auth_request(apiKey, '/export/event/%s.ics' % self._conf.getId())
        urls = generate_public_auth_request(apiKey, '/export/event/%s.ics' % self._conf.getId(),
                                            {'detail': 'contributions'})

        vars["requestURLs"] = {
            'publicRequestURL': topURLs["publicRequestURL"],
            'authRequestURL':  topURLs["authRequestURL"],
            'publicRequestDetailedURL': urls["publicRequestURL"],
            'authRequestDetailedURL':  urls["authRequestURL"]
        }

        vars["persistentUserEnabled"] = apiKey.is_persistent_allowed if apiKey else False
        vars["apiActive"] = apiKey is not None
        vars["userLogged"] = user is not None
        tpl = get_template_module('api/_messages.html')
        vars['apiKeyUserAgreement'] = tpl.get_ical_api_key_msg()
        vars['apiPersistentUserAgreement'] = tpl.get_ical_persistent_msg()

        return vars
Example #4
0
def get_base_ical_parameters(user, detail, path, params=None):
    """Returns a dict of all parameters expected by iCal template"""

    from indico.web.http_api.util import generate_public_auth_request

    api_mode = api_settings.get('security_mode')
    persistent_allowed = api_settings.get('allow_persistent')
    api_key = user.api_key if user else None
    persistent_user_enabled = api_key.is_persistent_allowed if api_key else None
    tpl = get_template_module('api/_messages.html')
    persistent_agreement = tpl.get_ical_persistent_msg()
    top_urls = generate_public_auth_request(api_key, path, params)
    urls = generate_public_auth_request(api_key, path,
                                        dict(params or {}, detail=detail))
    request_urls = {
        'publicRequestURL': top_urls['publicRequestURL'],
        'authRequestURL': top_urls['authRequestURL'],
        'publicRequestDetailedURL': urls['publicRequestURL'],
        'authRequestDetailedURL': urls['authRequestURL']
    }

    return {
        'api_mode': api_mode,
        'api_key': api_key,
        'persistent_allowed': persistent_allowed,
        'persistent_user_enabled': persistent_user_enabled,
        'api_active': api_key is not None,
        'api_key_user_agreement': tpl.get_ical_api_key_msg(),
        'api_persistent_user_agreement': persistent_agreement,
        'user_logged': user is not None,
        'request_urls': request_urls
    }
Example #5
0
 def _getAnswer(self):
     result = {}
     urls = generate_public_auth_request(self._apiKey, '/export/event/%s.ics' % self._target.getId())
     result["publicRequestURL"] = urls["publicRequestURL"]
     result["authRequestURL"] = urls["authRequestURL"]
     urls = generate_public_auth_request(self._apiKey, '/export/event/%s.ics' % self._target.getId(),
                                         {'detail': 'contribution'})
     result["publicRequestDetailedURL"] = urls["publicRequestURL"]
     result["authRequestDetailedURL"] = urls["authRequestURL"]
     return result
Example #6
0
 def _getAnswer(self):
     result = {}
     urls = generate_public_auth_request(
         self._apiKey, '/export/event/%s.ics' % self._target.getId())
     result["publicRequestURL"] = urls["publicRequestURL"]
     result["authRequestURL"] = urls["authRequestURL"]
     urls = generate_public_auth_request(
         self._apiKey, '/export/event/%s.ics' % self._target.getId(),
         {'detail': 'contribution'})
     result["publicRequestDetailedURL"] = urls["publicRequestURL"]
     result["authRequestDetailedURL"] = urls["authRequestURL"]
     return result
Example #7
0
    def _getAnswer(self):
        result = {}

        urls = generate_public_auth_request(self._apiKey, '/export/categ/%s.ics' % self._target.getId())
        result["publicRequestURL"] = urls["publicRequestURL"]
        result["authRequestURL"] = urls["authRequestURL"]
        return result
Example #8
0
    def _getAnswer(self):
        result = {}

        urls = generate_public_auth_request(self._apiKey, '/export/categ/%s.ics' % self._target.getId())
        result["publicRequestURL"] = urls["publicRequestURL"]
        result["authRequestURL"] = urls["authRequestURL"]
        return result
Example #9
0
    def _getIcalExportParams(self, user, url, params={}):
        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
        apiMode = minfo.getAPIMode()
        apiKey = user.getAPIKey() if user else None

        urls = generate_public_auth_request(
            apiMode,
            apiKey,
            url,
            params,
            minfo.isAPIPersistentAllowed() and (apiKey.isPersistentAllowed() if apiKey else False),
            minfo.isAPIHTTPSRequired(),
        )

        return {
            "currentUser": user,
            "icsIconURL": str(Config.getInstance().getSystemIconURL("ical_grey")),
            "apiMode": apiMode,
            "signingEnabled": apiMode in (API_MODE_SIGNED, API_MODE_ONLYKEY_SIGNED, API_MODE_ALL_SIGNED),
            "persistentAllowed": minfo.isAPIPersistentAllowed(),
            "requestURLs": urls,
            "persistentUserEnabled": apiKey.isPersistentAllowed() if apiKey else False,
            "apiActive": apiKey != None,
            "userLogged": user != None,
            "apiKeyUserAgreement": minfo.getAPIKeyUserAgreement(),
            "apiPersistentUserAgreement": minfo.getAPIPersistentUserAgreement(),
        }
Example #10
0
    def _getAnswer(self):
        result = {}

        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()

        urls = generate_public_auth_request(self._apiMode, self._apiKey, '/export/categ/%s.ics'%self._target.getId(), {}, minfo.isAPIPersistentAllowed() and self._apiKey.isPersistentAllowed(), minfo.isAPIHTTPSRequired())
        result["publicRequestURL"] = urls["publicRequestURL"]
        result["authRequestURL"] =  urls["authRequestURL"]
        return result
Example #11
0
 def _process(self):
     urls = {}
     api_key = session.user.api_key if session.user else None
     url_format = '/export/event/{0}/{1}/{2}.ics'
     if isinstance(self.object, Contribution):
         event = self.object.event
         urls = generate_public_auth_request(api_key, url_format.format(event.id, 'contribution', self.object.id))
     elif isinstance(self.object, Session):
         event = self.object.event
         urls = generate_public_auth_request(api_key, url_format.format(event.id, 'session', self.object.id))
     elif isinstance(self.object, Category):
         urls = generate_public_auth_request(api_key, '/export/categ/{0}.ics'.format(self.object.id),
                                             {'from': '-31d'})
     elif isinstance(self.object, Event):
         urls = generate_public_auth_request(api_key, '/export/event/{0}.ics'.format(self.object.id))
         event_urls = generate_public_auth_request(api_key, '/export/event/{0}.ics'.format(self.object.id),
                                                   {'detail': 'contribution'})
         urls['publicRequestDetailedURL'] = event_urls['publicRequestURL']
         urls['authRequestDetailedURL'] = event_urls['authRequestURL']
     return jsonify_data(flash=False, urls=urls)
Example #12
0
    def _getAnswer(self):
        result = {}

        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()

        urls = generate_public_auth_request(
            self._apiMode, self._apiKey,
            '/export/categ/%s.ics' % self._target.getId(), {},
            minfo.isAPIPersistentAllowed()
            and self._apiKey.isPersistentAllowed(), minfo.isAPIHTTPSRequired())
        result["publicRequestURL"] = urls["publicRequestURL"]
        result["authRequestURL"] = urls["authRequestURL"]
        return result
Example #13
0
def get_base_ical_parameters(user, detail, path, params=None):
    """Returns a dict of all parameters expected by iCal template"""

    from indico.web.http_api.util import generate_public_auth_request

    api_mode = api_settings.get('security_mode')
    persistent_allowed = api_settings.get('allow_persistent')
    api_key = user.api_key if user else None
    persistent_user_enabled = api_key.is_persistent_allowed if api_key else None
    tpl = get_template_module('api/_messages.html')
    persistent_agreement = tpl.get_ical_persistent_msg()
    top_urls = generate_public_auth_request(api_key, path, params)
    urls = generate_public_auth_request(api_key, path, dict(params or {}, detail=detail))
    request_urls = {
        'publicRequestURL': top_urls['publicRequestURL'],
        'authRequestURL': top_urls['authRequestURL'],
        'publicRequestDetailedURL': urls['publicRequestURL'],
        'authRequestDetailedURL': urls['authRequestURL']
    }

    return {'api_mode': api_mode, 'api_key': api_key, 'persistent_allowed': persistent_allowed,
            'persistent_user_enabled': persistent_user_enabled, 'api_active': api_key is not None,
            'api_key_user_agreement': tpl.get_ical_api_key_msg(), 'api_persistent_user_agreement': persistent_agreement,
            'user_logged': user is not None, 'request_urls': request_urls}
Example #14
0
def get_base_ical_parameters(user, event, detail, session_=None):
    """Returns a dict of all parameters expected by iCal template"""

    from indico.web.http_api.util import generate_public_auth_request

    api_mode = api_settings.get('security_mode')
    persistent_allowed = api_settings.get('allow_persistent')
    api_key = user.api_key if user else None
    persistent_user_enabled = api_key.is_persistent_allowed if api_key else None
    tpl = get_template_module('api/_messages.html')
    persistent_agreement = tpl.get_ical_persistent_msg()
    if session_:
        path = '/export/event/{0}/session/{1}.ics'.format(
            event.id, session_.id)
    else:
        path = '/export/event/{0}.ics'.format(event.id)
    top_urls = generate_public_auth_request(api_key, path)
    urls = generate_public_auth_request(api_key, path, {'detail': detail})
    request_urls = {
        'publicRequestURL': top_urls['publicRequestURL'],
        'authRequestURL': top_urls['authRequestURL'],
        'publicRequestDetailedURL': urls['publicRequestURL'],
        'authRequestDetailedURL': urls['authRequestURL']
    }

    return {
        'api_mode': api_mode,
        'api_key': api_key,
        'persistent_allowed': persistent_allowed,
        'persistent_user_enabled': persistent_user_enabled,
        'api_active': api_key is not None,
        'api_key_user_agreement': tpl.get_ical_api_key_msg(),
        'api_persistent_user_agreement': persistent_agreement,
        'user_logged': user is not None,
        'request_urls': request_urls
    }
Example #15
0
    def _getIcalExportParams(self, user, url, params=None):
        apiMode = api_settings.get('security_mode')
        apiKey = user.api_key if user else None

        urls = generate_public_auth_request(apiKey, url, params)
        tpl = get_template_module('api/_messages.html')

        return {
            'currentUser': user,
            'icsIconURL': str(Config.getInstance().getSystemIconURL("ical_grey")),
            'apiMode': apiMode,
            'signingEnabled': apiMode in {APIMode.SIGNED, APIMode.ONLYKEY_SIGNED, APIMode.ALL_SIGNED},
            'persistentAllowed': api_settings.get('allow_persistent'),
            'requestURLs': urls,
            'persistentUserEnabled': apiKey.is_persistent_allowed if apiKey else False,
            'apiActive': apiKey is not None,
            'userLogged': user is not None,
            'apiKeyUserAgreement': tpl.get_ical_api_key_msg(),
            'apiPersistentUserAgreement': tpl.get_ical_persistent_msg()
        }
Example #16
0
    def _getIcalExportParams(self, user, url, params = {}):
        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
        apiMode = minfo.getAPIMode()
        apiKey = user.getAPIKey() if user else None

        urls = generate_public_auth_request(apiMode, apiKey, url, params,
            minfo.isAPIPersistentAllowed() and (apiKey.isPersistentAllowed() if apiKey else False), minfo.isAPIHTTPSRequired())

        return {
            'currentUser': user,
            'icsIconURL': str(Config.getInstance().getSystemIconURL("ical_grey")),
            'apiMode': apiMode,
            'signingEnabled': apiMode in (API_MODE_SIGNED, API_MODE_ONLYKEY_SIGNED, API_MODE_ALL_SIGNED),
            'persistentAllowed': minfo.isAPIPersistentAllowed(),
            'requestURLs': urls,
            'persistentUserEnabled': apiKey.isPersistentAllowed() if apiKey else False,
            'apiActive': apiKey != None,
            'userLogged': user != None,
            'apiKeyUserAgreement': minfo.getAPIKeyUserAgreement(),
            'apiPersistentUserAgreement': minfo.getAPIPersistentUserAgreement()
        }
Example #17
0
    def _getIcalExportParams(self, user, url, params=None):
        apiMode = api_settings.get('security_mode')
        apiKey = user.api_key if user else None

        urls = generate_public_auth_request(apiKey, url, params)
        tpl = get_template_module('api/_messages.html')

        return {
            'currentUser': user,
            'icsIconURL':
            str(Config.getInstance().getSystemIconURL("ical_grey")),
            'apiMode': apiMode,
            'signingEnabled': apiMode
            in {APIMode.SIGNED, APIMode.ONLYKEY_SIGNED, APIMode.ALL_SIGNED},
            'persistentAllowed': api_settings.get('allow_persistent'),
            'requestURLs': urls,
            'persistentUserEnabled':
            apiKey.is_persistent_allowed if apiKey else False,
            'apiActive': apiKey is not None,
            'userLogged': user is not None,
            'apiKeyUserAgreement': tpl.get_ical_api_key_msg(),
            'apiPersistentUserAgreement': tpl.get_ical_persistent_msg()
        }
Example #18
0
    def getVars(self):
        from indico.web.http_api.util import generate_public_auth_request

        vars = WHeader.getVars(self)
        vars["categurl"] = self._conf.as_event.category.url

        vars["conf"] = vars["target"] = self._conf

        vars["imgLogo"] = Config.getInstance().getSystemIconURL("miniLogo")
        vars["MaKaCHomeURL"] = self._conf.as_event.category.url

        # Default values to avoid NameError while executing the template
        styles = theme_settings.get_themes_for("conference")

        vars["viewoptions"] = [{
            'id': theme_id,
            'name': data['title']
        } for theme_id, data in sorted(styles.viewitems(),
                                       key=lambda x: x[1]['title'])]
        vars["SelectedStyle"] = ""
        vars["pdfURL"] = ""
        vars["displayURL"] = str(
            urlHandlers.UHConferenceOtherViews.getURL(self._conf))

        # Setting the buttons that will be displayed in the header menu
        vars["showFilterButton"] = False
        vars["showMoreButton"] = True
        vars["showExportToICal"] = True
        vars["showExportToPDF"] = False
        vars["showDLMaterial"] = True
        vars["showLayout"] = True

        vars["displayNavigationBar"] = layout_settings.get(
            self._conf, 'show_nav_bar')

        # This is basically the same WICalExportBase, but we need some extra
        # logic in order to have the detailed URLs
        apiMode = api_settings.get('security_mode')

        vars["icsIconURL"] = str(
            Config.getInstance().getSystemIconURL("ical_grey"))
        vars["apiMode"] = apiMode
        vars["signingEnabled"] = apiMode in {
            APIMode.SIGNED, APIMode.ONLYKEY_SIGNED, APIMode.ALL_SIGNED
        }
        vars["persistentAllowed"] = api_settings.get('allow_persistent')
        user = self._aw.getUser()
        apiKey = user.api_key if user else None

        topURLs = generate_public_auth_request(
            apiKey, '/export/event/%s.ics' % self._conf.getId())
        urls = generate_public_auth_request(
            apiKey, '/export/event/%s.ics' % self._conf.getId(),
            {'detail': 'contributions'})

        vars["requestURLs"] = {
            'publicRequestURL': topURLs["publicRequestURL"],
            'authRequestURL': topURLs["authRequestURL"],
            'publicRequestDetailedURL': urls["publicRequestURL"],
            'authRequestDetailedURL': urls["authRequestURL"]
        }

        vars[
            "persistentUserEnabled"] = apiKey.is_persistent_allowed if apiKey else False
        vars["apiActive"] = apiKey is not None
        vars["userLogged"] = user is not None
        tpl = get_template_module('api/_messages.html')
        vars['apiKeyUserAgreement'] = tpl.get_ical_api_key_msg()
        vars['apiPersistentUserAgreement'] = tpl.get_ical_persistent_msg()

        return vars