Example #1
0
 def test_row_formsets(self):
     formsets = create_pronoun_formset(self.pdm, self._generate_post_data(self.pdm))
     for row in sort_formset(formsets):
         assert row[1]['A'] is not None
         assert row[1]['S'] is None
         assert row[1]['O'] is None
         assert row[1]['P'] is None
Example #2
0
 def test_tokens(self):
     formsets = create_pronoun_formset(self.pdm,
                                       self._generate_post_data(self.pdm))
     rows = sort_formset(formsets)
     assert rows[0][0] == u'1st (excl) Person Singular'
     assert rows[1][0] == u'2nd Person Singular'
     assert rows[2][0] == u'3rd Person Singular'
Example #3
0
 def test_four_per_row(self):
     formsets = create_pronoun_formset(self.pdm, self._generate_post_data(self.pdm))
     for row in sort_formset(formsets):
         assert len(row[1]) == 4
         assert 'A' in row[1]
         assert 'S' in row[1]
         assert 'O' in row[1]
         assert 'P' in row[1]
Example #4
0
 def test_row_formsets(self):
     formsets = create_pronoun_formset(self.pdm,
                                       self._generate_post_data(self.pdm))
     for row in sort_formset(formsets):
         assert row[1]['A'] is not None
         assert row[1]['S'] is None
         assert row[1]['O'] is None
         assert row[1]['P'] is None
Example #5
0
 def test_four_per_row(self):
     formsets = create_pronoun_formset(self.pdm,
                                       self._generate_post_data(self.pdm))
     for row in sort_formset(formsets):
         assert len(row[1]) == 4
         assert 'A' in row[1]
         assert 'S' in row[1]
         assert 'O' in row[1]
         assert 'P' in row[1]
Example #6
0
def edit(request, paradigm_id):
    pdm = get_object_or_404(Paradigm, pk=paradigm_id)
    paradigm_form = ParadigmForm(request.POST or None, instance=pdm, prefix='pdm')
    pronoun_form = create_pronoun_formset(pdm, request.POST or None)
    
    # save if valid.
    if pronoun_formsets_are_valid(pronoun_form) and paradigm_form.is_valid():
        pdm = paradigm_form.save(commit=False)
        pdm.editor = request.user
        pdm.save()
        for pronoun, formset in pronoun_form:
            save_pronoun_formset(pdm, pronoun, formset, request.user)
        return redirect('pronouns:detail', paradigm_id=pdm.id)
        
    # the initial view and the error view
    return render_to_response('pronouns/edit.html', {
        'paradigm': pdm,
        'paradigm_form': paradigm_form,
        'pronouns': sort_formset(pronoun_form),
    }, context_instance=RequestContext(request))
Example #7
0
def edit(request, paradigm_id):
    pdm = get_object_or_404(Paradigm, pk=paradigm_id)
    paradigm_form = ParadigmForm(request.POST or None,
                                 instance=pdm,
                                 prefix='pdm')
    pronoun_form = create_pronoun_formset(pdm, request.POST or None)
    # save if valid.
    if pronoun_formsets_are_valid(pronoun_form) and paradigm_form.is_valid():
        pdm = paradigm_form.save(commit=False)
        pdm.editor = request.user
        pdm.save()
        for pronoun, formset in pronoun_form:
            save_pronoun_formset(pdm, pronoun, formset, request.user)
        return redirect('pronouns:detail', paradigm_id=pdm.id)

    # the initial view and the error view
    return render(
        request, 'pronouns/edit.html', {
            'paradigm': pdm,
            'paradigm_form': paradigm_form,
            'pronouns': sort_formset(pronoun_form),
        })
Example #8
0
 def test_tokens(self):
     formsets = create_pronoun_formset(self.pdm, self._generate_post_data(self.pdm))
     rows = sort_formset(formsets)
     assert rows[0][0] == u'1st (excl) Person Singular'
     assert rows[1][0] == u'2nd Person Singular'
     assert rows[2][0] == u'3rd Person Singular'
Example #9
0
 def test_number_of_rows(self):
     formsets = create_pronoun_formset(self.pdm, self._generate_post_data(self.pdm))
     sortf = sort_formset(formsets)
     assert len(sortf) == 3
Example #10
0
 def test_number_of_rows(self):
     formsets = create_pronoun_formset(self.pdm,
                                       self._generate_post_data(self.pdm))
     sortf = sort_formset(formsets)
     assert len(sortf) == 3