• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python ctx.has_request_context函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: default_price_list

    def default_price_list():
        """Get the pricelist of active user. In the
        event that the logged in user does not have a pricelist set against
        the user, the shop's pricelist is chosen.

        :param user: active record of the nereid user
        """
        User = Pool().get('res.user')
        user = User(Transaction().user)
        shop_price_list = user.shop.price_list.id if user.shop else None

        if not has_request_context():
            # Not a nereid request
            return shop_price_list

        # If control reaches here, then this is a nereid request. Lets try
        # and personalise the pricelist of the user logged in.
        if current_user.is_anonymous():
            # Sorry anonymous users, you get the shop price
            return shop_price_list

        if current_user.party.sale_price_list:
            # There is a sale pricelist for the specific user's party.
            return current_user.party.sale_price_list.id

        return shop_price_list
开发者ID:PritishC,项目名称:nereid-cart-b2c,代码行数:26,代码来源:sale.py


示例2: confirm

    def confirm(cls, sales):
        "Send an email after sale is confirmed"
        super(Sale, cls).confirm(sales)

        if has_request_context():
            for sale in sales:
                sale.send_confirmation_email()
开发者ID:pokoli,项目名称:nereid-checkout,代码行数:7,代码来源:sale.py


示例3: default_price_list

    def default_price_list(user=None):
        """Get the pricelist of active user. In the
        event that the logged in user does not have a pricelist set against
        the user, the guest user's pricelist is chosen.

        :param user: active record of the nereid user
        """
        if not has_request_context():
            # Not a nereid request
            return None

        if user is not None and user.party.sale_price_list:
            # If a user was provided and the user has a pricelist, use
            # that
            return user.party.sale_price_list.id

        if not current_user.is_anonymous() and \
                current_user.party.sale_price_list:
            # If the currently logged in user has a pricelist defined, use
            # that
            return current_user.party.sale_price_list.id

        # Since there is no pricelist for the user, use the guest user's
        # pricelist if one is defined.
        guest_user = request.nereid_website.guest_user
        if guest_user.party.sale_price_list:
            return guest_user.party.sale_price_list.id

        return None
开发者ID:aroraumang,项目名称:nereid-cart-b2c,代码行数:29,代码来源:sale.py


示例4: confirm

    def confirm(self, ids):
        "Send an email after sale is confirmed"
        super(Sale, self).confirm(ids)

        if has_request_context():
            for sale in self.browse(ids):
                self.send_confirmation_email(sale)
开发者ID:shalabhaggarwal,项目名称:nereid-checkout,代码行数:7,代码来源:sale.py


示例5: validate_for_product_inventory

 def validate_for_product_inventory(self):
     """
     This method validates the sale line against the product's inventory
     attributes. This method requires request context.
     """
     if has_request_context() and not self.product.can_buy_from_eshop():
         flash(_("This product is no longer available"))
         abort(redirect(request.referrer))
开发者ID:tarunbhardwaj,项目名称:nereid-cart-b2c,代码行数:8,代码来源:sale.py


示例6: default_active

 def default_active():
     """
     If the user gets created from the web the activation should happen
     through the activation link. However, users created from tryton
     interface are activated by default
     """
     if has_request_context():
         return False
     return True
开发者ID:sharoonthomas,项目名称:nereid,代码行数:9,代码来源:user.py


示例7: confirm

    def confirm(cls, sales):
        "Send an email after sale is confirmed"
        super(Sale, cls).confirm(sales)

        if has_request_context():
            for sale in sales:

                # Change party name to invoice address name for guest user
                if current_user.is_anonymous():
                    sale.party.name = sale.invoice_address.name
                    sale.party.save()
开发者ID:rajatguptarg,项目名称:nereid-checkout,代码行数:11,代码来源:sale.py


示例8: _get_email_template_context

    def _get_email_template_context(self):
        """
        Update context
        """
        context = super(Sale, self)._get_email_template_context()

        if has_request_context() and not current_user.is_anonymous():
            customer_name = current_user.display_name
        else:
            customer_name = self.party.name

        context.update({
            'url_for': lambda *args, **kargs: url_for(*args, **kargs),
            'has_request_context': lambda *args, **kargs: has_request_context(
                *args, **kargs),
            'current_user': current_user,
            'customer_name': customer_name,
            'to_json': lambda *args, **kargs: json.dumps(*args, **kargs),
        })
        return context
开发者ID:rajatguptarg,项目名称:nereid-checkout,代码行数:20,代码来源:sale.py


示例9: create

 def create(self, values):
     if has_request_context():
         values['created_by'] = request.nereid_user.id
         if values['type'] == 'task':
             values.setdefault('participants', [])
             values['participants'].append(
                 ('add', [request.nereid_user.id])
             )
     else:
         # TODO: identify the nereid user through employee
         pass
     return super(Project, self).create(values)
