@@ -78,40 +78,22 @@ def post(self, request, id, format=None):
7878 boundary_set = boundary_set .prefetch_related ('submissions' )
7979 boundary = get_object_or_404 (boundary_set , pk = id )
8080
81- if boundary .status == BOUNDARY_STATUS .DRAFT :
82- if request .user .role not in [Roles .CONTRIBUTOR , Roles .ADMINISTRATOR ]:
83- raise ForbiddenException (
84- 'Only contributors and administrators can edit only drafts.'
85- )
86-
87- shape = BoundaryShapeView .get_valid_shape (request .data )
88-
89- boundary .latest_submission .shape = shape
90- boundary .latest_submission .save ()
91-
92- elif boundary .status == BOUNDARY_STATUS .IN_REVIEW :
93- if request .user .role not in [Roles .VALIDATOR , Roles .ADMINISTRATOR ]:
94- raise ForbiddenException (
95- 'Only validators and administrators can edit boundaries in review.'
96- )
97-
98- shape = BoundaryShapeView .get_valid_shape (request .data )
99-
100- boundary .latest_submission .review .shape = shape
101- boundary .latest_submission .review .save ()
81+ if request .user .role not in [Roles .CONTRIBUTOR , Roles .ADMINISTRATOR ]:
82+ raise ForbiddenException (
83+ 'Only contributors and administrators can edit boundaries.'
84+ )
10285
103- else :
104- return BadRequestException (
86+ if boundary . status != BOUNDARY_STATUS . DRAFT :
87+ raise BadRequestException (
10588 'Cannot update shape of boundary with status: {}' .format (
10689 boundary .status
10790 ),
10891 )
10992
110- return Response ()
111-
112- @staticmethod
113- def get_valid_shape (data ):
114- serializer = ShapeSerializer (data = data )
93+ serializer = ShapeSerializer (data = request .data )
11594 serializer .is_valid (raise_exception = True )
11695
117- return serializer .validated_data
96+ boundary .latest_submission .shape = serializer .validated_data
97+ boundary .latest_submission .save ()
98+
99+ return Response ()
0 commit comments