Пример #1
0
def need_stylesheet(instance):
    stylesheets = config.get_list('adhocracy.instance_stylesheets')
    themes = config.get_list('adhocracy.instance_themes')
    if instance is not None and instance.key in stylesheets:
        return static.instance_stylesheet(instance.key).need()
    elif (instance is not None and instance.theme in themes
          and instance.is_authenticated):
        return static.instance_theme(instance.theme).need()
    else:
        return static.style.need()
Пример #2
0
def need_stylesheet(instance):
    stylesheets = config.get_list('adhocracy.instance_stylesheets')
    themes = config.get_list('adhocracy.instance_themes')
    if instance is not None and instance.key in stylesheets:
        return static.instance_stylesheet(instance.key).need()
    elif (instance is not None and instance.theme in themes and
            instance.is_authenticated):
        return static.instance_theme(instance.theme).need()
    else:
        return static.style.need()
Пример #3
0
def get_enabled_locales():
    enabled_locales = config.get_list('adhocracy.enabled_locales')
    if enabled_locales is None:
        return LOCALES
    else:
        return filter(lambda x: x.language in enabled_locales, LOCALES)
Пример #4
0
def is_not_demo(check, u):
    if u is not None:
        demo_users = config.get_list('adhocracy.demo_users')
        check.other('demo_user', u.user_name in demo_users)
Пример #5
0
    def show(self, id, format='html'):
        c.page_instance = get_entity_or_abort(model.Instance, id)
        require.instance.show(c.page_instance)

        if format == 'json':
            return render_json(c.page_instance)
        elif format == 'rss':
            return self.activity(id, format)

        if c.page_instance != c.instance:
            redirect(h.entity_url(c.page_instance))

        c.tile = tiles.instance.InstanceTile(c.page_instance)
        c.sidebar_delegations = (_('Delegations are enabled.') if
                                 c.page_instance.allow_delegate else
                                 _('Delegations are disabled.'))

        overview_contents = config.get_list(
            'adhocracy.instance_overview_contents')
        overview_sidebar_contents = config.get_list(
            'adhocracy.instance_overview_sidebar_contents')

        if u'milestones' in overview_contents and c.page_instance.milestones:

            number = config.get_int(
                'adhocracy.number_instance_overview_milestones')

            milestones = model.Milestone.all_future_q(
                instance=c.page_instance).limit(number).all()

            c.next_milestones_pager = pager.milestones(
                milestones, size=number, enable_sorts=False,
                enable_pages=False, default_sort=sorting.milestone_time)

        c.events_pager = None
        if u'events' in overview_contents:
            events = model.Event.find_by_instance(c.page_instance, limit=10)
            c.events_pager = pager.events(events,
                                          enable_pages=False,
                                          enable_sorts=False)

        c.sidebar_events_pager = None
        if u'events' in overview_sidebar_contents:
            events = model.Event.find_by_instance(c.page_instance, limit=3)
            c.sidebar_events_pager = pager.events(events,
                                                  enable_pages=False,
                                                  enable_sorts=False,
                                                  row_type=u'sidebar_row')

        c.proposals_pager = None
        if u'proposals' in overview_contents:
            proposals = model.Proposal.all(instance=c.page_instance)

            if config.get_bool(
                    'adhocracy.show_instance_overview_proposals_all'):
                c.proposals_pager = pager.proposals(proposals, size=100,
                                                    initial_size=100)
            else:
                c.proposals_pager = pager.proposals(
                    proposals, size=7, enable_sorts=False,
                    enable_pages=False, default_sort=sorting.entity_newest)

        c.stats = None
        if config.get_bool('adhocracy.show_instance_overview_stats'):
            c.stats = {
                'comments': model.Comment.all_q().count(),
                'proposals': model.Proposal.all_q(
                    instance=c.page_instance).count(),
                'members': model.Membership.all_q().count()
            }

        c.tutorial_intro = _('tutorial_instance_show_intro')
        c.tutorial = 'instance_show'

        if c.page_instance.hidden:
            h.flash(_(u"This instance is not yet open for public "
                      u"participation."), 'warning')
        elif c.page_instance.frozen:
            h.flash(_(u"This instance is not active for use and is archived. "
                      u"It isn't possible to perform any changes to the "
                      u"instance, but all content is available to be read."),
                    'warning')

        if format == 'overlay':
            return render("/instance/show.html", overlay=True)
        else:
            return render("/instance/show.html")
Пример #6
0
def get_enabled_locales():
    enabled_locales = config.get_list('adhocracy.enabled_locales')
    if enabled_locales is None:
        return LOCALES
    else:
        return filter(lambda x: x.language in enabled_locales, LOCALES)