Exemple #1
0
    def test_compare_sample_form_displays_all_samples(self):
        '''
        Check to make sure that all samples are displayed in the sample
        compare form
        '''
        from samples.models import Sample

        make_fake_comparison_with_2_samples()
        form = SampleCompareForm()
        rendered_form = form.as_p()
        for sample in Sample.objects.all():
            self.assertIn(str(sample), rendered_form)
Exemple #2
0
def sample_compare(request):
    from cf_comparisons.forms import SampleCompareForm

    if request.method == 'POST':
        sample_compare_form = SampleCompareForm(request.POST)
        if sample_compare_form.is_valid():
            comparison = Comparison.default_from_samples(
                sample_compare_form.cleaned_data['samples'])
            return HttpResponseRedirect(reverse('cf_comparisons.views.compare', args=[comparison.id]))

    sample_compare_form = SampleCompareForm()
    context = {'sample_compare_form': sample_compare_form}
    return render(request, 'sample_compare.html', context)