diff --git a/sage_desktop_api/models/fields.py b/sage_desktop_api/models/fields.py index f0b449ad..e6cfd7c6 100644 --- a/sage_desktop_api/models/fields.py +++ b/sage_desktop_api/models/fields.py @@ -1,5 +1,6 @@ from django.db import models + class StringNotNullField(models.CharField): description = "Custom String with Not Null" @@ -9,6 +10,7 @@ def __init__(self, *args, **kwargs): kwargs['help_text'] = kwargs.get('help_text', 'string field with null false') super(StringNotNullField, self).__init__(*args, **kwargs) + class StringNullField(models.CharField): description = "Custom String with Null" @@ -18,6 +20,7 @@ def __init__(self, *args, **kwargs): kwargs['help_text'] = kwargs.get('help_text', 'string field with null True') super(StringNullField, self).__init__(*args, **kwargs) + class IntegerNullField(models.IntegerField): description = "Custom Integer with Null" @@ -26,6 +29,7 @@ def __init__(self, *args, **kwargs): kwargs['help_text'] = kwargs.get('help_text', 'Integer field with null True') super(IntegerNullField, self).__init__(*args, **kwargs) + class IntegerNotNullField(models.IntegerField): description = "Custom Integer with Not Null" @@ -34,6 +38,7 @@ def __init__(self, *args, **kwargs): kwargs['help_text'] = kwargs.get('help_text', 'Integer field with null false') super(IntegerNotNullField, self).__init__(*args, **kwargs) + class CustomJsonField(models.JSONField): description = "Custom Json Field with Null" @@ -43,6 +48,7 @@ def __init__(self, *args, **kwargs): kwargs['help_text'] = kwargs.get('help_text', 'Json field with null true') super(CustomJsonField, self).__init__(*args, **kwargs) + class CustomDateTimeField(models.DateTimeField): description = "Custom DateTime Field with Auto-Add Now" @@ -50,6 +56,7 @@ def __init__(self, *args, **kwargs): kwargs['null'] = True # Allow the field to be nullable super(CustomDateTimeField, self).__init__(*args, **kwargs) + class TextNotNullField(models.TextField): description = "Custom Text Field with Not Null" @@ -58,6 +65,7 @@ def __init__(self, *args, **kwargs): kwargs['help_text'] = kwargs.get('help_text', 'text field with null false') super(TextNotNullField, self).__init__(*args, **kwargs) + class StringOptionsField(models.CharField): description = "Custom String Field with Options" @@ -69,6 +77,7 @@ def __init__(self, *args, **kwargs): kwargs['null'] = True # Allow the field to be nullable super(StringOptionsField, self).__init__(max_length=max_length, choices=choices, default=default, **kwargs) + class BooleanFalseField(models.BooleanField): description = "Custom Boolean Field with Default True" @@ -81,6 +90,7 @@ def toggle(self, instance): setattr(instance, self.attname, not value) instance.save() + class BooleanTrueField(models.BooleanField): description = "Custom Boolean Field with Default True"