from django.db import models
from django.conf import settings

class TeamMember(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='user', on_delete=models.CASCADE)
    adminUser = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='admin_user', on_delete=models.CASCADE)
    isAdmin = models.BooleanField(default=False)

    def __str__(self):
        return f"TeamMember {self.user} - Admin: {self.isAdmin}"

    class Meta:
        unique_together = ('user', 'adminUser')  # Ensure that one user can be added only once per admin
