Mẫu tùy chỉnh để xuất tài liệu
Trình hướng dẫn Xuất tài liệu của Requirements Portal giúp bạn dễ dàng tạo các tệp Microsoft Word *.docx có thể chỉnh sửa trực tiếp từ các yêu cầu và hoạt động V&V. 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 sử dụng thư viện Python-Docx-Template, vốn được xây dựng dựa trên bộ máy tạo mẫu Jinja. Sự kết hợp này cho phép bạn tạo 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. Thư viện tích hợp bộ máy tạo mẫu Jinja, cho phép tạo nội dung động trong các tệp Word. Nhờ đó, bạn có thể sử dụng biến, vòng lặp và câu lệnh điều kiện để tự động điền dữ liệu vào tài liệu. Về cơ bản, điều này giống như tiếp thêm 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 trong phiên bản Requirements Portal của bạn được liệt kê trên trang Settings – Export templates (truy cập bằng cách nhấp vào biểu tượng
ở góc trên bên phải, chọn Settings từ menu xuất hiện, rồi chọn Export templates từ danh sách trong ngăn bên trái).
-
Theo mặc định, có sáu mẫu được cung cấp – ba mẫu để xuất tài liệu yêu cầu và ba mẫu để 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ẫu mới do người dùng định nghĩa, nhấp vào nút
ở góc trên bên trái của trang. Trong cửa sổ Add template xuất hiện, chọn xem mẫu mới cần được áp dụng cho Requirements hay V&V Activities bằng danh sách thả xuống Applicable objects, rồi sử dụng vùng Select template để chọn tệp mẫu.
Nhấp vào nút
trong hộp thoại để thêm mẫu. Mẫu sẽ xuất hiện trong danh sách trên trang Export templates và sau đó có thể được sử dụng để 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, nhấp vào nút
trong cột Name của mẫu cần tải và chọn lệnh Download. Tùy theo cài đặt trình duyệt của bạn, trình duyệt sẽ tự động tải tệp xuống một vị trí được xác định trước hoặc hỏi bạn muốn lưu tệp ở đâu trên ổ cứng.
-
Bạn có thể ghi đè một mẫu do người dùng định nghĩa bằng tệp mẫu mới. Để thực hiện, nhấp vào nút
trong cột Name của mẫu cần thay thế và chọn lệnh Overwrite Template từ menu xuất hiện. Sử dụng cửa sổ Overwrite template 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 rồi nhấp vào nút
để hoàn tất.
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 sẽ sử dụng để lấy thông tin.
Mẫu xuất yêu cầu – Cấu trúc đối tượng dữ liệu
{
"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": "string"
}]
}],
"specification_id": "number",
"group_id": "number",
"applicability_conditions": ["string"],
"content_type": {
"id": "string",
"name": "string"
},
"state": "string",
"compliance": "string",
"compliance_comment": "string",
"tags": ["string"],
"parents": [{
"id": "string",
"identifier": "string",
"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": "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",
"description": "string",
"valis": [{
"id": "number",
"name": "string",
"value": "string",
"formula": "string"
}],
"textvalis": [{
"id": "number",
"name": "string",
"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": ["string"]
}]
}]
}
],
"content_type": {
"id": "number",
"name": "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": "string"
}]
}],
"specification_id": "number",
"group_id": "number",
"applicability_conditions": ["string"],
"content_type": {
"id": "string",
"name": "string"
},
"state": "string",
"compliance": "string",
"compliance_comment": "string",
"tags": ["string"],
"parents": [{
"id": "string",
"identifier": "string",
"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": "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": "number",
"name": "string",
"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": ["string"]
}]
}]
}
],
"requirements_groups": [
{
"id": "number",
"name": "string",
"description": "string",
"specification_id": "number",
"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": "string"
}]
}],
"specification_id": "number",
"group_id": "number",
"applicability_conditions": ["string"],
"content_type": {
"id": "string",
"name": "string"
},
"state": "string",
"compliance": "string",
"compliance_comment": "string",
"tags": ["string"],
"parents": [{
"id": "string",
"identifier": "string",
"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": "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": "number",
"name": "string",
"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": ["string"]
}]
}]
}
],
"content_type": {
"id": "number",
"name": "string"
}
}
],
"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 hàm Sort trong tài liệu mẫu Jinja. Ví dụ, bạn có thể thêm |sort(attribute='identifier') để các yêu cầu được sắp xếp theo thứ tự chữ và số trong cột mã đị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 công cụ xuất tài liệu hiện tại, bạn có thể dễ dàng xuất các giá trị của cột tùy chỉnh. Đối với cột tùy chỉnh dạng 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ế văn bản Name of Custom Column bằng tên thực tế của cột được hiển thị trong tiêu đề cột.
Nếu cột tùy chỉnh không phải dạng văn bản mà là tùy chọn cho phép chọn nhiều giá trị, người dùng có thể sử dụng đoạn mã sau và điều chỉnh cho phù hợp với trường hợp sử dụng 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 sẽ sử dụng để lấy thông tin.
Mẫu xuất hoạt động V&V – Cấu trúc đối tượng dữ liệu
# TOP LEVEL
{
activities: [{}] # List of all Activities
folders: [{
name: string
activities: [{}] # List of Activities
}]
timestamp: datetime
template_name: string
}
# Activity
{
id: number
name: string
description: string
expected_results: string
tags: [string]
verification_methods: [{
name: string
description: string
}]
owner: User or Group
custom_fields: [] # List of CustomFields
approvals: boolean
items: [{}] # List of VVItems
step_definitions: [{}] # List of StepDefinitions
runs: [{}] # List of ActivityRuns
}
# VVItem
{
id: number
requirement_identifier: string
component: { # Same as linked components in the reqs doc export
id: number
name: string
valis: [{
id: number
name: string
value: string
formula: string
}]
textvalis: [{
id: number
name: string
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: [string]
}]
}
compliance: string
compliance_comment: string
last_item_run: {} # VVItemRun
last_item_run_status: str
item_runs: [{}] # List of VVItemRuns
}
# StepDefinition
{
id: int
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: [] # List of VVItems ids
}
# ActivityRun
{
id: int
name: string
description: string
timestamp: string
start_date: string # Format use same as in reqs doc export
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 # File/Doc name
custom_fields: [] # List of CustomFields
tags: [string]
run_executor: {} # User or Group
approver: {} # User or Group
approved: boolean
approved_by: User
approved_at: string
item_runs: [] # List of VVItemRuns
step_runs: [{}] # List of VVStepRuns
}
# VVItemRun
{
id: int
status: string
verified_by: User
activity_run_id: int
status: "status-display-name"
comment: string
serial_number: string
step_run_id: int # StepRun
verification_item:{} # VVItem
verification_item_requirement_identifier: string
verification_item_component_name: string
}
# StepRun
{
id: int
name: string
comment: string
status: string
description: string
activity_run_id: int
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: [] # List of VVItemRun ids
item_requirement_identifiers: str
}

