コード例 #1
0
ファイル: content_tags.py プロジェクト: encolpe/apetizer
def content_menu( context, path ):
    
    if path == '' or path == '/':
        item = models.Item.objects.get_at_url( path )
        roots = models.Item.objects.filter(parent=None)
    else:
        try:
            item = models.Item.objects.get_at_url( path )
            if not item.is_leaf_node():
                roots = item.get_children()
            else:
                if item.parent != None:
                    roots = item.parent.get_children()
                else:
                    roots = models.Item.objects.filter(parent=None)
        except:
            item = None
            roots = models.Item.objects.filter(parent=None)

        
    context['path'] = path
    context['item'] = item
    
    if context['user'].is_anonymous() or not context['user'].is_authenticated():
        context['has_permission'] = False
    else:
        context['has_permission'] = check_permission( context['request'], 'change', 'content', 'item' ),
    
    context['menu'] = roots
    #context['nodes'] = roots
    
    return context
コード例 #2
0
ファイル: content_tags.py プロジェクト: encolpe/apetizer
def content_related( context, path, recurse=False ):
    
    
    roots = []
    try:
        item = models.Item.objects.get_at_url( path )
            
        roots = item.related.all()
    except:
        item = None
    
    #item = models.Item.objects.get_at_url( path )
    #roots = item.related
    
    
    context['path'] = path
    context['node'] = item
    
    if context['user'].is_anonymous() or not context['user'].is_authenticated():
        context['has_permission'] = False
    else:
        context['has_permission'] = check_permission( context['request'], 'change', 'content', 'item' ),
    
    context['related'] = roots
    return context
コード例 #3
0
ファイル: content_ui_tags.py プロジェクト: encolpe/apetizer
def content_change_link(context, instance, label=None):
    
    if isinstance(instance, Item):
        target_url = instance.get_url()+'change/'
    elif isinstance(instance, Translation):
        target_url = instance.related.get_url()+'translate/'
    else:
        raise template.TemplateSyntaxError, "'%s' argument must be an item or a translation" % instance
    
    template_context = {
        'edit_link': target_url,
        'next_link': context['request'].META['PATH_INFO'],
        'label': label,
    }
    
    app_label = instance._meta.app_label
    #model_name = instance._meta.module_name
    
    # Check for permission
    if check_permission(request=context['request'], mode_name='change',
                                                    app_label=app_label,
                                                    model_name=None):
        template_context['has_permission'] = True
    else:
        template_context['has_permission'] = False
    
    context.update(template_context)
    
    return context
コード例 #4
0
ファイル: content_ui_tags.py プロジェクト: encolpe/apetizer
def content_add_link(context, instance, label=None):
    
    if isinstance(instance, Item):
        target_url = instance.get_url()
    else:
        raise template.TemplateSyntaxError, "'%s' argument must be an item or a translation" % instance
    
    template_context = {
        'add_link': target_url+'add/',
        'next_link': context['request'].META['PATH_INFO'],
        'label': label,
    }
    
    app_label = instance._meta.app_label
    model_name = instance._meta.model_name
    
    # Check for permission
    if check_permission(request=context['request'], mode_name='add',
                                                    app_label=app_label,
                                                    model_name=model_name):
        template_context['has_permission'] = True
    else:
        template_context['has_permission'] = False
    template_context['has_permission'] = True
    context.update(template_context)
    
    return context
コード例 #5
0
ファイル: content_tags.py プロジェクト: encolpe/apetizer
def content_item( context, path ):
    
    if type(path) == models.Item:
        item = path
        path = item.get_url()
    else:
        item = models.Item.objects.get_at_url( path, exact=True )

    context['item'] = item
    context['has_permission'] = check_permission( context['request'], 'change', 'content', 'item' ),
    return context
コード例 #6
0
ファイル: content_tags.py プロジェクト: encolpe/apetizer
def content_breadcrumb( context, item, action=None ):
    
    context['breadcrumbAction'] = action
    
    if item:
       
        ancestors = item.get_ancestors()
        
        context['breadcrumbNode'] = item
        context['breadcrumbAncestors'] = ancestors
        
        if not 'user' in context or context['user'].is_anonymous() or not context['user'].is_authenticated():
            context['has_permission'] = False
        else:
            context['has_permission'] = check_permission( context['request'], 'change', 'content', 'Translation' ),
    
    return context
コード例 #7
0
ファイル: content_tags.py プロジェクト: encolpe/apetizer
def content_knowmore( context, slug ):
    
    path = models.Item.objects.get_clean_path( context['request'].path )+'/'+slug
    
    template_context = {}
    
    # get current Item
    item = models.Item.objects.get_at_url( path )
    
    context['path'] = path
    context['item'] = item
    
    if context['user'].is_anonymous() or not context['user'].is_authenticated():
        context['has_permission'] = False
    else:
        context['has_permission'] = check_permission( context['request'], 'change', 'content', 'item' ),
    
    return context
コード例 #8
0
ファイル: content_tags.py プロジェクト: encolpe/apetizer
def content_tags( context, path, recurse=False ):
    
    item = models.Item.objects.get_at_url( path )
    
    roots = []
    
    for tag in item.tags.all():
        roots.append( tag.item )
    
    context['path'] = path
    context['node'] = item
    
    if context['user'].is_anonymous() or not context['user'].is_authenticated():
        context['has_permission'] = False
    else:
        context['has_permission'] = check_permission( context['request'], 'change', 'content', 'item' ),
    
    context['tags'] = roots
    #context['nodes'] = roots
    
    return context
コード例 #9
0
ファイル: content_tags.py プロジェクト: encolpe/apetizer
def content_tile( context, path ):
    
    if path == '':
        item = None
    else:
        item = models.Item.objects.get_at_url( path )
    
    roots = models.Item.objects.filter( parent=item )
    
    #context['path'] = path
    #context['item'] = item
    
    if context['user'].is_anonymous() or not context['user'].is_authenticated():
        context['has_permission'] = False
    else:
        context['has_permission'] = check_permission( context['request'], 'change', 'content', 'item' ),
    
    context['map'] = roots
    #context['nodes'] = roots
    
    return context
コード例 #10
0
ファイル: content_ui_tags.py プロジェクト: asuchi/apetizer
def content_delete_link(context, instance, label=None):
 
    target_url = instance.get_url()
    
    template_context = {
        'delete_link': target_url+'delete',
        'next_link': context['request'].META['PATH_INFO'],
        'label': label,
    }
    
    app_label = instance._meta.app_label
    #model_name = instance._meta.module_name
    # Check for permission
    if check_permission(request=context['request'], mode_name='delete',
                                                    app_label=app_label,
                                                    model_name=None):
        template_context['has_permission'] = True
    else:
        template_context['has_permission'] = False
    context.update(template_context)
    return context