From 4bfcdc6ef5b6e7501e8a0581f7236d8381a8e5e6 Mon Sep 17 00:00:00 2001 From: "AppleGrew (applegrew)" Date: Sat, 9 Nov 2013 10:00:43 +0530 Subject: [PATCH] Issue 76 testing --- testapp/test.db | Bin 2469888 -> 2469888 bytes testapp/testapp/templates/index.html | 1 + testapp/testapp/testmain/forms.py | 9 ++++++++- testapp/testapp/testmain/urls.py | 2 ++ testapp/testapp/testmain/views.py | 18 +++++++++++++++++- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/testapp/test.db b/testapp/test.db index 2f81331f041b58844ca4684769a8f6c4d5da894d..f2f5acc901461d3a59fa78ee745c6b059ae8110d 100644 GIT binary patch delta 341 zcmZvUy)pw)7>3U|dv>$L<~vJ%utBg&GcG`3#s#;Y} zNQfFCgdVxh;w2<42cWklDK++4|nMwry5SeVnhRzI_u^W%N&fv5>*RvJgPCNhzK;+0!e diff --git a/testapp/testapp/templates/index.html b/testapp/testapp/templates/index.html index 5f192a4..39c8207 100644 --- a/testapp/testapp/templates/index.html +++ b/testapp/testapp/templates/index.html @@ -14,5 +14,6 @@
  • Test multi value auto model field.
  • Test performance. Issue#54.
  • Test a search form using GET. Issue#66.
  • +
  • Test issue#73.
  • diff --git a/testapp/testapp/testmain/forms.py b/testapp/testapp/testmain/forms.py index 0754952..f7c4a8d 100644 --- a/testapp/testapp/testmain/forms.py +++ b/testapp/testapp/testmain/forms.py @@ -176,4 +176,11 @@ class WordsForm(forms.ModelForm): class GetSearchTestForm(forms.Form): name = GetSearchTestField(required=False, label='Name') - dept = GetModelSearchTestField(required=False, label='Department') \ No newline at end of file + dept = GetModelSearchTestField(required=False, label='Department') + +class AnotherWordForm(forms.ModelForm): + word = WordChoices(widget=AutoHeavySelect2Widget()) + + class Meta: + model = WordList + exclude = ['kind', 'words'] diff --git a/testapp/testapp/testmain/urls.py b/testapp/testapp/testmain/urls.py index c0c0cca..d1fede4 100644 --- a/testapp/testapp/testmain/urls.py +++ b/testapp/testapp/testmain/urls.py @@ -20,4 +20,6 @@ urlpatterns = patterns('testapp.testmain.views', url(r'auto_heavy/perf_test/$', 'test_auto_heavy_perf', name='test_auto_heavy_perf'), url(r'get_search/get_search_test/$', 'test_get_search_form', name='test_get_search_form'), + + url(r'issue76/$', 'test_issue_73', name='test_issue_73'), ) diff --git a/testapp/testapp/testmain/views.py b/testapp/testapp/testmain/views.py index 87444b5..4c5536c 100644 --- a/testapp/testapp/testmain/views.py +++ b/testapp/testapp/testmain/views.py @@ -2,7 +2,8 @@ from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect from django.shortcuts import render, get_object_or_404 -from .forms import EmployeeForm, DeptForm, MixedForm, InitialValueForm, QuestionForm, WordsForm, SchoolForm, GetSearchTestForm +from .forms import EmployeeForm, DeptForm, MixedForm, InitialValueForm, QuestionForm, WordsForm, SchoolForm, GetSearchTestForm, \ + AnotherWordForm from .models import Employee, Dept, Question, WordList, School def test_single_value_model_field(request): @@ -126,3 +127,18 @@ def test_get_search_form(request): form = GetSearchTestForm() results = Employee.objects.none() return render(request, 'formget.html', {'form': form, 'results' : results}) + +def test_issue_73(request): + try: + word = WordList.objects.get(kind='Word_Of_Day') + except WordList.DoesNotExist: + word = WordList(kind='Word_Of_Day') + + if request.POST: + form = AnotherWordForm(request.POST) + if form.is_valid(): + form.save() + return HttpResponseRedirect(reverse('home')) + else: + form = AnotherWordForm(instance=word) + return render(request, 'form.html', {'form': form})