feat(api): Add to common serializer meta notes model for notes url

ref: #779 #767
This commit is contained in:
2025-05-30 07:53:09 +09:30
parent 1d77247e40
commit a5227f0608

View File

@ -129,6 +129,7 @@ class CommonModelSerializer(CommonBaseSerializer):
if(
not str(item._meta.model_name).lower().endswith('notes')
and obj is not FeatureNotUsed
and not hasattr(self.Meta.model, '_notes_enabled')
):
app_namespace = ''
@ -155,4 +156,16 @@ class CommonModelSerializer(CommonBaseSerializer):
kwargs = item.get_url_kwargs_notes()
)
elif hasattr(self.Meta.model, '_notes_enabled'):
get_url['notes'] = reverse(
"v2:_api_centurionmodelnote_sub-list",
request = self._context['view'].request,
kwargs = {
'app_label': item._meta.app_label,
'model_name': item._meta.model_name,
'model_id': item.pk
}
)
return get_url