def index(): """Serve list of people in hs, show panel for logged users""" recent = Device.get_recent(**settings.recent_time) visible_devices = filter_hidden(recent) users = filter_hidden(owners_from_devices(visible_devices)) return render_template("landing.html", users=filter_anon_names(users), headcount=len(users), unknowncount=len(unclaimed_devices(recent)), **common_vars_tpl)
def devices(): recent = Device.get_recent(**settings.recent_time) visible_devices = filter_hidden(recent) users = filter_hidden(owners_from_devices(visible_devices)) if current_user.is_authenticated: unclaimed = unclaimed_devices(recent) mine = current_user.devices return render_template("devices.html", unclaimed=unclaimed, recent=recent, my_devices=mine, users=filter_anon_names(users), headcount=len(users), **common_vars_tpl)
def now_at_space(): """ Send list of people currently in HS as JSON, only registred people, used by other services in HS, requests should be from hs3.pl domain or from HSWAN """ period = {**settings.recent_time} for key in ["days", "hours", "minutes"]: if key in request.args: period[key] = request.args.get(key, default=0, type=int) devices = filter_hidden(Device.get_recent(**period)) users = filter_hidden(owners_from_devices(devices)) data = { "users": sorted(map(str, filter_anon_names(users))), "headcount": len(users), "unknown_devices": len(unclaimed_devices(devices)), } app.logger.info("sending request for /api/now {}".format(data)) return jsonify(data)