mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 11:01:12 +00:00
Merge pull request #1 from dato/django-4.2
minor contributions to django 4.2 upgrade
This commit is contained in:
commit
44eedd09d9
3 changed files with 10 additions and 6 deletions
|
@ -551,8 +551,12 @@ class Edition(Book):
|
||||||
|
|
||||||
# clear author cache
|
# clear author cache
|
||||||
if self.id:
|
if self.id:
|
||||||
for author_id in self.authors.values_list("id", flat=True):
|
cache.delete_many(
|
||||||
cache.delete(f"author-books-{author_id}")
|
[
|
||||||
|
f"author-books-{author_id}"
|
||||||
|
for author_id in self.authors.values_list("id", flat=True)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def repair(self):
|
def repair(self):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
""" Database utilities """
|
""" Database utilities """
|
||||||
|
|
||||||
from typing import Optional, Iterable, Set, cast
|
from typing import Optional, Iterable, Set, cast
|
||||||
import sqlparse # type: ignore
|
import sqlparse # type: ignore[import-untyped]
|
||||||
|
|
||||||
|
|
||||||
def format_trigger(sql: str) -> str:
|
def format_trigger(sql: str) -> str:
|
||||||
|
|
|
@ -222,17 +222,17 @@ class PartialDateDescriptor:
|
||||||
return [("DAY", "Day prec."), ("MONTH", "Month prec."), ("YEAR", "Year prec.")]
|
return [("DAY", "Day prec."), ("MONTH", "Month prec."), ("YEAR", "Year prec.")]
|
||||||
|
|
||||||
|
|
||||||
class PartialDateModel(models.DateTimeField): # type: ignore
|
class PartialDateModel(models.DateTimeField): # type: ignore[type-arg]
|
||||||
"""a date field for Django models, using PartialDate as values"""
|
"""a date field for Django models, using PartialDate as values"""
|
||||||
|
|
||||||
descriptor_class = PartialDateDescriptor
|
descriptor_class = PartialDateDescriptor
|
||||||
|
|
||||||
def formfield(self, **kwargs): # type: ignore
|
def formfield(self, **kwargs): # type: ignore[no-untyped-def]
|
||||||
kwargs.setdefault("form_class", PartialDateFormField)
|
kwargs.setdefault("form_class", PartialDateFormField)
|
||||||
return super().formfield(**kwargs)
|
return super().formfield(**kwargs)
|
||||||
|
|
||||||
# pylint: disable-next=arguments-renamed
|
# pylint: disable-next=arguments-renamed
|
||||||
def contribute_to_class(self, model, our_name_in_model, **kwargs): # type: ignore
|
def contribute_to_class(self, model, our_name_in_model, **kwargs): # type: ignore[no-untyped-def]
|
||||||
# Define precision field.
|
# Define precision field.
|
||||||
descriptor = self.descriptor_class(self)
|
descriptor = self.descriptor_class(self)
|
||||||
precision: models.Field[Optional[str], Optional[str]] = models.CharField(
|
precision: models.Field[Optional[str], Optional[str]] = models.CharField(
|
||||||
|
|
Loading…
Reference in a new issue