Mẫu Tùy chỉnh Xuất Tài liệu
Trình hướng dẫn Export Tài liệu của Requirements & Systems Portal là công cụ lý tưởng để nhanh chó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 của bạn. Bạn có thể dùng các mẫu được định nghĩa sẵn hoặc tải lên các mẫu của riêng mình. Trình hướng dẫn này được vận hành bởi thư viện Python-Docx-Template, và thư viện này lại tận dụng Jinja Templating Engine. Bộ đôi linh hoạt 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ẽ mở rộng chức năng của thư viện Python-Docx. Thư viện này tích hợp Jinja Templating Engine, 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 biến, vòng lặp và câu lệnh điều kiện để điền dữ liệu vào tài liệu theo thời gian thực. Về cơ bản, nó 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 khả dụng cho phiên bản Requirements & Systems Portal của bạn được liệt kê trên trang Export templates » Settings » Export templates).
-
Theo mặc định, có sẵn sáu mẫu – 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 Document Export.
-
Để 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 Document Export.
-
-
Để 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 cửa sổ Add template xuất hiện, hãy 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, sau đó 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ẽ được hiển thị trong danh sách trên trang Export templates và sau đó có thể được dùng để xuất tài liệu.
-
Tệp của bất kỳ mẫu nào cũng có thể được tải xuống. Để thực hiện việc này, hãy nhấp vào nút
trong cột Name của mẫu mong muốn và chọn lệnh Download. 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 hỏi bạn nơi lưu tệp 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 cột Name của mẫu mong muốn 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 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
Đâ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": "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') trong đó các yêu cầu được sắp xếp theo thứ tự chữ và số trên 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 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. Với một 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 tổng quát 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ế phần văn bản Name of Custom Column bằng tên thực tế của cột như được hiển thị trên 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 đa lựa chọn, 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
Đâ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
# 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
}