mirror of
https://github.com/complexcaresolutions/dak.c2s.git
synced 2026-03-17 14:53:41 +00:00
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:
parent
78ae11fb99
commit
28e4dc4333
2 changed files with 25 additions and 13 deletions
|
|
@ -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:
|
||||
"""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()
|
||||
if not dr:
|
||||
raise ValueError("Disclosure request not found")
|
||||
if dr.status != "approved":
|
||||
raise ValueError("Only approved disclosures can be reactivated")
|
||||
if dr.expires_at and dr.expires_at > _utcnow_naive():
|
||||
if dr.status == "pending":
|
||||
raise ValueError("Pending requests must be approved first")
|
||||
if dr.status == "approved" and dr.expires_at and dr.expires_at > _utcnow_naive():
|
||||
raise ValueError("Disclosure is still active")
|
||||
dr.status = "approved"
|
||||
dr.expires_at = _utcnow_naive() + timedelta(hours=24)
|
||||
db.commit()
|
||||
db.refresh(dr)
|
||||
|
|
|
|||
|
|
@ -160,15 +160,26 @@ export function DisclosuresPage() {
|
|||
</>
|
||||
)}
|
||||
{dr.status === 'rejected' && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
disabled={deleteMutation.isPending}
|
||||
onClick={() => deleteMutation.mutate(dr.id)}
|
||||
>
|
||||
<Trash2 className="size-4 mr-1" />
|
||||
Verwerfen
|
||||
</Button>
|
||||
<>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={reactivateMutation.isPending}
|
||||
onClick={() => reactivateMutation.mutate(dr.id)}
|
||||
>
|
||||
<RotateCcw className="size-4 mr-1" />
|
||||
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>
|
||||
</TableCell>
|
||||
|
|
|
|||
Loading…
Reference in a new issue