Commit 67918760 authored by RyanHerb's avatar RyanHerb

group* add group edit form

closes #2057
parent acbea875
......@@ -4,6 +4,8 @@ if request.env.http_origin:
response.headers['Access-Control-Allow-Credentials'] = 'true'
response.headers['Access-Control-Max-Age'] = 86400
ACCESS_DENIED = "access denied"
## return group list
def index():
count = db.auth_group.id.count()
......@@ -76,6 +78,31 @@ def add_form():
log.error(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def edit():
if auth.is_admin() or auth.has_permission(PermissionsEnum.admin.value, db.auth_group, request.vars["id"]):
group = db.auth_group[request.vars["id"]]
return dict(message=T('Edit group'), group=group)
return error_message(ACCESS_DENIED)
def edit_form():
error = ""
if request.vars["group_name"] == "" :
error += "group name needed, "
if error=="" :
db.auth_group[request.vars["id"]] = dict(role=request.vars["group_name"],
description=request.vars["info"])
res = {"redirect": "group/index",
"message" : "group '%s' modified" % id}
log.info(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"success" : "false", "message" : error}
log.error(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
## confirm page before group deletion
## need ["id"]
......
{{extend 'db_layout.html'}}
<div>
<h3>{{=message}}</h3>
<form id="data_form" action="DB_ADDRESS/group/edit_form" enctype="multipart/form-data" method="post">
<input type="HIDDEN" id="group_id" name="id" value="{{=request.vars["id"]}}">
<table>
<tbody>
<tr>
<td >
<label for="group_name" id="group_name__label"> Group Name: </label>
</td>
<td >
<input class="string" id="group_name" name="group_name" type="text" value="{{=group.role}}">
</td>
<td >
</td>
</tr>
<tr>
<td>
<label for="group_info" id="group_info__label">Info: </label>
</td>
<td>
<textarea class="text" cols="40" id="group_info" name="info" rows="10">{{=group.description}}</textarea>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td >
<input type="submit" value="Soumettre" class="btn">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</form>
</div>
......@@ -14,6 +14,7 @@
<td> parents </td>
<td class="column5"> </td>
<td class="column5"> </td>
<td class="column5"> </td>
</tr>
</thead>
{{for row in query :}}
......@@ -23,6 +24,7 @@
<td> {{=row.access}} // {{=row.auth_group.description }} </td>
<td> {{=row.parents}} </td>
<td onclick="db.call('group/permission', {'id' :'{{=row.auth_group.id}}'} )" > <i class="icon-key" title="set permissions"></i> </td>
<td onclick="db.call('group/edit', {'id' :'{{=row.auth_group.id}}'} )" > <i class="icon-pencil-2" title="edit group"></i> </td>
<td onclick="db.call('group/confirm', {'id' :'{{=row.auth_group.id}}'} )" > <i class="icon-erase" title="delete group"></i> </td>
</tr>
{{pass}}
......
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