# Path: harnas/contest/models.py
# class TestCase(models.Model):
#     QUEUED = "QUE"
#     MEMORY_LIMIT = "MEM"
#     TIME_LIMIT = "TLE"
#     ACCEPTED = "OK"
#     INTERNAL_ERROR = "INT"
#     WRONG_ANSWER = "ANS"
#     COMPILATION_ERROR = "CME"
#     RUNTIME_ERROR = "RTE"
#     STATUS_CHOICES = (
#         (QUEUED, "In checking queue"),
#         (MEMORY_LIMIT, "Memory limit exceeded"),
#         (TIME_LIMIT, "Time limit exceeded"),
#         (ACCEPTED, "Accepted"),
#         (INTERNAL_ERROR, "Internal error"),
#         (WRONG_ANSWER, "Wrong answer"),
#         (COMPILATION_ERROR, "Compilation error"),
#         (RUNTIME_ERROR, "Runtime error"),
#     )
# 
#     task = models.ForeignKey(Task)
#     name = models.CharField(max_length=100, null=True, default=None)
#     max_memory = models.PositiveIntegerField()
#     max_duration = models.PositiveIntegerField()
#     run_order_id = models.PositiveSmallIntegerField(default=0)
#     comparator = models.CharField(max_length=500)
#     executor = models.CharField(max_length=500)
#     in_file_path = models.FilePathField(max_length=500)
#     out_file_path = models.FilePathField(max_length=500)
# 
#     def __str__(self):
#         return self.name


from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from harnas.contest.models import TestCase

class TestEnvironment(models.Model):
    template_name = models.CharField(max_length=250)
    summary = models.CharField(max_length=250)
    description = models.TextField()
    maintainer = models.ForeignKey(User)

    class Meta:
        permissions = (
            ('view_test_environment', 'Can view test environment'),
            ('edit_test_environment', 'Can edit test environment'))

    def __str__(self):
        return self.template_name


class Submit(models.Model):
    submitter = models.ForeignKey(User)
    submitted = models.DateTimeField(auto_now_add=True)
    task = models.ForeignKey('contest.Task')
    solution = models.BinaryField()
    status = models.CharField(max_length=3,
                              choices=TestCase.STATUS_CHOICES)
    webhook_secret = models.CharField(
                        max_length=settings.WEBHOOK_SECRET_LENGTH)

    def __str__(self):
        return self.id

    def change_status(self, status):

# Path: harnas/contest/models.py
# class TestCase(models.Model):
#     QUEUED = "QUE"
#     MEMORY_LIMIT = "MEM"
#     TIME_LIMIT = "TLE"
#     ACCEPTED = "OK"
#     INTERNAL_ERROR = "INT"
#     WRONG_ANSWER = "ANS"
#     COMPILATION_ERROR = "CME"
#     RUNTIME_ERROR = "RTE"
#     STATUS_CHOICES = (
#         (QUEUED, "In checking queue"),
#         (MEMORY_LIMIT, "Memory limit exceeded"),
#         (TIME_LIMIT, "Time limit exceeded"),
#         (ACCEPTED, "Accepted"),
#         (INTERNAL_ERROR, "Internal error"),
#         (WRONG_ANSWER, "Wrong answer"),
#         (COMPILATION_ERROR, "Compilation error"),
#         (RUNTIME_ERROR, "Runtime error"),
#     )
# 
#     task = models.ForeignKey(Task)
#     name = models.CharField(max_length=100, null=True, default=None)
#     max_memory = models.PositiveIntegerField()
#     max_duration = models.PositiveIntegerField()
#     run_order_id = models.PositiveSmallIntegerField(default=0)
#     comparator = models.CharField(max_length=500)
#     executor = models.CharField(max_length=500)
#     in_file_path = models.FilePathField(max_length=500)
#     out_file_path = models.FilePathField(max_length=500)
# 
#     def __str__(self):
#         return self.name


# Path: harnas/checker/models.py
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from harnas.contest.models import TestCase


class TestEnvironment(models.Model):
    template_name = models.CharField(max_length=250)
    summary = models.CharField(max_length=250)
    description = models.TextField()
    maintainer = models.ForeignKey(User)

    class Meta:
        permissions = (
            ('view_test_environment', 'Can view test environment'),
            ('edit_test_environment', 'Can edit test environment'))

    def __str__(self):
        return self.template_name


class Submit(models.Model):
    submitter = models.ForeignKey(User)
    submitted = models.DateTimeField(auto_now_add=True)
    task = models.ForeignKey('contest.Task')
    solution = models.BinaryField()
    status = models.CharField(max_length=3,
                              choices=TestCase.STATUS_CHOICES)
    webhook_secret = models.CharField(
                        max_length=settings.WEBHOOK_SECRET_LENGTH)

    def __str__(self):
        return self.id

    def change_status(self, status):

        if status not in [choice[0] for choice in TestCase.STATUS_CHOICES]: