예제 #1
0
파일: views.py 프로젝트: paulovictor/sysat
def reclaim(request):
    if request.method == 'POST':
        form = ComplaintForm(request.POST,request.FILES)
        if form.is_valid():
            obj = Complaint(**form.cleaned_data)
            obj.save()
            #return HttpResponseRedirect('/inscricao/%d/' % obj.pk)
            return HttpResponseRedirect('/reclamacoes')
        else :
            return render(request, 'complaints/complaint_form.html', { 'form': form})
    else:
        return render(request,'complaints/complaint_form.html',{'form': ComplaintForm()})
예제 #2
0
class ComplaintTest(TestCase):
    def setUp(self):
        self.obj = Complaint(name = 'Paulo V',
            cpf='12345678901',
            email = '*****@*****.**',
            phone = '97487648'
            )
    def test_create(self):
        'Complaint must have name, cpf, email , phone'
        self.obj.save()
        self.assertEqual(1,self.obj.id)

    def test_has_created_at(self):
        'Complaint must have automatic created_at'
        self.obj.save()
        self.assertIsInstance(self.obj.created_at, datetime)

    def test_unicode(self):
        self.assertEqual(u'Paulo V',unicode(self.obj))
예제 #3
0
 def setUp(self):
     self.obj = Complaint(name = 'Paulo V',
         cpf='12345678901',
         email = '*****@*****.**',
         phone = '97487648'
         )