diff --git a/projects/forms.py b/projects/forms.py index c4b5d51..4117525 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -34,6 +34,7 @@ class RealtyForm(ModelForm): 'city', ) + class PortfolioForm(ModelForm): class Meta: model = Portfolio diff --git a/projects/templates/projects/test_form.html b/projects/templates/projects/test_form.html new file mode 100644 index 0000000..a949574 --- /dev/null +++ b/projects/templates/projects/test_form.html @@ -0,0 +1,8 @@ +

Test form

+
{% csrf_token %} + {{ form.errors }} + {{ form.as_p }} + {{ second_form.errors }} + {{ second_form.as_p }} + +
diff --git a/projects/urls.py b/projects/urls.py index f99957f..7a7d3fd 100644 --- a/projects/urls.py +++ b/projects/urls.py @@ -3,7 +3,7 @@ from django.conf import urls from .views import ProjectListView, ProjectDetailView, \ ProjectCreateView, PortfolioCreateView,\ - TestProjectView, manage_articles + TestProjectView, manage_articles, TestView app_name = 'projects' @@ -11,7 +11,8 @@ urlpatterns = [ urls.url(r'^$', ProjectListView.as_view(), name='list'), urls.url(r'^porttest/$', manage_articles, name='portfolio'), urls.url(r'^create/$', ProjectCreateView.as_view(), name='project-create'), - urls.url(r'^test/$', TestProjectView.as_view(), name='project-test'), + # urls.url(r'^test/$', TestProjectView.as_view(), name='project-test'), + urls.url(r'^test/$', TestView.as_view(), name='project-test'), urls.url(r'^portfolio/create/$', PortfolioCreateView.as_view(), name='portfolio-create'), urls.url(r'(?P\d+)$', ProjectDetailView.as_view(), name='detail'), ] diff --git a/projects/views.py b/projects/views.py index 4d170f6..bc4ddd2 100644 --- a/projects/views.py +++ b/projects/views.py @@ -1,7 +1,7 @@ from django.http import HttpResponseForbidden from django.core.urlresolvers import reverse from django.contrib.auth.mixins import PermissionRequiredMixin -from django.views.generic import ListView, DetailView, CreateView +from django.views.generic import ListView, DetailView, CreateView, View from django.views.generic.edit import FormMixin from .models import Project, Portfolio @@ -75,8 +75,38 @@ class PortfolioCreateView(PermissionRequiredMixin, CreateView): # import code; code.interact(local=dict(globals(), **locals())) +from django.http import HttpResponseRedirect +class TestView(View): + template_name = 'projects/test_form.html' + form_class = RealtyForm + form_second = ProjectForm -class TestProjectView(CreateView): + def get(self, request, *args, **kwargs): + form = self.form_class() + second_form = self.form_second(prefix='form_2') + return render(request,self.template_name, {'form': form, 'second_form': second_form}) + + def post(self, request, *args, **kwargs): + form = self.form_class(request.POST) + second_form = self.form_second(request.POST,prefix='form_2') + if form.is_valid() and second_form.is_valid(): + return self.form_valid(request, form, second_form) + return render(request, self.template_name, {'form': form, 'second_form': second_form}) + + def form_valid(self, request, form, second_form): + realty = second_form.save(commit=False) + realty.user = request.user + realty.save() + project = form.save(commit=False) + project.user = request.user + project.realty = realty + project.save() + + def form_invalid(self, form, second_form): + pass + + +class TestProjectView(View): model = Project form_class = ProjectForm template_name = 'projects/test.html' @@ -95,12 +125,11 @@ class TestProjectView(CreateView): form_class = self.get_form_class() form = self.get_form(form_class) realty_form = RealtyForm(self.request.POST) - import code; code.interact(local=dict(globals(), **locals())) + # import code; code.interact(local=dict(globals(), **locals())) if form.is_valid(): return self.form_valid(form, realty_form) else: return self.form_invalid(form, realty_form) - # import code; code.interact(local=dict(globals(), **locals())) def form_valid(self, form, realty_form): diff --git a/specializations/templates/specializations/specialization.html b/specializations/templates/specializations/specialization.html new file mode 100644 index 0000000..225a1ce --- /dev/null +++ b/specializations/templates/specializations/specialization.html @@ -0,0 +1,13 @@ +{% load staticfiles %} + + + + + + + Archilance + + + + + diff --git a/specializations/templates/specializations/specialization_list.html b/specializations/templates/specializations/specialization_list.html index 31ac6e2..37e8f3b 100644 --- a/specializations/templates/specializations/specialization_list.html +++ b/specializations/templates/specializations/specialization_list.html @@ -7,24 +7,28 @@ {# {% endfor %}#} {##} {% load mptt_tags %} -{# #} + {##} {% for ch in children %}

{{ ch }}

{% for ch1 in ch.get_children %} {# {{ ch1 }}#} {% endfor %} {% endfor %} + +
+ +
{% block js_block %}