2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 11:40:58 +00:00

Move Meta class to top of class definition (#4363)

This commit is contained in:
Oliver
2023-02-18 18:51:00 +11:00
committed by GitHub
parent 139274f356
commit cc2e7ee8a5
27 changed files with 1085 additions and 1084 deletions

View File

@ -852,6 +852,12 @@ class InvenTreeSetting(BaseInvenTreeSetting):
even if that key does not exist.
"""
class Meta:
"""Meta options for InvenTreeSetting."""
verbose_name = "InvenTree Setting"
verbose_name_plural = "InvenTree Settings"
def save(self, *args, **kwargs):
"""When saving a global setting, check to see if it requires a server restart.
@ -1601,12 +1607,6 @@ class InvenTreeSetting(BaseInvenTreeSetting):
typ = 'inventree'
class Meta:
"""Meta options for InvenTreeSetting."""
verbose_name = "InvenTree Setting"
verbose_name_plural = "InvenTree Settings"
key = models.CharField(
max_length=50,
blank=False,
@ -1631,6 +1631,15 @@ class InvenTreeSetting(BaseInvenTreeSetting):
class InvenTreeUserSetting(BaseInvenTreeSetting):
"""An InvenTreeSetting object with a usercontext."""
class Meta:
"""Meta options for InvenTreeUserSetting."""
verbose_name = "InvenTree User Setting"
verbose_name_plural = "InvenTree User Settings"
constraints = [
models.UniqueConstraint(fields=['key', 'user'], name='unique key and user')
]
SETTINGS = {
'HOMEPAGE_PART_STARRED': {
'name': _('Show subscribed parts'),
@ -1947,15 +1956,6 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
typ = 'user'
class Meta:
"""Meta options for InvenTreeUserSetting."""
verbose_name = "InvenTree User Setting"
verbose_name_plural = "InvenTree User Settings"
constraints = [
models.UniqueConstraint(fields=['key', 'user'], name='unique key and user')
]
key = models.CharField(
max_length=50,
blank=False,

View File

@ -77,8 +77,6 @@ class GlobalSettingsSerializer(SettingsSerializer):
class UserSettingsSerializer(SettingsSerializer):
"""Serializer for the InvenTreeUserSetting model."""
user = serializers.PrimaryKeyRelatedField(read_only=True)
class Meta:
"""Meta options for UserSettingsSerializer."""
@ -97,6 +95,8 @@ class UserSettingsSerializer(SettingsSerializer):
'typ',
]
user = serializers.PrimaryKeyRelatedField(read_only=True)
class GenericReferencedSettingSerializer(SettingsSerializer):
"""Serializer for a GenericReferencedSetting model.
@ -140,6 +140,33 @@ class GenericReferencedSettingSerializer(SettingsSerializer):
class NotificationMessageSerializer(InvenTreeModelSerializer):
"""Serializer for the InvenTreeUserSetting model."""
class Meta:
"""Meta options for NotificationMessageSerializer."""
model = NotificationMessage
fields = [
'pk',
'target',
'source',
'user',
'category',
'name',
'message',
'creation',
'age',
'age_human',
'read',
]
read_only_fields = [
'category',
'name',
'message',
'creation',
'age',
'age_human',
]
target = serializers.SerializerMethodField(read_only=True)
source = serializers.SerializerMethodField(read_only=True)
user = serializers.PrimaryKeyRelatedField(read_only=True)
@ -170,39 +197,10 @@ class NotificationMessageSerializer(InvenTreeModelSerializer):
"""Function to resolve generic object reference to source."""
return get_objectreference(obj, 'source_content_type', 'source_object_id')
class Meta:
"""Meta options for NotificationMessageSerializer."""
model = NotificationMessage
fields = [
'pk',
'target',
'source',
'user',
'category',
'name',
'message',
'creation',
'age',
'age_human',
'read',
]
read_only_fields = [
'category',
'name',
'message',
'creation',
'age',
'age_human',
]
class NewsFeedEntrySerializer(InvenTreeModelSerializer):
"""Serializer for the NewsFeedEntry model."""
read = serializers.BooleanField()
class Meta:
"""Meta options for NewsFeedEntrySerializer."""
@ -218,6 +216,8 @@ class NewsFeedEntrySerializer(InvenTreeModelSerializer):
'read',
]
read = serializers.BooleanField()
class ConfigSerializer(serializers.Serializer):
"""Serializer for the InvenTree configuration.