group_promote_admin. Admin-only route handler. This docstring was expanded to make future maintenance easier. Args: gid: Parameter. Returns: Varies.
(gid: int)
| 14558 | """ |
| 14559 | u = c["username"].lower() |
| 14560 | n = str(c["nickname"]).lower() |
| 14561 | # smaller is better |
| 14562 | s1 = _user_match_score(q, c["username"]) |
| 14563 | s2 = 0 if ql in u else 3 |
| 14564 | s3 = 1 if ql in n else 4 |
| 14565 | return (s1, s2, s3, len(u), u) |
| 14566 | cards.sort(key=score) |
| 14567 | cards = [c for c in cards if (ql in c["username"].lower() or ql in str(c["nickname"]).lower())][:12] |
| 14568 | else: |
| 14569 | cards = cards[:12] |
| 14570 | |
| 14571 | try: |
| 14572 | story_users = _story_active_usernames() |
| 14573 | except Exception: |
| 14574 | story_users = set() |
| 14575 | for c in cards: |
| 14576 | try: |
| 14577 | c["has_story"] = (c.get("username") in story_users) |
| 14578 | except Exception: |
| 14579 | c["has_story"] = False |
| 14580 | |
| 14581 | return jsonify({"users": cards}) |
| 14582 | |
| 14583 | @app.route("/api/ping", methods=["POST"]) |
| 14584 | @login_required |
| 14585 | def api_ping(): |
| 14586 | """api_ping. |
| 14587 | |
| 14588 | Route handler or application helper. |
| 14589 |
nothing calls this directly
no test coverage detected