File tree Expand file tree Collapse file tree
opendrift_leeway_webgui/api/v1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,20 @@ class LeewaySimulationSerializer(serializers.ModelSerializer):
1313 #: Show username instead of id
1414 username = serializers .ReadOnlyField (source = "user.username" )
1515
16+ #: Expose the model's error property (last line of traceback)
17+ error = serializers .ReadOnlyField ()
18+
19+ #: True once simulation_finished is set
20+ completed = serializers .SerializerMethodField ()
21+
22+ def get_completed (self , obj ):
23+ """
24+ :param obj: The simulation instance
25+ :type obj: ~opendrift_leeway_webgui.leeway.models.LeewaySimulation
26+ :rtype: bool
27+ """
28+ return obj .simulation_finished is not None
29+
1630 class Meta :
1731 """
1832 Define model and the corresponding fields
@@ -33,6 +47,8 @@ class Meta:
3347 "traceback" ,
3448 "simulation_started" ,
3549 "simulation_finished" ,
50+ "error" ,
51+ "completed" ,
3652 ]
3753
3854 def create (self , validated_data ):
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ class LeewaySimulationViewSet(
2525 #: The serializer to use for simulations
2626 serializer_class = LeewaySimulationSerializer
2727
28+ #: Use UUID as the lookup field instead of the integer primary key
29+ lookup_field = "uuid"
30+
2831 def get_queryset (self ):
2932 """
3033 Only return the simulations of the current user
You can’t perform that action at this time.
0 commit comments