def send_summaries(): session = get_session() if config.FORCE_MAIL_TO: send_summary(session, Users.get_by_id(config.FORCE_MAIL_TO), "Getränkeübersicht", force=True) return for user in Users.get_all(): try: send_summary(session, user, "Getränkeübersicht") except Exception: logger.exception("While sending summary for %s", user) continue
def send_low_balances(with_summary=True): session = get_session() if config.FORCE_MAIL_TO: send_low_balance(session, Users.get_by_id(config.FORCE_MAIL_TO), with_summary, force=True) return for user in Users.get_all(): try: send_low_balance(session, user, with_summary) except Exception: logger.exception("while sending lowbalances:") continue
def send_summaries(): session = get_session() if config.FORCE_MAIL_TO: send_summary(session, Users.get_by_id(config.FORCE_MAIL_TO), "Getränkeübersicht", force=True) return for user in Users.get_all(): try: send_summary(session, user, "Getränkeübersicht") except Exception: logging.exception("While sending summary for %s", user) continue
def send_low_balances(with_summary=True): session = get_session() if config.FORCE_MAIL_TO: send_low_balance(session, Users.get_by_id(config.FORCE_MAIL_TO), with_summary, force=True) return for user in Users.get_all(): try: send_low_balance(session, user, with_summary) except Exception: logging.exception("while sending lowbalances:") continue
def render_aufladungen(self): aufladungen = Users.get_recharges(self.user['id'], limit=12) y = 210 prev_date = None for i, aufladung in enumerate(aufladungen): x = 30 if y + 45 * 2 >= self.btn_drinks.pos[1]: self.elements_aufladungen.append(Label(self.screen, text="...", pos=(x, y) )) break date = aufladung.timestamp.strftime("%a, %-d.%-m.%Y") time = aufladung.timestamp.strftime("%H:%M") text = time helper = aufladung.helper_user_id if helper: user = Users.get_by_id(aufladung.helper_user_id) if user: helper = user['name'] text += " mit " + helper if date != prev_date: prev_date = date self.elements_aufladungen.append(Label(self.screen, text=date, size=35, pos=(x, y + 15) )) y += 45 count_width = 120 margin_right = 10 self.elements_aufladungen.append(Label(self.screen, text=text, pos=(x + 10, y), size=45, max_width=480 - x - margin_right - count_width )) self.elements_aufladungen.append(Label( self.screen, text=str(aufladung.amount), align_right=True, pos=(480 - margin_right, y - 5), max_width=count_width )) y += 35
def format_recharges(recharges): """ :type recharges: list[RechargeEvent] """ recharges_fmt = "\nAufladungen:\n" \ " # datum mit aufgeladen\n" for i, event in enumerate(recharges): date = event.timestamp.strftime("%F %T Z") mit = event.helper_user_id try: mit = Users.get_by_id(mit)['name'] except Exception: pass amount = event.amount recharges_fmt += " % 3d % 15s %7s %10s\n" % (i, date, mit, amount) return recharges_fmt