<commit_before>from django.db import models
from django.conf import settings
from event.models import Event
from shop.utils import upload_path_product
from referral.models import Referral
from django.contrib.auth.models import User
import uuid


class BaseModel(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    created = models.DateTimeField(
        verbose_name='Created', auto_now_add=True, editable=False)
    modified = models.DateTimeField(
        verbose_name='Last Modified', auto_now=True, editable=False)

    class Meta:
        abstract = True


class ProductManager(models.Manager):
    def get_product_bullets(self, product_uuid):
        if isinstance(product_uuid, str):
            product_uuid = uuid.UUID(product_uuid)
        return self.get(id=product_uuid).productbulletpoint_set.all()


class Product(BaseModel):
    event = models.ForeignKey(Event, on_delete=None)
    PRODUCT_TYPE = (
        ('convention', 'Fan Convention'),
        ('exhibition', 'Public Exhibition'),
        ('sponsor', 'Sponsorship'),
        ('vendor', 'Vendor'),
    )
    product_type = models.CharField(
        max_length=64, blank=False, choices=PRODUCT_TYPE, default='convention')
    title = models.CharField(max_length=64)
    description = models.TextField()
    price = models.FloatField()
    image = models.ImageField(upload_to=upload_path_product, null=True)
    quantity_available = models.IntegerField(
        verbose_name='Quantity Available', default=-1)
    objects = ProductManager()

    class Meta:
        ordering = ['product_type', 'title']
        unique_together = ('title', 'event')

    def __str__(self):
        return self.event.title + " - " + self.title


class ProductBulletPoint(BaseModel):
    product = models.ForeignKey(Product, on_delete=None)
    text = models.CharField(max_length=64, blank=True)


class Order(BaseModel):
    user = models.ForeignKey(User, on_delete=None)
    transaction_id = models.CharField(max_length=128)
    reference_id = models.CharField(max_length=128)
    guest = models.CharField(max_length=255)
    referral = models.ForeignKey(
        Referral, on_delete=None, blank=True, null=True)


class OrderItem(BaseModel):
    order = models.ForeignKey(Order, on_delete=None)
    user = models.ForeignKey(User,
                             on_delete=None, null=True)
    first_name = models.CharField(max_length=32, blank=True)
    last_name = models.CharField(max_length=64, blank=True)
    product = models.ForeignKey(Product, on_delete=None)
    price = models.FloatField()


class CartItem(BaseModel):
    cart = models.CharField(max_length=64, default=uuid.uuid4())
    first_name = models.CharField(max_length=32, blank=True)
    last_name = models.CharField(max_length=64, blank=True)
    email = models.EmailField(blank=True)
    product = models.ForeignKey(Product, on_delete=None)<commit_msg>* Added the logic for post processing of order logic.<commit_after>from django.db import models
from django.conf import settings
from event.models import Event
from shop.utils import upload_path_product
from referral.models import Referral
from django.contrib.auth.models import User
import uuid


class BaseModel(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    created = models.DateTimeField(
        verbose_name='Created', auto_now_add=True, editable=False)
    modified = models.DateTimeField(
        verbose_name='Last Modified', auto_now=True, editable=False)

    class Meta:
        abstract = True


class ProductManager(models.Manager):
    def get_product_bullets(self, product_uuid):
        if isinstance(product_uuid, str):
            product_uuid = uuid.UUID(product_uuid)
        return self.get(id=product_uuid).productbulletpoint_set.all()


class Product(BaseModel):
    event = models.ForeignKey(Event, on_delete=None)
    PRODUCT_TYPE = (
        ('convention', 'Fan Convention'),
        ('exhibition', 'Public Exhibition'),
        ('sponsor', 'Sponsorship'),
        ('vendor', 'Vendor'),
    )
    product_type = models.CharField(
        max_length=64, blank=False, choices=PRODUCT_TYPE, default='convention')
    title = models.CharField(max_length=64)
    description = models.TextField()
    price = models.FloatField()
    image = models.ImageField(upload_to=upload_path_product, null=True)
    quantity_available = models.IntegerField(
        verbose_name='Quantity Available', default=-1)
    objects = ProductManager()

    class Meta:
        ordering = ['product_type', 'title']
        unique_together = ('title', 'event')

    def __str__(self):
        return self.event.title + " - " + self.title


class ProductBulletPoint(BaseModel):
    product = models.ForeignKey(Product, on_delete=None)
    text = models.CharField(max_length=64, blank=True)


class Order(BaseModel):
    user = models.ForeignKey(User, on_delete=None)
    transaction_id = models.CharField(max_length=128, null=True)
    reference_id = models.CharField(max_length=128, null=True)
    guest = models.CharField(max_length=255)
    referral = models.ForeignKey(
        Referral, on_delete=None, blank=True, null=True)


class OrderItem(BaseModel):
    order = models.ForeignKey(Order, on_delete=None)
    user = models.ForeignKey(User,
                             on_delete=None, null=True)
    first_name = models.CharField(max_length=32, blank=True)
    last_name = models.CharField(max_length=64, blank=True)
    product = models.ForeignKey(Product, on_delete=None)
    price = models.FloatField()


class CartItem(BaseModel):
    cart = models.CharField(max_length=64, default=uuid.uuid4())
    first_name = models.CharField(max_length=32, blank=True)
    last_name = models.CharField(max_length=64, blank=True)
    email = models.EmailField(blank=True)
    product = models.ForeignKey(Product, on_delete=None)
{'fraction_non_alphanumeric': 0.10956580732700136, 'fraction_numerical': 0.009497964721845319, 'mean_word_length': 4.04448246364414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1723186', 'n_tokens_mistral': 1809, 'n_tokens_neox': 1748, 'n_words': 352}