Skip to content

Commit

Permalink
fix tsts
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 committed Oct 23, 2023
1 parent 17fdaed commit 3c39af4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sage_desktop_api/models/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models


class StringNotNullField(models.CharField):
description = "Custom String with Not Null"

Expand All @@ -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"

Expand All @@ -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"

Expand All @@ -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"

Expand All @@ -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"

Expand All @@ -43,13 +48,15 @@ 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"

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"

Expand All @@ -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"

Expand All @@ -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"

Expand All @@ -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"

Expand Down

0 comments on commit 3c39af4

Please sign in to comment.