开发者ID:Anoopsmohan,项目名称:nereid-project,代码行数:12,代码来源:project.py


示例10: default_employee

    def default_employee():
        User = Pool().get('res.user')

        if 'employee' in Transaction().context:
            return Transaction().context['employee']

        user = User(Transaction().user)
        if user.employee:
            return user.employee.id

        if has_request_context() and request.nereid_user.employee:
            return request.nereid_user.employee.id
开发者ID:priyankarani,项目名称:nereid-cms,代码行数:12,代码来源:cms.py


示例11: _get_receiver_email_address

    def _get_receiver_email_address(self):
        """
        Update reciever's email address(s)
        """
        to_emails = set()
        if self.party.email:
            to_emails.add(self.party.email.lower())
        if has_request_context() and not current_user.is_anonymous() and \
                current_user.email:
            to_emails.add(current_user.email.lower())

        return list(to_emails)
开发者ID:rajatguptarg,项目名称:nereid-checkout,代码行数:12,代码来源:sale.py


示例12: create

    def create(self, values):
        """
        Update create to save uploaded by

        :param values: A dictionary
        """
        if has_request_context():
            values['uploaded_by'] = request.nereid_user.id
        #else:
            # TODO: try to find the nereid user from the employee
            # if an employee made the update

        return super(IrAttachment, self).create(values)
开发者ID:shalabhaggarwal,项目名称:nereid,代码行数:13,代码来源:attachment.py


示例13: create

    def create(cls, vlist):
        """
        Create a Task and add current user as participant of the project

        :param vlist: List of dictionaries of values to create
        """
        for values in vlist:
            if has_request_context():
                if values["type"] == "task":
                    values.setdefault("participants", []).append(("add", [request.nereid_user.id]))
            else:
                # TODO: identify the nereid user through employee
                pass
        return super(Task, cls).create(vlist)
开发者ID:GauravButola,项目名称:nereid-project,代码行数:14,代码来源:task.py


示例14: create

    def create(cls, vlist):
        '''
        Create a Task and add current user as participant of the project

        :param vlist: List of dictionaries of values to create
        '''
        for values in vlist:
            if has_request_context():
                if values['type'] == 'task' and not current_user.is_anonymous():
                    values.setdefault('participants', []).append(
                        ('add', [current_user.id])
                    )
            else:
                # TODO: identify the nereid user through employee
                pass
        return super(Task, cls).create(vlist)
开发者ID:openlabs,项目名称:nereid-project,代码行数:16,代码来源:task.py


示例15: serialize

 def serialize(self, purpose=None):
     rv = {
         'create_date': self.create_date.isoformat(),
         "objectType": self.__name__,
         "id": self.id,
         "updatedBy": self.uploaded_by.serialize('listing'),
         "displayName": self.name,
         "description": self.description,
     }
     if has_request_context():
         rv['downloadUrl'] = url_for(
             'project.work.download_file',
             attachment_id=self.id,
             task=Transaction().context.get('task'),
         )
     return rv
开发者ID:GauravButola,项目名称:nereid-project,代码行数:16,代码来源:attachment.py


示例16: create_history_line

    def create_history_line(self, project, changed_values):
        """
        Creates a history line from the changed values of a project.work
        """
        if changed_values:
            data = {}

            # TODO: Also create a line when assigned user is cleared from task
            for field in ('assigned_to', 'state',
                    'constraint_start_time', 'constraint_finish_time'):
                if field not in changed_values or not changed_values[field]:
                    continue
                data['previous_%s' % field] = getattr(project, field)
                data['new_%s' % field] = changed_values[field]

            if data:
                if has_request_context():
                    data['updated_by'] = request.nereid_user.id
                else:
                    # TODO: try to find the nereid user from the employee
                    # if an employee made the update
                    pass
                data['project'] = project.id
                return self.create(data)
开发者ID:Anoopsmohan,项目名称:nereid-project,代码行数:24,代码来源:project.py


示例17: default_author

 def default_author():
     if has_request_context():
         return current_user.id
开发者ID:2cadz,项目名称:nereid-cms,代码行数:3,代码来源:cms.py


示例18: default_user

 def default_user():
     if has_request_context() and not current_user.is_anonymous:
         return current_user.id
开发者ID:fulfilio,项目名称:nereid-cart-b2c,代码行数:3,代码来源:cart.py


示例19: default_sessionid

 def default_sessionid():
     if has_request_context():
         return session.sid
开发者ID:fulfilio,项目名称:nereid-cart-b2c,代码行数:3,代码来源:cart.py


示例20: default_website

 def default_website():
     if has_request_context():
         return current_website.id
开发者ID:fulfilio,项目名称:nereid-cart-b2c,代码行数:3,代码来源:cart.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.slugify函数代码示例发布时间:2022-05-27
下一篇:
Python nereid.url_for函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap