def post(self, venue_id): venue = Venue.get_by_id(int(venue_id)) if not venue: self.abort(404) venue.title = self.request.get('title') venue.description = self.request.get('description') venue.called_phone = self.request.get('called_phone') if self.request.get('image_file') or self.request.get('image_url'): if self.request.get('image_file'): new_url = get_new_image_url( 'Venue', venue.key.id(), image_data=str(self.request.get('image_file'))) elif self.request.get('image_url') and self.request.get( 'image_url') != venue.pic: new_url = get_new_image_url('Venue', venue.key.id(), url=self.request.get('image_url')) else: new_url = None if new_url: venue.pic = new_url venue.phones = self.request.get('phones').split(',') venue.emails = self.request.get('emails').split(',') venue.legal = LegalInfo.get_by_id(int(self.request.get('legal'))).key venue.problem = self.request.get('problem').strip() venue.put() legals = LegalInfo.query().fetch() self.render('/venues/edit_venue.html', venue=venue, success=True, legals=legals)
def get(self): legals = LegalInfo.query().fetch() alfa_production = 'test' not in config.ALFA_BASE_URL self.render('/alfa.html', legals=legals, production=alfa_production, bind_login=config.ALFA_LOGIN, bind_password=config.ALFA_PASSWORD)
def get(self): namespace = namespace_manager.get_namespace() host = u'http://%s.%s.%s.appspot.com' % (namespace, CURRENT_VERSION, CURRENT_APP_ID) values = { 'licence_url': u'%s/docs/licence_agreement.html' % host, 'payment_rules_url': u'%s/docs/payment_rules.html' % host, 'paypal_privacy_policy_url': u'%s/docs/paypal_privacy_policy.html' % host, 'paypal_user_agreement_url': u'%s/docs/paypal_user_agreement.html' % host, } self.render('/docs/legal_list.html', legals=LegalInfo.query().fetch(), **values)
def post(self): cfg = Config.get() cfg.ALFA_BASE_URL = 'https://engine.paymentgate.ru/payment' if self.request.get('alfa') == 'production' \ else 'https://test.paymentgate.ru/testpayment' cfg.ALFA_LOGIN = self.request.get('bind_login') cfg.ALFA_PASSWORD = self.request.get('bind_password') cfg.put() legals = LegalInfo.query().fetch() for legal in legals: legal.alfa_login = self.request.get('login_%s' % legal.key.id()) legal.alfa_password = self.request.get('password_%s' % legal.key.id()) legal.put() self.redirect('/company/main')
def get(self): result = [] for namespace in metadata.get_namespaces(): namespace_manager.set_namespace(namespace) for legal in LegalInfo.query().fetch(): result.append({ 'id': [namespace, legal.key.id()], 'app_name': config.APP_NAME or "", 'name': legal.person_ooo or legal.person_ip, 'production': config.COMPANY_STATUS == COMPANY_IN_PRODUCTION, }) self.render_json({"legals": result})
def cancel(self, namespace): from methods.alfa_bank import reverse if self.status == self.READY: legal = LegalInfo.query().get( ) # TODO find solution for multiple legals reverse(legal.alfa_login, legal.alfa_password, self.payment_id) share = Share.get_by_id(self.share_id) share.deactivate() promo_code = self.promo_code.get() promo_code.deactivate() self.status = self.CANCELED self.put() sender = Client.get(self.client_id) text = u'Ваш подарок не был получен. Ссылка более не будет активна, а деньги вернутся в ближайшее время.' header = u'Отмена подарка' SimplePush(text, False, text, header, sender, namespace).send()
def post(self): client_id = self.request.get("client_id") or int( self.request.headers.get('Client-Id', 0)) binding_id = self.request.get("binding_id") amount = self.request.get_range("amount") legal = LegalInfo.query().get( ) # TODO find solution for multiple legals order_number = "dp_%s_%s" % (client_id, int(time.time())) success, result = alfa_bank.create_simple(legal.alfa_login, legal.alfa_password, amount, order_number, "_", client_id) if not success: self.response.set_status(400) self.render_json({"description": u"Ошибка перевода с карты"}) return alfa_order_id = result success, error = alfa_bank.hold_and_check(legal.alfa_login, legal.alfa_password, alfa_order_id, binding_id) if not success: self.response.set_status(400) self.render_json({"description": u"Ошибка перевода с карты"}) return wallet_source = "alfa:%s" % alfa_order_id try: wallet_result = empatika_wallet.deposit(client_id, amount * 100, wallet_source) except empatika_wallet.EmpatikaWalletError as e: alfa_bank.reverse(legal.alfa_login, legal.alfa_password, alfa_order_id) self.response.set_status(400) self.render_json({"description": e.message}) else: alfa_bank.deposit(legal.alfa_login, legal.alfa_password, alfa_order_id, 0) self.render_json({"balance": wallet_result["balance"] / 100.0})
def get(self): lat = self.request.get('lat') lon = self.request.get('lon') address = geocoder.get_houses_by_coordinates(lat, lon) address_str = '' if len(address): if address[0].get('address'): address = address[0].get('address') address_str = u'г. %s, ул. %s, д. %s' % (address.get('city'), address.get('street'), address.get('home')) if not address_str: self.redirect('/company/venues/map') else: legals = LegalInfo.query().fetch() self.render( '/venues/edit_venue.html', **{ 'DEFAULT_EMAIL': '*****@*****.**', 'legals': legals, 'lat': lat, 'lon': lon, 'address': address_str })
def get(self): for legal in LegalInfo.query(LegalInfo.status == STATUS_AVAILABLE).fetch(): self.render_doc('auto_paypal_user_agreement.html', **_get_values(legal))
def get(self): for legal in LegalInfo.query(LegalInfo.status == STATUS_AVAILABLE).fetch(): self.render_doc('auto_paypal_privacy_policy.html', **_get_values(legal))
def get(self): try: self.render_doc('%s/payment_rules.html' % namespace_manager.get_namespace()) except TemplateNotFound: for legal in LegalInfo.query(LegalInfo.status == STATUS_AVAILABLE).fetch(): self.render_doc('auto_payment_rules.html', **_get_values(legal))
def get(self, venue_id): venue = Venue.get_by_id(int(venue_id)) if not venue: self.abort(404) legals = LegalInfo.query().fetch() self.render('/venues/edit_venue.html', venue=venue, legals=legals)
def _send(namespace): namespace_manager.set_namespace(namespace) if config.REPORT_WEEKLY and datetime.datetime.now().isoweekday() != 1: return company_emails = config.REPORT_EMAILS.split( ",") if config.REPORT_EMAILS else () today = datetime.datetime.combine(datetime.date.today(), datetime.time()) if config.REPORT_WEEKLY: start = today - datetime.timedelta(days=7) else: start = today - datetime.timedelta(days=1) end = today - datetime.timedelta(microseconds=1) all_reports = [] legals = LegalInfo.query().fetch() for legal in legals: legal_emails = legal.report_emails.split( ",") if legal.report_emails else () if not legal_emails and not company_emails: continue venue_ids = legal.get_venue_ids() if not venue_ids: continue report_data = orders.get(None, start, end, venue_ids=legal.get_venue_ids()) excel_file = excel.send_excel_file(None, 'orders', 'orders.html', **report_data) io = StringIO() excel_file.save(io) legal_name = legal.person_ooo or legal.person_ip filename = u"report-%s-%s-%s.xls" % (namespace, latinize(legal_name), start.strftime("%d-%m-%Y")) filename = filename.encode('utf-8') attachment = mail.Attachment(filename, io.getvalue()) all_reports.append(attachment) if legal_emails: subject = u"Приложение %s - отчет для %s" % (config.APP_NAME, legal_name) body = u"Отчет за период: %s - %s" % (start.strftime("%d.%m.%Y"), end.strftime("%d.%m.%Y")) mail.send_mail(_EMAIL_SENDER, legal_emails, subject, body, attachments=[attachment]) if company_emails and all_reports: subject = u"Приложение %s - отчет" % config.APP_NAME body = u"Отчет за период: %s - %s" % (start.strftime("%d.%m.%Y"), end.strftime("%d.%m.%Y")) mail.send_mail(_EMAIL_SENDER, company_emails, subject, body, attachments=all_reports)
def post(self): client_id = self.request.get_range('client_id') or int(self.request.headers.get('Client-Id') or 0) client = Client.get(client_id) if not client: self.abort(400) sender_phone = get_phone(self.request.get('sender_phone')) sender_email = self.request.get('sender_email') items_json = json.loads(self.request.get('items')) items = set_modifiers(items_json) items = set_price_with_modifiers(items) share_items = [] for item in items: share_item = SharedGiftMenuItem.get_by_id(item.key.id()) if share_item.status == STATUS_UNAVAILABLE: return self.send_error(u'Продукт %s недоступен' % item.title) chosen_shared_item = ChosenSharedGiftMenuItem(shared_item=share_item.key) chosen_shared_item.group_choice_ids = [modifier.choice.choice_id for modifier in item.chosen_group_modifiers] chosen_shared_item.single_modifiers = [modifier.key for modifier in item.chosen_single_modifiers] chosen_shared_item.put() share_items.append(chosen_shared_item) total_sum = 0.0 for item in items: total_sum += item.total_price request_total_sum = float(self.request.get('total_sum')) if round(total_sum) != round(request_total_sum): return self.send_error(u'Сумма была пересчитана') recipient_phone = "".join(c for c in self.request.get('recipient_phone') if '0' <= c <= '9') recipient_name = self.request.get('recipient_name') payment_type_id = self.request.get_range('payment_type_id') payment_type = PaymentType.get_by_id(str(payment_type_id)) if payment_type.status == STATUS_AVAILABLE: if payment_type_id == CARD_PAYMENT_TYPE: alpha_client_id = self.request.get('alpha_client_id') binding_id = self.request.get('binding_id') return_url = self.request.get('return_url') order_id = "gift_%s_%s" % (client_id, int(time.time())) legal = LegalInfo.query().get() # TODO find solution for multiple legals success, result = alfa_bank.create_simple(legal.alfa_login, legal.alfa_password, int(total_sum * 100), order_id, return_url, alpha_client_id) if success: success, error = alfa_bank.hold_and_check(legal.alfa_login, legal.alfa_password, result, binding_id) else: error = result if not success: self.send_error(error) else: group_promo_codes = PromoCodeGroup() group_promo_codes.put() promo_code = PromoCode.create(group_promo_codes, KIND_SHARE_GIFT, 1) promo_code.put() group_promo_codes.promo_codes = [promo_code.key] group_promo_codes.put() share_item_keys = [item.key for item in share_items] gift = SharedGift(client_id=client_id, total_sum=total_sum, order_id=order_id, payment_type_id=payment_type_id, payment_id=result, share_items=share_item_keys, recipient_name=recipient_name, recipient_phone=recipient_phone, promo_code=promo_code.key) self.success(client, gift, promo_code, sender_phone, sender_email, recipient_name, recipient_phone) else: self.send_error(u'Возможна оплата только картой') else: self.send_error(u'Данный вид оплаты недоступен')