예제 #1
0
파일: views.py 프로젝트: bkolobara/indico
def render_event_header(event, conference_layout=False, theme=None, theme_override=False):
    print_url = _get_print_url(event, theme, theme_override) if not conference_layout else None
    show_nav_bar = event.type_ != EventType.conference or layout_settings.get(event, 'show_nav_bar')
    themes = {tid: {'name': data['title'], 'user_visible': data.get('user_visible')}
              for tid, data in theme_settings.get_themes_for(event.type_.name).viewitems()}
    return render_template('events/header.html',
                           event=event, print_url=print_url, show_nav_bar=show_nav_bar, themes=themes, theme=theme)
예제 #2
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
예제 #3
0
 def __init__(self, *args, **kwargs):
     event_type = kwargs.pop('event_type').legacy_name
     super(IndicoThemeSelectField, self).__init__(*args, **kwargs)
     self.choices = sorted([(tid, theme['title'])
                            for tid, theme in theme_settings.get_themes_for(event_type).viewitems()],
                           key=itemgetter(1))
     self.default = theme_settings.defaults[event_type]
예제 #4
0
 def __init__(self, *args, **kwargs):
     event_type = kwargs.pop('event_type').legacy_name
     super(IndicoThemeSelectField, self).__init__(*args, **kwargs)
     self.choices = sorted([(tid, theme['title'])
                            for tid, theme in theme_settings.get_themes_for(event_type).viewitems()],
                           key=itemgetter(1))
     self.default = theme_settings.defaults[event_type]
예제 #5
0
def get_theme(event, override_theme_id=None):
    """Get the theme ID and whether it's an override.

    This is useful for places where a user may specify a different
    timetable theme.  If the override theme is not valid for the
    event, a message is flashed and an exception redirecting the user
    to the main event page is raised.

    :raise BadRequest: if the override theme id is not valid
    :return: a ``(theme_id, is_override)`` tuple
    """
    if not override_theme_id:
        return event.theme, False
    elif override_theme_id == 'default':
        theme = theme_settings.defaults[event.type]
        return theme, theme != event.theme
    elif override_theme_id in theme_settings.get_themes_for(event.type_.name):
        return override_theme_id, override_theme_id != event.theme
    else:
        if override_theme_id in theme_settings.themes:
            flash(
                _("The theme '{}' is not valid for this event.").format(
                    override_theme_id))
        else:
            flash(
                _("The theme '{}' does not exist.").format(override_theme_id))
        raise BadRequest(response=redirect(event.url))
예제 #6
0
파일: events.py 프로젝트: indico/indico
 def theme(self):
     from indico.modules.events.layout import layout_settings, theme_settings
     theme = layout_settings.get(self, 'timetable_theme')
     if theme and theme in theme_settings.get_themes_for(self.type):
         return theme
     else:
         return theme_settings.defaults[self.type]
예제 #7
0
 def theme(self):
     from indico.modules.events.layout import layout_settings, theme_settings
     theme = layout_settings.get(self, 'timetable_theme')
     if theme and theme in theme_settings.get_themes_for(self.type):
         return theme
     else:
         return theme_settings.defaults[self.type]
예제 #8
0
def render_event_header(event, conference_layout=False, theme=None, theme_override=False):
    print_url = _get_print_url(event, theme, theme_override) if not conference_layout else None
    show_nav_bar = event.type_ != EventType.conference or layout_settings.get(event, u'show_nav_bar')
    themes = {tid: {'name': data[u'title'], 'user_visible': data.get(u'user_visible')}
              for tid, data in theme_settings.get_themes_for(event.type_.name).viewitems()}
    return render_template(u'events/header.html',
                           event=event, print_url=print_url, show_nav_bar=show_nav_bar, themes=themes, theme=theme)
예제 #9
0
 def __init__(self, *args, **kwargs):
     allow_default = kwargs.pop('allow_default', False)
     event_type = kwargs.pop('event_type').name
     super().__init__(*args, **kwargs)
     self.choices = sorted(((tid, theme['title'])
                            for tid, theme in theme_settings.get_themes_for(event_type).items()),
                           key=lambda x: x[1].lower())
     if allow_default:
         self.choices.insert(0, ('', _('Category default')))
     self.default = '' if allow_default else theme_settings.defaults[event_type]
예제 #10
0
파일: fields.py 프로젝트: indico/indico
 def __init__(self, *args, **kwargs):
     allow_default = kwargs.pop('allow_default', False)
     event_type = kwargs.pop('event_type').name
     super(IndicoThemeSelectField, self).__init__(*args, **kwargs)
     self.choices = sorted([(tid, theme['title'])
                            for tid, theme in theme_settings.get_themes_for(event_type).viewitems()],
                           key=lambda x: x[1].lower())
     if allow_default:
         self.choices.insert(0, ('', _('Category default')))
     self.default = '' if allow_default else theme_settings.defaults[event_type]
