def recharge_doit(): user_id = request.form['user_user'] helper_id = request.form['helper_user'] amount = request.form['amount'] if not user_id or not helper_id or not amount: return 'Please enter valid data!' if amount == u"0": return "Invalid amount" if not uid_pattern.match(user_id): return "Invalid user id" if not uid_pattern.match(helper_id): return "Invalid helper id" users = Users.get_all(filters=['uidNumber=' + user_id]) helpers = Users.get_all(filters=['uidNumber=' + helper_id]) if not users: return "user %s not found" % user_id if not helpers: return "user %s not found" % helper_id user = users[0] helper = helpers[0] session = get_session() ev = RechargeEvent(user['id'], helper['id'], amount) session.add(ev) session.commit() return render_template('recharge_success.html', amount=amount, user=user)
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 __init__(self, screen, char, **kwargs): super(NamesScreen, self).__init__(screen) self.char = char self.objects.append( Button(self.screen, text="BACK", pos=(30, 30), click=self.back, font=monospace, size=30)) self.timeout = Progress( self.screen, pos=(200, 50), speed=1 / 15.0, on_elapsed=self.time_elapsed, ) self.objects.append(self.timeout) self.timeout.start() self.objects.append( Label( self.screen, text='Wer bist du?', pos=(20, 110), )) users = Users.get_all(self.char) btns_y = 7 num_cols = int(math.ceil(len(users) / float(btns_y))) for i, user in enumerate(users): padding = 20 xoff, yoff = 30, 190 btn_ypos = 90 i_y = i % btns_y i_x = i // btns_y x = i_x * (screen.get_width() / num_cols) y = i_y * btn_ypos self.objects.append( Button(self.screen, text=user["name"], pos=(xoff + x, y + yoff), click=self.switch_to_screen, click_param=user, padding=padding)) i += 1
def recharge_doit(): user_id = request.form['user_user'] helper_id = request.form['helper_user'] amount = request.form['amount'] if not user_id or not helper_id or not amount: return 'Please enter valid data!' if amount == u"0": return "Invalid amount" if not uid_pattern.match(user_id): return "Invalid user id" if not uid_pattern.match(helper_id): return "Invalid helper id" users = Users.get_all(filters=['uidNumber=' + user_id]) helpers = Users.get_all(filters=['uidNumber=' + helper_id]) if not users: return "user %s not found" % user_id if not helpers: return "user %s not found" % helper_id user = users[0] helper = helpers[0] session = get_session() ev = RechargeEvent( user['id'], helper['id'], amount ) session.add(ev) session.commit() return render_template('recharge_success.html', amount=amount, user=user)
def __init__(self, screen, **kwargs): super(MainScreen, self).__init__(screen) self.objects.append(Image(self.screen, pos=(30, 20))) self.objects.append( Label(self.screen, text=u'member auswählen', pos=(65, 250), size=50)) all_users = Users.get_all() i = 0 for c in range(97, 97 + 26): text = str(chr(c)) users = filter(lambda u: u["name"].lower().startswith(text), all_users) if len(users) == 0: continue self.objects.append( Button( self.screen, text=text, pos=self.__get_pos(i), click=self.switch_to_screen, click_param=text, force_width=440 / 6, force_height=440 / 6, )) i += 1 self.objects.append( Button( self.screen, text='Abbrechen', pos=(150, 700), size=30, click=self.home, )) self.timeout = Progress( self.screen, pos=(380, 715), speed=1 / 15.0, on_elapsed=self.time_elapsed, ) self.objects.append(self.timeout) self.timeout.start()
def main(): users = Users.get_all(include_temp=True) init_db() session = get_session() for user in users: ldapName = user["name"] ldapUser = LdapUser(ldapId=user["id"], name=ldapName, id_card=user["id_card"], path=user["path"], is_card=ldapName.startswith("geld")) session.add(ldapUser) session.commit()
def main(): users = list(Users.get_all(include_temp=True)) init_db() session = get_session() for user in users: ldap_name = user["name"] ldap_user = LdapUser( ldap_id=user["id"], name=ldap_name, id_card=user["id_card"], path=user["path"], is_card=ldap_name.startswith("geld") ) session.add(ldap_user) session.commit()
def main(): for user in Users.get_all(): user['meta']['last_emailed'] = 0 user['meta']['last_drink_notification'] = 0 Users.save(user)
def index(): users = sorted(Users.get_all(), key=lambda u: u['name'].lower()) users.insert(0, {}) print(users) return render_template('index.html', users=users)
def main(args): for user in Users.get_all(): user['meta']['last_emailed'] = 0 user['meta']['last_drink_notification'] = 0 Users.save(user)