Пример #1
0
    def test_not_is_extreme(self):
        """
        Test that if is_extreme is not ticked, duration is required.
        """
        proposal_type = ProposalType.objects.get(name='Talk')
        audience_level = AudienceLevel.objects.get(name='Experienced')
        category = Category.objects.get(name='Web Framework')

        self.assertEqual(Proposal.objects.count(), 0)
        data = {'title': 'Awesome Talk',
                'type': proposal_type.id,
                'audience': audience_level.id,
                'category': category.id,
                'is_extreme': False,
                'duration_0': '',
                'duration_1': 'minutes',
                'description': 'Some awesome description.',
                'abstract': 'Some awesome abstract.'}
        form = ProposalForm(data=data)
        self.assertFalse(form.is_valid())
Пример #2
0
def proposal_create(request):
    if request.method == 'POST':
        form = ProposalForm(request.POST)
        if form.is_valid():
            form.save(request.user)
            messages.add_message(
                request,
                messages.SUCCESS,
                _(u"Your proposal has been submitted."))
            return redirect('proposal_list')
        else:
            messages.add_message(
                request,
                messages.ERROR,
                _(u"An error occured while trying to submit your proposal."))
    else:
        form = ProposalForm()
    context = {
        'form': form
    }
    return render(request, 'proposal/proposal_create.html', context)
Пример #3
0
 def on_get(request, form):
     return ProposalForm(instance=proposal)