Show only type person in no keyfobs panel
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
This commit is contained in:
parent
e7a017e766
commit
fe301f9c9a
@ -23,6 +23,7 @@ class User:
|
||||
username: str = None
|
||||
display_name: str = None
|
||||
slack_id: str = None
|
||||
user_type: str = None
|
||||
groups: List[str] = field(default_factory=list)
|
||||
|
||||
def __getitem__(self, item):
|
||||
@ -37,10 +38,11 @@ def get_users_inner():
|
||||
username = item['metadata']['name']
|
||||
display_name = item.get("spec", {}).get("customProfile", {}).get("name", None)
|
||||
slack_id = item.get("status", {}).get("slackId", None)
|
||||
user_type = item.get("status", {}).get("type", None)
|
||||
groups = []
|
||||
for group in item.get("status", {}).get("groups", []):
|
||||
groups.append(f"{group['prefix']}:{group['name']}")
|
||||
yield User(username, display_name, slack_id, groups)
|
||||
yield User(username, display_name, slack_id, user_type, groups)
|
||||
|
||||
def get_users():
|
||||
users = list(get_users_inner())
|
||||
|
@ -248,6 +248,9 @@ def view_doorboy_admin():
|
||||
|
||||
orphaned_keyfobs = user_keyfobs.pop(None)
|
||||
no_keyfobs = [u for u in g.users if not user_keyfobs.get(u.username)]
|
||||
for u in no_keyfobs:
|
||||
if u.user_type != "person":
|
||||
del no_keyfobs[u.username]
|
||||
last_seen = {key : max(datetime_handle(card.get("last_seen")) for card in value) for key, value in user_keyfobs.items()}
|
||||
|
||||
orphaned_keyfobs = sorted(orphaned_keyfobs, key = lambda o : (not bool(o.get("comment")), o.get("comment", "")))
|
||||
|
Loading…
Reference in New Issue
Block a user