Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
916003e8
Commit
916003e8
authored
3 years ago
by
Jonas Braathen
Browse files
Options
Downloads
Patches
Plain Diff
Replace use of greg.utils.utcnow with django.utils.timezone.now
parent
6b139807
No related branches found
No related tags found
1 merge request
!41
Identity model changes
Pipeline
#91909
passed
3 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
greg/models.py
+2
-3
2 additions, 3 deletions
greg/models.py
greg/tests/models/test_person.py
+3
-3
3 additions, 3 deletions
greg/tests/models/test_person.py
greg/utils.py
+0
-6
0 additions, 6 deletions
greg/utils.py
with
5 additions
and
12 deletions
greg/models.py
+
2
−
3
View file @
916003e8
...
...
@@ -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
=
utc
now
(),
verified_at__lte
=
timezone
.
now
(),
).
count
()
>=
1
)
...
...
This diff is collapsed.
Click to expand it.
greg/tests/models/test_person.py
+
3
−
3
View file @
916003e8
...
...
@@ -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
=
utc
now
()
-
timedelta
(
days
=
365
)
_a_year_into_future
=
utc
now
()
+
timedelta
(
days
=
365
)
_a_year_ago
=
timezone
.
now
()
-
timedelta
(
days
=
365
)
_a_year_into_future
=
timezone
.
now
()
+
timedelta
(
days
=
365
)
@pytest.fixture
...
...
This diff is collapsed.
Click to expand it.
greg/utils.py
+
0
−
6
View file @
916003e8
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment