Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hemp
Maják
Commits
2b1e7c4c
Commit
2b1e7c4c
authored
4 years ago
by
jan.bednarik
Browse files
Options
Downloads
Patches
Plain Diff
calendar utils: Update to new JSONField
parent
d2a8bb05
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
calendar_utils/models.py
+2
-2
2 additions, 2 deletions
calendar_utils/models.py
with
2 additions
and
2 deletions
calendar_utils/models.py
+
2
−
2
View file @
2b1e7c4c
import
arrow
import
requests
from
django.contrib.postgres.fields
import
JSONField
from
django.core.serializers.json
import
DjangoJSONEncoder
from
django.db
import
models
...
...
@@ -13,13 +12,14 @@ def _convert_arrow_to_datetime(event):
return
event
class
EventsJSONField
(
JSONField
):
class
EventsJSONField
(
models
.
JSONField
):
"""
JSONField for lists of events which converts `begin` and `end` to datetime
on load from DB.
"""
def
from_db_value
(
self
,
value
,
expression
,
connection
):
value
=
super
().
from_db_value
(
value
,
expression
,
connection
)
if
value
:
for
event
in
value
:
event
[
"
begin
"
]
=
arrow
.
get
(
event
[
"
begin
"
]).
datetime
...
...
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