generated from coulomb/repo-seed
Scope as first class root charactaristic
This commit is contained in:
@@ -647,6 +647,23 @@ def edit_repository_from_form(
|
||||
return RedirectResponse(f"/ui/repos/{repository_id}", status_code=303)
|
||||
|
||||
|
||||
@router.post("/ui/repos/{repository_id}/scope/edit")
|
||||
def edit_scope_from_form(
|
||||
repository_id: int,
|
||||
name: str = Form(...),
|
||||
description: str = Form(""),
|
||||
confidence: float = Form(1.0),
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> RedirectResponse:
|
||||
service.update_scope(
|
||||
repository_id,
|
||||
name=name,
|
||||
description=description,
|
||||
confidence=confidence,
|
||||
)
|
||||
return RedirectResponse(f"/ui/repos/{repository_id}", status_code=303)
|
||||
|
||||
|
||||
@router.post("/ui/repos/{repository_id}/delete")
|
||||
def delete_repository_from_form(
|
||||
repository_id: int,
|
||||
@@ -2697,11 +2714,9 @@ def render_candidate_merge_form(
|
||||
|
||||
def render_ability_map(ability_map: dict, repository_id: int) -> str:
|
||||
abilities = ability_map.get("abilities", [])
|
||||
if not abilities:
|
||||
return '<p class="muted">No approved entries yet.</p>'
|
||||
repository = ability_map["repository"]
|
||||
scope_description = repository.get("description") or (
|
||||
f"Scope root for the approved characteristics of {repository['name']}."
|
||||
scope = ability_map["scope"]
|
||||
scope_description = scope.get("description") or (
|
||||
f"Scope root for the approved characteristics of {scope['name']}."
|
||||
)
|
||||
items = []
|
||||
for ability in abilities:
|
||||
@@ -2745,17 +2760,32 @@ def render_ability_map(ability_map: dict, repository_id: int) -> str:
|
||||
return f"""
|
||||
<div class="tree">
|
||||
<ul>
|
||||
<li id="scope-{repository['id']}">
|
||||
<strong>{escape(repository['name'])}</strong>
|
||||
<li id="scope-{scope['id']}">
|
||||
<strong>{escape(scope['name'])}</strong>
|
||||
<span class="pill">scope</span>
|
||||
<span class="pill">{scope['confidence']:.2f} {escape(scope['confidence_label'])}</span>
|
||||
<p class="muted">{escape(scope_description)}</p>
|
||||
<ul>{"".join(items)}</ul>
|
||||
{render_approved_scope_form(scope, repository_id)}
|
||||
<ul>{"".join(items) or '<li class="muted">No approved characteristics yet.</li>'}</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
"""
|
||||
|
||||
|
||||
def render_approved_scope_form(scope: dict, repository_id: int) -> str:
|
||||
return f"""
|
||||
<form class="stack" method="post" action="/ui/repos/{repository_id}/scope/edit">
|
||||
<label>Name <input name="name" value="{escape(scope['name'])}" required></label>
|
||||
<label>Description <textarea name="description" rows="2">{escape(scope['description'])}</textarea></label>
|
||||
<label>Confidence <input name="confidence" type="number" min="0" max="1" step="0.01" value="{scope['confidence']:.2f}" required></label>
|
||||
<div class="actions">
|
||||
<button class="secondary" type="submit">Save Scope</button>
|
||||
</div>
|
||||
</form>
|
||||
"""
|
||||
|
||||
|
||||
def render_approved_ability_forms(ability: dict, repository_id: int) -> str:
|
||||
return f"""
|
||||
<form class="stack" method="post" action="/ui/repos/{repository_id}/abilities/{ability['id']}/edit">
|
||||
|
||||
Reference in New Issue
Block a user