main was 16 days and 259 commits behind the line the product is actually built on, at contract 0.30.0 against 0.35.0, with no per-PC credential code at all. It was neither current nor curated - just stale. This brings it forward and, at the same time, makes it mean something: main is what a receiving site installs, and nothing else. WHAT IT CARRIES. Twelve plugins - backups, computers, endpoints, guides, knowledgebase, machines, network, notifications, printers, slides, tools, warranty - plus applications, which is manifest-less core and always ships. The only manifest dependency inside that set is endpoints on computers, and both are in it, so the closure is self-contained. WHAT IT DOES NOT. employees, geenforce, measuringtools, printedparts and usb stay on the site line. So do the Windows installer tree, the VM rehearsal helpers, the agent tooling config, one site's data loader, the internal audit and findings records, and the planner spreadsheet. 1,135 tracked files against 1,438. A REMOVAL THAT BREAKS THE APP IS NOT A REMOVAL, and two nearly shipped: deploy/site-profile-universal.json still named all seventeen plugins. It is the file docs/DEPLOY.md tells a site to provision from, so a fresh install would have failed at `flask plugin apply-profile` with PluginError - the first thing a receiving site does, broken by the branch meant to serve them. It now names the twelve that exist, and its comment says the two must agree. agent/ was never refreshed. Whoever populated this branch copied shopdb/, plugins/, frontend/ and tests/ from the site line and left the agent tree at its September state: 22 C# and PowerShell sources missing, including AgentCredentials, EnrollmentService, AgentHttpFactory and the fleet-alert client, plus one file the site line had deleted still present. The old tree is internally consistent, so it compiles, and nothing in CI builds it - every gate was green over a server that speaks enrollment and per-PC credentials to a bundled agent source that cannot. Resynced whole. DECISIONS THIS ENCODES, rather than defers: - The plugin-authoring lab builds printedparts, whose manifest depends on employees, so it could not stay. The lab remains on the site line and main ships no build-along tutorial. That is a real loss for an adopting developer and is recorded here rather than discovered later. - Recognition, Training and Recertification notifications are no longer seeded. Each splits one notification into a card per employee and renders a photo, which needs a plugin this branch does not bundle. Seeding them would offer an author a type that cannot resolve anybody. A site that installs employees gets them from that plugin's own seed. - Windows/IIS is documented as the legacy path throughout, and the README leads with Docker, because that is what a receiving site gets. The API description is regenerated for THIS branch - 347 paths and 483 operations, down from 415 and 573 - so the published contract describes what is here rather than what the site line serves. docs/CONFIG.md lost the two measuring-tool label keys the code no longer declares, which two lanes had decided opposite ways. Suite: 3124 passed, 6 skipped. Naming and style gates pass. The docs gates run rather than skip, and every index line count is derived from the file it names.
71 lines
2.7 KiB
Python
71 lines
2.7 KiB
Python
"""What a scanned badge looks like, in one place.
|
|
|
|
Two callers read the same physical badges and disagreed about them. One
|
|
understood both shapes a scanner emits; the other took the string raw and
|
|
compared it to an SSO, so the wrapped form was simply "not recognized". The
|
|
same operator, with the same badge, was recognised at one screen and not at the
|
|
next. Anything that turns a scan into a person uses this module, so there is
|
|
one answer to the question.
|
|
|
|
The shapes:
|
|
|
|
270015376 the SSO as printed, what a keypad entry looks like
|
|
0270015376BZ the PayNo wrapper some scanners emit around it
|
|
|
|
Both mean the same person. Nothing else is a badge - and in particular a string
|
|
of NON-ASCII digits is not, however much it looks like one: Arabic-Indic digits
|
|
pass Python's str.isdigit(), and a badge written in them was accepted, stored as
|
|
the employee's SSO, and joined to nothing afterwards.
|
|
|
|
This lives in core rather than in a plugin because a plugin may not import
|
|
another plugin, and because a badge is a property of the site. Its consumer
|
|
today is the notifications plugin, which resolves an employee by SSO.
|
|
"""
|
|
|
|
import re
|
|
|
|
# The PayNo wrapper: a leading zero, the digits, and a BZ suffix.
|
|
PAYNO_BADGE = re.compile(r'^0(\d+)BZ$', re.IGNORECASE)
|
|
|
|
# ASCII digits only. str.isdigit() is true for Arabic-Indic and other decimal
|
|
# forms, and int() happily parses them, so a badge in those characters resolved
|
|
# to a real employee and was then written back in a form nothing else matches.
|
|
ASCII_DIGITS = re.compile(r'^[0-9]+$')
|
|
|
|
|
|
class BadgeShapeError(ValueError):
|
|
"""The scanned string is not a badge this site recognises."""
|
|
|
|
|
|
def normalise_badge(raw):
|
|
"""Return the plain SSO digits for a scanned badge.
|
|
|
|
Accepts the bare number and the PayNo wrapper, and raises BadgeShapeError
|
|
for anything else. The caller decides what to do about a badge that is
|
|
well-formed but matches no employee - that is a directory question, not a
|
|
shape one.
|
|
"""
|
|
badge = (raw or '').strip()
|
|
if not badge:
|
|
raise BadgeShapeError('Scan or enter a badge')
|
|
if ASCII_DIGITS.match(badge):
|
|
return badge
|
|
match = PAYNO_BADGE.match(badge)
|
|
if match and ASCII_DIGITS.match(match.group(1)):
|
|
return match.group(1)
|
|
raise BadgeShapeError('Unrecognized badge format')
|
|
|
|
|
|
def badge_kind(raw):
|
|
"""'sso' or 'payno' for a recognised badge; raises for anything else.
|
|
|
|
The external HR lookup searches a different column for each, so the shape
|
|
survives normalisation for that one caller.
|
|
"""
|
|
badge = (raw or '').strip()
|
|
if ASCII_DIGITS.match(badge):
|
|
return 'sso'
|
|
if PAYNO_BADGE.match(badge):
|
|
return 'payno'
|
|
raise BadgeShapeError('Unrecognized badge format')
|