def post(self): id = self.get_argument("id-contacto", "") name = self.get_argument("name", "") address = self.get_argument("address", "") town = self.get_argument("town", "") city = self.get_argument("city", "") zip_code = self.get_argument("zip_code", "") telephone = self.get_argument("telephone", "") contacto = Contact() res_contact = contacto.InitById(id) if "success" in res_contact: datos = res_contact["success"] contacto.initialize(datos) contacto.name = name contacto.address = address contacto.town = town contacto.city = city contacto.zip_code = zip_code contacto.telephone = telephone ciudad = City() res_city = ciudad.getNameById(city) if "success" in res_city: contacto.Edit() self.write(json_util.dumps(res_city))
def get(self): contact_id = self.get_argument("id", "") if contact_id != "": contact = Contact() json_str_contactos = contact.InitById(contact_id) self.write(json_util.dumps(json_str_contactos))
def post(self): name = self.get_argument("name", "") lastname = self.get_argument("lastname", "") email = self.get_argument("email", "") rut = self.get_argument("rut", "") address = self.get_argument("address", "") town = self.get_argument("town", "") city = self.get_argument("city_id", "") zip_code = self.get_argument("zip_code", "") additional_info = self.get_argument("additional_info", "") telephone = self.get_argument("telephone", "") if self.current_user: user_id = self.current_user["id"] contacto = Contact() contacto.name = name contacto.lastname = lastname contacto.email = email contacto.rut = rut contacto.address = address contacto.town = town contacto.city = city contacto.zip_code = zip_code contacto.additional_info = additional_info contacto.telephone = telephone contacto.user_id = user_id response = contacto.Save() if "success" in response: id = response["success"] res_contact = contacto.InitById(id) if "success" in res_contact: datos = res_contact["success"] self.write( self.render_string("profile/nuevafila.html", id=id, contacto=datos))
def notifyEmails(lista, order, current_user): try: detalle_orden = ExitoHandler.getDetalleOrden(lista) contact = Contact() facturacion_response = contact.InitById(order.billing_id) if "success" in facturacion_response: facturacion = facturacion_response["success"] else: ExitoHandler.sendError("error al obtener facturacion") despacho_response = contact.InitById(order.shipping_id) if "success" in despacho_response: despacho = despacho_response["success"] else: ExitoHandler.sendError("error al obtener despacho_response") # self.render("beauty_error.html", message="Error al obtener datos de despacho, {}".format( # despacho_response["error"])) # return datos_facturacion = ExitoHandler.generateMail( "datos_facturacion.html", order_id=order.id, name=facturacion["name"], address=facturacion["address"], town="", city=facturacion["city"], country="", telephone=facturacion["telephone"], email=facturacion["email"]) datos_despacho = ExitoHandler.generateMail( "datos_despacho.html", order_id=order.id, name=despacho["name"], address=despacho["address"], town="", city=despacho["city"], country="", telephone=despacho["telephone"], email=despacho["email"]) html = ExitoHandler.generateMail( "mail_confirmacion_cliente.html", name=current_user["name"].encode("utf-8"), order_id=order.id, datos_facturacion=datos_facturacion, datos_despacho=datos_despacho, detalle_orden=detalle_orden, order_total=ExitoHandler.money_format(order.total), order_subtotal=ExitoHandler.money_format(order.subtotal), order_tax=ExitoHandler.money_format(order.tax), url_local=url_local, costo_despacho=ExitoHandler.money_format(order.shipping)) # email_confirmacion = "*****@*****.**" client_status = ExitoHandler.sendEmail(html, current_user["email"], order.id) html = ExitoHandler.generateMail( "mail_confirmacion_giani.html", name=current_user["name"].encode("utf-8"), order_id=order.id, datos_facturacion=datos_facturacion, datos_despacho=datos_despacho, detalle_orden=detalle_orden, order_total=ExitoHandler.money_format(order.total), order_subtotal=ExitoHandler.money_format(order.subtotal), order_tax=ExitoHandler.money_format(order.tax), url_local=url_local, costo_despacho=ExitoHandler.money_format(order.shipping)) giani_status = ExitoHandler.sendEmail(html, to_giani, order.id) return client_status, giani_status, "ambos emails enviados" except Exception, ex: ExitoHandler.sendError("error trying to send emails : {}".format( str(ex))) return 0, 0, "{}".format(ex)
def post(self): post_office_id = self.get_argument("post_office_id", "") shipping_type = self.get_argument("shipping_type", 1) cart_id = self.get_argument("cart_id", "") ciudad = None items = 0 c = Cart() c.user_id = self.current_user["id"] detail = c.GetCartByUserId() for d in detail: items += int(d["quantity"]) if cart_id != "": cart = Cart() res = cart.InitById(cart_id) if "success" in res: contact = Contact() res_contact = contact.InitById(cart.shipping_id) if "success" in res_contact: ciudad = res_contact["success"]["city_id"] c = Cellar() res_cellar_id = c.GetWebCellar() web_cellar_id = cellar_id if "success" in res_cellar_id: web_cellar_id = res_cellar_id["success"] res_web_cellar = c.InitById(web_cellar_id) if "success" in res_web_cellar: if int(shipping_type) == 1: cellar_city_id = c.city_id shipping = Shipping() shipping.from_city_id = int(cellar_city_id) shipping.to_city_id = int(ciudad) res = shipping.GetGianiPrice() else: shipping = Shipping() shipping.post_office_id = post_office_id res = shipping.GetPriceByPostOfficeId() if "error" in res: self.write( json_util.dumps({ "state": "error", "message": res["error"] })) else: if shipping.charge_type == 1: costo_despacho = shipping.price * items else: costo_despacho = shipping.price self.write( json_util.dumps({ "state": "ok", "shipping_cost": costo_despacho })) else: self.write( json_util.dumps({ "state": "error", "message": res_web_cellar["error"] }))