This commit is contained in:
Egor Matveev
2022-01-22 15:08:12 +03:00
parent cabbace972
commit a49ecded94
5 changed files with 23 additions and 8 deletions

View File

@@ -1,4 +1,15 @@
from django import template
from Main.models import Solution
register = template.Library()
@register.filter('solved')
def solved(user, task):
solutions = Solution.objects.filter(user=user, task=task)
if len(solutions.filter(result='OK')) != 0:
return True
if len(solutions) != 0:
return False
return None

View File

@@ -7,9 +7,6 @@ class TasksView(BaseView):
required_login = True
endpoint = "tasks"
def get(self):
self.context["tasks"] = Task.objects.filter(public=True).order_by('-time_estimation')
def post(self):
task_name = self.request.POST["name"]
task = Task.objects.create(name=task_name, creator=self.request.user)