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
Container registry
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
TO
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
Branches
Branches containing commit
No related tags found
2 merge requests
!93
Merge test
,
!91
Upgrade to wagtail 2.10.1
Pipeline
#1176
passed
4 years ago
Stage: build
Changes
1
Pipelines
2
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
arrow
import
requests
import
requests
from
django.contrib.postgres.fields
import
JSONField
from
django.core.serializers.json
import
DjangoJSONEncoder
from
django.core.serializers.json
import
DjangoJSONEncoder
from
django.db
import
models
from
django.db
import
models
...
@@ -13,13 +12,14 @@ def _convert_arrow_to_datetime(event):
...
@@ -13,13 +12,14 @@ def _convert_arrow_to_datetime(event):
return
event
return
event
class
EventsJSONField
(
JSONField
):
class
EventsJSONField
(
models
.
JSONField
):
"""
"""
JSONField for lists of events which converts `begin` and `end` to datetime
JSONField for lists of events which converts `begin` and `end` to datetime
on load from DB.
on load from DB.
"""
"""
def
from_db_value
(
self
,
value
,
expression
,
connection
):
def
from_db_value
(
self
,
value
,
expression
,
connection
):
value
=
super
().
from_db_value
(
value
,
expression
,
connection
)
if
value
:
if
value
:
for
event
in
value
:
for
event
in
value
:
event
[
"
begin
"
]
=
arrow
.
get
(
event
[
"
begin
"
]).
datetime
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