Created
January 3, 2023 17:11
-
-
Save skolo-online/67367896eb15ec60d70319c126054a7b to your computer and use it in GitHub Desktop.
Whatsapp Business Plan Chat Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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