Xuất tài liệu theo mẫu tùy chỉnh
Trình hướng dẫn xuất tài liệu của Cổng thông tin Yêu cầu là công cụ lý tưởng để bạn nhanh chóng tạo ra các tệp Microsoft Word có thể chỉnh sửa *.docx trực tiếp từ các yêu cầu và hoạt động V&V của bạn. Bạn có thể sử dụng các mẫu có sẵn hoặc tải lên mẫu của riêng mình. Trình hướng dẫn này được hỗ trợ bởi thư viện Python-Docx-Template, vốn tận dụng công cụ tạo mẫu Jinja. Bộ đôi năng động này cho phép bạn tạo ra các mẫu tùy chỉnh
Thư viện Python-Docx-Template
Thư viện Python-Docx-Template là một công cụ mạnh mẽ giúp mở rộng chức năng của thư viện Python-Docx. Nó tích hợp công cụ tạo mẫu Jinja, cho phép tạo nội dung động trong các tệp Word của bạn. Điều này có nghĩa là bạn có thể sử dụng các biến, vòng lặp và điều kiện để điền dữ liệu vào tài liệu của mình ngay lập tức. Về cơ bản, nó giống như việc thêm một chút năng lượng cho tài liệu Word của bạn
Quản lý Mẫu Xuất
Các mẫu có sẵn cho phiên bản Cổng thông tin Yêu cầu của bạn được liệt kê trên trang Export templates trang » Settings » Export templates)
-
Theo mặc định, có sáu mẫu được cung cấp – ba mẫu dành cho xuất tài liệu yêu cầu và ba mẫu dành cho xuất tài liệu hoạt động V&V.
-
Để biết thêm thông tin về các mẫu xuất yêu cầu, hãy tham khảo trang Xuất tài liệu.
-
Để biết thêm thông tin về các mẫu xuất hoạt động V&V, hãy tham khảo trang Xuất tài liệu.
-
-
Để thêm một mẫu do người dùng định nghĩa mới, hãy nhấp vào nút “
” ở góc trên bên phải của trang. Trong Add template cửa sổ xuất hiện, chọn xem mẫu mới cần được áp dụng cho Requirements hay V&V Activities sử dụng Applicable objects menu thả xuống, sau đó sử dụng Select template khu vực để chọn tệp mẫu.
Nhấp vào nút "
" trong hộp thoại để thêm mẫu. Mẫu này sẽ được hiển thị trong danh sách trên Export templates trang và sau đó có thể được sử dụng khi xuất tài liệu.
-
Bạn có thể tải xuống tệp của bất kỳ mẫu nào. Để thực hiện việc này, hãy nhấp vào nút
trong Name cột của mẫu cần thiết và chọn lệnh Download lệnh. Tùy theo cài đặt trình duyệt cá nhân của bạn, trình duyệt sẽ tự động tải tệp xuống một vị trí đã định sẵn hoặc yêu cầu bạn chọn nơi lưu trữ trên ổ cứng.
-
Một mẫu do người dùng định nghĩa có thể được ghi đè bằng một tệp mẫu mới. Để thực hiện việc này, hãy nhấp vào nút
trong Name cột của mẫu cần thiết và chọn lệnh Overwrite Template lệnh từ menu xuất hiện. Sử dụng Overwrite template cửa sổ mở ra để xác định phạm vi áp dụng của mẫu và chọn tệp mới. Bật tùy chọn I confirm I want to overwrite tùy chọn và nhấp vào nút
để hoàn tất quá trình.
Phụ lục – Cấu trúc đối tượng dữ liệu của các mẫu xuất yêu cầu
Dưới đây là cấu trúc cơ bản của đối tượng mà các mẫu xuất yêu cầu của bạn sẽ lấy thông tin từ đó
Requirement Export Templates – Data Object Structure
{
"specifications": [
{
"id": "number",
"name": "string",
"description": "string",
"requirements": [
{
"id": "string",
"identifier": "string",
"text": "RichText",
"title": "string",
"rationale": "RichText",
"images": ["image"],
"type": "string",
"verification_methods": [{
"name": "string",
"text": "string",
"component_vms": [{
"name": "string",
"closeout_reference": "chuỗi"
}]
}],
"specification_id": "số",
"group_id": "số",
"applicability_conditions": ["chuỗi"],
"content_type": {
"id": "chuỗi",
"name": "chuỗi"
},
"state": "chuỗi",
"compliance": "chuỗi",
"compliance_comment": "chuỗi",
"tags": ["chuỗi"],
"parents": [{
"id": "chuỗi",
"identifier": "chuỗi",
"text": "RichText",
"title": "string"
}],
"children": [{
"id": "string",
"identifier": "string",
"text": "RichText",
"title": "string"
}],
"owner": {
"user": {
"username": "string",
"first_name": "string",
"last_name": "string",
"groups": ["string"]
},
"group": {
"name": "string",
"users": ["string"]
}
},
"files": [{
"name": "string",
"description": "string",
"version": "string",
"is_reference": "boolean",
"tags": ["string"]
}],
"custom_fields": [{
"field": "chuỗi",
"value": ["chuỗi"]
}],
"position": "number",
"verification_items_verified": "number",
"verification_items_total": "number",
"verification_items": [{
"status": "string",
"component": "string",
"tags": ["string"],
"activity": {
"name": "string",
"verification_methods": ["string"]
},
"last_item_run": {
"status": "string",
"comment": "string"
}
}],
"linked_components": [{
"id": "số",
"name": "chuỗi",
"description": "chuỗi",
"valis": [{
"id": "số",
"name": "chuỗi",
"value": "chuỗi",
"formula": "chuỗi"
}],
"textvalis": [{
"id": "số",
"name": "string",
"text": "string"
}],
"matrices": [{
"id": "number",
"name": "string",
"value": "string",
"formula": "string"
}],
"datevalis": [{
"id": "number",
"name": "string",
"date": "string"
}],
"creator": "chuỗi",
"attachments": [{
"name": "chuỗi",
"description": "chuỗi",
"version": "chuỗi",
"is_reference": "boolean",
"tags": ["chuỗi"]
}]
}]
}
],
"content_type": {
"id": "number",
"name": "string"
}
}
],
"requirements": [
{
"id": "string",
"identifier": "string",
"text": "RichText",
"title": "string",
"rationale": "RichText",
"images": ["image"],
"type": "string",
"verification_methods": [{
"name": "chuỗi",
"text": "chuỗi",
"component_vms": [{
"name": "chuỗi",
"closeout_reference": "chuỗi"
}]
}],
"specification_id": "số",
"group_id": "số",
"applicability_conditions": ["chuỗi"],
"content_type": {
"id": "string",
"name": "string"
},
"state": "string",
"compliance": "string",
"compliance_comment": "string",
"tags": ["chuỗi ký tự"],
"parents": [{
"id": "chuỗi ký tự",
"identifier": "chuỗi ký tự",
"text": "RichText",
"title": "chuỗi ký tự"
}],
"children": [{
"id": "chuỗi ký tự",
"identifier": "chuỗi ký tự",
"text": "RichText",
"title": "string"
}],
"owner": {
"user": {
"username": "string",
"first_name": "string",
"last_name": "string",
"groups": ["string"]
},
"group": {
"name": "string",
"users": ["string"]
}
},
"files": [{
"name": "string",
"description": "string",
"version": "string",
"is_reference": "boolean",
"tags": ["string"]
}],
"custom_fields": [{
"field": "string",
"value": ["string"]
}],
"position": "number",
"verification_items_verified": "number",
"verification_items_total": "number",
"verification_items": [{
"status": "string",
"component": "string",
"tags": ["string"],
"activity": {
"name": "string",
"verification_methods": ["string"]
},
"last_item_run": {
"status": "chuỗi",
"comment": "chuỗi"
}
}],
"linked_components": [{
"id": "số",
"name": "chuỗi",
"valis": [{
"id": "số",
"name": "chuỗi",
"value": "chuỗi",
"formula": "chuỗi"
}],
"textvalis": [{
"id": "số",
"name": "chuỗi",
"text": "chuỗi"
}],
"matrices": [{
"id": "số",
"name": "chuỗi",
"value": "chuỗi",
"formula": "chuỗi"
}],
"datevalis": [{
"id": "số",
"name": "chuỗi",
"date": "chuỗi"
}],
"creator": "chuỗi",
"attachments": [{
"name": "chuỗi",
"description": "chuỗi",
"version": "chuỗi",
"is_reference": "boolean",
"tags": ["chuỗi"]
}]
}]
}
],
"requirements_groups": [
{
"id": "number",
"name": "string",
"description": "string",
"specification_id": "number",
"requirements": [
{
"id": "string",
"identifier": "chuỗi",
"text": "RichText",
"title": "chuỗi",
"rationale": "RichText",
"images": ["hình ảnh"],
"type": "chuỗi",
"verification_methods": [{
"name": "chuỗi",
"text": "chuỗi",
"component_vms": [{
"name": "chuỗi",
"closeout_reference": "chuỗi"
}]
}],
"specification_id": "number",
"group_id": "number",
"applicability_conditions": ["string"],
"content_type": {
"id": "string",
"name": "chuỗi"
},
"state": "chuỗi",
"compliance": "chuỗi",
"compliance_comment": "chuỗi",
"tags": ["chuỗi"],
"parents": [{
"id": "chuỗi",
"identifier": "chuỗi",
"text": "RichText",
"title": "chuỗi"
}],
"children": [{
"id": "string",
"identifier": "chuỗi",
"text": "RichText",
"title": "chuỗi"
}],
"owner": {
"user": {
"username": "chuỗi",
"first_name": "chuỗi",
"last_name": "chuỗi",
"groups": ["chuỗi"]
},
"group": {
"name": "string",
"users": ["string"]
}
},
"files": [{
"name": "string",
"description": "string",
"version": "string",
"is_reference": "boolean",
"tags": ["string"]
}],
"custom_fields": [{
"field": "string",
"value": ["string"]
}],
"position": "number",
"verification_items_verified": "number",
"verification_items_total": "number",
"verification_items": [{
"status": "string",
"component": "string",
"tags": ["string"],
"activity": {
"name": "string",
"verification_methods": ["string"]
},
"last_item_run": {
"status": "string",
"comment": "string"
}
}],
"linked_components": [{
"id": "number",
"name": "string",
"valis": [{
"id": "number",
"name": "string",
"value": "string",
"formula": "string"
}],
"textvalis": [{
"id": "số",
"name": "chuỗi",
"text": "chuỗi"
}],
"matrices": [{
"id": "số",
"name": "chuỗi",
"value": "chuỗi",
"formula": "chuỗi"
}],
"datevalis": [{
"id": "number",
"name": "string",
"date": "string"
}],
"creator": "string",
"attachments": [{
"name": "string",
"description": "string",
"version": "chuỗi",
"is_reference": "boolean",
"tags": ["chuỗi"]
}]
}]
}
],
"content_type": {
"id": "số",
"name": "chuỗi"
}
}
],
"timestamp": "datetime",
"template_name": "string",
"verification_and_validation_methods": [{
"id": "number",
"name": "string",
"description": "string"
}]
}
Sắp xếp các trường
Bạn có thể sắp xếp các yêu cầu bằng cách sử dụng hàm Sort trên tài liệu mẫu Jinja. Ví dụ: bạn có thể thêm |sort(attribute='identifier') để sắp xếp các yêu cầu theo thứ tự chữ và số dựa trên cột định danh
Ví dụ
{% for requirement in requirements|selectattr("specification_id", "equalto", specification.id)|selectattr("group_id", "none") |sort(attribute='identifier') -%}
Cột tùy chỉnh
Với trình xuất tài liệu hiện tại, bạn có thể xuất các giá trị cột tùy chỉnh một cách dễ dàng. Đối với một cột tùy chỉnh dựa trên văn bản đơn giản, bạn có thể sử dụng cấu trúc chung sau
{% for custom_field in requirement.custom_fields|selectattr(“field”, “equalto”, “Name of Custom Column”) %}{{r custom_field.value }}{% endfor %}
Hãy nhớ thay thế Name of Custom Column bằng tên thực tế của cột được chỉ định trên tiêu đề cột
Nếu cột tùy chỉnh không phải là văn bản mà là tùy chọn chọn nhiều mục, người dùng có thể sử dụng mã sau và điều chỉnh cho phù hợp với trường hợp cụ thể của mình
{%- if requirement.custom_fields -%}
{%- set additional_info_values = [] -%}
{%- set category_values = [] -%}
{%- set additional_info_custom_fields = requirement.custom_fields | selectattr('field', 'equalto', 'Additional Information') -%}
{% for custom_field in additional_info_custom_fields -%}
{%- set additional_info_values = additional_info_values + custom_field.value -%}
{% endfor -%}
{%- set category_custom_fields = requirement.custom_fields | selectattr('field', 'equalto', 'Category') -%}
{% for custom_field in category_custom_fields -%}
{%- set category_values = category_values + custom_field.value -%}
{% endfor -%}
{%- set additional_info_string = additional_info_values | join(';') -%}
{%- set category_string = category_info_values | join(';') -%}
{%- endif -%}
Phụ lục – Cấu trúc đối tượng dữ liệu của các mẫu xuất hoạt động V&V
Dưới đây là cấu trúc cơ bản của đối tượng mà các mẫu xuất hoạt động V&V của bạn sẽ lấy thông tin từ đó
V&V Activity Export Templates – Data Object Structure
# CẤP ĐỘ CAO NHẤT
{
activities: [{}] # Danh sách tất cả các hoạt động
folders: [{
name: string
activities: [{}] # Danh sách các hoạt động
}]
timestamp: datetime
template_name: string
}
# Hoạt động
{
id: number
name: string
description: string
expected_results: string
tags: [string]
verification_methods: [{
name: string
description: string
}]
owner: User or Group
custom_fields: [] # Danh sách các trường tùy chỉnh
approvals: boolean
items: [{}] # Danh sách các mục VV
step_definitions: [{}] # Danh sách các định nghĩa bước
runs: [{}] # Danh sách các lần chạy hoạt động
}
# VVItem
{
id: số
requirement_identifier: chuỗi
component: { # Tương tự như các thành phần được liên kết trong tệp xuất tài liệu yêu cầu
id: số
name: chuỗi
valis: [{
id: số
name: chuỗi
value: chuỗi
formula: chuỗi
}]
textvalis: [{
id: số
name: chuỗi
text: string
}]
matrices: [{
id: number
name: string
value: string
formula: string
}]
datevalis: [{
id: number
name: string
date: string
}]
creator: string
attachments: [{
name: string
description: string
version: string
is_reference: boolean
tags: [chuỗi]
}]
}
compliance: chuỗi
compliance_comment: chuỗi
last_item_run: {} # VVItemRun
last_item_run_status: chuỗi
item_runs: [{}] # Danh sách các VVItemRuns
}
# StepDefinition
{
id: số nguyên
activity_id: int
step_number: int
position: float
full_step_number: str
full_step_path: str
parent_step_id: int
name: string
description: string
expected_results: string
tags: [string]
item_ids: [] # Danh sách các ID VVItems
}
# ActivityRun
{
id: int
name: string
description: string
timestamp: string
start_date: string # Định dạng sử dụng giống như trong tệp xuất tài liệu yêu cầu
finish_date: string
completion_state: int
completed_on: string
completed_by: User
activity_id: int
default_run: bool
position: float
steps_synced: bool
expected_results: string
evidence: string # Tên tệp/tài liệu
custom_fields: [] # Danh sách các trường tùy chỉnh
tags: [string]
run_executor: {} # Người dùng hoặc Nhóm
approver: {} # Người dùng hoặc Nhóm
approved: boolean
approved_by: User
approved_at: string
item_runs: [] # Danh sách các VVItemRuns
step_runs: [{}] # Danh sách các VVStepRuns
}
# VVItemRun
{
id: int
status: string
verified_by: User
activity_run_id: int
status: "status-display-name"
comment: chuỗi
serial_number: chuỗi
step_run_id: số nguyên # StepRun
verification_item:{} # VVItem
verification_item_requirement_identifier: chuỗi
verification_item_component_name: chuỗi
}
# StepRun
{
id: số nguyên
name: chuỗi
comment: chuỗi
status: chuỗi
description: chuỗi
activity_run_id: số nguyên
full_step_number: str
step_number: int
position: float
full_step_run_path: str
parent_step_run_id: int
expected_results: string
tags: [string]
item_run_ids: [] # Danh sách các ID VVItemRun
item_requirement_identifiers: str
}