- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
now = timezone.now().astimezone(cur_tz)
today = now.replace(hour=0, minute=0, second=0, microsecond=0)
td1day = datetime.timedelta(days=1)
td7days = datetime.timedelta(days=7)
td14days = datetime.timedelta(days=14)
td30days = datetime.timedelta(days=30)
categories = None
if user is not None:
try:
categories = self.categories.restrict_by_acl(
self.acl.by_user(user, can_enter=True), throw_if_all=True)
except CampaignProductCategory.NoAclRestriction:
categories = None
report3_url = reverse('report3', args=[self.pk])
df = lambda d: d.strftime('%d.%m.%Y')
stats = {'to': now}
stats['in_1d'] = get_count(today, categories)
stats['in_1d_from'] = today
stats['in_1d_url'] = (
report3_url +
'#from_date=%s&to_date=%s' % (df(stats['in_1d_from']),
df(stats['to'])))
stats['in_7d'] = get_count(today-td7days+td1day, categories)
stats['in_7d_from'] = today - td7days + td1day
stats['in_7d_url'] = (
report3_url +
'#from_date=%s&to_date=%s' % (df(stats['in_7d_from']),
df(stats['to'])))
stats['in_14d'] = get_count(today-td14days+td1day, categories)
stats['in_14d_from'] = today - td14days + td1day
stats['in_14d_url'] = (
report3_url +
'#from_date=%s&to_date=%s' % (df(stats['in_14d_from']),
df(stats['to'])))
stats['in_30d'] = get_count(today-td30days+td1day, categories)
stats['in_30d_from'] = today - td30days + td1day
stats['in_30d_url'] = (
report3_url +
'#from_date=%s&to_date=%s' % (df(stats['in_30d_from']),
df(stats['to'])))
Lure Of Chaos 18.11.2014 17:44 # +2
3_14dar 20.08.2015 03:25 # 0
Вот как в питоне не хватает синтаксиса для получения замыкания из метода.
roman-kashitsyn 20.08.2015 10:55 # 0
Представим, что он есть. Что бы от этого изменилось? Тут же ещё параметры в метод передавать надо.
roman-kashitsyn 20.08.2015 11:34 # 0
3_14dar 20.08.2015 15:32 # 0
roman-kashitsyn 20.08.2015 17:08 # 0
roman-kashitsyn 20.08.2015 17:37 # +1
3_14dar 20.08.2015 23:52 # 0
3_14dar 20.08.2015 23:52 # 0