Add status_text to API

This commit is contained in:
Oliver Walters 2019-04-17 23:33:19 +10:00
parent 963883acd6
commit ebcbf9a90e
3 changed files with 6 additions and 1 deletions

View File

@ -9,6 +9,7 @@ from .models import Build
class BuildSerializer(serializers.ModelSerializer):
url = serializers.CharField(source='get_absolute_url', read_only=True)
status_text = serializers.CharField(source='get_status_display', read_only=True)
class Meta:
model = Build
@ -20,4 +21,6 @@ class BuildSerializer(serializers.ModelSerializer):
'completion_date',
'part',
'quantity',
'status',
'status_text',
'notes']

View File

@ -365,7 +365,7 @@ function loadStockTable(modal, options) {
sortable: true,
formatter: function(value, row, index, field) {
var text = renderLink(value, row.url);
text = text + "<span class='badge'>" + row.status + "</span>";
text = text + "<span class='badge'>" + row.status_text + "</span>";
return text;
}
},

View File

@ -63,6 +63,7 @@ class StockItemSerializer(serializers.ModelSerializer):
part = PartBriefSerializer(many=False, read_only=True)
location = LocationBriefSerializer(many=False, read_only=True)
status_text = serializers.CharField(source='get_status_display', read_only=True)
class Meta:
model = StockItem
@ -78,6 +79,7 @@ class StockItemSerializer(serializers.ModelSerializer):
'serial',
'batch',
'status',
'status_text',
'notes',
]