mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 04:55:44 +00:00
Move Meta class to top of class definition (#4363)
This commit is contained in:
@ -562,6 +562,14 @@ class Owner(models.Model):
|
||||
owner: Returns the Group or User instance combining the owner_type and owner_id fields
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
"""Metaclass defines extra model properties"""
|
||||
# Ensure all owners are unique
|
||||
constraints = [
|
||||
UniqueConstraint(fields=['owner_type', 'owner_id'],
|
||||
name='unique_owner')
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def get_owners_matching_user(cls, user):
|
||||
"""Return all "owner" objects matching the provided user.
|
||||
@ -594,14 +602,6 @@ class Owner(models.Model):
|
||||
"""Returns the API endpoint URL associated with the Owner model"""
|
||||
return reverse('api-owner-list')
|
||||
|
||||
class Meta:
|
||||
"""Metaclass defines extra model properties"""
|
||||
# Ensure all owners are unique
|
||||
constraints = [
|
||||
UniqueConstraint(fields=['owner_type', 'owner_id'],
|
||||
name='unique_owner')
|
||||
]
|
||||
|
||||
owner_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, null=True, blank=True)
|
||||
|
||||
owner_id = models.PositiveIntegerField(null=True, blank=True)
|
||||
|
@ -12,10 +12,6 @@ from .models import Owner
|
||||
class OwnerSerializer(InvenTreeModelSerializer):
|
||||
"""Serializer for an "Owner" (either a "user" or a "group")"""
|
||||
|
||||
name = serializers.CharField(read_only=True)
|
||||
|
||||
label = serializers.CharField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
"""Metaclass defines serializer fields."""
|
||||
model = Owner
|
||||
@ -26,6 +22,10 @@ class OwnerSerializer(InvenTreeModelSerializer):
|
||||
'label',
|
||||
]
|
||||
|
||||
name = serializers.CharField(read_only=True)
|
||||
|
||||
label = serializers.CharField(read_only=True)
|
||||
|
||||
|
||||
class GroupSerializer(InvenTreeModelSerializer):
|
||||
"""Serializer for a 'Group'"""
|
||||
|
Reference in New Issue
Block a user