fix: allow reactivating rejected disclosures in admin view

"Wieder aufleben" now also works for rejected disclosures, setting
status to approved with a new 24h window. Both buttons (reactivate
and delete) now appear for rejected and expired/revoked disclosures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
CCS Admin 2026-02-27 08:45:26 +00:00
parent 78ae11fb99
commit 28e4dc4333
2 changed files with 25 additions and 13 deletions

View file

@ -141,14 +141,15 @@ def revoke_disclosure(db: Session, request_id: int, user_id: int, *, admin: bool
def reactivate_disclosure(db: Session, request_id: int) -> DisclosureRequest: def reactivate_disclosure(db: Session, request_id: int) -> DisclosureRequest:
"""Reactivate an expired/revoked disclosure by granting a new 24h window.""" """Reactivate an expired, revoked, or rejected disclosure with a new 24h window."""
dr = db.query(DisclosureRequest).filter(DisclosureRequest.id == request_id).first() dr = db.query(DisclosureRequest).filter(DisclosureRequest.id == request_id).first()
if not dr: if not dr:
raise ValueError("Disclosure request not found") raise ValueError("Disclosure request not found")
if dr.status != "approved": if dr.status == "pending":
raise ValueError("Only approved disclosures can be reactivated") raise ValueError("Pending requests must be approved first")
if dr.expires_at and dr.expires_at > _utcnow_naive(): if dr.status == "approved" and dr.expires_at and dr.expires_at > _utcnow_naive():
raise ValueError("Disclosure is still active") raise ValueError("Disclosure is still active")
dr.status = "approved"
dr.expires_at = _utcnow_naive() + timedelta(hours=24) dr.expires_at = _utcnow_naive() + timedelta(hours=24)
db.commit() db.commit()
db.refresh(dr) db.refresh(dr)

View file

@ -160,15 +160,26 @@ export function DisclosuresPage() {
</> </>
)} )}
{dr.status === 'rejected' && ( {dr.status === 'rejected' && (
<Button <>
size="sm" <Button
variant="ghost" size="sm"
disabled={deleteMutation.isPending} variant="outline"
onClick={() => deleteMutation.mutate(dr.id)} disabled={reactivateMutation.isPending}
> onClick={() => reactivateMutation.mutate(dr.id)}
<Trash2 className="size-4 mr-1" /> >
Verwerfen <RotateCcw className="size-4 mr-1" />
</Button> Wieder aufleben
</Button>
<Button
size="sm"
variant="ghost"
disabled={deleteMutation.isPending}
onClick={() => deleteMutation.mutate(dr.id)}
>
<Trash2 className="size-4 mr-1" />
Verwerfen
</Button>
</>
)} )}
</div> </div>
</TableCell> </TableCell>