class Migration(migrations.Migration): dependencies = [ ('kpi', '0023_partial_permissions'), ] operations = [ migrations.RunPython(forwards, noop), migrations.AlterField( model_name='asset', name='_deployment_data', field=JSONBField(default=dict), ), migrations.AlterField( model_name='asset', name='content', field=JSONBField(default=dict), ), migrations.AlterField( model_name='asset', name='summary', field=JSONBField(default=dict), ), migrations.AlterField( model_name='assetsnapshot', name='details', field=JSONBField(default=dict), ), migrations.AlterField( model_name='assetsnapshot', name='source', field=JSONBField(default=dict), ), migrations.AlterField( model_name='assetversion', name='_deployment_data', field=JSONBField(default=dict), ), migrations.AlterField( model_name='exporttask', name='data', field=JSONBField(), ), migrations.AlterField( model_name='exporttask', name='messages', field=JSONBField(default=dict), ), migrations.AlterField( model_name='importtask', name='data', field=JSONBField(), ), migrations.AlterField( model_name='importtask', name='messages', field=JSONBField(default=dict), ), ]
class Questionaire(models.Model): category = models.ForeignKey(Category, related_name='questionaire', on_delete=models.CASCADE, default=DEFAULT_CATEGORY_ID) # pages = ArrayField(models.CharField(max_length=10485758)) pages = JSONBField(default=list, null=True, blank=True) # VSCode will see the objects declared objects = models.Manager()
class Quotes(models.Model): name = models.CharField(max_length=50, unique=True) price = models.BigIntegerField() items = ArrayField(base_field=JSONBField(default=list, null=False, blank=True), null=False) deleted = models.BooleanField(default=False) def __str__(self): return self.name
class Answers(models.Model): school = models.ForeignKey(User, related_name='answers', on_delete=models.CASCADE) category = models.ForeignKey(Category, related_name='answers', on_delete=models.CASCADE, default=DEFAULT_CATEGORY_ID) answer = JSONBField(default=list, null=True, blank=True) def __str__(self): return self.answer # VSCode will see the objects declared objects = models.Manager()
class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) avatar = models.ImageField( upload_to='media/', default='/assets/img/common-images/avatars/avatars-03.svg') mobile = models.BigIntegerField(blank=True, null=True) gender = models.CharField(max_length=50, blank=True, null=True) address = models.CharField(max_length=100, blank=True, null=True) state = models.CharField(max_length=100, blank=True, null=True) city = models.CharField(max_length=100, blank=True, null=True) country = models.CharField(max_length=100, blank=True, null=True) pincode = models.CharField(max_length=20, blank=True, null=True) profession = models.TextField(blank=True, null=True) selfRefer = models.CharField(max_length=50, blank=True, null=True) otherRefer = models.CharField(max_length=50, blank=True, null=True) vetcoins = models.IntegerField(blank=True, null=True) vetcoinObj = JSONBField(null=True, blank=True) def __str__(self): return self.user.username
class LogMixin(models.Model): log = JSONBField(default=list, null=True, blank=True) def save(self, *args, **kwargs): """ Args: *args: **kwargs: Returns: runs Super Save Function """ # Getting Old Value of the current row With The primary key old = eval(self.__class__.__name__).objects.get(pk=self.pk) for key, value in old.__dict__.items(): # Validating The attributes whose values had changed if value not in self.__dict__.values( ) and key != '_state' and key != 'log': # Appending the changed field ,values ,datetime and user in json format into log ''' TO get the logged in username have created middleware Returning The user object and getting Username from the object ''' self.log.append({ 'field': key, 'from': value, 'to': self.__dict__.get(key), 'at': datetime.now().strftime("%m/%d/%Y, %H:%M:%S"), 'by': get_request().user.username }) print('mixin method') return super(LogMixin, self).save(*args, **kwargs)