本文整理汇总了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 ]
}
示例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 ]
}
示例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)]
}