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 d5048ee2
authored
Sep 05, 2024
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perbaikan base
1 parent
7dd0a9ed
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
12 deletions
opensipkd/base/scripts/data/groups.csv
opensipkd/base/scripts/data/routes.csv
opensipkd/base/scripts/initializedb.py
opensipkd/base/views/base_views.py
opensipkd/base/views/departemen.py
opensipkd/models/users.py
opensipkd/base/scripts/data/groups.csv
View file @
d5048ee
group_name,description
"Superuser","Superuser"
"Web Service","Webservice"
"Pindah Departemen","Pindah Departemen"
"Guest","Guest"
\ No newline at end of file
\ No newline at end of file
group_name,description,member_count
"Superuser","Superuser",0
"Web Service","Webservice",0
"Pindah Departemen","Pindah Departemen",0
"Guest","Guest",0
\ No newline at end of file
\ No newline at end of file
opensipkd/base/scripts/data/routes.csv
View file @
d5048ee
This diff is collapsed.
Click to expand it.
opensipkd/base/scripts/initializedb.py
View file @
d5048ee
...
@@ -254,9 +254,8 @@ def append_csv(table, filename, keys, get_file_func=get_file,
...
@@ -254,9 +254,8 @@ def append_csv(table, filename, keys, get_file_func=get_file,
# Penambahan checking field nullable false wajib ada datanya 2024-09-05
# Penambahan checking field nullable false wajib ada datanya 2024-09-05
for
c
in
columns_table
:
for
c
in
columns_table
:
if
(
not
c
[
"nullable"
]
and
(
c
[
"name"
]
not
in
data
or
not
data
[
c
[
"name"
]])
if
(
not
c
[
"nullable"
]
and
c
[
"name"
]
not
in
data
and
c
[
"name"
]
!=
"id"
):
and
c
[
"name"
]
!=
"id"
):
raise
Exception
(
f
"Field '{c['name']}' wajib ada {c} "
)
raise
Exception
(
f
"Field '{c['name']}' wajib ada {data}"
)
db_session
.
add
(
row
)
db_session
.
add
(
row
)
db_session
.
flush
()
db_session
.
flush
()
...
...
opensipkd/base/views/base_views.py
View file @
d5048ee
...
@@ -366,7 +366,7 @@ class BaseView(object):
...
@@ -366,7 +366,7 @@ class BaseView(object):
output_file
.
write
(
data
)
output_file
.
write
(
data
)
output_file
.
close
()
output_file
.
close
()
try
:
try
:
self
.
save_upload
(
fullpath
,
delimiter
=
delimiter
,
**
args
)
self
.
save_upload
(
fullpath
,
**
args
)
except
Exception
as
e
:
except
Exception
as
e
:
self
.
req
.
session
.
flash
(
str
(
e
),
'error'
)
self
.
req
.
session
.
flash
(
str
(
e
),
'error'
)
return
dict
(
form
=
form
.
render
(),
return
dict
(
form
=
form
.
render
(),
...
@@ -384,9 +384,9 @@ class BaseView(object):
...
@@ -384,9 +384,9 @@ class BaseView(object):
def
get_file
(
self
,
filename
):
def
get_file
(
self
,
filename
):
return
open
(
filename
)
return
open
(
filename
)
def
save_upload
(
self
,
file_name
,
delimiter
=
","
,
**
args
):
def
save_upload
(
self
,
file_name
,
**
args
):
return
append_csv
(
self
.
table
,
file_name
,
self
.
upload_keys
,
return
append_csv
(
self
.
table
,
file_name
,
self
.
upload_keys
,
get_file_func
=
self
.
get_file
,
update_exist
=
True
,
delimiter
=
delimiter
,
get_file_func
=
self
.
get_file
,
update_exist
=
True
,
**
args
)
**
args
)
def
before_add
(
self
):
def
before_add
(
self
):
...
...
opensipkd/base/views/departemen.py
View file @
d5048ee
...
@@ -29,7 +29,7 @@ def get_departemen_list():
...
@@ -29,7 +29,7 @@ def get_departemen_list():
@colander.deferred
@colander.deferred
def
departemen_widget
(
node
,
kw
):
def
departemen_widget
(
node
,
kw
):
values
=
kw
.
get
(
'departemen_list'
,
[])
values
=
kw
.
get
(
'departemen_list'
,
[])
return
widget
.
Select2Widget
(
values
=
values
)
return
widget
.
Select2Widget
(
values
=
values
,
placeholder
=
"Pilih Departemen"
)
def
departemen_widget_form
():
def
departemen_widget_form
():
...
...
opensipkd/models/users.py
View file @
d5048ee
...
@@ -30,6 +30,7 @@ class GroupPermission(GroupPermissionMixin, Base):
...
@@ -30,6 +30,7 @@ class GroupPermission(GroupPermissionMixin, Base):
pass
pass
class
UserGroup
(
UserGroupMixin
,
Base
,
CommonModel
):
class
UserGroup
(
UserGroupMixin
,
Base
,
CommonModel
):
@classmethod
@classmethod
def
_get_by_user
(
cls
,
user
):
def
_get_by_user
(
cls
,
user
):
...
@@ -204,6 +205,7 @@ class Permission(Base, CommonModel):
...
@@ -204,6 +205,7 @@ class Permission(Base, CommonModel):
class
Group
(
GroupMixin
,
Base
,
DefaultModel
):
class
Group
(
GroupMixin
,
Base
,
DefaultModel
):
member_count
=
Column
(
Integer
,
nullable
=
True
,
default
=
0
)
@classmethod
@classmethod
def
query_group_name
(
cls
,
group_name
):
def
query_group_name
(
cls
,
group_name
):
return
DBSession
.
query
(
cls
)
.
filter_by
(
group_name
=
group_name
)
return
DBSession
.
query
(
cls
)
.
filter_by
(
group_name
=
group_name
)
...
...
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