diff --git a/asuzr/forms.py b/asuzr/forms.py index 432d141..f8257a7 100644 --- a/asuzr/forms.py +++ b/asuzr/forms.py @@ -68,3 +68,11 @@ class ProdTableForm(ModelForm): queryset = CostItem.objects.all(), widget=RelatedFieldWidgetCanAdd(CostItem) ) + +class ProdPlanForm(ModelForm): + class Meta: + model = ProdPlan + fields = ['start_date', 'order', 'executor','action'] + + submit_text = "Добавить" + start_date = forms.DateField(widget = AdminDateWidget(format = '%d.%m.%Y')) \ No newline at end of file diff --git a/asuzr/tables.py b/asuzr/tables.py index e2c1357..8c0b2e0 100644 --- a/asuzr/tables.py +++ b/asuzr/tables.py @@ -213,6 +213,7 @@ class ProdPlanTable(tables.Table): class Meta: attrs = {'class': 'paleblue'} + template = 'asuzr/table_with_form.html' class ProductionTable(tables.Table): cost_item = tables.Column(verbose_name = 'Комплектующие') diff --git a/asuzr/views.py b/asuzr/views.py index d55c122..e11ac5d 100644 --- a/asuzr/views.py +++ b/asuzr/views.py @@ -302,9 +302,13 @@ def prod_plan_view(request): table = ProdPlanTable(week_days.values()) title = u'Производственный план на %s - %s' % (sdate.strftime('%d.%m.%Y'), edate.strftime('%d.%m.%Y')) - form = DateForm({'date':curr_date}) + date_form = DateForm({'date':curr_date}) + add_form = ProdPlanForm() RequestConfig(request).configure(table) - return render(request, 'asuzr/table.html', {'table': table, 'title': title, 'dateform': form}) + return render(request, 'asuzr/table.html', {'table': table, 'title': title, 'dateform': date_form, 'add_form': add_form, 'form_action' : 'add-plan-item'}) + +def prod_plan_add_item(request): + return redirect(prod_plan_view) @login_required def log_view(request): diff --git a/record/settings.py b/record/settings.py index 7d9d4aa..1445fe8 100644 --- a/record/settings.py +++ b/record/settings.py @@ -82,13 +82,17 @@ USE_L10N = False USE_TZ = True -DATE_FORMAT = 'd/m/Y' +DATE_FORMAT = 'd.m.Y' + +DATE_INPUT_FORMATS = ('%d.%m.%Y',) # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.6/howto/static-files/ STATIC_URL = '/static/' +ADMIN_MEDIA_PREFIX = '/static/admin/' + TEMPLATE_DIRS = ('templates/') TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.request', diff --git a/record/urls.py b/record/urls.py index 911e527..a6b01d2 100644 --- a/record/urls.py +++ b/record/urls.py @@ -24,12 +24,14 @@ urlpatterns = patterns('', url(r'^sketches/(?P\d+)/$', 'asuzr.views.sketches'), url(r'^sketches/delete/$', 'asuzr.views.delete_sketch', name = 'asuzr-del-sketch'), url(r'^prodplan/$', 'asuzr.views.prod_plan_view'), + url(r'^prodplan/add_item/$', 'asuzr.views.prod_plan_add_item', name = 'add-plan-item'), url(r'^admin/', include(admin.site.urls)), url(r'^log/$', 'asuzr.views.log_view'), url(r'^inplaceeditform/', include('inplaceeditform.urls')), url(r'^accounts/login/$', login), url(r'^accounts/logout/$', logout), url(r'^jsi18n$', 'django.views.i18n.javascript_catalog', js_info_dict), + url(r'^admin/jsi18n', 'django.views.i18n.javascript_catalog'), ) if settings.DEBUG: diff --git a/templates/asuzr/base.html b/templates/asuzr/base.html index 9f30bb0..936b217 100644 --- a/templates/asuzr/base.html +++ b/templates/asuzr/base.html @@ -24,6 +24,11 @@ return false; } + {% if dateform %} + + + {{ dateform.media }} + {% endif %}