コード例 #1
0
ファイル: blocks.py プロジェクト: pombredanne/djpcms
 def edit_menu(self, request, block):
     ul = html.Widget('ul')
     return ul.add(
         views.application_views_links(request,
                                       asbuttons=False,
                                       text=False,
                                       include=('delete', )))
コード例 #2
0
ファイル: __init__.py プロジェクト: pombredanne/djpcms
def userlinks(request, asbuttons=False):
    request = request.for_model(request.view.User, root = True)
    if request:
        if request.user.is_authenticated():
            for a in views.application_views_links(request,
                                        asbuttons=asbuttons,
                                        include=('view','logout'),
                                        instance=request.user):
                yield a
            pk = request.view.settings.PROFILING_KEY
            if request.user.is_superuser and pk:
                if request.view.settings.PROFILING_KEY not in request.REQUEST:
                    yield html.Widget('a','profile',href='{0}?{1}'\
                                      .format(request.path,pk))
        else:
            for a in views.application_views_links(request,
                                                   asbuttons=asbuttons,
                                                   include=('login',)):
                yield a
コード例 #3
0
 def models_list(self, request, **kwargs):
     all = []
     for c in self.query(request):
         links = Widget('div',
                        views.application_views_links(c),
                        cn=classes.button_holder)
         all.append(Widget('dl', (Widget('a', c.title, href=c.url), links)))
     if all:
         return Widget('div', all, cn=classes.object_definition)
     else:
         return ''
コード例 #4
0
ファイル: __init__.py プロジェクト: pombredanne/djpcms
def page_links(request, asbuttons=False, ul=None):
    '''Utility for displaying page navigation links.'''
    ul = ul if ul is not None else html.Widget('ul')
    view = request.view
    Page = view.Page
    if Page:
        # We are on a page application view
        if view.mapper == Page:
            page = request.instance
            if page:
                route = Route(page.url)
                urlargs = dict(request.GET.items())
                try:
                    path = route.url(**urlargs)
                except:
                    path = '/'
                a = html.anchor_or_button('exit',
                                          href=path,
                                          icon='exit-page-edit',
                                          asbutton=asbuttons)
                ul.add(a)
        else:
            page = request.page
            page_request = request.for_model(Page)
            if page_request is not None:
                if page:
                    kwargs = {NEXT_KEY: request.path}
                    include = ('change',)
                else:
                    kwargs = {'url': request.view.path}
                    include = ('add',)
                for link in views.application_views_links(
                                    page_request,
                                    instance=page,
                                    include=include,
                                    asbuttons=asbuttons):
                    kwargs.update(request.urlargs)
                    href = link.attrs['href']
                    link.attrs['href'] = iri_to_uri(href, kwargs)
                    ul.add(link)
    return ul
コード例 #5
0
ファイル: blocks.py プロジェクト: pombredanne/djpcms
 def edit_menu(self, request, block):
     ul = html.Widget('ul')
     return ul.add(views.application_views_links(request,
                                                 asbuttons=False,
                                                 text=False,
                                                 include=('delete',)))