| 123456789101112131415161718192021222324252627282930 |
- from django.db import models
- # Create your models here.
- from django.contrib.auth.models import User
- class UserProfile(models.Model):
- POSITION_CHOICES = [
- ('QA_STAFF', 'QA Staff'),
- ('QA_MANAGER', 'QA. MG.'),
- ('QA_AST_MANAGER', 'QA. Asst. MG.'),
- ('QA_ENGINEER', 'QA. Engineer'),
- ]
- user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
- bio = models.TextField(blank=True, null=True)
- profile_picture = models.ImageField(upload_to="profile/%Y/%m/%d/", blank=True, null=True)
- signed_picture = models.ImageField(upload_to="signed/%Y/%m/%d/", blank=True, null=True)
- email = models.EmailField(blank=True, null=True) # New email field
- position = models.CharField(max_length=20, choices=POSITION_CHOICES, blank=True, null=True) # New position field
- qa2_default = models.BooleanField(default=False)
- def save(self, *args, **kwargs):
- if self.qa2_default:
- UserProfile.objects.exclude(pk=self.pk).filter(qa2_default=True).update(qa2_default=False)
- super().save(*args, **kwargs)
- def __str__(self):
- pos = self.get_position_display()
- return f"{self.user.username} / {self.user.first_name} {self.user.last_name} #{pos}"
|