예제 #11
0
 def _process_default_themes(self, old_cat):
     default_themes = {
         'meeting': theme_settings.defaults['meeting'],
         'lecture': theme_settings.defaults['lecture']
     }
     old_default_styles = getattr(old_cat, '_defaultStyle', None)
     if old_default_styles:
         if not old_default_styles['simple_event']:
             pass
         elif old_default_styles['simple_event'] in theme_settings.get_themes_for('simple_event'):
             default_themes['lecture'] = old_default_styles['simple_event']
         else:
             self.print_warning('Invalid lecture theme: {}'.format(old_default_styles['simple_event']),
                                always=False, event_id=old_cat.id)
         if not old_default_styles['meeting']:
             pass
         elif old_default_styles['meeting'] in theme_settings.get_themes_for('meeting'):
             default_themes['meeting'] = old_default_styles['meeting']
         else:
             self.print_warning('Invalid meeting theme: {}'.format(old_default_styles['meeting']),
                                always=False, event_id=old_cat.id)
     return default_themes
예제 #12
0
 def _process_default_themes(self, old_cat):
     default_themes = {
         'meeting': theme_settings.defaults['meeting'],
         'lecture': theme_settings.defaults['lecture']
     }
     old_default_styles = getattr(old_cat, '_defaultStyle', None)
     if old_default_styles:
         if not old_default_styles['simple_event']:
             pass
         elif old_default_styles['simple_event'] in theme_settings.get_themes_for('simple_event'):
             default_themes['lecture'] = old_default_styles['simple_event']
         else:
             self.print_warning('Invalid lecture theme: {}'.format(old_default_styles['simple_event']),
                                always=False, event_id=old_cat.id)
         if not old_default_styles['meeting']:
             pass
         elif old_default_styles['meeting'] in theme_settings.get_themes_for('meeting'):
             default_themes['meeting'] = old_default_styles['meeting']
         else:
             self.print_warning('Invalid meeting theme: {}'.format(old_default_styles['meeting']),
                                always=False, event_id=old_cat.id)
     return default_themes
예제 #13
0
파일: util.py 프로젝트: indico/indico
def get_theme(event, override_theme_id=None):
    """Get the theme ID and whether it's an override.

    This is useful for places where a user may specify a different
    timetable theme.  If the override theme is not valid for the
    event, a message is flashed and an exception redirecting the user
    to the main event page is raised.

    :raise BadRequest: if the override theme id is not valid
    :return: a ``(theme_id, is_override)`` tuple
    """
    if not override_theme_id:
        return event.theme, False
    elif override_theme_id == 'default':
        theme = theme_settings.defaults[event.type]
        return theme, theme != event.theme
    elif override_theme_id in theme_settings.get_themes_for(event.type_.name):
        return override_theme_id, override_theme_id != event.theme
    else:
        if override_theme_id in theme_settings.themes:
            flash(_("The theme '{}' is not valid for this event.").format(override_theme_id))
        else:
            flash(_("The theme '{}' does not exist.").format(override_theme_id))
        raise BadRequest(response=redirect(event.url))
예제 #14
0
    def getVars( self ):
        vars = WConferenceHeader.getVars( self )

        vars["categurl"] = self._conf.as_event.category.url
        view_options = [{'id': tid, 'name': data['title']} for tid, data in
                        sorted(theme_settings.get_themes_for(vars["type"]).viewitems(), key=lambda x: x[1]['title'])]

        vars["viewoptions"] = view_options
        vars["SelectedStyle"] = theme_settings.themes[vars['currentView']]['title']
        vars["displayURL"] = urlHandlers.UHConferenceDisplay.getURL(self._rh._conf)

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

        # Dates Menu
        tz = DisplayTZ(self._aw,self._conf,useServerTZ=1).getDisplayTZ()
        sdate = self._conf.getStartDate().astimezone(timezone(tz))
        edate = self._conf.getEndDate().astimezone(timezone(tz))
        selected = ""
        if vars.has_key("selectedDate"):
            selectedDate = vars["selectedDate"]
            if selectedDate == "all" or selectedDate == "":
                selected = "selected"
        else:
            selectedDate = "all"
        dates = [ i18nformat(""" <option value="all" %s>- -  _("all days") - -</option> """)%selected]
        while sdate.date() <= edate.date():
            iso_date = sdate.date().isoformat()
            selected = 'selected' if selectedDate == iso_date else ''
            dates.append('<option value="{}" {}>{}</option>'.format(iso_date, selected, format_date(sdate)))
            sdate = sdate + timedelta(days=1)
        vars["datesMenu"] = "".join(dates);

        # Sessions Menu
        selected = ""
        if vars.has_key("selectedSession"):
            selectedSession = vars["selectedSession"]
            if selectedSession == "all" or selectedSession == "":
                selected = "selected"
        else:
            selectedSession = "all"
        sessions = [ i18nformat(""" <option value="all" %s>- -  _("all sessions") - -</option> """)%selected]
        for session_ in self._conf.as_event.sessions:
            selected = "selected" if unicode(session_.friendly_id) == selectedSession else ''
            title = session_.title
            if len(title) > 60:
                title = title[0:40] + u"..."
            sessions.append(""" <option value="%s" %s>%s</option> """ % (session_.friendly_id, selected,
                                                                         title.encode('utf-8')))
        vars["sessionsMenu"] = "".join(sessions)

        # Handle hide/show contributions option
        hideContributions = None;
        if len(self._conf.getSessionList()) != 0:
            if vars.has_key("detailLevel"):
                if vars["detailLevel"] == "session":
                    hideContributions = "checked"
                else:
                    hideContributions = ""
        vars["hideContributions"] = hideContributions

        urlCustPrint = urlHandlers.UHConferenceOtherViews.getURL(self._conf)
        urlCustPrint.addParam("showDate", vars.get("selectedDate") or "all")
        urlCustPrint.addParam("showSession", vars.get("selectedSession") or "all")
        urlCustPrint.addParam("detailLevel", vars.get("detailLevel") or "all")
        urlCustPrint.addParam("fr", "no")
        urlCustPrint.addParam("view", vars["currentView"])
        vars["printURL"]=str(urlCustPrint)
        vars["pdfURL"] = url_for('timetable.export_pdf', self._conf)
        return vars
