# Path: harnas/contest/models.py
# class Contest(models.Model):
#     name = models.CharField(max_length=250, unique=True, null=False)
#     slug = models.SlugField()
#     description = models.TextField()
#     created_at = models.DateTimeField(auto_now_add=True)
#     modified_at = models.DateTimeField(auto_now=True)
#     creator = models.ForeignKey(User)
# 
#     class Meta:
#         permissions = (
#             ('view_contest', 'Can view'),
#             ('participate_in_contest', 'Can participate'),
#             ('manage_contest', 'Can manage contest'))
# 
#     def __str__(self):
#         return self.name
# 
# class GroupTaskDetails(models.Model):
#     group = models.ForeignKey(Group, null=False)
#     task = models.ForeignKey(Task, null=False)
# 
#     open = models.DateTimeField()
#     deadline = models.DateTimeField()
#     close = models.DateTimeField()
# 
#     class Meta:
#         index_together = ['group', 'task']
# 
# class News(models.Model):
#     title = models.CharField(max_length=250)
#     description = models.TextField()
#     created_at = models.DateTimeField(auto_now_add=True)
#     modified_at = models.DateTimeField(auto_now=True)
#     author = models.ForeignKey(User)
#     contest = models.ForeignKey(Contest)
# 
#     class Meta:
#         verbose_name_plural = "news"
# 
#     def __str__(self):
#         return self.title
# 
# class Task(models.Model):
#     name = models.CharField(max_length=250)
#     short_name = models.CharField(max_length=3)
#     description = models.TextField()
#     test_environment = models.ForeignKey('checker.TestEnvironment')
#     author = models.ForeignKey(User)
#     parent = models.ForeignKey('self', null=True, default=None)
#     contest = models.ForeignKey(Contest, null=True, default=None)
#     max_solution_size = models.PositiveIntegerField()
# 
#     # Default timestamps values for task. Can be overridden individually in
#     # groups. See GroupsTaskDetails.
#     open = models.DateTimeField(null=True, default=None)
#     deadline = models.DateTimeField(null=True, default=None)
#     close = models.DateTimeField(null=True, default=None)
# 
#     class Meta:
#         permissions = (
#             ('view_task', 'Can view task'),
#             ('submit_solution', 'Can submit solution'),
#             ('edit_task', 'Can edit task'))
# 
#     def __str__(self):
#         return self.name
# 
#     @property
#     def display_name(self):
#         if self.contest is not None and self.contest.name.strip() != "":
#             return "%s (%s)" % (self.name, self.contest.name)
#         else:
#             return self.name
# 
# 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


import floppyforms.__future__ as forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit
from django.contrib.auth.models import Group
from django.utils.timezone import now, timedelta
from harnas.contest.models import (Contest, GroupTaskDetails, News, Task,
                                   TestCase)
        model = Task
        fields = ['name', 'short_name', 'description', 'test_environment',
                  'max_solution_size']


class NewsForm(forms.ModelForm):
    class Meta:
        model = News
        fields = ['title', 'description']


class ContestForm(forms.ModelForm):
    class Meta:
        model = Contest
        fields = ['name', 'description']


class GroupForm(forms.ModelForm):
    class Meta:
        model = Group
        fields = ['name']


class TaskDetailsForm(forms.ModelForm):
    class Meta:
        model = GroupTaskDetails
        fields = ['open', 'deadline', 'close']


class TaskFetchForm(forms.Form):

# Path: harnas/contest/models.py
# class Contest(models.Model):
#     name = models.CharField(max_length=250, unique=True, null=False)
#     slug = models.SlugField()
#     description = models.TextField()
#     created_at = models.DateTimeField(auto_now_add=True)
#     modified_at = models.DateTimeField(auto_now=True)
#     creator = models.ForeignKey(User)
# 
#     class Meta:
#         permissions = (
#             ('view_contest', 'Can view'),
#             ('participate_in_contest', 'Can participate'),
#             ('manage_contest', 'Can manage contest'))
# 
#     def __str__(self):
#         return self.name
# 
# class GroupTaskDetails(models.Model):
#     group = models.ForeignKey(Group, null=False)
#     task = models.ForeignKey(Task, null=False)
# 
#     open = models.DateTimeField()
#     deadline = models.DateTimeField()
#     close = models.DateTimeField()
# 
#     class Meta:
#         index_together = ['group', 'task']
# 
# class News(models.Model):
#     title = models.CharField(max_length=250)
#     description = models.TextField()
#     created_at = models.DateTimeField(auto_now_add=True)
#     modified_at = models.DateTimeField(auto_now=True)
#     author = models.ForeignKey(User)
#     contest = models.ForeignKey(Contest)
# 
#     class Meta:
#         verbose_name_plural = "news"
# 
#     def __str__(self):
#         return self.title
# 
# class Task(models.Model):
#     name = models.CharField(max_length=250)
#     short_name = models.CharField(max_length=3)
#     description = models.TextField()
#     test_environment = models.ForeignKey('checker.TestEnvironment')
#     author = models.ForeignKey(User)
#     parent = models.ForeignKey('self', null=True, default=None)
#     contest = models.ForeignKey(Contest, null=True, default=None)
#     max_solution_size = models.PositiveIntegerField()
# 
#     # Default timestamps values for task. Can be overridden individually in
#     # groups. See GroupsTaskDetails.
#     open = models.DateTimeField(null=True, default=None)
#     deadline = models.DateTimeField(null=True, default=None)
#     close = models.DateTimeField(null=True, default=None)
# 
#     class Meta:
#         permissions = (
#             ('view_task', 'Can view task'),
#             ('submit_solution', 'Can submit solution'),
#             ('edit_task', 'Can edit task'))
# 
#     def __str__(self):
#         return self.name
# 
#     @property
#     def display_name(self):
#         if self.contest is not None and self.contest.name.strip() != "":
#             return "%s (%s)" % (self.name, self.contest.name)
#         else:
#             return self.name
# 
# 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/contest/forms.py
import floppyforms.__future__ as forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit
from django.contrib.auth.models import Group
from django.utils.timezone import now, timedelta
from harnas.contest.models import (Contest, GroupTaskDetails, News, Task,
                                   TestCase)

        model = Task
        fields = ['name', 'short_name', 'description', 'test_environment',
                  'max_solution_size']


class NewsForm(forms.ModelForm):
    class Meta:
        model = News
        fields = ['title', 'description']


class ContestForm(forms.ModelForm):
    class Meta:
        model = Contest
        fields = ['name', 'description']


class GroupForm(forms.ModelForm):
    class Meta:
        model = Group
        fields = ['name']


class TaskDetailsForm(forms.ModelForm):
    class Meta:
        model = GroupTaskDetails
        fields = ['open', 'deadline', 'close']


class TaskFetchForm(forms.Form):

    task = forms.ModelChoiceField(queryset=Task.objects.filter(parent=None),