Add equipment field to equipment instance log serializer to correctly identify equipment when viewing logs

This commit is contained in:
Keannu Bernasol 2023-11-12 22:08:34 +08:00
parent 53e4d8e02d
commit 1163d64c06

View file

@ -116,12 +116,14 @@ class EquipmentInstanceLogsSerializer(serializers.HyperlinkedModelSerializer):
history_date = serializers.DateTimeField(
format="%m-%d-%Y %I:%M%p", read_only=True)
history_user = serializers.SerializerMethodField()
equipment = serializers.PrimaryKeyRelatedField(
source='equipment.name', queryset=Equipment.objects.all())
class Meta:
model = EquipmentInstance.history.model
fields = ('history_id', 'status', 'remarks',
fields = ('history_id', 'id', 'equipment', 'status', 'remarks',
'history_date', 'history_user')
read_only_fields = ('history_id', 'id', 'status', 'remarks',
read_only_fields = ('history_id', 'id', 'equipment', 'status', 'remarks',
'history_date', 'history_user')
def get_history_user(self, obj):