from django.conf import settings
from django.db import models
class LeadershipPosition(models.Model):
 class Level(models.TextChoices): CAMPUS='CAMPUS','Campus'; NATIONAL='NATIONAL','National'; PATRON='PATRON','Patron'; BOARD='BOARD','Church Board'
 name=models.CharField(max_length=120); level=models.CharField(max_length=20,choices=Level.choices); rank=models.PositiveSmallIntegerField(default=100); active=models.BooleanField(default=True)
 class Meta: ordering=['level','rank','name']; unique_together=[('name','level')]
 def __str__(self): return f'{self.name} ({self.level})'
class LeadershipAssignment(models.Model):
 user=models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,related_name='leadership_assignments'); position=models.ForeignKey(LeadershipPosition,on_delete=models.PROTECT); campus=models.ForeignKey('core.Campus',null=True,blank=True,on_delete=models.CASCADE,related_name='leadership'); starts_on=models.DateField(); ends_on=models.DateField(null=True,blank=True); active=models.BooleanField(default=True); appointed_by=models.ForeignKey(settings.AUTH_USER_MODEL,null=True,blank=True,on_delete=models.SET_NULL,related_name='appointments_made')
 class Meta: ordering=['position__rank','-starts_on']
