from django.db import models from django.utils.translation import gettext_lazy as _ from apps.account.models import StudentUser, User from apps.course.models import Course from phonenumber_field.modelfields import PhoneNumberField from utils.validators import validate_possible_number class TransactionParticipant(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='transactions') course = models.ForeignKey(Course, on_delete=models.CASCADE, related_name='course_transactions') is_paid = models.BooleanField(default=False, verbose_name='Payment Status', help_text='Indicates whether the payment has been completed or not') price = models.DecimalField(max_digits=10, decimal_places=2, default=0.00, verbose_name='Transaction Price') created_at = models.DateTimeField(auto_now_add=True, verbose_name=_("Created at")) updated_at = models.DateTimeField(auto_now=True, verbose_name=_("Updated at")) class ParticipantInfo(models.Model): class GenderChoices(models.TextChoices): MALE = 'male', 'Male' FEMALE = 'female', 'Female' transaction_participant = models.ForeignKey( TransactionParticipant, on_delete=models.CASCADE, related_name='participant_infos', verbose_name="Transaction Participant" ) fullname = models.CharField(max_length=255, verbose_name="Full Name", help_text="Enter the full name of the user.") email = models.EmailField(unique=True, verbose_name="Email Address", help_text="Enter the user's email address.") phone_number = PhoneNumberField(unique=True, validators=[validate_possible_number], null=True, blank=True, verbose_name=_('phone')) gender = models.CharField( max_length=20, choices=GenderChoices.choices, null=True, blank=True, verbose_name=_('Gender'), help_text="Select the user's gender." ) birthdate = models.DateField(verbose_name=_('birthdate'), null=True, blank=True)