mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Closes #6850: Default to current user when creating journal entries via REST API
This commit is contained in:
parent
d2bdf4e822
commit
b806220074
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
### Enhancements
|
### Enhancements
|
||||||
|
|
||||||
|
* [#6850](https://github.com/netbox-community/netbox/issues/6850) - Default to current user when creating journal entries via REST API
|
||||||
* [#7462](https://github.com/netbox-community/netbox/issues/7462) - Include count of assigned virtual machines under platform view
|
* [#7462](https://github.com/netbox-community/netbox/issues/7462) - Include count of assigned virtual machines under platform view
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from drf_yasg.utils import swagger_serializer_method
|
from drf_yasg.utils import swagger_serializer_method
|
||||||
@ -30,6 +31,7 @@ __all__ = (
|
|||||||
'ExportTemplateSerializer',
|
'ExportTemplateSerializer',
|
||||||
'ImageAttachmentSerializer',
|
'ImageAttachmentSerializer',
|
||||||
'JobResultSerializer',
|
'JobResultSerializer',
|
||||||
|
'JournalEntrySerializer',
|
||||||
'ObjectChangeSerializer',
|
'ObjectChangeSerializer',
|
||||||
'ReportDetailSerializer',
|
'ReportDetailSerializer',
|
||||||
'ReportSerializer',
|
'ReportSerializer',
|
||||||
@ -192,6 +194,12 @@ class JournalEntrySerializer(ValidatedModelSerializer):
|
|||||||
queryset=ContentType.objects.all()
|
queryset=ContentType.objects.all()
|
||||||
)
|
)
|
||||||
assigned_object = serializers.SerializerMethodField(read_only=True)
|
assigned_object = serializers.SerializerMethodField(read_only=True)
|
||||||
|
created_by = serializers.PrimaryKeyRelatedField(
|
||||||
|
allow_null=True,
|
||||||
|
queryset=User.objects.all(),
|
||||||
|
required=False,
|
||||||
|
default=serializers.CurrentUserDefault()
|
||||||
|
)
|
||||||
kind = ChoiceField(
|
kind = ChoiceField(
|
||||||
choices=JournalEntryKindChoices,
|
choices=JournalEntryKindChoices,
|
||||||
required=False
|
required=False
|
||||||
|
Loading…
Reference in New Issue
Block a user