mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: display stats about total & active TUs on proposals
This patch brings in two new features: - when viewing proposal listings, there is a new Statistics section, containing the total and active number of Trusted Users found in the database. - when viewing a proposal directly, the number of active trusted users assigned when the proposal was added is now displayed in the details section. Closes #323 Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
0afa07ed3b
commit
49c5a3facf
6 changed files with 107 additions and 0 deletions
|
@ -267,6 +267,48 @@ def test_tu_index(client, tu_user):
|
|||
assert int(vote_id.text.strip()) == vote_records[1].ID
|
||||
|
||||
|
||||
def test_tu_stats(client: TestClient, tu_user: User):
|
||||
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
|
||||
with client as request:
|
||||
response = request.get("/tu", cookies=cookies, allow_redirects=False)
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
|
||||
root = parse_root(response.text)
|
||||
stats = root.xpath('//table[@class="no-width"]')[0]
|
||||
rows = stats.xpath("./tbody/tr")
|
||||
|
||||
# We have one trusted user.
|
||||
total = rows[0]
|
||||
label, count = total.xpath("./td")
|
||||
assert int(count.text.strip()) == 1
|
||||
|
||||
# And we have one active TU.
|
||||
active = rows[1]
|
||||
label, count = active.xpath("./td")
|
||||
assert int(count.text.strip()) == 1
|
||||
|
||||
with db.begin():
|
||||
tu_user.InactivityTS = time.utcnow()
|
||||
|
||||
with client as request:
|
||||
response = request.get("/tu", cookies=cookies, allow_redirects=False)
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
|
||||
root = parse_root(response.text)
|
||||
stats = root.xpath('//table[@class="no-width"]')[0]
|
||||
rows = stats.xpath("./tbody/tr")
|
||||
|
||||
# We have one trusted user.
|
||||
total = rows[0]
|
||||
label, count = total.xpath("./td")
|
||||
assert int(count.text.strip()) == 1
|
||||
|
||||
# But we have no more active TUs.
|
||||
active = rows[1]
|
||||
label, count = active.xpath("./td")
|
||||
assert int(count.text.strip()) == 0
|
||||
|
||||
|
||||
def test_tu_index_table_paging(client, tu_user):
|
||||
ts = time.utcnow()
|
||||
|
||||
|
@ -515,6 +557,8 @@ def test_tu_proposal_unauthorized(client: TestClient, user: User,
|
|||
def test_tu_running_proposal(client: TestClient,
|
||||
proposal: Tuple[User, User, TUVoteInfo]):
|
||||
tu_user, user, voteinfo = proposal
|
||||
with db.begin():
|
||||
voteinfo.ActiveTUs = 1
|
||||
|
||||
# Initiate an authenticated GET request to /tu/{proposal_id}.
|
||||
proposal_id = voteinfo.ID
|
||||
|
@ -536,6 +580,11 @@ def test_tu_running_proposal(client: TestClient,
|
|||
'./div[contains(@class, "user")]/strong/a/text()')[0]
|
||||
assert username.strip() == user.Username
|
||||
|
||||
active = details.xpath('./div[contains(@class, "field")]')[1]
|
||||
content = active.text.strip()
|
||||
assert "Active Trusted Users assigned:" in content
|
||||
assert "1" in content
|
||||
|
||||
submitted = details.xpath(
|
||||
'./div[contains(@class, "submitted")]/text()')[0]
|
||||
assert re.match(r'^Submitted: \d{4}-\d{2}-\d{2} \d{2}:\d{2} \(.+\) by$',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue