fix: Set image as posted, get last posted image first
This commit is contained in:
parent
e02ec77308
commit
791330e415
@ -8,7 +8,7 @@ from django.urls import reverse
|
||||
from django.core.files import File
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.db.models import Q
|
||||
from datetime import datetime
|
||||
from django.utils import timezone
|
||||
|
||||
from imagebot import settings
|
||||
|
||||
@ -45,7 +45,8 @@ class Image(models.Model):
|
||||
|
||||
def set_image_posted(self):
|
||||
self.number_times_posted += 1
|
||||
self.last_posted = datetime.now()
|
||||
self.last_posted = timezone.now()
|
||||
self.save()
|
||||
|
||||
@staticmethod
|
||||
def consume():
|
||||
@ -70,5 +71,5 @@ class Image(models.Model):
|
||||
|
||||
@staticmethod
|
||||
def get_image_to_post():
|
||||
image = Image.objects.filter(Q(alt_text__isnull=False) & Q(title__isnull=False)).first()
|
||||
image = Image.objects.filter(Q(alt_text__isnull=False) & Q(title__isnull=False)).order_by('last_posted').first()
|
||||
return image
|
||||
|
Loading…
Reference in New Issue
Block a user