Coverage for django_napse/core/models/modifications/modification.py: 94%
16 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
1from django.db import models
3from django_napse.utils.constants import MODIFICATION_STATUS
4from django_napse.utils.findable_class import FindableClass
5from django_napse.utils.usefull_functions import process_value_from_type
8class Modification(models.Model, FindableClass):
9 order = models.ForeignKey("Order", on_delete=models.CASCADE, related_name="modifications")
11 status = models.CharField(default=MODIFICATION_STATUS.PENDING, max_length=15)
12 created_at = models.DateTimeField(auto_now_add=True)
13 ignore_failed_order = models.BooleanField(default=False)
15 key = models.CharField(max_length=100)
16 value = models.CharField(max_length=100)
17 target_type = models.CharField(max_length=100)
19 def __str__(self) -> str:
20 return f"MODIFICATION: {self.pk=}"
22 def get_value(self, **kwargs):
23 return process_value_from_type(self.value, self.target_type, **kwargs)