# Path: hackday/users/models.py
# class Tshirt(models.Model):
# class Diet(models.Model):
# class Location(models.Model):
# class UserProfile(models.Model):
#     def __unicode__(self):
#     def __unicode__(self):
#     def __unicode__(self):
#     def __unicode__(self):
#     def image(self):
# 
# Path: hackday/teams/models.py
# class Team(models.Model):
#     """
#     A team of participants that will work on a project and compete for fabulous
#     prizes, fame, and glory.
# 
#     Upon creation, a team needs:
# 
#         * a name--hopefully an awesome one
#         * a slug, to be used for the URL of the team's page
#         * a project description
#         * a project type, so that we can differentiate "real" hacks vs. thought
#           experiments (aka "code vs. ppt")
#         * a creator
#         * a captain
#         * team members
#         * a judged category
#         * a charity that the team is supporting
# 
#     The creator and captain may have management powers above and beyond
#     those of a mere member.
#     """
# 
#     name = models.CharField('name of team', max_length=255, db_index=True,
#             unique=True)
#     slug = models.SlugField('slugified team name', db_index=True, unique=True,
#             editable=False)
# 
#     project = models.TextField('description of project')
#     logo = models.ImageField('team logo image', blank=True,
#             upload_to=create_unique_team_filename)
# 
#     project_type = models.CharField('type of project', max_length=1,
#             db_index=True, choices=PROJECT_TYPE.CHOICES)
#     status = models.CharField(max_length=1, db_index=True,
#             choices=STATUS.CHOICES)
# 
#     creator = models.ForeignKey(User,
#             related_name="%(app_label)s_%(class)s_creator")
#     captain = models.ForeignKey(User,
#             related_name="%(app_label)s_%(class)s_captain")
#     members = models.ManyToManyField(User,
#             related_name="%(app_label)s_%(class)s_members")
# 
#     attachments = models.ManyToManyField(Attachment, blank=True,
#             related_name="%(app_label)s_%(class)s_attachments")
#     images = models.ManyToManyField(ImageAttachment, blank=True,
#             related_name="%(app_label)s_%(class)s_images")
#     links = models.ManyToManyField(Link, blank=True,
#             related_name="%(app_label)s_%(class)s_links")
# 
#     category = models.ForeignKey(Category)
#     charity = models.ForeignKey(Charity)
# 
#     create_date = models.DateTimeField('date created', auto_now_add=True)
#     mod_date = models.DateTimeField('date modified', auto_now=True)
# 
#     @property
#     def is_concept(self):
#         return self.project_type == PROJECT_TYPE.CONCEPT
# 
#     @property
#     def is_implemented(self):
#         return self.project_type == PROJECT_TYPE.IMPLEMENTED
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)  #TODO: check if slug exists in DB
#         return super(Team, self).save()
# 
#     def add_captain_as_member(self):
#         if not self.is_member(self.captain):
#             self.members.add(self.captain)
#             self.save()
# 
#     def is_member(self, user):
#         return user in self.members.all()
# 
#     def __unicode__(self):
#         return self.name
# 
#     class Meta:
#         ordering = ['name']
# 
# Path: hackday/voting/moremodels.py
# class Category(models.Model):
#     """
#     Awards categories that teams can compete for.
# 
#     Categories of 'voted' type should be available for popular voting in the
#     voting UI.
# 
#     Categories of 'judged' type should NOT be available for popular voting as
#     they will be decided by a panel of judges outside of the voting system.
# 
#     Teams should self-declare a 'judged' category to enter when the team is
#     created.
#     """
# 
#     name = models.CharField('name of category', max_length=255, unique=True)
#     slug = models.SlugField('slugified category name', db_index=True,
#             unique=True)
#     description = models.TextField('description of category')
#     type = models.CharField('type of category', max_length=1, db_index=True,
#             choices=TYPE.CHOICES)
#     project_type = models.CharField('type of project', max_length=1,
#                 choices=PROJECT_TYPE.CHOICES, blank=True)
# 
#     create_date = models.DateTimeField('date created', auto_now_add=True)
#     mod_date = models.DateTimeField('date modified', auto_now=True)
# 
#     def __unicode__(self):
#         return self.name
# 
#     @property
#     def is_concept(self):
#         return self.project_type is not None and self.project_type == PROJECT_TYPE.CONCEPT
# 
#     @property
#     def is_implemented(self):
#         return self.project_type is not None and self.project_type == PROJECT_TYPE.IMPLEMENTED
# 
#     class Meta:
#         verbose_name_plural = "Categories"
#         ordering = ['name']
# 
# class TYPE(object):
#     """
#     Differentiate categories by type; some categories may be decided by
#     a panel of judges, while others may be voted on by event participants.
#     """
#     JUDGED = 'J'
#     VOTED = 'V'
# 
#     CHOICES = (
#         (JUDGED, 'Judged'),
#         (VOTED, 'Voted'),
#     )


from django import forms
from hackday.users.models import User, UserProfile
from hackday.teams.models import Team
from hackday.voting.moremodels import Category, TYPE

class UserChoiceField(forms.ModelChoiceField):
    def label_from_instance(self, user):
        return "{0} {1}".format(user.first_name, user.last_name)


class UserMultipleChoiceField(forms.ModelMultipleChoiceField):
    def label_from_instance(self, user):
        return "{0} {1}".format(user.first_name, user.last_name)


class BaseTeamForm(forms.ModelForm):
    captain = UserChoiceField(queryset=User.objects.filter(
                is_active=True).order_by('first_name', 'last_name'))

# Path: hackday/users/models.py
# class Tshirt(models.Model):
# class Diet(models.Model):
# class Location(models.Model):
# class UserProfile(models.Model):
#     def __unicode__(self):
#     def __unicode__(self):
#     def __unicode__(self):
#     def __unicode__(self):
#     def image(self):
# 
# Path: hackday/teams/models.py
# class Team(models.Model):
#     """
#     A team of participants that will work on a project and compete for fabulous
#     prizes, fame, and glory.
# 
#     Upon creation, a team needs:
# 
#         * a name--hopefully an awesome one
#         * a slug, to be used for the URL of the team's page
#         * a project description
#         * a project type, so that we can differentiate "real" hacks vs. thought
#           experiments (aka "code vs. ppt")
#         * a creator
#         * a captain
#         * team members
#         * a judged category
#         * a charity that the team is supporting
# 
#     The creator and captain may have management powers above and beyond
#     those of a mere member.
#     """
# 
#     name = models.CharField('name of team', max_length=255, db_index=True,
#             unique=True)
#     slug = models.SlugField('slugified team name', db_index=True, unique=True,
#             editable=False)
# 
#     project = models.TextField('description of project')
#     logo = models.ImageField('team logo image', blank=True,
#             upload_to=create_unique_team_filename)
# 
#     project_type = models.CharField('type of project', max_length=1,
#             db_index=True, choices=PROJECT_TYPE.CHOICES)
#     status = models.CharField(max_length=1, db_index=True,
#             choices=STATUS.CHOICES)
# 
#     creator = models.ForeignKey(User,
#             related_name="%(app_label)s_%(class)s_creator")
#     captain = models.ForeignKey(User,
#             related_name="%(app_label)s_%(class)s_captain")
#     members = models.ManyToManyField(User,
#             related_name="%(app_label)s_%(class)s_members")
# 
#     attachments = models.ManyToManyField(Attachment, blank=True,
#             related_name="%(app_label)s_%(class)s_attachments")
#     images = models.ManyToManyField(ImageAttachment, blank=True,
#             related_name="%(app_label)s_%(class)s_images")
#     links = models.ManyToManyField(Link, blank=True,
#             related_name="%(app_label)s_%(class)s_links")
# 
#     category = models.ForeignKey(Category)
#     charity = models.ForeignKey(Charity)
# 
#     create_date = models.DateTimeField('date created', auto_now_add=True)
#     mod_date = models.DateTimeField('date modified', auto_now=True)
# 
#     @property
#     def is_concept(self):
#         return self.project_type == PROJECT_TYPE.CONCEPT
# 
#     @property
#     def is_implemented(self):
#         return self.project_type == PROJECT_TYPE.IMPLEMENTED
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)  #TODO: check if slug exists in DB
#         return super(Team, self).save()
# 
#     def add_captain_as_member(self):
#         if not self.is_member(self.captain):
#             self.members.add(self.captain)
#             self.save()
# 
#     def is_member(self, user):
#         return user in self.members.all()
# 
#     def __unicode__(self):
#         return self.name
# 
#     class Meta:
#         ordering = ['name']
# 
# Path: hackday/voting/moremodels.py
# class Category(models.Model):
#     """
#     Awards categories that teams can compete for.
# 
#     Categories of 'voted' type should be available for popular voting in the
#     voting UI.
# 
#     Categories of 'judged' type should NOT be available for popular voting as
#     they will be decided by a panel of judges outside of the voting system.
# 
#     Teams should self-declare a 'judged' category to enter when the team is
#     created.
#     """
# 
#     name = models.CharField('name of category', max_length=255, unique=True)
#     slug = models.SlugField('slugified category name', db_index=True,
#             unique=True)
#     description = models.TextField('description of category')
#     type = models.CharField('type of category', max_length=1, db_index=True,
#             choices=TYPE.CHOICES)
#     project_type = models.CharField('type of project', max_length=1,
#                 choices=PROJECT_TYPE.CHOICES, blank=True)
# 
#     create_date = models.DateTimeField('date created', auto_now_add=True)
#     mod_date = models.DateTimeField('date modified', auto_now=True)
# 
#     def __unicode__(self):
#         return self.name
# 
#     @property
#     def is_concept(self):
#         return self.project_type is not None and self.project_type == PROJECT_TYPE.CONCEPT
# 
#     @property
#     def is_implemented(self):
#         return self.project_type is not None and self.project_type == PROJECT_TYPE.IMPLEMENTED
# 
#     class Meta:
#         verbose_name_plural = "Categories"
#         ordering = ['name']
# 
# class TYPE(object):
#     """
#     Differentiate categories by type; some categories may be decided by
#     a panel of judges, while others may be voted on by event participants.
#     """
#     JUDGED = 'J'
#     VOTED = 'V'
# 
#     CHOICES = (
#         (JUDGED, 'Judged'),
#         (VOTED, 'Voted'),
#     )


# Path: hackday/teams/forms.py
from django import forms
from hackday.users.models import User, UserProfile
from hackday.teams.models import Team
from hackday.voting.moremodels import Category, TYPE


class UserChoiceField(forms.ModelChoiceField):
    def label_from_instance(self, user):
        return "{0} {1}".format(user.first_name, user.last_name)


class UserMultipleChoiceField(forms.ModelMultipleChoiceField):
    def label_from_instance(self, user):
        return "{0} {1}".format(user.first_name, user.last_name)


class BaseTeamForm(forms.ModelForm):
    captain = UserChoiceField(queryset=User.objects.filter(
                is_active=True).order_by('first_name', 'last_name'))

    members = UserMultipleChoiceField(queryset=User.objects.filter(