Исправлены конфликты
This commit is contained in:
@@ -16,4 +16,8 @@ class custom_date(date):
|
||||
|
||||
@property
|
||||
def date_dd_mm_yy(self):
|
||||
return self.strftime("%d/%m/%Y")
|
||||
return self.strftime("%d/%m/%Y")
|
||||
|
||||
@property
|
||||
def is_weekend(self):
|
||||
return self.weekday() >= 5
|
||||
|
||||
@@ -124,8 +124,17 @@ class VisitTable(tables.Table):
|
||||
orders = tables.Column(verbose_name = 'Заказы', accessor = 'order.product__count')
|
||||
cost = tables.Column(verbose_name = 'Стоимость', accessor = 'order.price__sum')
|
||||
designer = tables.Column(verbose_name = 'Дизайнеры')
|
||||
|
||||
summary = ['Итого:','',0,0,0,0,'']
|
||||
|
||||
def render_orders(self, value, record):
|
||||
def set_summaries(self, summaries):
|
||||
indexes = {'calls': 2, 'visits': 3, 'orders': 4, 'cost': 5}
|
||||
for s in summaries:
|
||||
idx = indexes[s]
|
||||
self.summary[idx] = summaries[s]
|
||||
|
||||
def render_orders(self, value, record, column):
|
||||
value = 0 if value == None else value
|
||||
return mark_safe('<a href="%s?date=%s">%s</a>' % (
|
||||
reverse('asuzr.views.visit_view'),
|
||||
record['date'].strftime('%d.%m.%Y'),
|
||||
@@ -134,6 +143,8 @@ class VisitTable(tables.Table):
|
||||
|
||||
class Meta:
|
||||
attrs = {'class': 'paleblue'}
|
||||
orderable = False
|
||||
template = 'asuzr/weekend_table.html'
|
||||
|
||||
class ProdPlanTable(tables.Table):
|
||||
date = tables.Column(verbose_name = 'Дата')
|
||||
|
||||
@@ -53,13 +53,17 @@ def visit_view(request):
|
||||
edate = date(y,m,day_in_month)
|
||||
|
||||
attend_list = Attendance.objects.filter(date__range = (sdate,edate))
|
||||
attend_sum = attend_list.aggregate(Sum('calls'), Sum('visits'))
|
||||
for attend in attend_list:
|
||||
month_days[attend.date.day]['attend'] = attend
|
||||
|
||||
order_list = Order.objects.filter(date__range = (sdate,edate))
|
||||
order_sum = order_list.aggregate(Count('product'), Sum('price'))
|
||||
order_list = order_list.values('date')
|
||||
order_list = order_list.annotate(Count('product'), Sum('price'))
|
||||
|
||||
print order_sum
|
||||
|
||||
for order in order_list:
|
||||
month_days[order['date'].day]['order'] = order
|
||||
|
||||
@@ -71,9 +75,15 @@ def visit_view(request):
|
||||
month_days[day]['designer'] = '%s, %s' % (month_days[day]['designer'], designer)
|
||||
else:
|
||||
month_days[day]['designer'] = designer
|
||||
|
||||
|
||||
table = VisitTable(month_days.values())
|
||||
RequestConfig(request, paginate={'per_page': 32}).configure(table)
|
||||
table.set_summaries({
|
||||
'calls': attend_sum['calls__sum'],
|
||||
'visits': attend_sum['visits__sum'],
|
||||
'orders': order_sum['product__count'],
|
||||
'cost': order_sum['price__sum'],
|
||||
})
|
||||
title = 'Таблица посещаемости на %s г.' % curr_date.strftime('%B %Y')
|
||||
return render(request, 'asuzr/table.html', {'table': table, 'title': title})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user