# Path: apps/quests/models.py
# class QuestAnswer(qtils.CreateAndUpdateDateMixin, qtils.ModelDiffMixin, models.Model):
#     """Model that describes someones try to score quest"""
#     quest_variant = models.ForeignKey(QuestVariant, blank=False, null=False)
# 
#     is_checked = models.BooleanField(default=False, null=False, blank=False, db_index=True)
#     is_success = models.BooleanField(default=False, null=False, blank=False, db_index=True)
# 
#     result = models.TextField(editable=True, blank=True, null=False)
#     score = models.IntegerField(default=0, null=False, blank=False, db_index=True)
# 
#     answer = models.TextField()
#     answer_file = models.FileField(upload_to="media", editable=False)
# 
#     class Meta(object):
#         index_together = [
#             ['is_success', 'is_checked'],
#             ['quest_variant', 'is_success', 'is_checked'],
#         ]
# 
#     @classmethod
#     def count_by_time(cls, team, period=timedelta(minutes=1)):
#         return cls.objects.filter(quest_variant__team__id=team.id, created_at__gte=timezone.now() - period).aggregate(
#             count=Count('id'))['count']
# 
#     def check_answer(self):
#         status, message = self.quest_variant.check_answer(self.answer)
#         self.is_checked = True
#         self.is_success = status
#         self.result = message
#         self.score = self.quest_variant.quest.score
#         self.save()
# 
#     def get_absolute_url(self):
#         from django.core.urlresolvers import reverse
# 
#         return reverse('quests.views.check_answer', args=[self.id])


from django import forms
from .models import QuestAnswer
from django.utils.translation import ugettext as _
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals, absolute_import


__author__ = 'Last G'


class AnswerForm(forms.ModelForm):
    class Meta:
        model = QuestAnswer

# Path: apps/quests/models.py
# class QuestAnswer(qtils.CreateAndUpdateDateMixin, qtils.ModelDiffMixin, models.Model):
#     """Model that describes someones try to score quest"""
#     quest_variant = models.ForeignKey(QuestVariant, blank=False, null=False)
# 
#     is_checked = models.BooleanField(default=False, null=False, blank=False, db_index=True)
#     is_success = models.BooleanField(default=False, null=False, blank=False, db_index=True)
# 
#     result = models.TextField(editable=True, blank=True, null=False)
#     score = models.IntegerField(default=0, null=False, blank=False, db_index=True)
# 
#     answer = models.TextField()
#     answer_file = models.FileField(upload_to="media", editable=False)
# 
#     class Meta(object):
#         index_together = [
#             ['is_success', 'is_checked'],
#             ['quest_variant', 'is_success', 'is_checked'],
#         ]
# 
#     @classmethod
#     def count_by_time(cls, team, period=timedelta(minutes=1)):
#         return cls.objects.filter(quest_variant__team__id=team.id, created_at__gte=timezone.now() - period).aggregate(
#             count=Count('id'))['count']
# 
#     def check_answer(self):
#         status, message = self.quest_variant.check_answer(self.answer)
#         self.is_checked = True
#         self.is_success = status
#         self.result = message
#         self.score = self.quest_variant.quest.score
#         self.save()
# 
#     def get_absolute_url(self):
#         from django.core.urlresolvers import reverse
# 
#         return reverse('quests.views.check_answer', args=[self.id])


# Path: apps/quests/forms.py
from django import forms
from .models import QuestAnswer
from django.utils.translation import ugettext as _

# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals, absolute_import


__author__ = 'Last G'


class AnswerForm(forms.ModelForm):
    class Meta:
        model = QuestAnswer

        fields = ['answer']