docs(development): add requirement that tenancy model needs kb article linking

ref: #331 #426 #427
This commit is contained in:
2024-12-21 17:38:09 +09:30
parent 11cb476055
commit 8457eb6bd9

View File

@ -54,6 +54,8 @@ All models must meet the following requirements:
- `clean()` method within a model is **only** used to ensure that the data entered into the DB is valid and/or to ensure application wide changes/validation is conducted prior to saving model. - `clean()` method within a model is **only** used to ensure that the data entered into the DB is valid and/or to ensure application wide changes/validation is conducted prior to saving model.
- Tenancy models must have the ability to have a [knowledge base article](#knowledge-base-article-linking) linked to it.
## Checklist ## Checklist
@ -148,6 +150,50 @@ The following Unit test cases exists for models:
If you add a feature you will have to write the test cases for that feature if they are not covered by existing test cases. If you add a feature you will have to write the test cases for that feature if they are not covered by existing test cases.
## Knowledge Base Article linking
All Tenancy Models must have the ability to be able to have a knowledge base article linked to it. To do so the following must be done:
- Add to the serializer as part of dictionary `_urls` key `knowledge_base` that resolves to the article url.
``` python
def get_url(self, obj) -> dict:
return {
'_self': ...,
'knowledge_base': reverse(
"v2:_api_v2_model_kb-list",
request=self._context['view'].request,
kwargs={
'model': self.Meta.model._meta.model_name,
'model_pk': item.pk
}
),
}
```
- Add to the models `page_layout` attirubute a tab called `Knowledge Base`
``` python
page_layout: dict = [
{
"name": "Knowledge Base",
"slug": "kb_articles",
"sections": [
{
"layout": "table",
"field": "knowledge_base",
}
]
},
]
```
## Docs to clean up ## Docs to clean up
!!! note !!! note