Commit 7d2550e5 authored by Muhamad's avatar Muhamad

edit group permission

parent 588f190e
from django.http import response
from API.views import jalan
from django.contrib.auth.models import User, Group
from django.contrib.auth.models import User, Group, Permission
from django.shortcuts import render, redirect
# from django.views.generic import ListView, DetailView, DeleteView, UpdateView, CreateView
from django.views import View, generic
......@@ -502,10 +502,14 @@ class Dashboard(generic.TemplateView):
}
res_all.append(data_all)
perm_group = []
if request.user.is_authenticated:
current_user = request.user
thisUser = current_user.id
for xx in request.user.get_group_permissions():
perm_group.append(xx.split(".")[1])
if thisUser == None:
user_data = {"filepath":'placeholder.jpg'}
else:
......@@ -618,6 +622,7 @@ class Dashboard(generic.TemplateView):
'global':all[0],
'res_all':res_all,
'thisUser' : user_data,
'perm_group' : perm_group
# 'user_res':user_res
}
return render (request, self.template_name, context)
......
......@@ -470,10 +470,17 @@ def load_group_edit(request):
}
resgroup.append(datas)
print(datas)
group = Group.objects.get(name=datas['name'])
group_perm = []
for group_p in group.permissions.all():
g = str(group_p).split("| Can ")[1].replace(" ","_")
group_perm.append(g)
data = {
"info" : "success",
"code" : 0,
"data" : datas,
"perm_group":group_perm
}
return Response(data)
......
......@@ -816,6 +816,7 @@ function loadgroupbyid(id) {
isObject.id = id;
$("#idgroup").val(id)
$("input[name='chekbox'][name='chekbox']").attr('checked', false)
$.ajax({
url: "/loadgroup/",
......@@ -831,10 +832,10 @@ function loadgroupbyid(id) {
let response = data;
if (response.code == 0) {
for (i in list_perm) {
console.log()
$("input[name='chekbox'][value=" + list_perm[i] + "]").prop('checked', 'checked')
for (i in data.perm_group) {
$("input[name='chekbox'][value=" + data.perm_group[i] + "]").prop('checked', 'checked')
}
var grup = response.data;
$("#ingroup").val(grup.name);
......
......@@ -1094,14 +1094,6 @@
<div class="tab-pane" id="grouproleuser">
<table class="table table-responsive datatable-show-all table-sm list_group" id="list_group" style="font-size : 8pt;padding:0px;border-top:0.5pt solid #EFEFEF;border-bottom:0.5pt solid #EFEFEF;margin-bottom: 10px;">
<div style="position: absolute;right: 30px;font-size: 10pt;">
<a class="btn side-bar-but" id="download_perbaikan" onclick="download_user_list('xlsx')" style="z-index:9;">
<div>
<i class="icon-download4"></i><span>&nbsp;&nbsp;&nbsp;Download</span>
</div>
</a>
</div>
<div style="position: absolute;left: 292px;font-size: 10pt;background: #2196F3;border-radius: 10px;">
<a class="btn side-bar-but" id="add_group" style="z-index:9;color:white;">
<div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment