Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
irul
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9b14a9e7
authored
Aug 05, 2024
by
aagusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perbaikan from dict
1 parent
3aece825
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
opensipkd/models/base.py
opensipkd/models/base.py
View file @
9b14a9e
...
...
@@ -64,11 +64,13 @@ class CommonModel(object):
def
from_dict
(
self
,
values
,
date_format
=
"
%
d-
%
m-
%
Y"
):
for
column
in
self
.
__table__
.
columns
:
if
column
.
name
in
values
:
if
type
(
column
.
type
)
==
DateTime
and
date_format
:
if
values
[
column
.
name
]:
setattr
(
self
,
column
.
name
,
datetime
.
strptime
(
values
[
column
.
name
],
date_format
))
else
:
setattr
(
self
,
column
.
name
,
values
[
column
.
name
])
if
type
(
column
.
type
)
is
DateTime
and
date_format
:
if
values
[
column
.
name
]
and
type
(
values
[
column
.
name
])
is
String
:
setattr
(
self
,
column
.
name
,
datetime
.
strptime
(
values
[
column
.
name
],
date_format
))
continue
setattr
(
self
,
column
.
name
,
values
[
column
.
name
])
def
as_timezone
(
self
,
fieldname
):
date_
=
getattr
(
self
,
fieldname
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment