From deea76f8e0408261d2c2b0a0f067ccf83ec632b1 Mon Sep 17 00:00:00 2001 From: bashmak Date: Sun, 16 Apr 2017 12:52:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D1=82=D0=B0=D1=80=D1=8B=D0=B5=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B4=D0=B0=D1=87=D0=B8=20=D0=BF=D0=BE=D0=B4=D1=81=D0=B2?= =?UTF-8?q?=D0=B5=D1=87=D0=B8=D0=B2=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D1=81?= =?UTF-8?q?=D0=B5=D1=80=D1=8B=D0=BC=20=D0=B1=D0=BB=D0=B5=D0=B4=D0=BD=D1=8B?= =?UTF-8?q?=D0=BC=20=D1=81=D0=B2=D0=B5=D1=82=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taskapp/models.py | 3 +++ taskapp/templates/taskapp/tasklist_all.html | 2 +- taskapp/views.py | 4 +--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/taskapp/models.py b/taskapp/models.py index 4c5373d..b755fca 100644 --- a/taskapp/models.py +++ b/taskapp/models.py @@ -101,6 +101,9 @@ class Task(models.Model): def get_attachment_fname(self): return os.path.basename(self.attachment.name) + def is_outdated(self): + return self.out_date < timezone.now().date() + def task_handler(sender, instance, **kwargs): group = '' diff --git a/taskapp/templates/taskapp/tasklist_all.html b/taskapp/templates/taskapp/tasklist_all.html index 4ed5c92..ce4209c 100644 --- a/taskapp/templates/taskapp/tasklist_all.html +++ b/taskapp/templates/taskapp/tasklist_all.html @@ -32,7 +32,7 @@ {% for task in tasks %} - {% if task.out_date > current_date %} + {% if task.is_outdated %} {% else %} {% if task.priority == 'E' %} diff --git a/taskapp/views.py b/taskapp/views.py index 495ebbb..8200cf5 100644 --- a/taskapp/views.py +++ b/taskapp/views.py @@ -5,7 +5,6 @@ from django.shortcuts import render, redirect, get_object_or_404 from django.contrib import messages from abonapp.models import Abon from django.utils.translation import ugettext as _ -from django.utils import timezone from datetime import date from .models import Task from mydefs import pag_mn, only_admins, safe_int, MultipleException @@ -68,8 +67,7 @@ def all_tasks(request): tasks = Task.objects.all() tasks = pag_mn(request, tasks) return render(request, 'taskapp/tasklist_all.html', { - 'tasks': tasks, - 'current_date': timezone.now() + 'tasks': tasks })