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


Python Messages.failedToDelete方法代码示例

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


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

示例1: delete

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToDelete [as 别名]
    def delete(self):
        result = {}
        for id in request.params.getall('id'):
            try:
                item = self.dbFacade().balances.changeDao.find_by_uid(id, options=[eagerload('balance'), eagerload('transfer')])
                if item is None:
                    result[id] = {
                        "deleted" : False,
                        "message": Messages.elementNotFound(key=id)
                    }
                    continue

                if not item.balance or not item.balance.can_modify_balance(h.authenticated_user().uid) \
                    or (item.transfer and not item.transfer.balance) \
                    or (item.transfer and not item.transfer.balance.can_modify_balance(h.authenticated_user().uid)):
                    result[id] = {
                        "deleted" : False,
                        "message": Messages.permissionDenied()
                    }
                    continue
                
                if item.transfer:
                    self.dbFacade().db.delete(item.transfer)
                self.dbFacade().db.delete(item)
                self.dbFacade().db.commit()
                result[id] = { "deleted" : True }
            except Exception, e:
                result[id] = {
                    "deleted" : False,
                    "message" : Messages.failedToDelete(exception=e),
                }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:33,代码来源:balance_changes.py

示例2: delete

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToDelete [as 别名]
    def delete(self):
        db = self.get_sa_session()
        model = self.get_sa_model()

        result = {}
        for id in request.params.getall('id'):
            try:
                item = db.query(model.ChangeCategory).filter_by(uid=id).one()
            except InvalidRequestError:
                result[id] = {
                    "deleted" : False,
                    "message": Messages.elementNotFound(key=id)
                }
                continue

            if (db.query(model.BalanceChange).filter_by(change_category_uid=item.uid).count() > 0):
                result[item.uid] = { 
                    "deleted" : False,
                    "message" : Messages.changeCategoryInUse(id=item.uid)
                }
            else:
                try:
                    db.delete(item)
                    db.commit()
                    result[item.uid] = {
                        "deleted" : True,
                    }
                except Exception, e:
                    result[item.uid] = {
                        "deleted" : False,
                        "message" : Messages.failedToDelete(exception=e),
                    }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:34,代码来源:change_categories.py

示例3: delete

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToDelete [as 别名]
    def delete(self, balance_uid):
        model = request.environ['sqlalchemy.model']
        db = request.environ['sqlalchemy.session']

        if not Operations(db, model).can_modify_balance(h.authenticated_user().uid, balance_uid):
            return { "failure": Messages.permissionDenied() }

        result = {}
        for id in request.params.getall('id'):
            try:
                item = db.query(model.BalanceChange).filter_by(uid=id).filter_by(balance_uid=balance_uid).one()
            except InvalidRequestError:
                result[id] = {
                    "deleted" : False,
                    "message": Messages.elementNotFound(key=id)
                }
                continue

            else:
                try:
                    Operations(db, model).delete_balance_change(item)
                    result[item.uid] = {
                        "deleted" : True,
                    }
                except Exception, e:
                    result[item.uid] = {
                        "deleted" : False,
                        "message" : Messages.failedToDelete(exception=e),
                    }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:31,代码来源:balance_changes.py

示例4: delete

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToDelete [as 别名]
    def delete(self):
        dbFacade = self.dbFacade()

        result = {}
        for id in request.params.getall('id'):
            try:
                item = dbFacade.balances.balanceDao.find_by_uid(id)
                if not item or not item.can_modify_balance(h.authenticated_user().uid):
                    result[id] = {
                        "deleted": False,
                        "message": Messages.permissionDenied()
                    }
                    continue
            except InvalidRequestError:
                result[id] = {
                    "deleted" : False,
                    "message": Messages.elementNotFound(key=id)
                }
                continue

            try:
                dbFacade.db.delete(item)
                dbFacade.db.commit()
                result[item.uid] = {
                    "deleted" : True,
                }
            except Exception, e:
                result[item.uid] = {
                    "deleted" : False,
                    "message" : Messages.failedToDelete(exception=e)
                }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:33,代码来源:balances.py

