Esempio n. 1
0
File: event.py Progetto: alkadis/vcv
    def all(self, format="html"):
        if c.instance is None:
            require.perm("event.index_all")

        events = (
            model.Event.all_q(
                instance=c.instance, include_hidden=False, event_filter=request.params.getall("event_filter")
            )
            .order_by(model.Event.time.desc())
            .limit(min(int(request.params.get("count", 50)), 100))
            .all()
        )

        if format == "rss":
            return event.rss_feed(
                events, _("%s News" % h.site.name()), h.base_url(instance=None), _("News from %s") % h.site.name()
            )

        elif format == "ajax":
            query_params = request.params.copy()
            while True:
                try:
                    query_params.pop("count")
                except KeyError:
                    break

            more_url = h.base_url(instance=c.instance, member="event/all", query_params=query_params)
            return render_def("/event/tiles.html", "carousel", events=events, more_url=more_url)
        else:
            c.event_pager = pager.events(events, count=50)

            if format == "overlay":
                return render("/event/all.html", overlay=True, overlay_size=OVERLAY_SMALL)
            else:
                return render("/event/all.html")
Esempio n. 2
0
File: event.py Progetto: alkadis/vcv
    def carousel(self, format=u"html"):
        if c.instance is None:
            require.perm("event.index_all")

        data = {u"data_url": h.base_url("/event/all", query_params=request.params)}

        return render("/event/carousel.html", data, overlay=format == u"overlay", overlay_size=OVERLAY_SMALL)
Esempio n. 3
0
    def new(self, id=None, errors={}, format=u'html'):

        if id is None:
            require.perm('global.message')
            template = '/massmessage/new.html'
            c.preview_url = h.base_url('/message/preview')
        else:
            c.page_instance = InstanceController._get_current_instance(id)
            require.instance.message(c.page_instance)
            template = '/instance/message.html'
            c.preview_url = h.base_url('/instance/%s/message/preview' % id)

        defaults = dict(request.params)
        defaults.setdefault('include_footer', 'on')

        data = {
            'instances': self._get_allowed_instances(c.user),
            'sender_options': self._get_allowed_sender_options(c.user),
            'userbadges': UserBadge.all(instance=c.instance,
                                        include_global=True)
        }

        return htmlfill.render(render(template,
                                      data,
                                      overlay=format == u'overlay'),
                               defaults=defaults,
                               errors=errors,
                               force_defaults=False)
Esempio n. 4
0
 def require_permission(self):
     """
     Backends can add additional permission checks.
     """
     if self.private:
         from adhocracy.lib.auth import require
         require.perm('static.show_private')
Esempio n. 5
0
    def new(self, id=None, errors={}, format=u'html'):

        if id is None:
            require.perm('global.message')
            template = '/massmessage/new.html'
            c.preview_url = h.base_url('/message/preview')
        else:
            c.page_instance = InstanceController._get_current_instance(id)
            require.instance.message(c.page_instance)
            template = '/instance/message.html'
            c.preview_url = h.base_url(
                '/instance/%s/message/preview' % id)

        defaults = dict(request.params)
        defaults.setdefault('include_footer', 'on')

        data = {
            'instances': self._get_allowed_instances(c.user),
            'sender_options': self._get_allowed_sender_options(c.user),
            'userbadges': UserBadge.all(instance=c.instance,
                                        include_global=True)
        }

        return htmlfill.render(render(template, data,
                                      overlay=format == u'overlay'),
                               defaults=defaults, errors=errors,
                               force_defaults=False)
Esempio n. 6
0
 def require_permission(self):
     """
     Backends can add additional permission checks.
     """
     if self.private:
         from adhocracy.lib.auth import require
         require.perm('static.show_private')
Esempio n. 7
0
File: event.py Progetto: alkadis/vcv
    def carousel(self, format=u'html'):
        if c.instance is None:
            require.perm('event.index_all')

        data = {
            u'data_url': h.base_url('/event/all', query_params=request.params)
        }

        return render('/event/carousel.html',
                      data,
                      overlay=format == u'overlay',
                      overlay_size=OVERLAY_SMALL)
Esempio n. 8
0
File: event.py Progetto: alkadis/vcv
    def all(self, format='html'):
        if c.instance is None:
            require.perm('event.index_all')

        events = model.Event.all_q(
            instance=c.instance,
            include_hidden=False,
            event_filter=request.params.getall('event_filter'))\
            .order_by(model.Event.time.desc())\
            .limit(min(int(request.params.get('count', 50)), 100)).all()

        if format == 'rss':
            return event.rss_feed(events, _('%s News' % h.site.name()),
                                  h.base_url(instance=None),
                                  _("News from %s") % h.site.name())

        elif format == 'ajax':
            query_params = request.params.copy()
            while True:
                try:
                    query_params.pop('count')
                except KeyError:
                    break

            more_url = h.base_url(instance=c.instance,
                                  member='event/all',
                                  query_params=query_params)
            return render_def('/event/tiles.html',
                              'carousel',
                              events=events,
                              more_url=more_url)
        else:
            c.event_pager = pager.events(events, count=50)

            if format == 'overlay':
                return render('/event/all.html',
                              overlay=True,
                              overlay_size=OVERLAY_SMALL)
            else:
                return render('/event/all.html')
Esempio n. 9
0
    def new(self, id=None, errors={}):

        if id is None:
            require.perm('global.message')
            template = '/massmessage/new.html'
        else:
            c.page_instance = InstanceController._get_current_instance(id)
            require.message.create(c.page_instance)
            c.settings_menu = InstanceController.settings_menu(c.page_instance,
                                                               'massmessage')
            template = '/instance/settings_massmessage.html'

        defaults = dict(request.params)

        data = {
            'instances': self.get_allowed_instances(c.user),
            'sender_options': self.get_allowed_sender_options(c.user),
            'userbadges': UserBadge.all(instance=c.instance,
                                        include_global=True)
        }

        return htmlfill.render(render(template, data),
                               defaults=defaults, errors=errors,
                               force_defaults=False)