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


Python Messages.invalidDate方法代码示例

本文整理汇总了Python中fivecents.lib.i18n.Messages.invalidDate方法的典型用法代码示例。如果您正苦于以下问题:Python Messages.invalidDate方法的具体用法?Python Messages.invalidDate怎么用?Python Messages.invalidDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fivecents.lib.i18n.Messages的用法示例。


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

示例1: _edit_stock

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import invalidDate [as 别名]
    def _edit_stock(self, stock):
        try:
            stock.ticker = request.params['ticker'][0:50].upper()
        except:
            return { "failure": Messages.invalidArguments() }

        try:
            stock.count = int(request.params['count'])
        except:
            return { "failure": Messages.invalidArguments() }

        try:
            stock.buy = asbool(request.params['buy'])
        except:
            return { "failure": Messages.invalidArguments() }
        
        try: 
            with localcontext() as ctx: 
                ctx.prec = 2 
                stock.price = h.parse_decimal(request.params['price']) 
        except: 
            log.error("Invalid number: %s" % request.params.get('amount'), exc_info=1) 
            return { "failure": Messages.invalidCurrencyFormat() }

        try:
            stock.occurred_on = h.parse_date(request.params['occurred_on'])
        except:
            return { "failure": Messages.invalidDate() }

        if stock.user is None:
            stock.user = h.authenticated_user()

        self.dbFacade().stocks.changeDao.save(stock)
        self.dbFacade().db.commit()

        return { "id" : stock.uid }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:38,代码来源:stocks.py

示例2: _edit_change

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import invalidDate [as 别名]
    def _edit_change(self, to_bc):
        dbFacade = self.dbFacade()
    
        if to_bc.uid is not None:
            if not to_bc.balance or not to_bc.balance.can_modify_balance(h.authenticated_user().uid):
                return { "failure": Messages.permissionDenied() }

            # If it's a transfer check if user can modify the other balance
            if to_bc.transfer:
                old_from_balance = dbFacade.balances.balanceDao.find_by_uid(to_bc.transfer.balance_uid)
                if not old_from_balance or not old_from_balance.can_modify_balance(h.authenticated_user().uid):
                    return { "failure": Messages.permissionDenied() }

        to_balance_uid = request.params.get('to_balance_uid')
        to_balance = dbFacade.balances.balanceDao.find_by_uid(to_balance_uid)
        if not to_balance or not to_balance.can_modify_balance(h.authenticated_user().uid):
            return { "failure": Messages.permissionDenied() }

        try:
             with localcontext() as ctx:
                ctx.prec = 2
                to_bc.amount = h.parse_decimal(request.params['amount'])
        except:
            log.error("Invalid number: %s" % request.params.get('amount'), exc_info=1)
            return { "failure": Messages.invalidCurrencyFormat() }
    
        try:
            to_bc.occurred_on = h.parse_date(request.params['occurred_on']) 
        except:
            return { "failure": Messages.invalidDate() }
            
        try:
            to_bc.change_category_uid = int(request.params['change_category_uid'])
        except:
            log.error("Failed to parse arguments %s" % str(request.params), exc_info=1)
            return { "failure": Messages.invalidArguments() }

        to_bc.balance = to_balance
        to_bc.tags = [dbFacade.model.ChangeTag(tag=tag) for tag in dbFacade.balances.elements_from_string(request.params.get('tags', ''))]
        to_bc.description = request.params.get('description', '')
        to_bc.user_uid = h.authenticated_user().uid

        from_balance_uid = request.params.get('from_balance_uid')
        if from_balance_uid is not None:
            if from_balance_uid == to_balance_uid:
                return { "failure": Messages.pleaseSelectDifferentAccounts() }

            from_balance = dbFacade.balances.balanceDao.find_by_uid(from_balance_uid)
            if not from_balance or not from_balance.can_modify_balance(h.authenticated_user().uid):
                return { "failure": Messages.permissionDenied() }

            from_bc = to_bc.transfer and to_bc.transfer or dbFacade.model.BalanceChange()
            to_bc.amount = abs(to_bc.amount)
            from_bc.amount = -to_bc.amount
            from_bc.occurred_on = to_bc.occurred_on
            from_bc.change_category_uid = to_bc.change_category_uid
            from_bc.balance = from_balance
            from_bc.tags = [dbFacade.model.ChangeTag(tag=tag) for tag in dbFacade.balances.elements_from_string(request.params.get('tags', ''))] 
            from_bc.description = to_bc.description
            from_bc.user_uid = h.authenticated_user().uid

            from_bc.transfer = to_bc
            to_bc.transfer = from_bc
        elif to_bc.transfer is not None:
            from_bc = to_bc.transfer
            from_bc.transfer = None
            to_bc.transfer = None
            dbFacade.db.flush()
            dbFacade.db.delete(from_bc)
            
        dbFacade.balances.changeDao.save(to_bc)
        dbFacade.db.commit()
        return { "id" : to_bc.uid }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:75,代码来源:balance_changes.py


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