当前位置: 首页>>代码示例>>Python>>正文


Python rendering.render_to_string函数代码示例

本文整理汇总了Python中treeio.core.rendering.render_to_string函数的典型用法代码示例。如果您正苦于以下问题:Python render_to_string函数的具体用法?Python render_to_string怎么用?Python render_to_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了render_to_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: attachment

def attachment(request, object_id, update_id=None):
    dajax = Dajax()

    try:

        if object_id:
            attachments = Attachment.objects.filter(
                attached_object__id=object_id)
            template = 'core/tags/attachments_block'

            object_markup = render_to_string(template,
                                             {'object_id': object_id,
                                                 'attachments': attachments},
                                             context_instance=RequestContext(
                                                 request),
                                             response_format='html')

            dajax.add_data(
                {'target': 'div.attachment-block[object="%s"]' % object_id, 'content': object_markup}, 'treeio.add_data')

        if update_id:
            attachments = Attachment.objects.filter(
                attached_record__id=update_id)
            template = 'core/tags/attachments_record_block'
            update_markup = render_to_string(template,
                                             {'update_id': update_id,
                                                 'attachments': attachments},
                                             context_instance=RequestContext(
                                                 request),
                                             response_format='html')
            dajax.add_data(
                {'target': 'div.attachment-record-block[object="%s"]' % update_id, 'content': update_markup}, 'treeio.add_data')

    except Exception, e:
        print e
开发者ID:AlexLX2,项目名称:treeio,代码行数:35,代码来源:ajax.py

示例2: permission_block

def permission_block(context, object):
    "Block with objects permissions"
    request = context['request']
    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']

    response_format_tags = response_format
    if 'response_format_tags' in context:
        response_format_tags = context['response_format_tags']

    if 'permission' in request.GET:
        if request.user.get_profile().has_permission(object, mode='w'):
            if request.POST:
                if 'cancel' in request.POST:
                    request.redirect = request.path
                    return Markup(render_to_string('core/tags/permission_block',
                                                   {'object': object,
                                                       'path': request.path},
                                                   context_instance=RequestContext(
                                                       request),
                                                   response_format=response_format))
                form = PermissionForm(request.POST, instance=object)
                if form.is_valid():
                    form.save()
                    request.redirect = request.path
                    return Markup(render_to_string('core/tags/permission_block',
                                                   {'object': object,
                                                       'path': request.path},
                                                   context_instance=RequestContext(
                                                       request),
                                                   response_format=response_format))
            else:
                form = PermissionForm(instance=object)

            context = {'object': object, 'path': request.path, 'form': form}

            if 'ajax' in response_format_tags:
                context = converter.preprocess_context(context)

            return Markup(render_to_string('core/tags/permission_block_edit',
                                           context,
                                           context_instance=RequestContext(
                                               request),
                                           response_format=response_format))

    return Markup(render_to_string('core/tags/permission_block',
                                   {'object': object, 'path': request.path},
                                   context_instance=RequestContext(request),
                                   response_format=response_format))
开发者ID:AlexLX2,项目名称:treeio,代码行数:50,代码来源:object.py

示例3: icon_line

def icon_line(context, user=None, size=25):
    """
    Print a line with a certain amount off achievement-icons.

    Arguments:
    context -- the current Context object, supplied by the decorator
    user -- which user, defaults to the active account
    size -- how many icons should be displayed
    """
    request = context["request"]
    if not user:
        user = request.user

    response_format = "html"
    if "response_format" in context:
        response_format = context["response_format"]

    achievements = user.achievements.all()[:size]

    return Markup(
        render_to_string(
            "achievements/tags/icon_line",
            {"achievements": achievements},
            context_instance=RequestContext(request),
            response_format=response_format,
        )
    )
开发者ID:pascalmouret,项目名称:treeio-achievements,代码行数:27,代码来源:achievements.py

示例4: messaging_unread

def messaging_unread(context):
    "Print a number of unread messages"
    
    request = context['request']
    
    user = None
    if request.user.username:
        try: 
            user = request.user.get_profile()
        except Exception:
            pass
    
    unread = 0
    messaging = None
    if user:
        modules = user.get_perspective().get_modules()
        messaging = modules.filter(name='treeio.messaging')
        if messaging:
            unread = Object.filter_permitted(user, 
                                             Message.objects.filter(reply_to__isnull=True).exclude(read_by=user)).count()
        
    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']
    
    return Markup(render_to_string('messaging/tags/unread',
                               {'messaging': messaging, 'unread': unread},
                               context_instance=RequestContext(request),
                               response_format=response_format))
开发者ID:3atmospheres,项目名称:treeio,代码行数:29,代码来源:messaging.py

示例5: logo_block_container

def logo_block_container(context):
    "Returns logo_block_container"

    # request = context['request']
    response_format = "html"

    return Markup(render_to_string("core/tags/logo_block_container", response_format=response_format))
开发者ID:nardus64,项目名称:treeio,代码行数:7,代码来源:modules.py

示例6: user_block

def user_block(context):
    "User block"
    request = context['request']
    user = None
    if request.user.username:
        try:
            user = request.user.get_profile()
        except Exception:
            pass

    modules = user.get_perspective().get_modules()

    account = modules.filter(name='treeio.account')

    admin = modules.filter(name='treeio.core')
    if admin:
        admin = admin[0]

    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']

    trial = False
    if getattr(settings, 'HARDTREE_SUBSCRIPTION_USER_LIMIT') == 3:
        trial = True

    active = context.get('active', None)

    return Markup(render_to_string('core/tags/user_block',
                  {'user': user,
                   'account': account,
                   'admin': admin,
                   'active': active,
                   'trial': trial},
                  response_format=response_format))
开发者ID:5n1p,项目名称:treeio,代码行数:35,代码来源:user.py

示例7: attachments

def attachments(context, object=None):
    "Attachments for an object or update record"

    request = context['request']

    profile = request.user.get_profile()

    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']

    update = isinstance(object,UpdateRecord)

    if not update:
        attachments = Attachment.objects.filter(attached_object=object)
        if profile.has_permission(object, mode='w'):
            template = 'core/tags/attachments'
        else:
            template = 'core/tags/attachments_block'

    else:
        attachments = Attachment.objects.filter(attached_record=object)
        if profile == object.author:
            template = 'core/tags/attachments_record'
        else:
            template = 'core/tags/attachments_record_block'

    return Markup(render_to_string(template,
                                   {'object': object,
                                    'attachments': attachments,
                                    },
                                   context_instance=RequestContext(request),
                                   response_format=response_format))
开发者ID:3atmospheres,项目名称:treeio,代码行数:33,代码来源:object.py

示例8: core_watchlist

def core_watchlist(context, objects=None, skip_group=False, paginate=False):
    "Print a list of objects a user is subscribed to"
    
    request = context['request']
    profile = request.user.get_profile()
        
    if not objects:
        objects = profile.subscriptions.all()
    
    if 'unsubscribe' in request.GET:
        for object in objects.filter(pk=request.GET.get('unsubscribe')):
            object.subscribers.remove(profile)
        objects = profile.subscriptions.all()
    
    pathurl = request.path + '?'
    if request.GET:
        params = request.GET.copy()
        if 'unsubscribe' in params:
            del params['unsubscribe']
        pathurl += urllib.urlencode(params) + '&'
    
    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']
    
    return Markup(render_to_string('core/tags/watchlist',
                               {'objects': objects,
                                'skip_group': skip_group,
                                'dopaginate': paginate,
                                'pathurl': pathurl},
                               context_instance=RequestContext(request),
                               response_format=response_format))
开发者ID:3atmospheres,项目名称:treeio,代码行数:32,代码来源:object.py

示例9: email_caller_on_new_ticket

