# Path: web/Model/database.py
# class Activities(db.Model):
#     __bind_key__ = 'activity'
#     activity_name = db.Column(db.VARCHAR(10), primary_key=True, unique=True)
#     title = db.Column(db.Text)
#     reg_enable = db.Column(db.Boolean, default=True)
#     team_enable = db.Column(db.Boolean, default=False)
#     upload_enable = db.Column(db.Boolean, default=False)
#     note = db.Column(db.Text, default="")
#     rank = db.Column(db.Integer, default=0)
#     hide = db.Column(db.Boolean, default=False)
# 
#     def __init__(self, activity_name, title, reg_enable, team_enable, upload_enable, note, rank):
#         self.activity_name = activity_name
#         self.title = title
#         self.team_enable = team_enable
#         self.upload_enable = upload_enable
#         self.reg_enable = reg_enable
#         self.note = note
#         self.rank = rank
#         self.hide = False
# 
#     def __repr__(self):
#         return "{0} {1} {2}".format(self.activity_name, self.team_enable, self.upload_enable)


from flask_wtf import Form
from flask_wtf.file import FileField, FileAllowed, FileRequired
from wtforms import SubmitField, StringField, validators, TextAreaField, BooleanField, SelectField, IntegerField, PasswordField
from .database import Activities
        FileRequired(message='请选择文件'),
        FileAllowed(['zip', 'rar'], '请使用zip或rar压缩格式提交'),
    ],        
    description="文件请打包压缩后上传，推荐使用ZIP格式～～")
    button = SubmitField('提交')


class Login(Form):
    name = StringField('姓名', [validators.required()], description="就是你的名字")
    stucode = StringField('学号', [validators.required()], description="学号")
    button = SubmitField('提交')


class TeamModify(Form):
    team = TextAreaField('队员信息', description="组队参加请按照\"姓名 学号\"一人一行填写在文本框内 如: 王尼玛 22150xxxx")
    button = SubmitField('提交')


class ActModify(Form):
    name = StringField('活动名(网址)', [validators.required()], description="建议英文")
    title = StringField('活动Title', [validators.required()], description="显示标题")
    note = TextAreaField('Note', description="显示于活动页下方")
    rank = IntegerField('排序', [validators.NumberRange(min=0, max=10)], description="0在最上面")
    reg_enable = BooleanField('开放报名')
    team_enable = BooleanField('允许组队')
    upload_enable = BooleanField('开放上传')
    hide = BooleanField('隐藏显示')
    button = SubmitField('提交')

def getChoices():

# Path: web/Model/database.py
# class Activities(db.Model):
#     __bind_key__ = 'activity'
#     activity_name = db.Column(db.VARCHAR(10), primary_key=True, unique=True)
#     title = db.Column(db.Text)
#     reg_enable = db.Column(db.Boolean, default=True)
#     team_enable = db.Column(db.Boolean, default=False)
#     upload_enable = db.Column(db.Boolean, default=False)
#     note = db.Column(db.Text, default="")
#     rank = db.Column(db.Integer, default=0)
#     hide = db.Column(db.Boolean, default=False)
# 
#     def __init__(self, activity_name, title, reg_enable, team_enable, upload_enable, note, rank):
#         self.activity_name = activity_name
#         self.title = title
#         self.team_enable = team_enable
#         self.upload_enable = upload_enable
#         self.reg_enable = reg_enable
#         self.note = note
#         self.rank = rank
#         self.hide = False
# 
#     def __repr__(self):
#         return "{0} {1} {2}".format(self.activity_name, self.team_enable, self.upload_enable)


# Path: web/Model/Forms.py
from flask_wtf import Form
from flask_wtf.file import FileField, FileAllowed, FileRequired
from wtforms import SubmitField, StringField, validators, TextAreaField, BooleanField, SelectField, IntegerField, PasswordField
from .database import Activities

        FileRequired(message='请选择文件'),
        FileAllowed(['zip', 'rar'], '请使用zip或rar压缩格式提交'),
    ],        
    description="文件请打包压缩后上传，推荐使用ZIP格式～～")
    button = SubmitField('提交')


class Login(Form):
    name = StringField('姓名', [validators.required()], description="就是你的名字")
    stucode = StringField('学号', [validators.required()], description="学号")
    button = SubmitField('提交')


class TeamModify(Form):
    team = TextAreaField('队员信息', description="组队参加请按照\"姓名 学号\"一人一行填写在文本框内 如: 王尼玛 22150xxxx")
    button = SubmitField('提交')


class ActModify(Form):
    name = StringField('活动名(网址)', [validators.required()], description="建议英文")
    title = StringField('活动Title', [validators.required()], description="显示标题")
    note = TextAreaField('Note', description="显示于活动页下方")
    rank = IntegerField('排序', [validators.NumberRange(min=0, max=10)], description="0在最上面")
    reg_enable = BooleanField('开放报名')
    team_enable = BooleanField('允许组队')
    upload_enable = BooleanField('开放上传')
    hide = BooleanField('隐藏显示')
    button = SubmitField('提交')

def getChoices():

    return list((o.activity_name, o.activity_name) for o in Activities.query.all())