# Path: app/models.py
# class Player(models.Model):
#     id = models.AutoField(primary_key=True)
#     user = models.OneToOneField(User, verbose_name="User", help_text="The user of this player.")
#     team = models.ForeignKey(Team,
#                              verbose_name="Team",
#                              help_text="The team this player belongs to.",
#                              related_name="player")
# 
#     @property
#     def points_acquired(self):
#         s = self.captured_card.filter(active=True).aggregate(models.Sum('value'))
#         if s['value__sum'] is None:
#             return 0
#         return s['value__sum']
# 
#     def __str__(self):
#         return (str(self.user.get_full_name()) + " (" +
#                 str(self.user.get_username()) + "), " + self.team.name)


from django import forms
from app.models import Player

class CardForm(forms.Form):
    name = forms.CharField(max_length=32, label="名字", help_text="點數卡的名子", required=False)
    value = forms.IntegerField(label="值", help_text="點數卡的數值", initial="64", max_value=2560, min_value=-2560)
    long_desc = forms.CharField(max_length=200, widget=forms.Textarea(), label="說明", required=False)
    active = forms.BooleanField(label="開通", help_text="該點數卡是否可用", required=False, initial=True)

class FeedForm(forms.Form):

# Path: app/models.py
# class Player(models.Model):
#     id = models.AutoField(primary_key=True)
#     user = models.OneToOneField(User, verbose_name="User", help_text="The user of this player.")
#     team = models.ForeignKey(Team,
#                              verbose_name="Team",
#                              help_text="The team this player belongs to.",
#                              related_name="player")
# 
#     @property
#     def points_acquired(self):
#         s = self.captured_card.filter(active=True).aggregate(models.Sum('value'))
#         if s['value__sum'] is None:
#             return 0
#         return s['value__sum']
# 
#     def __str__(self):
#         return (str(self.user.get_full_name()) + " (" +
#                 str(self.user.get_username()) + "), " + self.team.name)


# Path: app/card/forms.py
from django import forms
from app.models import Player


class CardForm(forms.Form):
    name = forms.CharField(max_length=32, label="名字", help_text="點數卡的名子", required=False)
    value = forms.IntegerField(label="值", help_text="點數卡的數值", initial="64", max_value=2560, min_value=-2560)
    long_desc = forms.CharField(max_length=200, widget=forms.Textarea(), label="說明", required=False)
    active = forms.BooleanField(label="開通", help_text="該點數卡是否可用", required=False, initial=True)

class FeedForm(forms.Form):

    player = forms.ModelChoiceField(Player.objects.all(), label="玩家")