Esempio n. 1
0
def crearBilletera(cedul, cedulaTipo):
    form_data = {
        'nombre': 'Carlos',
        'apellido': 'Perez',
        'cedula': cedul,
        'PIN': '1234',
        'cedulaTipo': cedulaTipo
    }
    form = BilleteraForm(data = form_data)
    billetera = BilleteraElectronica.objects.all()
    
    if form.is_valid():
        if len(billetera) == 9999:
            pass
                
        #elif not BilleteraElectronica.objects.filter(cedula=form.cleaned_data['cedula']).exists():
        else:    
            obj = BilleteraElectronica(
                    nombre = form.cleaned_data['nombre'],
                    apellido = form.cleaned_data['apellido'],
                    PIN = form.cleaned_data['PIN'],
                    cedula = form.cleaned_data['cedula'],
                    saldo = 0.00,
                    cedulaTipo = form.cleaned_data['cedulaTipo']
                )
            
            try:
                with transaction.atomic():
                    obj.save()
            except (IntegrityError):
                pass 
Esempio n. 2
0
def billetera_crear(request):
    form = BilleteraElectronicaForm()
    
    if request.method == 'POST':
        form = BilleteraElectronicaForm(request.POST)
        if form.is_valid():
            
            billetera = BilleteraElectronica(
                nombreUsuario    = form.cleaned_data['nombre'],
                apellidoUsuario  = form.cleaned_data['apellido'],
                cedulaTipo       = form.cleaned_data['cedulaTipo'],
                cedula           = form.cleaned_data['cedula'],
                PIN              = form.cleaned_data['pin'],
                saldo            = Decimal(0).quantize(Decimal('1.00'))
            )
            
            billetera.save();
            
            return render(
                request,
                'crearbilletera.html',
                { "billetera"    : billetera
                , "color"   : "green"
                , 'mensaje' : "Se ha creado la billetera satisfactoriamente."
                }
            )
    
    return render(
        request,
        'crearbilletera.html',
        {
         'form' : form
        }
    )
Esempio n. 3
0
def crearBilletera(cedul, cedulaTipo):
    form_data = {
        'nombre': 'Carlos',
        'apellido': 'Perez',
        'cedula': cedul,
        'PIN': '1234',
        'cedulaTipo': cedulaTipo
    }
    form = BilleteraForm(data=form_data)
    billetera = BilleteraElectronica.objects.all()

    if form.is_valid():
        if len(billetera) == 9999:
            pass

        #elif not BilleteraElectronica.objects.filter(cedula=form.cleaned_data['cedula']).exists():
        else:
            obj = BilleteraElectronica(
                nombre=form.cleaned_data['nombre'],
                apellido=form.cleaned_data['apellido'],
                PIN=form.cleaned_data['PIN'],
                cedula=form.cleaned_data['cedula'],
                saldo=0.00,
                cedulaTipo=form.cleaned_data['cedulaTipo'])

            try:
                with transaction.atomic():
                    obj.save()
            except (IntegrityError):
                pass
Esempio n. 4
0
def crear_billetera(monto=0):
    r = BilleteraElectronica(nombre="Daniel",
                             apellido="Nuñez",
                             cedula="10",
                             cedulaTipo="V",
                             PIN="1234",
                             saldo=monto)
    r.save()
Esempio n. 5
0
 def testConsultaSaldoNulo(self):
     billetera = BilleteraElectronica(nombre='Alejandro',
                                      apellido='Banega',
                                      cedula="12345678",
                                      cedulaTipo='V',
                                      PIN="1234")
     billetera.save()
     billeteraE = BilleteraElectronica.objects.get(pk=1)
     self.assertEqual(billeteraE.saldo, 0)
Esempio n. 6
0
def crear_billetera(monto = 0):
    r = BilleteraElectronica(
            nombre = "Daniel",
            apellido = "Nuñez",
            cedula = "10",
            cedulaTipo = "V",
            PIN = "1234",
            saldo = monto                 
    )
    r.save()
Esempio n. 7
0
 def test_AutenticarBilletera(self):
     billetera1 = BilleteraElectronica(cedula = '10', 
                                       cedulaTipo = 'V', 
                                       nombre = 'Maria', 
                                       apellido = 'Perez', 
                                       saldo = 0.00, 
                                       PIN = '1234')
     billetera1.save()
     billetera = billetera_autenticar(1, "1234")
     self.assertEqual(billetera1, billetera)
Esempio n. 8
0
 def test_AutenticarIDinvalido(self):
     billetera = BilleteraElectronica(cedula = '10', 
                                      cedulaTipo = 'V', 
                                      nombre = 'Maria', 
                                      apellido = 'Perez', 
                                      saldo = 0.00, 
                                      PIN = '1234')
     billetera.save()
     billetera1 = billetera_autenticar(2, '1234')
     self.assertNotEqual(billetera, billetera1)
Esempio n. 9
0
 def test_AutenticarPINinvalido(self):
     billetera = BilleteraElectronica(cedula = '11', 
                                      cedulaTipo = 'V', 
                                      nombre = 'Mario', 
                                      apellido = 'Jimenez', 
                                      saldo = 0.00, 
                                      PIN = '1234')
     billetera.save()
     billetera1 = billetera_autenticar(1, '1235')
     self.assertEqual(billetera1, None)
Esempio n. 10
0
 def test_AutenticarPINinvalido(self):
     billetera = BilleteraElectronica(cedula='11',
                                      cedulaTipo='V',
                                      nombre='Mario',
                                      apellido='Jimenez',
                                      saldo=0.00,
                                      PIN='1234')
     billetera.save()
     billetera1 = billetera_autenticar(1, '1235')
     self.assertEqual(billetera1, None)
Esempio n. 11
0
 def test_AutenticarBilletera(self):
     billetera1 = BilleteraElectronica(cedula='10',
                                       cedulaTipo='V',
                                       nombre='Maria',
                                       apellido='Perez',
                                       saldo=0.00,
                                       PIN='1234')
     billetera1.save()
     billetera = billetera_autenticar(1, "1234")
     self.assertEqual(billetera1, billetera)
Esempio n. 12
0
 def test_AutenticarIDinvalido(self):
     billetera = BilleteraElectronica(cedula='10',
                                      cedulaTipo='V',
                                      nombre='Maria',
                                      apellido='Perez',
                                      saldo=0.00,
                                      PIN='1234')
     billetera.save()
     billetera1 = billetera_autenticar(2, '1234')
     self.assertNotEqual(billetera, billetera1)
Esempio n. 13
0
 def testConsultaSaldoNulo(self):
     billetera = BilleteraElectronica(
                     nombre = 'Alejandro',
                     apellido = 'Banega',
                     cedula = "12345678",
                     cedulaTipo = 'V',
                     PIN = "1234"
     )
     billetera.save()
     billeteraE = BilleteraElectronica.objects.get(pk = 1)
     self.assertEqual(billeteraE.saldo, 0)