Gruppen anlegen ändern löschen
This commit is contained in:
parent
ee18f37b31
commit
315367f203
|
|
@ -25,7 +25,6 @@
|
|||
$(document).ready(function(){
|
||||
// FIRST CALL GROUPS, When Groups finished User will call by Groups
|
||||
createAgencyGroups(groupids[0]);
|
||||
|
||||
//DEV
|
||||
//addGroupFolder();
|
||||
//addDirs(dirids[0]);
|
||||
|
|
|
|||
|
|
@ -354,3 +354,4 @@ def NCAddDirs(request):
|
|||
|
||||
|
||||
return JsonResponse({'status' : False, 'message': 'AUTH ERROR'})
|
||||
|
||||
|
|
|
|||
|
|
@ -387,9 +387,9 @@ function updateGroupName(){
|
|||
},
|
||||
success: function( data )
|
||||
{
|
||||
|
||||
if(data['success']){
|
||||
window.location.href = window.location.href + "?showtoast=true";
|
||||
//window.location.href = window.location.href + "?showtoast=true";
|
||||
$("#newGroup").modal("toggle");
|
||||
}
|
||||
else{
|
||||
$("#newGroup").modal("toggle");
|
||||
|
|
@ -413,7 +413,7 @@ function updateGroupName(){
|
|||
success: function( data )
|
||||
{
|
||||
if(data['success']){
|
||||
$("#newGroup").modal("toggle");
|
||||
$("#newGroup").modal("hide");
|
||||
$('#notchange_done').toast('show');
|
||||
$("#groupname_" + groupupdate_id).html("Gruppe <b>"+data['data']['newvalue']+" </b>");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -547,6 +547,7 @@ Hier werden die Profilinfos des User zurückgesetzt; Parameter kommen von Settin
|
|||
- Passwort aktualisieren
|
||||
|
||||
'''
|
||||
import requests
|
||||
@login_required
|
||||
def SettingsProfilManagement(request, context):
|
||||
# Check, which form
|
||||
|
|
@ -590,6 +591,10 @@ def SettingsProfilManagement(request, context):
|
|||
context['passwordform'] = passwordform
|
||||
return render(request, 'dasettings/settings.html', context)
|
||||
|
||||
def get_random_number(length = 6):
|
||||
result_str = ''.join(random.choice("0123456789") for i in range(length))
|
||||
return result_str
|
||||
|
||||
@login_required
|
||||
def SettingsAjaxRouter(request):
|
||||
success = False
|
||||
|
|
@ -645,7 +650,7 @@ def SettingsAjaxRouter(request):
|
|||
tempjob = AgencyJob.objects.get(pk=job_id, agency=request.user.profile.agency)
|
||||
data = {"funcname" : tempjob.name}
|
||||
success = True
|
||||
# DELETE FINAL AGECY JOB
|
||||
# DELETE FINAL AGENCY JOB
|
||||
elif request.method == 'GET' and request.GET['action'] == "delete_agencyfunc" :
|
||||
job_id = request.GET['id']
|
||||
tempjob = AgencyJob.objects.get(pk=job_id, agency=request.user.profile.agency)
|
||||
|
|
@ -663,6 +668,19 @@ def SettingsAjaxRouter(request):
|
|||
group.agencygroupname = request.GET['newvalue']
|
||||
group.save()
|
||||
data = {"newvalue" : group.agencygroupname}
|
||||
|
||||
# Update Groupname in NC
|
||||
headers = {
|
||||
'Accept' : 'application/json',
|
||||
'Access-Control-Allow-Headers' : 'OCS-APIRequest',
|
||||
'OCS-APIRequest' : 'true'
|
||||
}
|
||||
data_nc = {
|
||||
"groupid" : group.nc_name,
|
||||
"newvalue" : request.GET['newvalue']
|
||||
}
|
||||
r = requests.post(settings.NEXTCLOUD_URL + "/apps/agency/updateagencygroup", data=data_nc, headers=headers, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API))
|
||||
|
||||
success = True
|
||||
else:
|
||||
success = False
|
||||
|
|
@ -671,21 +689,66 @@ def SettingsAjaxRouter(request):
|
|||
group = AgencyGroup.objects.get(pk=request.GET['id'], agency=request.user.profile.agency)
|
||||
data = {"groupname" : group.agencygroupname}
|
||||
success = True
|
||||
# SAVE NEW GROUP ADD GROUP
|
||||
elif request.method == 'GET' and request.GET['action'] == "add_group" :
|
||||
if(checkForGroupName(request, request.GET['newvalue'])):
|
||||
tempgroup = Group(name=str(request.user.profile.agency.pk) + "_" + randomString(8))
|
||||
tempgroup.save()
|
||||
tempgroup_ag = AgencyGroup(savefordel=False, group=tempgroup, agency=request.user.profile.agency, agencygroupname=request.GET['newvalue'])
|
||||
tempgroup_ag.save()
|
||||
|
||||
success = True
|
||||
data = {"group_id" : tempgroup_ag.pk, "group_name" : tempgroup_ag.agencygroupname}
|
||||
nc_groupid = "agencymaingroupid_" + str(tempgroup_ag.agency.pk) + "_subgroup_" + get_random_number()
|
||||
tempgroup_ag.nc_name = nc_groupid
|
||||
tempgroup_ag.save()
|
||||
|
||||
# ADD group in NC
|
||||
headers = {
|
||||
'Accept' : 'application/json',
|
||||
'Access-Control-Allow-Headers' : 'OCS-APIRequest',
|
||||
'OCS-APIRequest' : 'true'
|
||||
}
|
||||
data_nc = {
|
||||
"groupid" : nc_groupid,
|
||||
}
|
||||
r = requests.post(settings.NEXTCLOUD_URL + "ocs/v1.php/cloud/groups", data=data_nc, headers=headers, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API))
|
||||
|
||||
# Group created, set display name in NC
|
||||
data_nc = {
|
||||
"name": tempgroup_ag.agencygroupname,
|
||||
"id" : nc_groupid
|
||||
}
|
||||
|
||||
r = requests.post(settings.NEXTCLOUD_URL + "apps/agency/regr", data=data_nc, headers=headers, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API))
|
||||
|
||||
# Add current User to this Group
|
||||
# TODO: Hier checken, ob das wirklich nötig ist...?
|
||||
#data_nc = {
|
||||
# "groupid" : nc_groupid
|
||||
#}
|
||||
|
||||
#r = requests.post(settings.NEXTCLOUD_URL + "ocs/v1.php/cloud/users/" + request.user.username + "/groups", data=data_nc, headers=headers, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API))
|
||||
|
||||
else:
|
||||
success = False
|
||||
# DELETE A GROUP
|
||||
elif request.method == 'GET' and request.GET['action'] == "delete_group" :
|
||||
groupag = AgencyGroup.objects.get(pk=request.GET['id'], agency=request.user.profile.agency)
|
||||
|
||||
# DELETE GROUP IN NC
|
||||
headers = {
|
||||
'Accept' : 'application/json',
|
||||
'Access-Control-Allow-Headers' : 'OCS-APIRequest',
|
||||
'OCS-APIRequest' : 'true'
|
||||
}
|
||||
data_nc = {
|
||||
"groupid" : groupag.nc_name,
|
||||
}
|
||||
r = requests.request("DELETE", settings.NEXTCLOUD_URL + "/ocs/v1.php/cloud/groups/" + groupag.nc_name,headers=headers, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API))
|
||||
group_to_del = groupag.group
|
||||
group_to_del.delete()
|
||||
success = True
|
||||
|
||||
# PERMISSIONS ON GROUP!
|
||||
elif request.method == 'GET' and request.GET['action'] == "change_perm_group" :
|
||||
success = True
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -31,8 +31,8 @@ SESSION_COOKIE_AGE = 100*60*60
|
|||
#CHANNELS_PRESENCE_MAX_AGE = 30
|
||||
|
||||
# FOR SUMMERNOTE ORIGIN
|
||||
X_FRAME_OPTIONS = 'SAMEORIGIN'
|
||||
#X_FRAME_OPTIONS = 'ALLOWALL'
|
||||
#X_FRAME_OPTIONS = 'SAMEORIGIN'
|
||||
X_FRAME_OPTIONS = 'ALLOWALL'
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
||||
|
|
|
|||
Loading…
Reference in New Issue