本文整理汇总了Python中models.event.Event.get_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get_dict方法的具体用法?Python Event.get_dict怎么用?Python Event.get_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.event.Event
的用法示例。
在下文中一共展示了Event.get_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_dict
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_dict [as 别名]
def get_dict(term_type=False):
from models.event import Event
types = EventType.get_types(term_type)
events = Event.get_dict()
result = {}
for row in types:
result[row.event_id] = events[row.event_id]
return result
示例2: get_person_report
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_dict [as 别名]
def get_person_report(self, **kwargs):
time_pattern = '%H:%M'
date_pattern = '%d.%m.%Y'
month_pattern = '%m.%Y'
self._get_search_params(**kwargs)
if self.period == 'day':
result_date_pattern = date_pattern
elif self.period == 'month':
result_date_pattern = month_pattern
answer = self.person_general_query(**kwargs)
result = []
events = Event.get_dict()
term_name_dict = Term.select_name_dict()
term_tz_dict = Term.select_tz_dict()
for report in answer['reports']:
search_date = date_helper.from_utc(
report[0],
self.tz)
creation_date = search_date.strftime(date_pattern)
data = dict(
creation_date=search_date.strftime(result_date_pattern),
amount=0,
count=0
)
summ_kop = 0
data['page_dates'] = answer['page_dates']
data['detaled'] = []
detaled_reports = self.person_detaled_query(search_date)
for row in detaled_reports:
term_name = 'Empty'
if row.term_id in term_name_dict:
term_name = term_name_dict[row.term_id]
tz = self.tz
if row.term_id in term_tz_dict:
tz = term_tz_dict[row.term_id]
creation_date = date_helper.from_utc(
row.creation_date,
tz)
detaled_data = dict(
id=row.id,
term=term_name,
time=creation_date.strftime(time_pattern),
date=creation_date.strftime(date_pattern),
event=events[
row.event_id] if events[
row.event_id] else 'Empty',
amount=float(row.amount) / 100,
name=row.name,
)
data['count'] += 1
summ_kop += row.amount
data['detaled'].append(detaled_data)
if summ_kop % 100:
data['amount'] = "%d.%02d" % (summ_kop / 100, summ_kop % 100)
else:
data['amount'] = "%d" % (summ_kop / 100)
result.append(data)
value = dict(
result=result,
count=answer['reports_count'],
)
return value