Skip to content

models

django_spire.notification.sms.models

SmsTemporaryMedia

Bases: Model

content = models.TextField() class-attribute instance-attribute

content_type = models.CharField(max_length=64, choices=SmsMediaContentTypeChoices) class-attribute instance-attribute

name = models.CharField(max_length=255) class-attribute instance-attribute

expire_datetime = models.DateTimeField() class-attribute instance-attribute

external_access_key = models.UUIDField(unique=True) class-attribute instance-attribute

objects = SmsTemporaryMediaQuerySet.as_manager() class-attribute instance-attribute

external_url property

Meta

db_table = 'django_spire_notification_sms_temporary_media' class-attribute instance-attribute
verbose_name = 'SMS Temporary Media' class-attribute instance-attribute
verbose_name_plural = 'SMS Temporary Media' class-attribute instance-attribute

__str__

Source code in django_spire/notification/sms/models.py
def __str__(self):
    return f'{self.name} - {self.content_type}'

is_expired

Source code in django_spire/notification/sms/models.py
def is_expired(self) -> bool:
    return self.expire_datetime < now()

is_ready_for_deletion

Source code in django_spire/notification/sms/models.py
def is_ready_for_deletion(self) -> bool:
    return not self.has_unsent_notifications() or self.is_expired()

has_unsent_notifications

Source code in django_spire/notification/sms/models.py
def has_unsent_notifications(self) -> bool:
    return self.sms_notifications.notification.unsent().active().exists()

SmsNotification

Bases: Model

notification = models.OneToOneField(Notification, editable=False, on_delete=(models.CASCADE), related_name='sms', related_query_name='sms') class-attribute instance-attribute

temporary_media = models.ForeignKey(SmsTemporaryMedia, on_delete=(models.SET_NULL), blank=True, null=True, related_name='sms_notifications', related_query_name='sms_notification') class-attribute instance-attribute

to_phone_number = models.CharField(max_length=11, blank=True) class-attribute instance-attribute

media_url = models.URLField(max_length=255, blank=True, null=True) class-attribute instance-attribute

objects = SmsNotificationQuerySet.as_manager() class-attribute instance-attribute

Meta

db_table = 'django_spire_notification_sms' class-attribute instance-attribute
verbose_name = 'SMS Notification' class-attribute instance-attribute
verbose_name_plural = 'SMS Notifications' class-attribute instance-attribute

__str__

Source code in django_spire/notification/sms/models.py
def __str__(self):
    return f'{self.to_phone_number} - {self.notification.title}'