def invoice_update_status(): if request.method == "POST": form = InvoicePaidForm(request.form) if form.validate(): invoice_number = form.data.get('order_number') invoice = json.loads( app.redis.get(KEYS['invoice'] % invoice_number)) old_status = invoice['status'] if old_status != 'paid': #send mail mail(u'Objednávka zaplacena - {0}'.format(invoice_number), '*****@*****.**', invoice['email'], 'data/paid-order.md', invoice, sender_name=u'Petr Joachim / Barcamp Brno') invoice['status'] = 'paid' app.redis.set(KEYS['invoice'] % invoice_number, json.dumps(invoice)) flash( u'Objednávka číslo {number} za {total_price} kč zaplacena'. format(**invoice), 'success') return redirect(url_for('invoices_admin')) flash() return redirect(url_for('invoices_admin'))
def add_content_line(content=None): if content: mail_content_line.append(content) else: content = ('\n'.join(mail_content_line)) self.logger.info(content) mail(content=content, title='VPS定时提醒', to_addrs=MAILLIST.get('recivers'))
def insert_invoice(invoice, user): app.redis.setnx(KEYS['invoice_number'], INVOICE_NUMBER_START) invoice_number = app.redis.incr(KEYS['invoice_number']) invoice['number'] = invoice_number invoice['user'] = user invoice['ip'] = request.remote_addr invoice['date'] = datetime.now().isoformat() invoice['user_agent'] = str(request.user_agent) invoice['status'] = 'new' app.redis.set(KEYS['invoice'] % invoice_number, json.dumps(invoice)) app.redis.sadd(KEYS['user_invoices'] % user['user_hash'], KEYS['invoice'] % invoice_number) app.redis.sadd(KEYS['year_invoices'], KEYS['invoice'] % invoice_number) # send inovice mail mail(u'Objednávka k potvrzení', '*****@*****.**', user['email'], 'data/new-order.md', invoice, sender_name=u'Petr Joachim / Barcamp Brno') return invoice
def insert_invoice(invoice, user): app.redis.setnx(KEYS['invoice_number'], INVOICE_NUMBER_START) invoice_number = app.redis.incr(KEYS['invoice_number']) invoice['number'] = invoice_number invoice['user'] = user invoice['ip'] = request.remote_addr invoice['date'] = datetime.now().isoformat() invoice['user_agent'] = str(request.user_agent) invoice['status'] = 'new' app.redis.set(KEYS['invoice'] % invoice_number, json.dumps(invoice)) app.redis.sadd(KEYS['user_invoices'] % user['user_hash'], KEYS['invoice'] % invoice_number) app.redis.sadd(KEYS['year_invoices'], KEYS['invoice'] % invoice_number) # send inovice mail mail( u'Objednávka k potvrzení', '*****@*****.**', user['email'], 'data/new-order.md', invoice, sender_name=u'Petr Joachim / Barcamp Brno' ) return invoice
def invoice_update_status(): if request.method == "POST": form = InvoicePaidForm(request.form) if form.validate(): invoice_number = form.data.get('order_number') invoice = json.loads(app.redis.get(KEYS['invoice'] % invoice_number)) old_status = invoice['status'] if old_status != 'paid': #send mail mail( u'Objednávka zaplacena - {0}'.format(invoice_number), '*****@*****.**', invoice['email'], 'data/paid-order.md', invoice, sender_name=u'Petr Joachim / Barcamp Brno' ) invoice['status'] = 'paid' app.redis.set(KEYS['invoice'] % invoice_number, json.dumps(invoice)) flash(u'Objednávka číslo {number} za {total_price} kč zaplacena'.format(**invoice), 'success') return redirect(url_for('invoices_admin')) flash() return redirect(url_for('invoices_admin'))
def submit( self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> List[EventType]: """Once we have an email, attempt to add it to the database""" email = tracker.get_slot("business_email") person_name = tracker.get_slot("person_name") message = tracker.get_slot("message") # envoi de l'email succes = mail(message, person_name, email) if succes is True: dispatcher.utter_message("Merci, votre message a bien été envoyé") print("message enregistré :", message) else: dispatcher.utter_message( "Oups, le message n'a pas pu être transmis : réessayez plus tard" ) return []
def main(argv=sys.argv): active = True try: while active: screen = curses.initscr() screen.border(0) screen.addstr(2, 2, " \u2022\u2022") screen.addstr(3, 2, " \u2022\u2022") screen.addstr( 4, 2, " \u2022\u2022\u2022\u2022\u2022\u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022\u2022", ) screen.addstr( 5, 2, " \u2022\u2022 \u2022\u2022 \ \u2022\u2022 \u2022\u2022 \u2022\u2022", ) screen.addstr( 6, 2, " \u2022\u2022 \u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022 \u2022\u2022 \u2022\u2022 \ - Once a day", ) screen.addstr( 7, 2, " \u2022\u2022 \u2022\u2022 \u2022\u2022 \ \u2022\u2022 \u2022\u2022 \u2022\u2022", ) screen.addstr( 8, 2, " \u2022\u2022\u2022\u2022\u2022\u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022\u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022\u2022", ) screen.addstr(11, 4, "1 - Mailsettings") screen.addstr(12, 4, "2 - Time Settings") screen.addstr(13, 4, "3 - Notifications") screen.addstr(14, 4, "4 - Exit") screen.refresh() choice = screen.getch() if choice == ord("4"): active = False curses.endwin() elif choice == ord("1"): # TODO: write function utils.mail() curses.endwin() elif choice == ord("2"): # TODO: write function utils.time() curses.endwin() elif choice == ord("3"): utils.notification() curses.endwin() except Exception as e: curses.endwin() windows = True if platform.system() == "Windows" else False clear = "cls" if windows else "clear" subprocess.run(clear) print("Once-a-day exited because of an Exception:\n {}".format(e))