Skip to content
Snippets Groups Projects
Commit 916003e8 authored by Jonas Braathen's avatar Jonas Braathen
Browse files

Replace use of greg.utils.utcnow with django.utils.timezone.now

parent 6b139807
No related branches found
No related tags found
1 merge request!41Identity model changes
Pipeline #91909 passed
......@@ -4,8 +4,7 @@ from dirtyfields import DirtyFieldsMixin
from django.db import models
from django.db.models import Lookup
from django.db.models.fields import Field
from greg.utils import utcnow
from django.utils import timezone
@Field.register_lookup
......@@ -109,7 +108,7 @@ class Person(BaseModel):
return (
self.identities.filter(
verified_at__isnull=False,
verified_at__lte=utcnow(),
verified_at__lte=timezone.now(),
).count()
>= 1
)
......
......@@ -2,6 +2,7 @@ from datetime import timedelta
from functools import partial
import pytest
from django.utils import timezone
from greg.models import (
OrganizationalUnit,
......@@ -11,7 +12,6 @@ from greg.models import (
RoleType,
Sponsor,
)
from greg.utils import utcnow
role_with = partial(
Role.objects.create,
......@@ -21,8 +21,8 @@ role_with = partial(
available_in_search=True,
)
_a_year_ago = utcnow() - timedelta(days=365)
_a_year_into_future = utcnow() + timedelta(days=365)
_a_year_ago = timezone.now() - timedelta(days=365)
_a_year_into_future = timezone.now() + timedelta(days=365)
@pytest.fixture
......
import datetime
import re
def camel_to_snake(s: str) -> str:
"""Turns `FooBar` into `foo_bar`."""
return re.sub("([A-Z])", "_\\1", s).lower().lstrip("_")
def utcnow() -> datetime.datetime:
"""The current date and time with the timezone set to UTC."""
return datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment