Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f409c726
authored
Jun 26, 2026
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add error handling for table creation in Alembic migrations
1 parent
884d29c3
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
241 additions
and
39 deletions
opensipkd/base/alembic/versions/021a8a342d5b_init_db.py
opensipkd/base/alembic/versions/10a68b1510a6_.py
opensipkd/base/alembic/versions/663de8bbd563_text_printer_init.py
opensipkd/base/models/__init__.py
opensipkd/base/models/departmen.py
opensipkd/base/models/users.py
opensipkd/base/views/departemen.py
opensipkd/base/alembic/versions/021a8a342d5b_init_db.py
View file @
f409c72
...
@@ -19,6 +19,7 @@ schema=None
...
@@ -19,6 +19,7 @@ schema=None
# schema = 'public'
# schema = 'public'
def
upgrade
():
def
upgrade
():
# ### commands auto generated by Alembic - please adjust! ###
# ### commands auto generated by Alembic - please adjust! ###
try
:
op
.
create_table
(
'groups'
,
op
.
create_table
(
'groups'
,
sa
.
Column
(
'member_count'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'member_count'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
...
@@ -30,12 +31,18 @@ def upgrade():
...
@@ -30,12 +31,18 @@ def upgrade():
mysql_charset
=
'utf8'
,
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
mysql_engine
=
'InnoDB'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'holiday'
,
op
.
create_table
(
'holiday'
,
sa
.
Column
(
'tanggal'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'tanggal'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
primary_key
=
True
,
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_holiday'
))
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_holiday'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'logs'
,
op
.
create_table
(
'logs'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
primary_key
=
True
,
nullable
=
False
),
...
@@ -48,6 +55,9 @@ def upgrade():
...
@@ -48,6 +55,9 @@ def upgrade():
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_logs'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_logs'
)),
sa
.
UniqueConstraint
(
'line_id'
,
name
=
op
.
f
(
'uq_logs_line_id'
))
sa
.
UniqueConstraint
(
'line_id'
,
name
=
op
.
f
(
'uq_logs_line_id'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'parameters'
,
op
.
create_table
(
'parameters'
,
sa
.
Column
(
'value'
,
sa
.
String
(
length
=
256
),
nullable
=
False
),
sa
.
Column
(
'value'
,
sa
.
String
(
length
=
256
),
nullable
=
False
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
...
@@ -61,6 +71,9 @@ def upgrade():
...
@@ -61,6 +71,9 @@ def upgrade():
primary_key
=
True
,
nullable
=
False
),
primary_key
=
True
,
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_parameters'
))
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_parameters'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'departemen'
,
op
.
create_table
(
'departemen'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
primary_key
=
True
,
nullable
=
False
),
...
@@ -81,6 +94,9 @@ def upgrade():
...
@@ -81,6 +94,9 @@ def upgrade():
# schema=schema
# schema=schema
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'permissions'
,
op
.
create_table
(
'permissions'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
primary_key
=
True
,
nullable
=
False
),
...
@@ -91,6 +107,9 @@ def upgrade():
...
@@ -91,6 +107,9 @@ def upgrade():
sa
.
UniqueConstraint
(
'perm_name'
,
name
=
op
.
f
(
'uq_permissions_perm_name'
)),
sa
.
UniqueConstraint
(
'perm_name'
,
name
=
op
.
f
(
'uq_permissions_perm_name'
)),
# schema=schema
# schema=schema
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'res_provinsi'
,
op
.
create_table
(
'res_provinsi'
,
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'ibu_kota'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
sa
.
Column
(
'ibu_kota'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
...
@@ -106,6 +125,9 @@ def upgrade():
...
@@ -106,6 +125,9 @@ def upgrade():
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_provinsi'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_provinsi'
)),
# schema=schema
# schema=schema
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'routes'
,
op
.
create_table
(
'routes'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
primary_key
=
True
,
nullable
=
False
),
...
@@ -133,6 +155,9 @@ def upgrade():
...
@@ -133,6 +155,9 @@ def upgrade():
sa
.
UniqueConstraint
(
'kode'
,
name
=
op
.
f
(
'uq_routes_kode'
)),
sa
.
UniqueConstraint
(
'kode'
,
name
=
op
.
f
(
'uq_routes_kode'
)),
sa
.
UniqueConstraint
(
'path'
,
name
=
op
.
f
(
'uq_routes_path'
))
sa
.
UniqueConstraint
(
'path'
,
name
=
op
.
f
(
'uq_routes_path'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'target_jenis'
,
op
.
create_table
(
'target_jenis'
,
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
...
@@ -145,6 +170,9 @@ def upgrade():
...
@@ -145,6 +170,9 @@ def upgrade():
primary_key
=
True
,
nullable
=
False
),
primary_key
=
True
,
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_target_jenis'
))
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_target_jenis'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'targets'
,
op
.
create_table
(
'targets'
,
sa
.
Column
(
'tahun'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'tahun'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'jenis'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'jenis'
,
sa
.
Integer
(),
nullable
=
False
),
...
@@ -171,6 +199,9 @@ def upgrade():
...
@@ -171,6 +199,9 @@ def upgrade():
primary_key
=
True
,
nullable
=
False
),
primary_key
=
True
,
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_targets'
))
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_targets'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'users'
,
op
.
create_table
(
'users'
,
sa
.
Column
(
'last_login_date'
,
sa
.
DateTime
(
timezone
=
True
),
nullable
=
True
),
sa
.
Column
(
'last_login_date'
,
sa
.
DateTime
(
timezone
=
True
),
nullable
=
True
),
sa
.
Column
(
'registered_date'
,
sa
.
DateTime
(
timezone
=
True
),
nullable
=
False
),
sa
.
Column
(
'registered_date'
,
sa
.
DateTime
(
timezone
=
True
),
nullable
=
False
),
...
@@ -196,6 +227,9 @@ def upgrade():
...
@@ -196,6 +227,9 @@ def upgrade():
mysql_charset
=
'utf8'
,
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
mysql_engine
=
'InnoDB'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'external_identities'
,
op
.
create_table
(
'external_identities'
,
sa
.
Column
(
'external_id'
,
sa
.
Unicode
(
length
=
255
),
nullable
=
False
),
sa
.
Column
(
'external_id'
,
sa
.
Unicode
(
length
=
255
),
nullable
=
False
),
sa
.
Column
(
'external_user_name'
,
sa
.
Unicode
(
length
=
255
),
nullable
=
True
),
sa
.
Column
(
'external_user_name'
,
sa
.
Unicode
(
length
=
255
),
nullable
=
True
),
...
@@ -209,6 +243,9 @@ def upgrade():
...
@@ -209,6 +243,9 @@ def upgrade():
mysql_charset
=
'utf8'
,
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
mysql_engine
=
'InnoDB'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'groups_permissions'
,
op
.
create_table
(
'groups_permissions'
,
sa
.
Column
(
'group_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'group_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'perm_name'
,
sa
.
Unicode
(
length
=
64
),
nullable
=
False
),
sa
.
Column
(
'perm_name'
,
sa
.
Unicode
(
length
=
64
),
nullable
=
False
),
...
@@ -218,6 +255,9 @@ def upgrade():
...
@@ -218,6 +255,9 @@ def upgrade():
mysql_engine
=
'InnoDB'
mysql_engine
=
'InnoDB'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'res_dati2'
,
op
.
create_table
(
'res_dati2'
,
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'ibu_kota'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
sa
.
Column
(
'ibu_kota'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
...
@@ -235,6 +275,9 @@ def upgrade():
...
@@ -235,6 +275,9 @@ def upgrade():
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_dati2'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_dati2'
)),
# schema=schema
# schema=schema
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'resources'
,
op
.
create_table
(
'resources'
,
sa
.
Column
(
'resource_id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
sa
.
Column
(
'resource_id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
autoincrement
=
True
,
nullable
=
False
),
primary_key
=
True
,
autoincrement
=
True
,
nullable
=
False
),
...
@@ -251,8 +294,17 @@ def upgrade():
...
@@ -251,8 +294,17 @@ def upgrade():
mysql_charset
=
'utf8'
,
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
mysql_engine
=
'InnoDB'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_index
(
op
.
f
(
'ix_resources_owner_group_id'
),
'resources'
,
[
'owner_group_id'
],
unique
=
False
)
op
.
create_index
(
op
.
f
(
'ix_resources_owner_group_id'
),
'resources'
,
[
'owner_group_id'
],
unique
=
False
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_index
(
op
.
f
(
'ix_resources_owner_user_id'
),
'resources'
,
[
'owner_user_id'
],
unique
=
False
)
op
.
create_index
(
op
.
f
(
'ix_resources_owner_user_id'
),
'resources'
,
[
'owner_user_id'
],
unique
=
False
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'user_device'
,
op
.
create_table
(
'user_device'
,
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
...
@@ -270,6 +322,9 @@ def upgrade():
...
@@ -270,6 +322,9 @@ def upgrade():
sa
.
ForeignKeyConstraint
([
'user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_user_device_user_id_users'
)),
sa
.
ForeignKeyConstraint
([
'user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_user_device_user_id_users'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_user_device'
))
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_user_device'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'users_groups'
,
op
.
create_table
(
'users_groups'
,
sa
.
Column
(
'group_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'group_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
False
),
...
@@ -279,6 +334,9 @@ def upgrade():
...
@@ -279,6 +334,9 @@ def upgrade():
mysql_charset
=
'utf8'
,
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
mysql_engine
=
'InnoDB'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'users_permissions'
,
op
.
create_table
(
'users_permissions'
,
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'perm_name'
,
sa
.
Unicode
(
length
=
64
),
nullable
=
False
),
sa
.
Column
(
'perm_name'
,
sa
.
Unicode
(
length
=
64
),
nullable
=
False
),
...
@@ -287,6 +345,9 @@ def upgrade():
...
@@ -287,6 +345,9 @@ def upgrade():
mysql_charset
=
'utf8'
,
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
mysql_engine
=
'InnoDB'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'groups_resources_permissions'
,
op
.
create_table
(
'groups_resources_permissions'
,
sa
.
Column
(
'group_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'group_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'resource_id'
,
sa
.
Integer
(),
autoincrement
=
False
,
nullable
=
False
),
sa
.
Column
(
'resource_id'
,
sa
.
Integer
(),
autoincrement
=
False
,
nullable
=
False
),
...
@@ -297,6 +358,9 @@ def upgrade():
...
@@ -297,6 +358,9 @@ def upgrade():
mysql_charset
=
'utf8'
,
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
mysql_engine
=
'InnoDB'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'res_kecamatan'
,
op
.
create_table
(
'res_kecamatan'
,
sa
.
Column
(
'ibu_kota'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
sa
.
Column
(
'ibu_kota'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
sa
.
Column
(
'dati2_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'dati2_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
...
@@ -313,6 +377,9 @@ def upgrade():
...
@@ -313,6 +377,9 @@ def upgrade():
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_kecamatan'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_kecamatan'
)),
# schema=schema
# schema=schema
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'users_resources_permissions'
,
op
.
create_table
(
'users_resources_permissions'
,
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'resource_id'
,
sa
.
Integer
(),
autoincrement
=
False
,
nullable
=
False
),
sa
.
Column
(
'resource_id'
,
sa
.
Integer
(),
autoincrement
=
False
,
nullable
=
False
),
...
@@ -323,6 +390,9 @@ def upgrade():
...
@@ -323,6 +390,9 @@ def upgrade():
mysql_charset
=
'utf8'
,
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
mysql_engine
=
'InnoDB'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'res_desa'
,
op
.
create_table
(
'res_desa'
,
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'kecamatan_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'kecamatan_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
...
@@ -339,6 +409,9 @@ def upgrade():
...
@@ -339,6 +409,9 @@ def upgrade():
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_desa'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_desa'
)),
# schema=schema
# schema=schema
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'partner'
,
op
.
create_table
(
'partner'
,
sa
.
Column
(
'kelurahan'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'kelurahan'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'kecamatan'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'kecamatan'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
...
@@ -385,6 +458,9 @@ def upgrade():
...
@@ -385,6 +458,9 @@ def upgrade():
sa
.
ForeignKeyConstraint
([
'provinsi_id'
],
[
'res_provinsi.id'
],
name
=
op
.
f
(
'fk_partner_provinsi_id_res_provinsi'
)),
sa
.
ForeignKeyConstraint
([
'provinsi_id'
],
[
'res_provinsi.id'
],
name
=
op
.
f
(
'fk_partner_provinsi_id_res_provinsi'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_partner'
))
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_partner'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'user_area'
,
op
.
create_table
(
'user_area'
,
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'desa_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'desa_id'
,
sa
.
Integer
(),
nullable
=
True
),
...
@@ -394,6 +470,9 @@ def upgrade():
...
@@ -394,6 +470,9 @@ def upgrade():
sa
.
ForeignKeyConstraint
([
'user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_user_area_user_id_users'
)),
sa
.
ForeignKeyConstraint
([
'user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_user_area_user_id_users'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_user_area'
))
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_user_area'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'partner_files'
,
op
.
create_table
(
'partner_files'
,
sa
.
Column
(
'partner_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'partner_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'file_name'
,
sa
.
String
(
length
=
256
),
nullable
=
False
),
sa
.
Column
(
'file_name'
,
sa
.
String
(
length
=
256
),
nullable
=
False
),
...
@@ -408,37 +487,121 @@ def upgrade():
...
@@ -408,37 +487,121 @@ def upgrade():
sa
.
ForeignKeyConstraint
([
'partner_id'
],
[
'partner.id'
],
name
=
op
.
f
(
'fk_partner_files_partner_id_partner'
)),
sa
.
ForeignKeyConstraint
([
'partner_id'
],
[
'partner.id'
],
name
=
op
.
f
(
'fk_partner_files_partner_id_partner'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_partner_files'
))
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_partner_files'
))
)
)
except
Exception
as
e
:
print
(
str
(
e
))
# ### end Alembic commands ###
# ### end Alembic commands ###
def
downgrade
():
def
downgrade
():
# ### commands auto generated by Alembic - please adjust! ###
# ### commands auto generated by Alembic - please adjust! ###
try
:
op
.
drop_table
(
'partner_files'
)
op
.
drop_table
(
'partner_files'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'user_area'
)
op
.
drop_table
(
'user_area'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'partner'
)
op
.
drop_table
(
'partner'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'res_desa'
)
#, schema=schema
op
.
drop_table
(
'res_desa'
)
#, schema=schema
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'users_resources_permissions'
)
op
.
drop_table
(
'users_resources_permissions'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'res_kecamatan'
),
# schema = schema
op
.
drop_table
(
'res_kecamatan'
),
# schema = schema
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'groups_resources_permissions'
)
op
.
drop_table
(
'groups_resources_permissions'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'users_permissions'
)
op
.
drop_table
(
'users_permissions'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'users_groups'
)
op
.
drop_table
(
'users_groups'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'user_device'
)
op
.
drop_table
(
'user_device'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_index
(
op
.
f
(
'ix_resources_owner_user_id'
),
table_name
=
'resources'
)
op
.
drop_index
(
op
.
f
(
'ix_resources_owner_user_id'
),
table_name
=
'resources'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_index
(
op
.
f
(
'ix_resources_owner_group_id'
),
table_name
=
'resources'
)
op
.
drop_index
(
op
.
f
(
'ix_resources_owner_group_id'
),
table_name
=
'resources'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'resources'
)
op
.
drop_table
(
'resources'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'res_dati2'
)
op
.
drop_table
(
'res_dati2'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'groups_permissions'
)
op
.
drop_table
(
'groups_permissions'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'external_identities'
)
op
.
drop_table
(
'external_identities'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'users'
)
op
.
drop_table
(
'users'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'targets'
)
op
.
drop_table
(
'targets'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'target_jenis'
)
op
.
drop_table
(
'target_jenis'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'routes'
)
op
.
drop_table
(
'routes'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'res_provinsi'
)
op
.
drop_table
(
'res_provinsi'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'permissions'
)
op
.
drop_table
(
'permissions'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'departemen'
)
op
.
drop_table
(
'departemen'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'parameters'
)
op
.
drop_table
(
'parameters'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'logs'
)
op
.
drop_table
(
'logs'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'holiday'
)
op
.
drop_table
(
'holiday'
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
drop_table
(
'groups'
)
op
.
drop_table
(
'groups'
)
except
Exception
as
e
:
print
(
str
(
e
))
# ### end Alembic commands ###
# ### end Alembic commands ###
opensipkd/base/alembic/versions/10a68b1510a6_.py
View file @
f409c72
...
@@ -18,6 +18,7 @@ depends_on = None
...
@@ -18,6 +18,7 @@ depends_on = None
def
upgrade
():
def
upgrade
():
# ### commands auto generated by Alembic - please adjust! ###
# ### commands auto generated by Alembic - please adjust! ###
try
:
op
.
create_table
(
'eselon'
,
op
.
create_table
(
'eselon'
,
sa
.
Column
(
'pangkat'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'pangkat'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'ruang'
,
sa
.
String
(
length
=
1
),
nullable
=
True
),
sa
.
Column
(
'ruang'
,
sa
.
String
(
length
=
1
),
nullable
=
True
),
...
@@ -29,10 +30,14 @@ def upgrade():
...
@@ -29,10 +30,14 @@ def upgrade():
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_eselon'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_eselon'
)),
# schema='public'
# schema='public'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'pangkat'
,
op
.
create_table
(
'pangkat'
,
sa
.
Column
(
'pangkat'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'pangkat'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'ruang'
,
sa
.
String
(
length
=
1
),
nullable
=
True
),
sa
.
Column
(
'ruang'
,
sa
.
String
(
length
=
1
),
nullable
=
True
),
...
@@ -43,10 +48,14 @@ def upgrade():
...
@@ -43,10 +48,14 @@ def upgrade():
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_pangkat'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_pangkat'
)),
# schema='public'
# schema='public'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'jabatan'
,
op
.
create_table
(
'jabatan'
,
sa
.
Column
(
'jenis'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'jenis'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'nama_lain'
,
sa
.
String
(
sa
.
Column
(
'nama_lain'
,
sa
.
String
(
...
@@ -61,19 +70,24 @@ def upgrade():
...
@@ -61,19 +70,24 @@ def upgrade():
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'eselon_id'
],
[
'eselon.id'
],
name
=
op
.
f
(
sa
.
ForeignKeyConstraint
([
'eselon_id'
],
[
'eselon.id'
],
name
=
op
.
f
(
'fk_jabatan_eselon_id_eselon'
)),
'fk_jabatan_eselon_id_eselon'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_jabatan'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_jabatan'
)),
# schema='public'
# schema='public'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
try
:
op
.
create_table
(
'partner_departemen'
,
op
.
create_table
(
'partner_departemen'
,
sa
.
Column
(
'partner_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'partner_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'departemen_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'departemen_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'jabatan_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'jabatan_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'mulai'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'mulai'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'selesai'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'selesai'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'departemen_id'
],
[
'departemen.id'
],
name
=
op
.
f
(
sa
.
ForeignKeyConstraint
([
'departemen_id'
],
[
'departemen.id'
],
name
=
op
.
f
(
'fk_partner_departemen_departemen_id_departemen'
)),
'fk_partner_departemen_departemen_id_departemen'
)),
sa
.
ForeignKeyConstraint
([
'jabatan_id'
],
[
'jabatan.id'
],
name
=
op
.
f
(
sa
.
ForeignKeyConstraint
([
'jabatan_id'
],
[
'jabatan.id'
],
name
=
op
.
f
(
...
@@ -86,6 +100,9 @@ def upgrade():
...
@@ -86,6 +100,9 @@ def upgrade():
'jabatan_id'
,
'mulai'
,
name
=
'partner_dept_uq'
),
'jabatan_id'
,
'mulai'
,
name
=
'partner_dept_uq'
),
# schema='public'
# schema='public'
)
)
except
Exception
as
e
:
print
(
str
(
e
))
# ### end Alembic commands ###
# ### end Alembic commands ###
...
...
opensipkd/base/alembic/versions/663de8bbd563_text_printer_init.py
View file @
f409c72
...
@@ -30,7 +30,8 @@ def upgrade():
...
@@ -30,7 +30,8 @@ def upgrade():
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
sa
.
Identity
(
always
=
True
),
primary_key
=
True
,
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_text_printers'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_text_printers'
)),
# schema='public'
# schema='public'
)
)
...
...
opensipkd/base/models/__init__.py
View file @
f409c72
from
datetime
import
datetime
,
timezone
import
sqlalchemy
as
sa
class
ForceUTCDatetime
(
sa
.
TypeDecorator
):
"""Ensures datetimes are timezone-aware UTC objects across both DBs."""
impl
=
sa
.
TIMESTAMP
(
timezone
=
True
)
cache_ok
=
True
def
process_bind_param
(
self
,
value
,
dialect
):
if
value
is
not
None
:
if
value
.
tzinfo
is
None
:
# Interpret naive datetime as UTC or handle according to business logic
value
=
value
.
replace
(
tzinfo
=
timezone
.
utc
)
else
:
# Convert any other timezone directly to UTC
value
=
value
.
astimezone
(
timezone
.
utc
)
return
value
def
process_result_value
(
self
,
value
,
dialect
):
if
value
is
not
None
and
value
.
tzinfo
is
None
:
# Force the Python object to be aware if Oracle stripped the offset
return
value
.
replace
(
tzinfo
=
timezone
.
utc
)
return
value
from
.meta
import
*
from
.meta
import
*
from
.common
import
*
from
.common
import
*
from
.base
import
*
from
.base
import
*
...
...
opensipkd/base/models/departmen.py
View file @
f409c72
...
@@ -59,7 +59,7 @@ class _Departemen(NamaModel):
...
@@ -59,7 +59,7 @@ class _Departemen(NamaModel):
eng
=
cls
.
db_session
.
get_bind
()
eng
=
cls
.
db_session
.
get_bind
()
if
eng
.
dialect
.
name
.
lower
()
==
"oracle"
:
if
eng
.
dialect
.
name
.
lower
()
==
"oracle"
:
sql
=
"""
sql
=
"""
SELECT
SELECT
--LPAD(' ', (LEVEL - 1) * 2) || nama AS hierarchy,
--LPAD(' ', (LEVEL - 1) * 2) || nama AS hierarchy,
SYS_CONNECT_BY_PATH(nama, '/') AS hierarchy,
SYS_CONNECT_BY_PATH(nama, '/') AS hierarchy,
id,
id,
...
@@ -69,62 +69,56 @@ SELECT
...
@@ -69,62 +69,56 @@ SELECT
status,
status,
(LEVEL - 1) AS lvl,
(LEVEL - 1) AS lvl,
SYS_CONNECT_BY_PATH(id, ',') AS path
SYS_CONNECT_BY_PATH(id, ',') AS path
FROM
FROM
departemen
departemen
START WITH
START WITH
parent_id IS NULL
parent_id IS NULL
CONNECT BY
CONNECT BY
PRIOR id = parent_id
PRIOR id = parent_id
ORDER SIBLINGS BY
ORDER SIBLINGS BY
id
"""
id
"""
else
:
else
:
sql
=
"""
sql
=
"""
WITH RECURSIVE dep_tree AS (
WITH RECURSIVE dep_tree AS (
SELECT
SELECT
id,
id,
kode,
kode,
nama,
nama::text AS
nama,
parent_id,
parent_id,
status,
status,
0 AS lvl,
0 AS lvl,
ARRAY[id] AS path
ARRAY[id] AS path
FROM
FROM departemen
public.departemen
WHERE
{str_where}
UNION ALL
UNION ALL
SELECT
SELECT
c.id,
c.id,
c.kode,
c.kode,
c.
nama,
ct.nama || '/' || c.nama::text AS
nama,
c.parent_id,
c.parent_id,
c.status,
c.status,
ct.leve
l + 1,
ct.lv
l + 1,
ct.path || c.id
ct.path || c.id
FROM
FROM departemen c
public.departemen c
JOIN dep_tree ct ON c.parent_id = ct.id
JOIN
dep_tree ct ON c.parent_id = ct.id
)
)
SELECT
SELECT DISTINCT ON (kode)
REPEAT(' ', lvl) || nama AS hierarchy, -- Indent names based on level
id,
id,
kode,
kode,
nama
,
nama as hierarchy
,
parent_id,
parent_id,
status,
status,
leve
l,
lv
l,
path
path
FROM
FROM
dep_tree
dep_tree
"""
"""
.
format
(
str_where
=
str_where
)
#
.format(str_where=str_where)
if
search
:
if
search
:
sql
=
f
"{sql} WHERE nama ILIKE '
%
{search}
%
' "
sql
=
f
"{sql} WHERE nama ILIKE '
%
{search}
%
' "
sql
=
sql
+
"""ORDER BY
path;
"""
sql
=
sql
+
"""ORDER BY
kode, path
"""
return
cls
.
db_session
.
execute
(
text
(
sql
))
.
fetchall
()
return
cls
.
db_session
.
execute
(
text
(
sql
))
.
fetchall
()
...
...
opensipkd/base/models/users.py
View file @
f409c72
from
datetime
import
datetime
from
datetime
import
datetime
import
logging
import
logging
from
math
import
log
from
requests
import
session
import
pytz
import
sqlalchemy
as
sa
import
sqlalchemy
as
sa
from
pyramid.authorization
import
(
Allow
,
Authenticated
,
ALL_PERMISSIONS
)
from
pyramid.authorization
import
(
Allow
,
Authenticated
,
ALL_PERMISSIONS
)
# from sqlalchemy import TIMESTAMP
from
sqlalchemy
import
(
from
sqlalchemy
import
(
Column
,
Integer
,
DateTime
,
SmallInteger
,
String
)
Column
,
Integer
,
DateTime
,
SmallInteger
,
String
)
from
sqlalchemy.orm
import
(
relationship
,
backref
)
from
sqlalchemy.orm
import
(
relationship
,
backref
)
...
@@ -28,7 +26,7 @@ from opensipkd.tools import as_timezone
...
@@ -28,7 +26,7 @@ from opensipkd.tools import as_timezone
from
.base
import
CommonModel
,
DBSession
,
DefaultModel
from
.base
import
CommonModel
,
DBSession
,
DefaultModel
from
.meta
import
Base
from
.meta
import
Base
from
.base
import
TABLE_ARGS
from
.base
import
TABLE_ARGS
from
.
import
ForceUTCDatetime
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
class
_GroupPermission
(
GroupPermissionMixin
):
class
_GroupPermission
(
GroupPermissionMixin
):
pass
pass
...
@@ -93,7 +91,7 @@ class _UserResourcePermission(UserResourcePermissionMixin):
...
@@ -93,7 +91,7 @@ class _UserResourcePermission(UserResourcePermissionMixin):
class
UserResourcePermission
(
_UserResourcePermission
,
Base
):
class
UserResourcePermission
(
_UserResourcePermission
,
Base
):
pass
pass
from
sqlalchemy
import
TIMESTAMP
class
_User
(
UserMixin
,
BaseModel
):
class
_User
(
UserMixin
,
BaseModel
):
db_session
=
DBSession
db_session
=
DBSession
last_login_date
=
Column
(
DateTime
(
timezone
=
True
),
nullable
=
True
)
last_login_date
=
Column
(
DateTime
(
timezone
=
True
),
nullable
=
True
)
...
@@ -106,7 +104,8 @@ class _User(UserMixin, BaseModel):
...
@@ -106,7 +104,8 @@ class _User(UserMixin, BaseModel):
# 'Asia/Jakarta')),
# 'Asia/Jakarta')),
# server_default="2000-01-01 01:01+7",
# server_default="2000-01-01 01:01+7",
# )
# )
security_code_date
=
Column
(
TIMESTAMP
(
timezone
=
True
))
# security_code_date = Column(TIMESTAMP(timezone=True))
security_code_date
=
Column
(
ForceUTCDatetime
)
api_key
=
Column
(
String
(
256
))
api_key
=
Column
(
String
(
256
))
partner_id
=
Column
(
Integer
)
# , ForeignKey(Partner.id))
partner_id
=
Column
(
Integer
)
# , ForeignKey(Partner.id))
company_id
=
Column
(
Integer
)
# , ForeignKey(Partner.id))
company_id
=
Column
(
Integer
)
# , ForeignKey(Partner.id))
...
...
opensipkd/base/views/departemen.py
View file @
f409c72
...
@@ -179,7 +179,10 @@ class Views(BaseView):
...
@@ -179,7 +179,10 @@ class Views(BaseView):
url_dict
=
request
.
matchdict
url_dict
=
request
.
matchdict
if
url_dict
[
'act'
]
==
'grid'
:
if
url_dict
[
'act'
]
==
'grid'
:
query
=
Departemen
.
cte_get
()
query
=
Departemen
.
cte_get
()
data
=
[{
"id"
:
d
.
id
,
"kode"
:
d
.
kode
,
"nama"
:
d
.
hierarchy
[
1
:],
"status"
:
d
.
status
,
data
=
[{
"id"
:
d
.
id
,
"kode"
:
d
.
kode
,
"nama"
:
d
.
hierarchy
.
startswith
(
'/'
)
and
d
.
hierarchy
[
1
:]
or
d
.
hierarchy
,
"status"
:
d
.
status
,
"level_id"
:
d
.
lvl
,
"parent_id"
:
d
.
parent_id
}
for
d
in
query
]
"level_id"
:
d
.
lvl
,
"parent_id"
:
d
.
parent_id
}
for
d
in
query
]
return
{
return
{
...
...
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