From e965a76fb8a244f484c687a5d211d9a73328f19a Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Mon, 28 Jul 2014 15:13:55 +0200 Subject: [PATCH] [BUGFIX] Restructure view classes so they actually work. --- citavi_mapper/urls.py | 3 +- frontend/forms.py | 53 ++++++++++++++++++++++++++ frontend/templates/index.html | 3 +- frontend/templates/layout/base.html | 2 + frontend/templates/projectcontext.html | 9 +++++ frontend/views.py | 52 +++++++++++++++++++++---- 6 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 frontend/forms.py create mode 100644 frontend/templates/projectcontext.html diff --git a/citavi_mapper/urls.py b/citavi_mapper/urls.py index b68ce19..badc63f 100644 --- a/citavi_mapper/urls.py +++ b/citavi_mapper/urls.py @@ -6,11 +6,12 @@ from django.contrib import admin admin.autodiscover() from frontend.views import login_wrap, logout_wrap -from frontend.views import IndexView, RegisterView +from frontend.views import IndexView, RegisterView, ProjectContextView urlpatterns = patterns('', url(r'^$', IndexView.as_view(), name='frontend-index'), + url(r'^project/$', ProjectContextView.as_view(), name='frontend-projectcontext'), url(r'^login/$', login_wrap, name='frontend-login'), url(r'^logout/$', logout_wrap, name='frontend-logout'), url(r'^register/', RegisterView.as_view(), name='frontend-register'), diff --git a/frontend/forms.py b/frontend/forms.py new file mode 100644 index 0000000..704eb0f --- /dev/null +++ b/frontend/forms.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +from django import forms +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Submit, Layout + +class ExampleForm(forms.Form): + def __init__(self, *args, **kwargs): + super(ExampleForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.form_class = 'form-horizontal' + self.helper.label_class = 'col-lg-2' + self.helper.field_class = 'col-lg-10' + self.helper.form_method = 'post' + self.helper.layout = Layout( + 'like_website', + 'favorite_food', + 'favorite_color', + 'favorite_number', + 'notes', + Submit('send', 'Senden', css_class = 'btn-default pull-right') + ) + + like_website = forms.TypedChoiceField( + label = "Do you like this website?", + choices = ((1, "Yes"), (0, "No")), + coerce = lambda x: bool(int(x)), + widget = forms.RadioSelect, + initial = '1', + required = True, + ) + + favorite_food = forms.CharField( + label = "What is your favorite food?", + max_length = 80, + required = True, + ) + + favorite_color = forms.CharField( + label = "What is your favorite color?", + max_length = 80, + required = True, + ) + + favorite_number = forms.IntegerField( + label = "Favorite number", + required = False, + ) + + notes = forms.CharField( + label = "Additional notes or feedback", + required = False, + ) diff --git a/frontend/templates/index.html b/frontend/templates/index.html index a755a80..f4ea2ce 100644 --- a/frontend/templates/index.html +++ b/frontend/templates/index.html @@ -2,6 +2,7 @@ {% block content %}

Welcome, {{user}}!
- Feel free to discover. + Feel free to discover.
+ Project Contexts

{% endblock %} \ No newline at end of file diff --git a/frontend/templates/layout/base.html b/frontend/templates/layout/base.html index 04809fd..ba1e496 100644 --- a/frontend/templates/layout/base.html +++ b/frontend/templates/layout/base.html @@ -12,6 +12,8 @@ {% compressed_js 'bootstrap' %} {% compressed_css 'frontend' %} + + {% block head %}{% endblock %}