예제 #15
0
    def getVars(self):
        vars = WConferenceHeader.getVars(self)

        vars["categurl"] = self._conf.as_event.category.url
        view_options = [{
            'id': tid,
            'name': data['title']
        } for tid, data in sorted(theme_settings.get_themes_for(
            vars["type"]).viewitems(),
                                  key=lambda x: x[1]['title'])]

        vars["viewoptions"] = view_options
        vars["SelectedStyle"] = theme_settings.themes[
            vars['currentView']]['title']
        vars["displayURL"] = urlHandlers.UHConferenceDisplay.getURL(
            self._rh._conf)

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

        # Dates Menu
        tz = DisplayTZ(self._aw, self._conf, useServerTZ=1).getDisplayTZ()
        sdate = self._conf.getStartDate().astimezone(timezone(tz))
        edate = self._conf.getEndDate().astimezone(timezone(tz))
        selected = ""
        if vars.has_key("selectedDate"):
            selectedDate = vars["selectedDate"]
            if selectedDate == "all" or selectedDate == "":
                selected = "selected"
        else:
            selectedDate = "all"
        dates = [
            i18nformat(
                """ <option value="all" %s>- -  _("all days") - -</option> """)
            % selected
        ]
        while sdate.date() <= edate.date():
            iso_date = sdate.date().isoformat()
            selected = 'selected' if selectedDate == iso_date else ''
            dates.append('<option value="{}" {}>{}</option>'.format(
                iso_date, selected, format_date(sdate)))
            sdate = sdate + timedelta(days=1)
        vars["datesMenu"] = "".join(dates)

        # Sessions Menu
        selected = ""
        if vars.has_key("selectedSession"):
            selectedSession = vars["selectedSession"]
            if selectedSession == "all" or selectedSession == "":
                selected = "selected"
        else:
            selectedSession = "all"
        sessions = [
            i18nformat(
                """ <option value="all" %s>- -  _("all sessions") - -</option> """
            ) % selected
        ]
        for session_ in self._conf.as_event.sessions:
            selected = "selected" if unicode(
                session_.friendly_id) == selectedSession else ''
            title = session_.title
            if len(title) > 60:
                title = title[0:40] + u"..."
            sessions.append(
                """ <option value="%s" %s>%s</option> """ %
                (session_.friendly_id, selected, title.encode('utf-8')))
        vars["sessionsMenu"] = "".join(sessions)

        # Handle hide/show contributions option
        hideContributions = None
        if len(self._conf.getSessionList()) != 0:
            if vars.has_key("detailLevel"):
                if vars["detailLevel"] == "session":
                    hideContributions = "checked"
                else:
                    hideContributions = ""
        vars["hideContributions"] = hideContributions

        urlCustPrint = urlHandlers.UHConferenceOtherViews.getURL(self._conf)
        urlCustPrint.addParam("showDate", vars.get("selectedDate") or "all")
        urlCustPrint.addParam("showSession",
                              vars.get("selectedSession") or "all")
        urlCustPrint.addParam("detailLevel", vars.get("detailLevel") or "all")
        urlCustPrint.addParam("fr", "no")
        urlCustPrint.addParam("view", vars["currentView"])
        vars["printURL"] = str(urlCustPrint)
        vars["pdfURL"] = url_for('timetable.export_pdf', self._conf)
        return vars
예제 #16
0
파일: forms.py 프로젝트: indico/indico
def _get_timetable_theme_choices(event):
    it = ((tid, data['title']) for tid, data in theme_settings.get_themes_for(event.type).viewitems())
    return sorted(it, key=lambda x: x[1].lower())
예제 #17
0
def _get_timetable_theme_choices(event):
    it = ((tid, data['title'])
          for tid, data in theme_settings.get_themes_for(event.type).items())
    return sorted(it, key=lambda x: x[1].lower())
예제 #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