# Path: user_resource/models.py
# class ContactNumber(models.Model):
#     user = models.ForeignKey(User, related_name='contacts')
#     number = models.CharField(max_length=16)
#     _history_ = HistoricalRecords()
# 
#     def __str__(self):
#         return self.number
# 
# class InstituteAddress(models.Model):
#     user = models.OneToOneField(User, related_name='insti_address')
#     room = models.CharField(max_length=8, null=True, blank=True)
#     hostel = models.CharField(max_length=8, choices=HOSTELS, null=True, blank=True)
#     _history_ = HistoricalRecords()
# 
#     def clean(self):
#         if self.room:
#             if self.hostel in HOSTELS_WITH_WINGS:
#                 if not ROOM_VALIDATION_REGEX.match(self.room):
#                     raise ValidationError(_('Room number must have wing name like A-123'))
# 
#     def __str__(self):
#         if self.hostel:
#             if self.room:
#                 return "%s-%s" % (self.hostel, self.room)
#             return self.hostel
#         return ''
# 
# class Program(models.Model):
#     user = models.OneToOneField(User, related_name='program')
#     department = models.CharField(max_length=16, choices=SORTED_DISCIPLINES, null=True, blank=True)
#     join_year = models.PositiveSmallIntegerField(null=True, blank=True, validators=[validate_join_year])
#     graduation_year = models.PositiveSmallIntegerField(null=True, blank=True, validators=[validate_graduation_year])
#     degree = models.CharField(max_length=16, choices=DEGREES, null=True, blank=True)
#     _history_ = HistoricalRecords()
# 
#     def __str__(self):
#         return "%s, %s" % (self.get_degree_display(), self.get_department_display())
# 
# class SecondaryEmail(models.Model):
#     user = models.ForeignKey(User, related_name='secondary_emails')
#     email = models.EmailField()
#     _history_ = HistoricalRecords()
# 
#     def __str__(self):
#         return self.email
# 
# Path: account/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User)
#     profile_picture = models.ImageField(upload_to=user_profile_picture, null=True, blank=True)
#     description = models.TextField(null=True, blank=True)
#     roll_number = models.CharField(max_length=16, null=True, blank=True)
#     type = models.CharField(max_length=16, null=True, blank=True)
#     mobile = models.CharField(max_length=16, null=True, blank=True)
#     is_alumni = models.BooleanField(default=False)
#     sex = models.CharField(max_length=10, choices=SEXES, null=True, blank=True)
#     _history_ = HistoricalRecords()
# 
#     def __str__(self):
#         return self.user.username


from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from simple_history.admin import SimpleHistoryAdmin
from user_resource.models import ContactNumber, InstituteAddress, Program, SecondaryEmail
from .models import UserProfile




class UserProfileAdmin(SimpleHistoryAdmin):
    list_display = ['id', 'user', 'roll_number', 'sex', 'type']
    list_filter = ['sex', 'type', ]
    search_fields = ['user__username', 'user__first_name', 'roll_number']


class InstituteAddressInline(admin.TabularInline):
    model = InstituteAddress


class UserProfileInline(admin.StackedInline):
    model = UserProfile


class ProgramInline(admin.StackedInline):

# Path: user_resource/models.py
# class ContactNumber(models.Model):
#     user = models.ForeignKey(User, related_name='contacts')
#     number = models.CharField(max_length=16)
#     _history_ = HistoricalRecords()
# 
#     def __str__(self):
#         return self.number
# 
# class InstituteAddress(models.Model):
#     user = models.OneToOneField(User, related_name='insti_address')
#     room = models.CharField(max_length=8, null=True, blank=True)
#     hostel = models.CharField(max_length=8, choices=HOSTELS, null=True, blank=True)
#     _history_ = HistoricalRecords()
# 
#     def clean(self):
#         if self.room:
#             if self.hostel in HOSTELS_WITH_WINGS:
#                 if not ROOM_VALIDATION_REGEX.match(self.room):
#                     raise ValidationError(_('Room number must have wing name like A-123'))
# 
#     def __str__(self):
#         if self.hostel:
#             if self.room:
#                 return "%s-%s" % (self.hostel, self.room)
#             return self.hostel
#         return ''
# 
# class Program(models.Model):
#     user = models.OneToOneField(User, related_name='program')
#     department = models.CharField(max_length=16, choices=SORTED_DISCIPLINES, null=True, blank=True)
#     join_year = models.PositiveSmallIntegerField(null=True, blank=True, validators=[validate_join_year])
#     graduation_year = models.PositiveSmallIntegerField(null=True, blank=True, validators=[validate_graduation_year])
#     degree = models.CharField(max_length=16, choices=DEGREES, null=True, blank=True)
#     _history_ = HistoricalRecords()
# 
#     def __str__(self):
#         return "%s, %s" % (self.get_degree_display(), self.get_department_display())
# 
# class SecondaryEmail(models.Model):
#     user = models.ForeignKey(User, related_name='secondary_emails')
#     email = models.EmailField()
#     _history_ = HistoricalRecords()
# 
#     def __str__(self):
#         return self.email
# 
# Path: account/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User)
#     profile_picture = models.ImageField(upload_to=user_profile_picture, null=True, blank=True)
#     description = models.TextField(null=True, blank=True)
#     roll_number = models.CharField(max_length=16, null=True, blank=True)
#     type = models.CharField(max_length=16, null=True, blank=True)
#     mobile = models.CharField(max_length=16, null=True, blank=True)
#     is_alumni = models.BooleanField(default=False)
#     sex = models.CharField(max_length=10, choices=SEXES, null=True, blank=True)
#     _history_ = HistoricalRecords()
# 
#     def __str__(self):
#         return self.user.username


# Path: account/admin.py
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from simple_history.admin import SimpleHistoryAdmin
from user_resource.models import ContactNumber, InstituteAddress, Program, SecondaryEmail
from .models import UserProfile





class UserProfileAdmin(SimpleHistoryAdmin):
    list_display = ['id', 'user', 'roll_number', 'sex', 'type']
    list_filter = ['sex', 'type', ]
    search_fields = ['user__username', 'user__first_name', 'roll_number']


class InstituteAddressInline(admin.TabularInline):
    model = InstituteAddress


class UserProfileInline(admin.StackedInline):
    model = UserProfile


class ProgramInline(admin.StackedInline):

    model = Program