-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
114 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
from ninja import Schema | ||
import os | ||
from ninja import ModelSchema | ||
from reporting.models.report_attachment import ReportAttachment | ||
|
||
|
||
class ReportAttachmentOut(Schema): | ||
class ReportAttachmentOut(ModelSchema): | ||
|
||
file_name: str | ||
|
||
@staticmethod | ||
def resolve_file_name(obj): | ||
return os.path.basename(obj.attachment.name) | ||
|
||
class Meta: | ||
model = ReportAttachment | ||
fields = ['id', 'attachment', 'attachment_type'] | ||
fields = ['id', 'attachment_type'] |
Binary file removed
BIN
-45.7 KB
bc_obps/test_media/report_attachments/2024/OBPS_application_architecture.pdf
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions
4
...s/reporting/src/app/bceidbusiness/industry_user/reports/[version_id]/attachments/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Attachments from "@reporting/src/app/components/attachments/Attachments"; | ||
import AttachmentsPage from "@reporting/src/app/components/attachments/AttachmentsPage"; | ||
import defaultPageFactory from "@reporting/src/app/utils/defaultPageFactory"; | ||
|
||
export default defaultPageFactory(Attachments); | ||
export default defaultPageFactory(AttachmentsPage); |
4 changes: 2 additions & 2 deletions
4
...rting/src/app/bceidbusiness/industry_user_admin/reports/[version_id]/attachments/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Attachments from "@reporting/src/app/components/attachments/Attachments"; | ||
import AttachmentsPage from "@reporting/src/app/components/attachments/AttachmentsPage"; | ||
import defaultPageFactory from "@reporting/src/app/utils/defaultPageFactory"; | ||
|
||
export default defaultPageFactory(Attachments); | ||
export default defaultPageFactory(AttachmentsPage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
bciers/apps/reporting/src/app/components/attachments/Attachments.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
bciers/apps/reporting/src/app/components/attachments/AttachmentsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { HasReportVersion } from "../../utils/defaultPageFactory"; | ||
import AttachmentsForm from "./AttachmentsForm"; | ||
import getAttachments from "@bciers/actions/api/getAttachments"; | ||
import { UploadedAttachment } from "./types"; | ||
|
||
const AttachmentsPage: React.FC<HasReportVersion> = async ({ version_id }) => { | ||
const uploaded_attachments: UploadedAttachment[] = | ||
await getAttachments(version_id); | ||
console.log("!~!!!!@@~~~~~~~~~~~~~~~~~~~~~~~~```", uploaded_attachments); | ||
const uploaded_attachments_dict = Object.fromEntries( | ||
uploaded_attachments.map((a) => [a.attachment_type, a]), | ||
); | ||
return ( | ||
<AttachmentsForm | ||
version_id={version_id} | ||
uploaded_attachments={uploaded_attachments_dict} | ||
/> | ||
); | ||
}; | ||
|
||
export default AttachmentsPage; |
5 changes: 5 additions & 0 deletions
5
bciers/apps/reporting/src/app/components/attachments/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface UploadedAttachment { | ||
id: number; | ||
file_name: string; | ||
attachment_type: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { actionHandler } from "@bciers/actions"; | ||
|
||
// 🛠️ Function to fetch a contact by id | ||
export default async function getAttachments(report_version_id: number) { | ||
const endpoint = `reporting/report-version/${report_version_id}/attachments`; | ||
return actionHandler(endpoint, "GET", ""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters