def post(self, request, *args, **kwargs): project = self.get_object() label_config = self.request.data.get('label_config') if not label_config: raise RestValidationError('Label config is not set or is empty') # check new config includes meaningful changes has_changed = config_essential_data_has_changed(label_config, project.label_config) project.validate_config(label_config) return Response({'config_essential_data_has_changed': has_changed}, status=status.HTTP_200_OK)
def patch(self, request, *args, **kwargs): project = self.get_object() label_config = self.request.data.get('label_config') # config changes can break view, so we need to reset them if label_config: try: has_changes = config_essential_data_has_changed(label_config, project.label_config) except KeyError: pass else: if has_changes: View.objects.filter(project=project).all().delete() return super(ProjectAPI, self).patch(request, *args, **kwargs)