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


Python Messages.pemissionDenied方法代码示例

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


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

示例1: _list_by_category

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

        try:
            user_uid = h.authenticated_user().uid
        except:
            return { "failure": Messages.pemissionDenied() }
        if not Operations(db, model).can_see_balance(user_uid, balance_uid):
            return { "failure": Messages.permissionDenied() }

        now = date.today()
       
        select_expenses = select(
            [model.ExpenseCategory.c.uid.label('uid'), model.ExpenseCategory.c.name.label('name'), func.sum(model.BalanceChange.c.amount).label('summary')], 
            and_(model.BalanceChange.is_income==False,
                model.ExpenseCategory.uid==model.BalanceChange.expense_category_uid,
                model.BalanceChange.balance_uid==balance_uid,
                model.BalanceChange.occurred_on >= date(now.year, now.month, 1)), 
            from_obj=[model.expense_categories_table, model.balance_changes_table],
            group_by=[model.ExpenseCategory.c.uid, model.ExpenseCategory.c.name])

        select_incomes = select(
            [model.IncomeCategory.c.uid.label('uid'), model.IncomeCategory.c.name.label('name'), func.sum(model.BalanceChange.c.amount).label('summary')], 
            and_(model.BalanceChange.is_income==True,
                model.IncomeCategory.uid==model.BalanceChange.income_category_uid,
                model.BalanceChange.balance_uid==balance_uid,
                model.BalanceChange.occurred_on >= date(now.year, now.month, 1)), 
            from_obj=[model.income_categories_table, model.balance_changes_table],
            group_by=[model.IncomeCategory.c.uid, model.IncomeCategory.c.name])

        if expenses and incomes:
            query = union(select_expenses, select_incomes)
        else:
            query = expenses and select_expenses or select_incomes

        balance_changes = db.execute(query.order_by('name')).fetchall()
        total = len(balance_changes)
        try:
            page_nr = request.params['page_nr']
        except:
            page_nr = 1

        try:
            items_per_page = int(request.params['items_per_page'])
        except:
            items_per_page = 15
        
        subset = Page(balance_changes, item_count=total, current_page=page_nr, items_per_page=items_per_page)
        return { 
            "totalItems" : total,
            "itemsFound" : len(subset),
            "items" : [{ 
                "uid" : item.uid,
                "name" : item.name,
                "summary" : h.format_decimal(Decimal(item.summary))} for item in subset ]
        }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:59,代码来源:balance_changes.py

示例2: list

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

        try:
            user_uid = h.authenticated_user().uid
        except:
            return { "failure": Messages.pemissionDenied() }
        if not Operations(db, model).can_see_balance(user_uid, balance_uid):
            return { "failure": Messages.permissionDenied() }

        balance_changes = db.query(model.BalanceChange) \
            .options(eagerload('expense_category'), eagerload('income_category')) \
            .filter_by(balance_uid = balance_uid).order_by(model.BalanceChange.occurred_on).all()
        total = len(balance_changes)
        try:
            page_nr = request.params['page_nr']
        except:
            page_nr = 1

        try:
            items_per_page = int(request.params['items_per_page'])
        except:
            items_per_page = 15
        
        subset = Page(balance_changes, item_count=total, current_page=page_nr, items_per_page=items_per_page)
        return { 
            "totalItems" : total,
            "itemsFound" : len(subset),
            "items" : [{ 
                "uid" : item.uid, 
                "category_uid" : item.is_income and item.income_category_uid or item.expense_category_uid, 
                "category" : (item.is_income and item.income_category or item.expense_category).name, 
                "amount" : h.format_decimal(Decimal(item.amount)), 
                "description" : item.description, 
                "occurred_on": str(item.occurred_on), 
                "is_income": item.is_income,
                "tags_as_string": item.tags_as_string()} for item in subset ]
        }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:41,代码来源:balance_changes.py

示例3: list_tags

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

        try:
            user_uid = h.authenticated_user().uid
        except:
            return { "failure": Messages.pemissionDenied() }
        if not Operations(db, model).can_see_balance(user_uid, id):
            return { "failure": Messages.permissionDenied() }

        try:
            query = request.params['query']
        except:
            query = ""

        tags = db.query(model.BalanceTag) \
            .filter_by(balance_uid = id).order_by(model.BalanceTag.tag).all()
        total = len(tags)
        try:
            page_nr = int(request.params['page_nr'])
        except:
            page_nr = 1

        try:
            items_per_page = int(request.params['items_per_page'])
        except:
            items_per_page = 15
        
        subset = Page(tags, item_count=total, current_page=page_nr, items_per_page=items_per_page)
        return { 
            "totalItems" : total,
            "itemsFound" : len(subset),
            "items" : [{ 
                "uid" : item.uid, 
                "tag": item.tag } for item in subset if item.tag.startswith(query)]
        }
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:39,代码来源:balances.py


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