Fix MinIO DPP upload linking to frontend
This commit is contained in:
@@ -1342,14 +1342,15 @@ async def upload_admin_test(
|
|||||||
|
|
||||||
test_obj = models.Test(
|
test_obj = models.Test(
|
||||||
title=title,
|
title=title,
|
||||||
type="Mock",
|
type="DPS",
|
||||||
exam_pattern=models.ExamEnum(exam_pattern),
|
exam_pattern=models.ExamEnum(exam_pattern),
|
||||||
sections={},
|
sections={},
|
||||||
total_time=time_limit,
|
total_time=time_limit,
|
||||||
difficulty="Medium",
|
difficulty="Medium",
|
||||||
scheduled_date=scheduled_date,
|
scheduled_date=scheduled_date,
|
||||||
is_active=False,
|
is_active=False,
|
||||||
created_by=admin_id
|
created_by=admin_id,
|
||||||
|
pdf_url=url
|
||||||
)
|
)
|
||||||
session.add(test_obj)
|
session.add(test_obj)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ class Test(SQLModel, table=True):
|
|||||||
end_date: Optional[datetime] = None
|
end_date: Optional[datetime] = None
|
||||||
is_active: bool = Field(default=True)
|
is_active: bool = Field(default=True)
|
||||||
created_by: UUID
|
created_by: UUID
|
||||||
|
pdf_url: Optional[str] = None
|
||||||
|
|
||||||
class Transaction(SQLModel, table=True):
|
class Transaction(SQLModel, table=True):
|
||||||
id: UUID = Field(default_factory=uuid4, primary_key=True)
|
id: UUID = Field(default_factory=uuid4, primary_key=True)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { fetchWithAuth } from "@/lib/apiClient";
|
import { fetchWithAuth } from "@/lib/apiClient";
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
@@ -197,8 +197,12 @@ export default function AIDailyPracticePage() {
|
|||||||
<div className="flex flex-col sm:flex-row gap-2 shrink-0 md:self-center">
|
<div className="flex flex-col sm:flex-row gap-2 shrink-0 md:self-center">
|
||||||
{isUpcoming ? (
|
{isUpcoming ? (
|
||||||
<Button disabled variant="outline" size="sm" className="font-bold">Starts Soon</Button>
|
<Button disabled variant="outline" size="sm" className="font-bold">Starts Soon</Button>
|
||||||
) : isExpired && !isAttempted ? (
|
) : isExpired && !isAttempted && !dpp.pdf_url ? (
|
||||||
<Button disabled variant="outline" size="sm" className="font-bold bg-secondary/50">Expired</Button>
|
<Button disabled variant="outline" size="sm" className="font-bold bg-secondary/50">Expired</Button>
|
||||||
|
) : dpp.pdf_url ? (
|
||||||
|
<Button onClick={() => setSelectedPdfDpp(dpp)} variant="secondary" size="sm" className="rounded-xl bg-[var(--cyan-ai)] text-black hover:bg-[var(--cyan-ai-80)] font-extrabold gap-2 text-xs shadow-[0_0_12px_rgba(12,96,96,0.2)]">
|
||||||
|
<FileText size={14} className="text-black" /> View PDF
|
||||||
|
</Button>
|
||||||
) : isAttempted ? (
|
) : isAttempted ? (
|
||||||
<>
|
<>
|
||||||
<Link href={`/cbt/${dpp.id}/result`}>
|
<Link href={`/cbt/${dpp.id}/result`}>
|
||||||
@@ -298,7 +302,7 @@ export default function AIDailyPracticePage() {
|
|||||||
style={{minHeight: isFullScreen ? 'calc(100vh - 120px)' : '75vh'}}
|
style={{minHeight: isFullScreen ? 'calc(100vh - 120px)' : '75vh'}}
|
||||||
>
|
>
|
||||||
<embed
|
<embed
|
||||||
src={getPdfUrl(selectedPdfDpp.title)}
|
src={selectedPdfDpp.pdf_url || getPdfUrl(selectedPdfDpp.title)}
|
||||||
type="application/pdf"
|
type="application/pdf"
|
||||||
className="w-full h-full"
|
className="w-full h-full"
|
||||||
style={{height: isFullScreen ? 'calc(100vh - 120px)' : '75vh'}}
|
style={{height: isFullScreen ? 'calc(100vh - 120px)' : '75vh'}}
|
||||||
|
|||||||
Reference in New Issue
Block a user