def save_data(self, f): data = {} if f.is_valid(): f.save(commit=False) if int(f.data['tipo']) == 0: if verificar(f.data['num_doc']): prod = f.save() data['resp'] = True data['proveedor'] = prod.toJSON() else: f.add_error("num_doc", "Numero de Cedula no valido para Ecuador") data['error'] = f.errors else: if verificar(f.data['num_doc']): prod = f.save() data['resp'] = True data['proveedor'] = prod.toJSON() else: f.add_error("num_doc", "Numero de Ruc no valido para Ecuador") data['error'] = f.errors else: data['error'] = f.errors return data
def save_data(self, f, datos): data = {} if f.is_valid(): if verificar(f.data['cedula']): use = User() use.username = datos['cedula'] use.cedula = datos['cedula'] use.first_name = datos['first_name'] use.last_name = datos['last_name'] use.sexo = datos['sexo'] use.email = datos['email'] use.telefono = datos['telefono'] use.celular = datos['celular'] use.direccion = datos['direccion'] use.tipo = 0 use.password = make_password(datos['cedula']) use.save() data['resp'] = True data['cliente'] = use.toJSON() grupo = Group.objects.get(name__icontains='cliente') usersave = User.objects.get(id=use.id) usersave.groups.add(grupo) usersave.save() else: f.add_error("cedula", "Numero de Cedula no valido para Ecuador") data['error'] = f.errors else: data['error'] = f.errors return data
def save_data(self, f): data = {} if f.is_valid(): f.save(commit=False) if verificar(f.data['cedula']): cli = f.save() data['resp'] = True data['empleado'] = cli.toJSON() else: f.add_error("cedula", "Numero de Cedula no valido para Ecuador") data['error'] = f.errors else: data['error'] = f.errors return data
def save_data(self, f): data = {} if f.is_valid(): f.save(commit=False) if verificar(f.data['cedula']): cli = f.save() data['resp'] = True data['empleado'] = cli.toJSON() if cli.cargo == 0 or 1 or 2: us = User() us.cedula = cli.cedula us.username = cli.cedula us.set_password(cli.cedula) us.save() else: f.add_error("cedula", "Numero de Cedula no valido para Ecuador") data['error'] = f.errors else: data['error'] = f.errors return data