示例5: delete

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToDelete [as 别名]
    def delete(self):
        model = self.get_sa_model()
        db = self.get_sa_session()

        result = {}
        for id in request.params.getall('id'):
            try:
                if not Operations(db, model).can_modify_balance(h.authenticated_user().uid, id):
                    result[id] = {
                        "deleted": False,
                        "message": Messages.permissionDenied()
                    }
                    continue
                item = db.query(model.Balance).filter_by(uid=id).one()
            except InvalidRequestError:
                result[id] = {
                    "deleted" : False,
                    "message": Messages.elementNotFound(key=id)
                }
                continue

            try:
                db.delete(item)
                db.commit()
                result[item.uid] = {
                    "deleted" : True,
                }
            except Exception, e:
                result[item.uid] = {
                    "deleted" : False,
                    "message" : Messages.failedToDelete(exception=e)
                }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:34,代码来源:balances.py

示例6: delete

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToDelete [as 别名]
    def delete(self):
        model = request.environ["sqlalchemy.model"]
        db = request.environ["sqlalchemy.session"]

        result = {}
        for id in request.params.getall('id'):
            try:
                item = db.query(model.IncomeCategory).filter_by(uid=id).one()
            except InvalidRequestError:
                result[id] = {
                    "deleted" : False,
                    "message": Messages.elementNotFound(key=id)
                }
                continue

            if (db.query(model.BalanceChange).filter_by(income_category_uid=item.uid).count() > 0):
                result[item.uid] = { 
                    "deleted" : False,
                    "message" : Messages.incomeCategoryIsInUse(id=item.uid)
                }
            else:
                try:
                    db.delete(item)
                    db.commit()
                    result[item.uid] = {
                        "deleted" : True,
                    }
                except Exception, e:
                    result[item.uid] = {
                        "deleted" : False,
                        "message" : Messages.failedToDelete(exception=e)
                    }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:34,代码来源:income_categories.py

示例7: category

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToDelete [as 别名]
    def category(self):
        dbFacade = self.dbFacade()
        result = {}
            
        category = dbFacade.balances.categoryDao.find_by_name(request.params.get('category'))
        if category is None:
            return { "failure": Messages.invalidArguments() }

        for id in request.params.getall('id'):
            try:
                item = dbFacade.balances.changeDao.find_by_uid(id, options=[eagerload('balance')])
                if item is None:
                    result[id] = {
                        "deleted" : False,
                        "message": Messages.elementNotFound(key=id)
                    }
                    continue

                if not item.balance or not item.balance.can_modify_balance(h.authenticated_user().uid):
                    result[id] = {
                        "deleted" : False,
                        "message": Messages.permissionDenied()
                    }
                    continue

                item.category = category.name
                
                dbFacade.db.commit()
                result[id] = { "modified" : True }
            except Exception, e:
                result[id] = {
                    "deleted" : False,
                    "message" : Messages.failedToDelete(exception=e),
                }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:36,代码来源:balance_changes.py

示例8: delete

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToDelete [as 别名]
 def delete(self):
     result = {}        
     try:
         category_name = request.params.get('name')
         category_tc = self.dbFacade().balances.categoryDao.find_by_name(category_name, h.authenticated_user().uid)
         if category_tc is None:
             return { "failure" : Messages.elementNotFound(key=category_name) }
         parent = self.dbFacade().balances.categoryDao.find_by_key(category_tc.parent, h.authenticated_user().uid)                     
         self.dbFacade().db.delete(category_tc)
         self._change_changes_category(category_name, parent.name)
         self.dbFacade().db.commit()
     except Exception, e:
         return { "failure" : Messages.failedToDelete(exception=e) }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:15,代码来源:balance_categories.py

示例9: delete

# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToDelete [as 别名]
    def delete(self):
        dbFacade = self.dbFacade()
        result = {}
        for id in request.params.getall('id'):
            item = dbFacade.stocks.changeDao.find_by_uid(id)
            if item is None:
                result[id] = {
                    "deleted" : False,
                    "message": Messages.elementNotFound(key=id)
                }
                continue

            try:
                dbFacade.db.delete(item)
                dbFacade.db.commit()
                result[item.uid] = {
                    "deleted" : True,
                }
            except Exception, e:
                result[item.uid] = {
                    "deleted" : False,
                    "message" : Messages.failedToDelete(exception=e)
                }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:25,代码来源:stocks.py


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