Code review comments

This commit is contained in:
Paul Konstantin Gerke 2022-02-27 21:12:01 +01:00
parent c665ebb181
commit a35df92fe2
2 changed files with 4 additions and 8 deletions

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
import re
import time
from datetime import timedelta
from typing import Iterable, Optional
@ -12,7 +10,6 @@ from django.utils.text import slugify
from django.utils import timezone
from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy as _
from django.utils.timezone import now
from django.core.validators import RegexValidator
import random
@ -20,7 +17,7 @@ import random
from taggit.managers import TaggableManager
from taggit.models import TagBase, GenericTaggedItemBase, TaggedItemBase
random.seed(time.time())
random.seed()
def validate_date(date, field_name):
@ -120,7 +117,7 @@ class BabyBuddyTag(TagBase):
)
last_used = models.DateTimeField(
default=now,
default=timezone.now,
blank=False,
)
@ -133,7 +130,7 @@ class BabyBuddyTagged(GenericTaggedItemBase):
)
def save_base(self, *args, **kwargs):
self.tag.last_used = now()
self.tag.last_used = timezone.now()
self.tag.save()
return super().save_base(*args, **kwargs)

View File

@ -2,6 +2,7 @@ from django.forms import Media
from typing import Any, Dict, Optional
from django.forms import Widget
from . import models
class TagsEditor(Widget):
class Media:
@ -27,8 +28,6 @@ class TagsEditor(Widget):
return attrs
def get_context(self, name: str, value: Any, attrs) -> Dict[str, Any]:
from . import models
most_tags = models.BabyBuddyTag.objects.order_by("-last_used").all()[:256]
result = super().get_context(name, value, attrs)