Skip to content

Instantly share code, notes, and snippets.

@skolo-online
Created January 3, 2023 17:11
Show Gist options
  • Save skolo-online/67367896eb15ec60d70319c126054a7b to your computer and use it in GitHub Desktop.
Save skolo-online/67367896eb15ec60d70319c126054a7b to your computer and use it in GitHub Desktop.
Whatsapp Business Plan Chat Model
from django.db import models
from django.utils import timezone
from uuid import uuid4
class ChatSession(models.Model):
OPTIONS = [
('(Pty) Ltd', '(Pty) Ltd'),
('Not Profit', 'Not Profit'),
('Partnership', 'Partnership'),
]
business_name = models.TextField(null=True, blank=True)
business_type = models.CharField(choices=OPTIONS, null=True, blank=True, max_length=200)
country = models.TextField(null=True, blank=True)
product_service = models.TextField(null=True, blank=True)
short_description = models.TextField(null=True, blank=True)
years = models.IntegerField(null=True, blank=True)
progress = models.TextField(null=True, blank=True)
profile = models.ForeignKey(Profile, on_delete=models.CASCADE)
uniqueId = models.CharField(null=True, blank=True, unique=True, max_length=100)
date_created = models.DateTimeField(blank=True, null=True)
last_updated = models.DateTimeField(blank=True, null=True)
def save(self, *args, **kwargs):
if self.date_created is None:
self.date_created = timezone.localtime(timezone.now())
if self.uniqueId is None:
self.uniqueId = str(uuid4()).split('-')[4]
self.last_updated = timezone.localtime(timezone.now())
super(ChatSession, self).save(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment