wallet/apps/notifications/models.py
2020-03-21 13:37:53 +04:30

28 lines
No EOL
1.1 KiB
Python

import uuid
from django.db import models
from django.utils.translation import gettext_lazy as _
from model_utils import Choices
class Notification(models.Model):
STATE_CHOICES = Choices(
(1, 'created', 'created'),
(2, 'delayed', 'delayed'),
(3, 'pending', 'pending'),
(4, 'failed', 'failed'),
(5, 'done', 'done'),
)
uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4, unique=True,
db_index=True)
state = models.IntegerField(choices=STATE_CHOICES, default=STATE_CHOICES.created)
phone_number = models.CharField(max_length=30, db_index=True, blank=True, null=True)
body = models.TextField(max_length=200)
application_client_id = models.CharField(max_length=100, db_index=True, null=True)
user_uuid = models.UUIDField(db_index=True, null=True)
create = models.DateTimeField(_('create'), blank=True, null=True, auto_now_add=True)
last_update = models.DateTimeField(_('last update'), blank=True, null=True, auto_now=True)
def send(self):
from .tasks import send_sms
send_sms.delay(self.uuid)