X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ae60b2a3949e96357477cc04f90fd0873cee8a92..dc73f49045fe845b141230a95f9122e2d90e6ff6:/src/waiter/models.py diff --git a/src/waiter/models.py b/src/waiter/models.py index bffaf7f8a..45ff80ed4 100644 --- a/src/waiter/models.py +++ b/src/waiter/models.py @@ -1,19 +1,16 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from os.path import join, isfile -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db import models from waiter.settings import WAITER_URL, WAITER_MAX_QUEUE from waiter.utils import check_abspath -from picklefield import PickledObjectField class WaitedFile(models.Model): path = models.CharField(max_length=255, unique=True, db_index=True) task_id = models.CharField(max_length=128, db_index=True, null=True, blank=True) - task = PickledObjectField(null=True, editable=False) description = models.CharField(max_length=255, null=True, blank=True) @classmethod @@ -52,9 +49,9 @@ class WaitedFile(models.Model): already = cls.exists(path) if not already: waited, created = cls.objects.get_or_create(path=path) - if created or waited.is_stale(): - waited.task = task_creator(check_abspath(path), waited.pk) - waited.task_id = waited.task.task_id + if created: + task = task_creator(check_abspath(path), waited.pk) + waited.task_id = task.task_id waited.description = description waited.save() return reverse("waiter", args=[path])