# Path: treeupload/models.py
# class TreeSubmission(models.Model):
#     tree_file = models.FileField(
#         upload_to=os.path.join(settings.MEDIA_ROOT),
#     )
#     
#     tree_id = models.CharField(max_length=100)
#     
#     format_choices = sorted(bp._io.supported_formats.keys())
#     format_choices = [(x,x) for x in format_choices]
#     format = models.CharField(choices=format_choices, default='newick',
#                               max_length=20)
#     
#     uploaded_by = models.ForeignKey(User, related_name='uploaded_by')
#     upload_time = models.DateTimeField(auto_now_add=True)
# 
#     doi = models.CharField(max_length=100)
#     
#     def tree_file_name(self):
#         return os.path.split(self.tree_file.name)[1]
#         
#     def tree_file_size(self):
#         return filesizeformat(self.tree_file.size)
# 
# class TreeSubmissionJob(models.Model):
#     user = models.ForeignKey(User, related_name='user')
#     start_time = models.DateTimeField(auto_now_add=True)
#     submission = models.ForeignKey(TreeSubmission, related_name='submission')
#     status = models.TextField(default='Pending')


from django import forms
from django.template.defaultfilters import filesizeformat
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from treeupload.models import TreeSubmission, TreeSubmissionJob


MAX_UPLOAD_SIZE_MB = 100
MAX_UPLOAD_SIZE = MAX_UPLOAD_SIZE_MB * 1024**2

class TreeSubmissionForm(forms.ModelForm):
    max_upload_size = MAX_UPLOAD_SIZE

    tree_id = forms.RegexField(
        r'^[a-zA-Z][a-zA-Z0-9\_\-]*$', 
        min_length=10, required=True,
        error_message='Tree ID must be at least 10 characters, start with a letter, and contain only letters, numbers, dashes and underscores.'
    )
    
    class Meta:

# Path: treeupload/models.py
# class TreeSubmission(models.Model):
#     tree_file = models.FileField(
#         upload_to=os.path.join(settings.MEDIA_ROOT),
#     )
#     
#     tree_id = models.CharField(max_length=100)
#     
#     format_choices = sorted(bp._io.supported_formats.keys())
#     format_choices = [(x,x) for x in format_choices]
#     format = models.CharField(choices=format_choices, default='newick',
#                               max_length=20)
#     
#     uploaded_by = models.ForeignKey(User, related_name='uploaded_by')
#     upload_time = models.DateTimeField(auto_now_add=True)
# 
#     doi = models.CharField(max_length=100)
#     
#     def tree_file_name(self):
#         return os.path.split(self.tree_file.name)[1]
#         
#     def tree_file_size(self):
#         return filesizeformat(self.tree_file.size)
# 
# class TreeSubmissionJob(models.Model):
#     user = models.ForeignKey(User, related_name='user')
#     start_time = models.DateTimeField(auto_now_add=True)
#     submission = models.ForeignKey(TreeSubmission, related_name='submission')
#     status = models.TextField(default='Pending')


# Path: treeupload/forms.py
from django import forms
from django.template.defaultfilters import filesizeformat
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from treeupload.models import TreeSubmission, TreeSubmissionJob



MAX_UPLOAD_SIZE_MB = 100
MAX_UPLOAD_SIZE = MAX_UPLOAD_SIZE_MB * 1024**2

class TreeSubmissionForm(forms.ModelForm):
    max_upload_size = MAX_UPLOAD_SIZE

    tree_id = forms.RegexField(
        r'^[a-zA-Z][a-zA-Z0-9\_\-]*$', 
        min_length=10, required=True,
        error_message='Tree ID must be at least 10 characters, start with a letter, and contain only letters, numbers, dashes and underscores.'
    )
    
    class Meta:

        model = TreeSubmission