Исправлены конфликты
This commit is contained in:
@@ -19,7 +19,7 @@ class Schedule(models.Model):
|
|||||||
designer = models.ForeignKey(User)
|
designer = models.ForeignKey(User)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return ', '.join((self.date.strftime('%d %b %Y'), self.designer.first_name,))
|
return ' '.join((self.designer.first_name, self.designer.last_name))
|
||||||
|
|
||||||
#Таблица посещаемости
|
#Таблица посещаемости
|
||||||
class Attendance(models.Model):
|
class Attendance(models.Model):
|
||||||
|
|||||||
@@ -1,34 +1,46 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
from django.utils.html import escape
|
||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
from models import *
|
from models import *
|
||||||
|
|
||||||
def editable(field_name):
|
|
||||||
return '{{% load inplace_edit %}}\n\n{{% inplace_edit "record.{field}" auto_height = 1 %}}'.format(field = field_name)
|
|
||||||
|
|
||||||
|
|
||||||
class EditableColumn(tables.TemplateColumn):
|
class EditableColumn(tables.TemplateColumn):
|
||||||
def __init__(self, field_name, *args, **kwargs):
|
def __init__(self, field_name, object_name = '', *args, **kwargs):
|
||||||
super(tables.TemplateColumn, self).__init__(*args, **kwargs)
|
super(tables.TemplateColumn, self).__init__(*args, **kwargs)
|
||||||
print kwargs
|
template = '''
|
||||||
template = '{{% load inplace_edit %}}\n\n{{% inplace_edit "record.{field}" auto_height = 1 %}}'.format(field = field_name)
|
{{{{% load inplace_edit %}}}}
|
||||||
self.template_code = template
|
|
||||||
|
{main_part}
|
||||||
|
'''
|
||||||
|
main_part = ''
|
||||||
|
if object_name == '':
|
||||||
|
main_part = '''
|
||||||
|
{{% inplace_edit "record.{field}" auto_height = 1 %}}
|
||||||
|
'''
|
||||||
|
else:
|
||||||
|
main_part = '''
|
||||||
|
{{% if record.{object_name} %}}
|
||||||
|
{{% inplace_edit "record.{object_name}.{field}" auto_height = 1 %}}
|
||||||
|
{{% endif %}}
|
||||||
|
'''
|
||||||
|
template = template.format(main_part = main_part)
|
||||||
|
|
||||||
|
self.template_code = template.format(field = field_name, object_name = object_name)
|
||||||
|
|
||||||
class ThumbnailColumn(tables.TemplateColumn):
|
class ThumbnailColumn(tables.TemplateColumn):
|
||||||
def __init__(self, field_name, *args, **kwargs):
|
def __init__(self, field_name, *args, **kwargs):
|
||||||
super(tables.TemplateColumn, self).__init__(*args, **kwargs)
|
super(tables.TemplateColumn, self).__init__(*args, **kwargs)
|
||||||
template = '{{% load thumbnail %}}\n\n{{% thumbnail record.{field} "100x100" as im %}}<img src="{{{{ im.url }}}}">{{% endthumbnail %}}'.format(field = field_name)
|
template = '''
|
||||||
|
{{% load thumbnail %}}
|
||||||
|
|
||||||
|
{{% thumbnail record.{field} "100x100" as im %}}
|
||||||
|
<img src="{{{{ im.url }}}}">
|
||||||
|
{{% endthumbnail %}}
|
||||||
|
'''.format(field = field_name)
|
||||||
self.template_code = template
|
self.template_code = template
|
||||||
|
|
||||||
class TestTable(tables.Table):
|
|
||||||
name = EditableColumn('name', "Наименование")
|
|
||||||
prod_period = EditableColumn('prod_period', "Время производства")
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Product
|
|
||||||
attrs = {"class": "paleblue"}
|
|
||||||
|
|
||||||
class OrdersTable(tables.Table):
|
class OrdersTable(tables.Table):
|
||||||
date = tables.DateColumn('d/m/Y', verbose_name = 'Дата')
|
date = tables.DateColumn('d/m/Y', verbose_name = 'Дата')
|
||||||
deadline = tables.DateColumn('d/m/Y/', verbose_name = 'Срок сдачи')
|
deadline = tables.DateColumn('d/m/Y/', verbose_name = 'Срок сдачи')
|
||||||
@@ -78,6 +90,7 @@ class ArchiveOrdersTable(OrdersTable):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
attrs = {'class': 'paleblue'}
|
attrs = {'class': 'paleblue'}
|
||||||
|
empty_text = 'Архивных заказов нет'
|
||||||
|
|
||||||
class DesignerTable(tables.Table):
|
class DesignerTable(tables.Table):
|
||||||
full_name = tables.Column(empty_values=(), verbose_name = 'Дизайнер')
|
full_name = tables.Column(empty_values=(), verbose_name = 'Дизайнер')
|
||||||
@@ -93,9 +106,31 @@ class DesignerTable(tables.Table):
|
|||||||
class Meta:
|
class Meta:
|
||||||
attrs = {'class': 'paleblue'}
|
attrs = {'class': 'paleblue'}
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
attrs = {'class': 'paleblue'}
|
||||||
|
|
||||||
class SketchesTable(tables.Table):
|
class SketchesTable(tables.Table):
|
||||||
sketch_file = tables.FileColumn(verbose_name = 'Имя файла')
|
sketch_file = tables.FileColumn(verbose_name = 'Имя файла')
|
||||||
sketch_image = ThumbnailColumn('sketch_file', verbose_name = 'Эскиз', orderable = False)
|
sketch_image = ThumbnailColumn('sketch_file', verbose_name = 'Эскиз', orderable = False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
attrs = {'class': 'paleblue'}
|
attrs = {'class': 'paleblue'}
|
||||||
|
|
||||||
|
class VisitTable(tables.Table):
|
||||||
|
date = tables.Column(verbose_name = 'Дата')
|
||||||
|
week_day = tables.Column(verbose_name = 'День недели', accessor = 'date.weekday_name')
|
||||||
|
calls = EditableColumn('calls', 'attend' ,verbose_name = 'Звонки', accessor = 'attend.calls')
|
||||||
|
visits = EditableColumn('visits','attend', verbose_name = 'Посещения', accessor = 'attend.visits')
|
||||||
|
orders = tables.Column(verbose_name = 'Заказы', accessor = 'order.product__count')
|
||||||
|
cost = tables.Column(verbose_name = 'Стоимость', accessor = 'order.price__sum')
|
||||||
|
designer = tables.Column(verbose_name = 'Дизайнеры')
|
||||||
|
|
||||||
|
def render_orders(self, value, record):
|
||||||
|
return mark_safe('<a href="%s?date=%s">%s</a>' % (
|
||||||
|
reverse('asuzr.views.visit_view'),
|
||||||
|
record['date'].strftime('%d.%m.%Y'),
|
||||||
|
escape(value),
|
||||||
|
))
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
attrs = {'class': 'paleblue'}
|
||||||
|
|||||||
@@ -42,6 +42,42 @@ def get_orders_by_date(dt):
|
|||||||
order_list = Order.objects.filter(date=dt).order_by('id')
|
order_list = Order.objects.filter(date=dt).order_by('id')
|
||||||
return order_list
|
return order_list
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def visit_view(request):
|
||||||
|
curr_date = datetime.strptime(request.GET.get('date', date.today().strftime('%d.%m.%Y')), '%d.%m.%Y')
|
||||||
|
y,m = curr_date.year, curr_date.month
|
||||||
|
day_in_month = calendar.monthrange(y,m)[1]
|
||||||
|
month_days = {i+1: {'date': custom_date(y,m,i+1)} for i in range(day_in_month)}
|
||||||
|
sdate = date(y,m,1)
|
||||||
|
edate = date(y,m,day_in_month)
|
||||||
|
|
||||||
|
attend_list = Attendance.objects.filter(date__range = (sdate,edate))
|
||||||
|
for attend in attend_list:
|
||||||
|
month_days[attend.date.day]['attend'] = attend
|
||||||
|
|
||||||
|
order_list = Order.objects.filter(date__range = (sdate,edate))
|
||||||
|
order_list = order_list.values('date')
|
||||||
|
order_list = order_list.annotate(Count('product'), Sum('price'))
|
||||||
|
|
||||||
|
for order in order_list:
|
||||||
|
month_days[order['date'].day]['order'] = order
|
||||||
|
|
||||||
|
schedule = Schedule.objects.filter(date__range = (sdate,edate))
|
||||||
|
|
||||||
|
for designer in schedule:
|
||||||
|
day = designer.date.day
|
||||||
|
if 'designer' in month_days[day]:
|
||||||
|
month_days[day]['designer'] = '%s, %s' % (month_days[day]['designer'], designer)
|
||||||
|
else:
|
||||||
|
month_days[day]['designer'] = designer
|
||||||
|
|
||||||
|
print month_days
|
||||||
|
|
||||||
|
table = VisitTable(month_days.values())
|
||||||
|
RequestConfig(request, paginate={'per_page': 32}).configure(table)
|
||||||
|
title = 'Таблица посещаемости на %s г.' % curr_date.strftime('%B %Y')
|
||||||
|
return render(request, 'asuzr/table.html', {'table': table, 'title': title})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def main(request, day, month, year):
|
def main(request, day, month, year):
|
||||||
if day == None:
|
if day == None:
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ DATABASES = {
|
|||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/1.6/topics/i18n/
|
# https://docs.djangoproject.com/en/1.6/topics/i18n/
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'ru-ru'
|
||||||
|
|
||||||
TIME_ZONE = 'Asia/Yekaterinburg'
|
TIME_ZONE = 'Asia/Yekaterinburg'
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ urlpatterns = patterns('',
|
|||||||
url(r'^product/$', 'asuzr.views.prod_list'),
|
url(r'^product/$', 'asuzr.views.prod_list'),
|
||||||
url(r'^product/(?P<prod_id>\d+)/$', 'asuzr.views.prod_detail'),
|
url(r'^product/(?P<prod_id>\d+)/$', 'asuzr.views.prod_detail'),
|
||||||
url(r'^main/?(?P<day>\d+)?/?(?P<month>\d+)?/?(?P<year>\d+)?/$', 'asuzr.views.main', name='asuzr-main'),
|
url(r'^main/?(?P<day>\d+)?/?(?P<month>\d+)?/?(?P<year>\d+)?/$', 'asuzr.views.main', name='asuzr-main'),
|
||||||
|
url(r'^visits/$', 'asuzr.views.visit_view'),
|
||||||
url(r'^orders/(?P<archive>\d+)/$', 'asuzr.views.orders',name='asuzr-orders'),
|
url(r'^orders/(?P<archive>\d+)/$', 'asuzr.views.orders',name='asuzr-orders'),
|
||||||
url(r'^desreport/$', 'asuzr.views.desreport'),
|
url(r'^desreport/$', 'asuzr.views.desreport'),
|
||||||
url(r'^production_table/(?P<order_id>\d+)/$', 'asuzr.views.production_table'),
|
url(r'^production_table/(?P<order_id>\d+)/$', 'asuzr.views.production_table'),
|
||||||
|
|||||||
Reference in New Issue
Block a user