Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OKU-GIS
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhamad
OKU-GIS
Commits
b88eff76
Commit
b88eff76
authored
Jul 12, 2021
by
reynaldi adriantama
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
group management/user management
parent
2f08a104
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
396 additions
and
20 deletions
+396
-20
OKU/urls.py
OKU/urls.py
+3
-1
myauth/views.py
myauth/views.py
+86
-3
static/js/pages/form_select2.js
static/js/pages/form_select2.js
+1
-0
templates/includes/scripts.html
templates/includes/scripts.html
+2
-2
templates/layout/user_layout.html
templates/layout/user_layout.html
+303
-13
templates/user/login.html
templates/user/login.html
+1
-1
No files found.
OKU/urls.py
View file @
b88eff76
...
@@ -32,5 +32,7 @@ urlpatterns = [
...
@@ -32,5 +32,7 @@ urlpatterns = [
path
(
'adduser/'
,
views
.
addUser
,
name
=
"adduser"
),
path
(
'adduser/'
,
views
.
addUser
,
name
=
"adduser"
),
path
(
'getallGroups/'
,
views
.
listGroup
,
name
=
"getallGroups"
),
path
(
'getallGroups/'
,
views
.
listGroup
,
name
=
"getallGroups"
),
path
(
'switchStatus/'
,
views
.
deactivateUser
,
name
=
"switchStatus"
),
path
(
'switchStatus/'
,
views
.
deactivateUser
,
name
=
"switchStatus"
),
path
(
'loadUserbyId/'
,
views
.
loadUserbyId
,
name
=
"loadUserbyId"
)
path
(
'loadUserbyId/'
,
views
.
loadUserbyId
,
name
=
"loadUserbyId"
),
path
(
'addGroup/'
,
views
.
addGroup
,
name
=
"addGroup"
),
path
(
'deleteGroup/'
,
views
.
deleteGroup
,
name
=
"deleteGroup"
)
]
]
myauth/views.py
View file @
b88eff76
...
@@ -52,10 +52,22 @@ class Usermanagement(generic.TemplateView):
...
@@ -52,10 +52,22 @@ class Usermanagement(generic.TemplateView):
}
}
user_res
.
append
(
datas
)
user_res
.
append
(
datas
)
with
conn
.
cursor
()
as
grouplist_
:
grouplist_
.
execute
(
"SELECT * FROM auth_group ORDER BY name ASC"
)
allGroup
=
grouplist_
.
fetchall
()
group_res
=
[]
for
rows
in
allGroup
:
datas
=
{
"id"
:
rows
[
0
],
"name"
:
rows
[
1
],
}
group_res
.
append
(
datas
)
context
=
{
context
=
{
'title'
:
'user management'
,
'title'
:
'user management'
,
'data'
:
user_res
'data'
:
user_res
,
'dataGroup'
:
group_res
}
}
print
(
context
)
print
(
context
)
...
@@ -130,7 +142,7 @@ def addUser(request):
...
@@ -130,7 +142,7 @@ def addUser(request):
@
api_view
((
'POST'
,))
@
api_view
((
'POST'
,))
def
listGroup
(
request
):
def
listGroup
(
request
):
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
groupList
=
Group
.
objects
.
all
()
groupList
=
Group
.
objects
.
all
()
.
order_by
(
'name'
)
group
=
[]
group
=
[]
for
g
in
groupList
:
for
g
in
groupList
:
...
@@ -247,3 +259,74 @@ def loadGroupById(iduser):
...
@@ -247,3 +259,74 @@ def loadGroupById(iduser):
print
(
resGroup
)
print
(
resGroup
)
return
resGroup
return
resGroup
@
api_view
((
'POST'
,))
def
addGroup
(
request
):
if
request
.
method
==
"POST"
:
name
=
request
.
POST
.
get
(
'name'
)
idgroup
=
request
.
POST
.
get
(
'id'
)
try
:
if
idgroup
:
with
conn
.
cursor
()
as
cursor
:
cursor
.
execute
(
"UPDATE auth_group SET name = '"
+
name
+
"' WHERE id="
+
idgroup
)
result
=
cursor
.
rowcount
print
(
result
)
data
=
{
"code"
:
0
,
"data"
:
"Group telah diperbaharui."
,
"info"
:
"success"
}
else
:
group
=
Group
.
objects
.
get
(
name
=
name
)
data
=
{
"code"
:
4
,
"data"
:
"Group telah tersedia."
,
"info"
:
"failed"
}
except
Group
.
DoesNotExist
:
Group
.
objects
.
create
(
name
=
name
)
if
Group
.
objects
.
get
(
name
=
name
):
data
=
{
"code"
:
0
,
"info"
:
"success"
,
"data"
:
"Group berhasil ditambahkan"
}
else
:
data
=
{
"code"
:
4
,
"info"
:
"failed"
,
"data"
:
"Group gagal ditambahkan"
}
return
Response
(
data
)
@
api_view
((
'POST'
,))
def
deleteGroup
(
request
):
if
request
.
method
==
"POST"
:
id
=
request
.
POST
.
get
(
'id'
)
with
conn
.
cursor
()
as
cursor
:
cursor
.
execute
(
"DELETE FROM auth_group WHERE id="
+
id
)
result
=
cursor
.
rowcount
if
result
>
0
:
data
=
{
"code"
:
0
,
"info"
:
"success"
,
"data"
:
"data berhasil dihapus"
}
else
:
data
=
{
"code"
:
4
,
"info"
:
"success"
,
"data"
:
"data berhasil dihapus"
}
return
Response
(
data
)
\ No newline at end of file
static/js/pages/form_select2.js
View file @
b88eff76
...
@@ -93,6 +93,7 @@ $(function() {
...
@@ -93,6 +93,7 @@ $(function() {
// Mini
// Mini
$
(
'
.select-size-xs
'
).
select2
({
$
(
'
.select-size-xs
'
).
select2
({
maximumSelectionLength
:
5
,
containerCssClass
:
'
select-xs
'
containerCssClass
:
'
select-xs
'
});
});
...
...
templates/includes/scripts.html
View file @
b88eff76
...
@@ -37,6 +37,6 @@
...
@@ -37,6 +37,6 @@
Notific{% static 'Plugin -->
Notific{% static 'Plugin -->
<script
src=
"{% static '/js/plugins/bootstrap-notify.js' %}"
></script>
<script
src=
"{% static '/js/plugins/bootstrap-notify.js' %}"
></script>
<!-- Control {% static 'for Material Dashboard: parallax effects, scripts for the example pages etc -->
<!-- Control {% static 'for Material Dashboard: parallax effects, scripts for the example pages etc -->
<
script
src=
"{% static '/js/material-dashboard.js' %}"
type=
"text/javascript"
></script
>
<
!-- <script src="{% static '/js/material-dashboard.js' %}" type="text/javascript"></script> --
>
<!-- Material{% static 'ard DEMO methods, don't include it in your project! -->
<!-- Material{% static 'ard DEMO methods, don't include it in your project! -->
<script
src=
"{% static '/demo/demo.js' %}"
></script>
<!-- <script src="{% static '/demo/demo.js' %}"></script> -->
\ No newline at end of file
\ No newline at end of file
templates/layout/user_layout.html
View file @
b88eff76
This diff is collapsed.
Click to expand it.
templates/user/login.html
View file @
b88eff76
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
<div>
<div>
{% if form.errors %}
{% if form.errors %}
<div
class=
"alert alert-danger"
>
<div
class=
"alert alert-danger"
>
Username atau Password
kamu
salah. Silahkan coba kembali.
Username atau Password salah. Silahkan coba kembali.
</div>
</div>
{% endif %}
{% endif %}
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment