# Path: judge/models.py
# class Coder(models.Model):
#     user = models.OneToOneField(User)
#     link = models.URLField()
#     score = models.DecimalField(default = 0, decimal_places = 3, max_digits = 100)
#     rank = models.IntegerField(default = -1)
#     problems_tried = models.ForeignKey('Problem', null = True, related_name = "problems_tried")
#     problems_ac = models.ForeignKey('Problem', null = True, related_name = "problems_ac")
# 
#     def __unicode__(self):
#         return self.user.username
# 
# class Problem(models.Model):
#     # Problem name (example: life, the universe and everything)
#     name = models.CharField(max_length=255)
#     # Problem code (example: TEST)
#     code = models.CharField(max_length=20, unique = True)
#     # Problem link (example: poj.com/problems/TEST)
#     link = models.URLField()
#     # Problem statement
#     statement = models.TextField()
# 
#     num_submissions = models.IntegerField(default = 0) # number of submissions
#     num_ac = models.IntegerField(default = 0)     # number of accepted submissions
#     num_wa = models.IntegerField(default = 0)          # number of wrong answers
#     num_re = models.IntegerField(default = 0)          # number of runtime errors
#     num_tle = models.IntegerField(default = 0)         # number of tles
#     num_ce = models.IntegerField(default = 0)
#     date_added = models.DateTimeField(auto_now_add = True) # When added
#     time_limit = models.IntegerField(default=1)         # Time Limit
#     source = models.CharField(max_length=255)
#     num_tests = models.IntegerField(default = 1)
# 
#     author = models.ForeignKey('Coder', null = True)
# 
#     def __unicode__(self):
#         return self.code
# 
# class TestCase(models.Model):
#     problem = models.ForeignKey(Problem)
#     input_file = models.FileField(upload_to=in_upload_path)
#     output_file = models.FileField(upload_to=out_upload_path)
# 
#     def __unicode__(self):
#         return self.problem.code
# 
# class Submission(models.Model):
#     STATUSES = (
#                 ("NT", "Not tested"),
#                 ("CE", "Compile Error"),
#                 ("TL", "Time Limit Exceeded"),
#                 ("RE", "Runtime Error"),
#                 ("AC", "Accepted")
#                 )
#     submitter = models.ForeignKey(Coder, null = True)
#     problem = models.ForeignKey(Problem, default = None, null = True)
#     status = models.CharField(max_length = 2, default = "NT", choices = STATUSES)
#     lang = models.CharField(max_length = 4, default = "C", choices = LANGUAGES)
#     code = models.TextField(default="")
#     created = models.DateTimeField(auto_now_add=True)
#     private = models.BooleanField(default = True)


from django import forms
from judge.models import Coder, Problem, TestCase, Submission
from django.contrib.auth.models import User

class UserForm(forms.ModelForm):
    password = forms.CharField(widget=forms.PasswordInput())
    class Meta:
        model = User
        fields = {'username', 'password'}

class ProblemForm(forms.ModelForm):
    name = forms.CharField()
    code = forms.CharField()
    statement = forms.CharField(widget = forms.Textarea)
    time_limit = forms.IntegerField()
    source = forms.CharField()
    input1 = forms.FileField()
    output1 = forms.FileField()

    class Meta:
        model = Problem
        fields = ['name', 'code', 'statement', 'time_limit', 'source', 'input1', 'output1']


class SubmissionForm(forms.ModelForm):
    langs = [("C", "C"),  ("CPP", "C++"), ("JAVA", "Java"), ("PYTH", "python"), ("PYTH3", "python 3")]

# Path: judge/models.py
# class Coder(models.Model):
#     user = models.OneToOneField(User)
#     link = models.URLField()
#     score = models.DecimalField(default = 0, decimal_places = 3, max_digits = 100)
#     rank = models.IntegerField(default = -1)
#     problems_tried = models.ForeignKey('Problem', null = True, related_name = "problems_tried")
#     problems_ac = models.ForeignKey('Problem', null = True, related_name = "problems_ac")
# 
#     def __unicode__(self):
#         return self.user.username
# 
# class Problem(models.Model):
#     # Problem name (example: life, the universe and everything)
#     name = models.CharField(max_length=255)
#     # Problem code (example: TEST)
#     code = models.CharField(max_length=20, unique = True)
#     # Problem link (example: poj.com/problems/TEST)
#     link = models.URLField()
#     # Problem statement
#     statement = models.TextField()
# 
#     num_submissions = models.IntegerField(default = 0) # number of submissions
#     num_ac = models.IntegerField(default = 0)     # number of accepted submissions
#     num_wa = models.IntegerField(default = 0)          # number of wrong answers
#     num_re = models.IntegerField(default = 0)          # number of runtime errors
#     num_tle = models.IntegerField(default = 0)         # number of tles
#     num_ce = models.IntegerField(default = 0)
#     date_added = models.DateTimeField(auto_now_add = True) # When added
#     time_limit = models.IntegerField(default=1)         # Time Limit
#     source = models.CharField(max_length=255)
#     num_tests = models.IntegerField(default = 1)
# 
#     author = models.ForeignKey('Coder', null = True)
# 
#     def __unicode__(self):
#         return self.code
# 
# class TestCase(models.Model):
#     problem = models.ForeignKey(Problem)
#     input_file = models.FileField(upload_to=in_upload_path)
#     output_file = models.FileField(upload_to=out_upload_path)
# 
#     def __unicode__(self):
#         return self.problem.code
# 
# class Submission(models.Model):
#     STATUSES = (
#                 ("NT", "Not tested"),
#                 ("CE", "Compile Error"),
#                 ("TL", "Time Limit Exceeded"),
#                 ("RE", "Runtime Error"),
#                 ("AC", "Accepted")
#                 )
#     submitter = models.ForeignKey(Coder, null = True)
#     problem = models.ForeignKey(Problem, default = None, null = True)
#     status = models.CharField(max_length = 2, default = "NT", choices = STATUSES)
#     lang = models.CharField(max_length = 4, default = "C", choices = LANGUAGES)
#     code = models.TextField(default="")
#     created = models.DateTimeField(auto_now_add=True)
#     private = models.BooleanField(default = True)


# Path: judge/forms.py
from django import forms
from judge.models import Coder, Problem, TestCase, Submission
from django.contrib.auth.models import User


class UserForm(forms.ModelForm):
    password = forms.CharField(widget=forms.PasswordInput())
    class Meta:
        model = User
        fields = {'username', 'password'}

class ProblemForm(forms.ModelForm):
    name = forms.CharField()
    code = forms.CharField()
    statement = forms.CharField(widget = forms.Textarea)
    time_limit = forms.IntegerField()
    source = forms.CharField()
    input1 = forms.FileField()
    output1 = forms.FileField()

    class Meta:
        model = Problem
        fields = ['name', 'code', 'statement', 'time_limit', 'source', 'input1', 'output1']


class SubmissionForm(forms.ModelForm):
    langs = [("C", "C"),  ("CPP", "C++"), ("JAVA", "Java"), ("PYTH", "python"), ("PYTH3", "python 3")]

    lang = forms.ChoiceField(choices = langs)