@@ -78,40 +78,22 @@ def post(self, request, id, format=None):
78
78
boundary_set = boundary_set .prefetch_related ('submissions' )
79
79
boundary = get_object_or_404 (boundary_set , pk = id )
80
80
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
+ )
102
85
103
- else :
104
- return BadRequestException (
86
+ if boundary . status != BOUNDARY_STATUS . DRAFT :
87
+ raise BadRequestException (
105
88
'Cannot update shape of boundary with status: {}' .format (
106
89
boundary .status
107
90
),
108
91
)
109
92
110
- return Response ()
111
-
112
- @staticmethod
113
- def get_valid_shape (data ):
114
- serializer = ShapeSerializer (data = data )
93
+ serializer = ShapeSerializer (data = request .data )
115
94
serializer .is_valid (raise_exception = True )
116
95
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