fix: The interface for obtaining model metadata cannot access public models (#2787)
This commit is contained in:
parent
add1cba8cb
commit
9d6451b95b
@ -313,6 +313,7 @@ class ModelSerializer(serializers.Serializer):
|
|||||||
return ModelSerializer.model_to_dict(model)
|
return ModelSerializer.model_to_dict(model)
|
||||||
|
|
||||||
def one_meta(self, with_valid=False):
|
def one_meta(self, with_valid=False):
|
||||||
|
model = None
|
||||||
if with_valid:
|
if with_valid:
|
||||||
super().is_valid(raise_exception=True)
|
super().is_valid(raise_exception=True)
|
||||||
model = QuerySet(Model).filter(id=self.data.get("id")).first()
|
model = QuerySet(Model).filter(id=self.data.get("id")).first()
|
||||||
@ -320,6 +321,7 @@ class ModelSerializer(serializers.Serializer):
|
|||||||
raise AppApiException(500, _('Model does not exist'))
|
raise AppApiException(500, _('Model does not exist'))
|
||||||
if model.permission_type == 'PRIVATE' and str(model.user_id) != str(self.data.get("user_id")):
|
if model.permission_type == 'PRIVATE' and str(model.user_id) != str(self.data.get("user_id")):
|
||||||
raise Exception(_('No permission to use this model') + f"{model.name}")
|
raise Exception(_('No permission to use this model') + f"{model.name}")
|
||||||
|
if model is None:
|
||||||
model = QuerySet(Model).get(id=self.data.get('id'))
|
model = QuerySet(Model).get(id=self.data.get('id'))
|
||||||
return {'id': str(model.id), 'provider': model.provider, 'name': model.name, 'model_type': model.model_type,
|
return {'id': str(model.id), 'provider': model.provider, 'name': model.name, 'model_type': model.model_type,
|
||||||
'model_name': model.model_name,
|
'model_name': model.model_name,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user