mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-01 09:41:22 +00:00
Remove NotesFieldMixin
This commit is contained in:
@@ -20,7 +20,6 @@ from drf_spectacular.utils import extend_schema_field
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
from rest_framework.fields import empty
|
from rest_framework.fields import empty
|
||||||
from rest_framework.mixins import ListModelMixin
|
|
||||||
from rest_framework.permissions import SAFE_METHODS
|
from rest_framework.permissions import SAFE_METHODS
|
||||||
from rest_framework.serializers import DecimalField, Serializer
|
from rest_framework.serializers import DecimalField, Serializer
|
||||||
from rest_framework.utils import model_meta
|
from rest_framework.utils import model_meta
|
||||||
@@ -764,26 +763,6 @@ class InvenTreeDecimalField(serializers.FloatField):
|
|||||||
raise serializers.ValidationError(_('Invalid value'))
|
raise serializers.ValidationError(_('Invalid value'))
|
||||||
|
|
||||||
|
|
||||||
class NotesFieldMixin:
|
|
||||||
"""Serializer mixin for handling 'notes' fields.
|
|
||||||
|
|
||||||
The 'notes' field will be hidden in a LIST serializer,
|
|
||||||
but available in a DETAIL serializer.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
"""Remove 'notes' field from list views."""
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
if hasattr(self, 'context'):
|
|
||||||
if view := self.context.get('view', None):
|
|
||||||
if (
|
|
||||||
issubclass(view.__class__, ListModelMixin)
|
|
||||||
and not InvenTree.ready.isGeneratingSchema()
|
|
||||||
):
|
|
||||||
self.fields.pop('notes', None)
|
|
||||||
|
|
||||||
|
|
||||||
class ContentTypeField(serializers.ChoiceField):
|
class ContentTypeField(serializers.ChoiceField):
|
||||||
"""Serializer field which represents a ContentType as 'app_label.model_name'.
|
"""Serializer field which represents a ContentType as 'app_label.model_name'.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user