def email_caller_on_new_ticket(sender, instance, created, **kwargs):
    "When a new ticket is created send an email to the caller"
    if created:
        send_email_to_caller = False
        try:
            conf = ModuleSetting.get_for_module("treeio.services", "send_email_to_caller")[0]
            send_email_to_caller = conf.value
        except:
            send_email_to_caller = getattr(settings, "HARDTREE_SEND_EMAIL_TO_CALLER", True)

        if send_email_to_caller:
            # don't send email to yourself
            creator_contact = None
            if instance.creator:
                creator_contact = instance.creator.get_contact()

            if instance.caller and instance.caller != creator_contact:
                if not instance.reference:
                    if instance.queue:
                        instance.reference = instance.queue.ticket_code + str(instance.id)
                    else:
                        instance.reference = str(instance.id)
                    instance.save()
                subject = "[#%s] %s" % (instance.reference, instance.name)

                # Construct context and render to html, body
                context = {"ticket": instance}
                try:
                    conf = ModuleSetting.get_for_module("treeio.services", "send_email_template")[0]
                    send_email_template = conf.value
                    html = render_string_template(send_email_template, context)
                except Exception, e:
                    html = render_to_string("services/emails/notify_caller", context, response_format="html")
                body = strip_tags(html)

                if instance.queue and instance.queue.message_stream:
                    stream = instance.queue.message_stream
                    if stream.outgoing_server_name:
                        try:
                            caller_email = instance.caller.get_email()
                            if caller_email:
                                toaddr = caller_email
                                ssl = False
                                if stream.outgoing_server_type == "SMTP-SSL":
                                    ssl = True
                                email = BaseEmail(
                                    stream.outgoing_server_name,
                                    stream.outgoing_server_username,
                                    stream.outgoing_password,
                                    stream.outgoing_email,
                                    toaddr,
                                    subject,
                                    body,
                                    html=html,
                                    ssl=ssl,
                                )
                                email.process_email()
                        except:
                            pass
开发者ID:nrazon,项目名称:treeio,代码行数:59,代码来源:models.py

示例10: demo_user

def demo_user(context):
    "Print demo block if demo"

    response_format = 'html'
    
    demo = getattr(settings, 'HARDTREE_DEMO_MODE', False)
        
    return Markup(render_to_string('core/tags/demo_user',
                  {'demo': demo},
                  response_format=response_format))
开发者ID:3atmospheres,项目名称:treeio,代码行数:10,代码来源:user.py

示例11: object_tree_path

def object_tree_path(context, object, skipself=False):
    "Object tree path"
    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']
        
    path = object.get_tree_path(skipself)
        
    return Markup(render_to_string('core/tags/object_tree_path',
                                   {'path': path, 'skipself': skipself},
                                   response_format=response_format))
开发者ID:appost,项目名称:treeio,代码行数:11,代码来源:modules.py

示例12: projects_time_slot_list

def projects_time_slot_list(context, time_slots, no_dates=False):
    "Print a list of time slots"
    request = context['request']
    
    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']
    
    return Markup(render_to_string('projects/tags/time_slot_list',
                               {'time_slots': time_slots, 'no_dates': no_dates},
                               context_instance=RequestContext(request),
                               response_format=response_format))
开发者ID:3atmospheres,项目名称:treeio,代码行数:12,代码来源:projects.py

示例13: finance_liability_list

def finance_liability_list(context, liabilities, skip_group=False):
    "Print a list of orders"
    request = context['request']
    
    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']
    
    return Markup(render_to_string('finance/tags/liability_list',
                               {'liabilities': liabilities, 'skip_group': skip_group},
                               context_instance=RequestContext(request),
                               response_format=response_format))
开发者ID:3atmospheres,项目名称:treeio,代码行数:12,代码来源:finance.py

示例14: documents_weblink_list

def documents_weblink_list(context, links, skip_group=False):
    "Print a list of links"
    request = context['request']
    
    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']
    
    return Markup(render_to_string('documents/tags/weblink_list',
                               {'links': links, 'skip_group': skip_group},
                               context_instance=RequestContext(request),
                               response_format=response_format))
开发者ID:3atmospheres,项目名称:treeio,代码行数:12,代码来源:documents.py

示例15: identities_group_list

def identities_group_list(context, groups, skip_group=False):
    "Print a list of groups"
    request = context['request']
    
    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']
    
    return Markup(render_to_string('identities/tags/group_list',
                               {'groups': groups, 'skip_group': skip_group},
                               context_instance=RequestContext(request),
                               response_format=response_format))
开发者ID:3atmospheres,项目名称:treeio,代码行数:12,代码来源:identities.py


注:本文中的treeio.core.rendering.render_to_string函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。