def show_places(): """ List of Places for menu(4) """ t0 = time.time() print(f"--- {request}") print(f"--- {user_session}") # Set context by owner and the data selections u_context = UserContext(user_session, current_user, request) # Which range of data is shown u_context.set_scope_from_request(request, 'place_scope') u_context.count = request.args.get('c', 50, type=int) dbdriver = Neo4jReadDriver(shareds.driver) reader = PlaceReader(dbdriver, u_context) # The list has Place objects, which include also the lists of # nearest upper and lower Places as place[i].upper[] and place[i].lower[] results = reader.get_list() elapsed = time.time() - t0 stk_logger( u_context, f"-> bp.scene.routes.show_places n={len(results['items'])} e={elapsed:.3f}" ) return render_template("/scene/places.html", places=results['items'], menuno=4, user_context=u_context, elapsed=elapsed)
def show_persons_all(): """ List all persons for menu(12). Both my own and other persons depending on sum of url attributes div + div2 or session variables. The position in persons list is defined by – 1. by attribute fw, if defined (the forward arrow or from seach field) 2. by session next_person[1], if defined (the page last visited) #TODO: next_person[0] is not in use, yet (backward arrow) 3. otherwise "" (beginning) """ print(f"--- {request}") print(f"--- {user_session}") # Set filter by owner and the data selections u_context = UserContext(user_session, current_user, request) # Which range of data is shown u_context.set_scope_from_request(request, 'person_scope') # How many objects are shown? u_context.count = int(request.args.get('c', 100)) u_context.privacy_limit = shareds.PRIVACY_LIMIT t0 = time.time() dbdriver = Neo4jReadDriver(shareds.driver) db = DBreader(dbdriver, u_context) results = db.get_person_list() elapsed = time.time() - t0 hidden = f" hide={results.num_hidden}" if results.num_hidden > 0 else "" stk_logger( u_context, f"-> bp.scene.routes.show_persons_all" f" n={len(results.items)}{hidden} e={elapsed:.3f}") # print(f"Got {len(results.items)} persons" # f" with {len(results.items)-results.num_hidden} hidden" # f" and {results.error} errors" # f" in {elapsed:.3f}s") return render_template("/scene/persons_list.html", persons=results.items, num_hidden=results.num_hidden, user_context=u_context, menuno=12, elapsed=elapsed)
def show_sources(series=None): """ Lähdeluettelon näyttäminen ruudulla for menu(5) Possible args example: ?years=1800-1899&series=birth - source years (#todo) - series, one of {"birth", "babtism", "wedding", "death", "move"} Missing series or years = all Theme may also be expressed in url path """ print(f"--- {request}") print(f"--- {user_session}") t0 = time.time() # Set context by owner and the data selections u_context = UserContext(user_session, current_user, request) # Which range of data is shown u_context.set_scope_from_request(request, 'source_scope') u_context.count = request.args.get('c', 100, type=int) dbdriver = Neo4jReadDriver(shareds.driver) reader = SourceReader(dbdriver, u_context) if series: u_context.series = series try: results = reader.get_source_list() if results['status'] == Status.NOT_FOUND: return redirect( url_for('virhesivu', code=1, text=f'Ei löytynyt yhtään')) if results['status'] != Status.OK: return redirect(url_for('virhesivu', code=1, text=f'Virhetilanne')) except KeyError as e: return redirect(url_for('virhesivu', code=1, text=str(e))) series = u_context.series if u_context.series else "all" stk_logger( u_context, f"-> bp.scene.routes.show_sources/{series} n={len(results['items'])}") return render_template("/scene/sources.html", sources=results['items'], user_context=u_context, elapsed=time.time() - t0)