Gruppen anlegen ändern löschen
This commit is contained in:
parent
ee18f37b31
commit
315367f203
|
|
@ -25,7 +25,6 @@
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
// FIRST CALL GROUPS, When Groups finished User will call by Groups
|
// FIRST CALL GROUPS, When Groups finished User will call by Groups
|
||||||
createAgencyGroups(groupids[0]);
|
createAgencyGroups(groupids[0]);
|
||||||
|
|
||||||
//DEV
|
//DEV
|
||||||
//addGroupFolder();
|
//addGroupFolder();
|
||||||
//addDirs(dirids[0]);
|
//addDirs(dirids[0]);
|
||||||
|
|
|
||||||
|
|
@ -354,3 +354,4 @@ def NCAddDirs(request):
|
||||||
|
|
||||||
|
|
||||||
return JsonResponse({'status' : False, 'message': 'AUTH ERROR'})
|
return JsonResponse({'status' : False, 'message': 'AUTH ERROR'})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -387,15 +387,15 @@ function updateGroupName(){
|
||||||
},
|
},
|
||||||
success: function( data )
|
success: function( data )
|
||||||
{
|
{
|
||||||
|
if(data['success']){
|
||||||
if(data['success']){
|
//window.location.href = window.location.href + "?showtoast=true";
|
||||||
window.location.href = window.location.href + "?showtoast=true";
|
$("#newGroup").modal("toggle");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$("#newGroup").modal("toggle");
|
$("#newGroup").modal("toggle");
|
||||||
$('#notchange_err').toast('show');
|
$('#notchange_err').toast('show');
|
||||||
$("#toast_errcontent").html("Der Gruppenname ist in der Agentur bereits vorhanden!");
|
$("#toast_errcontent").html("Der Gruppenname ist in der Agentur bereits vorhanden!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -413,9 +413,9 @@ function updateGroupName(){
|
||||||
success: function( data )
|
success: function( data )
|
||||||
{
|
{
|
||||||
if(data['success']){
|
if(data['success']){
|
||||||
$("#newGroup").modal("toggle");
|
$("#newGroup").modal("hide");
|
||||||
$('#notchange_done').toast('show');
|
$('#notchange_done').toast('show');
|
||||||
$("#groupname_" + groupupdate_id).html("Gruppe <b>"+data['data']['newvalue']+" </b>");
|
$("#groupname_" + groupupdate_id).html("Gruppe <b>"+data['data']['newvalue']+" </b>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$('#notchange_err').toast('show');
|
$('#notchange_err').toast('show');
|
||||||
|
|
|
||||||
|
|
@ -547,6 +547,7 @@ Hier werden die Profilinfos des User zurückgesetzt; Parameter kommen von Settin
|
||||||
- Passwort aktualisieren
|
- Passwort aktualisieren
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
import requests
|
||||||
@login_required
|
@login_required
|
||||||
def SettingsProfilManagement(request, context):
|
def SettingsProfilManagement(request, context):
|
||||||
# Check, which form
|
# Check, which form
|
||||||
|
|
@ -590,6 +591,10 @@ def SettingsProfilManagement(request, context):
|
||||||
context['passwordform'] = passwordform
|
context['passwordform'] = passwordform
|
||||||
return render(request, 'dasettings/settings.html', context)
|
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
|
@login_required
|
||||||
def SettingsAjaxRouter(request):
|
def SettingsAjaxRouter(request):
|
||||||
success = False
|
success = False
|
||||||
|
|
@ -645,7 +650,7 @@ def SettingsAjaxRouter(request):
|
||||||
tempjob = AgencyJob.objects.get(pk=job_id, agency=request.user.profile.agency)
|
tempjob = AgencyJob.objects.get(pk=job_id, agency=request.user.profile.agency)
|
||||||
data = {"funcname" : tempjob.name}
|
data = {"funcname" : tempjob.name}
|
||||||
success = True
|
success = True
|
||||||
# DELETE FINAL AGECY JOB
|
# DELETE FINAL AGENCY JOB
|
||||||
elif request.method == 'GET' and request.GET['action'] == "delete_agencyfunc" :
|
elif request.method == 'GET' and request.GET['action'] == "delete_agencyfunc" :
|
||||||
job_id = request.GET['id']
|
job_id = request.GET['id']
|
||||||
tempjob = AgencyJob.objects.get(pk=job_id, agency=request.user.profile.agency)
|
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.agencygroupname = request.GET['newvalue']
|
||||||
group.save()
|
group.save()
|
||||||
data = {"newvalue" : group.agencygroupname}
|
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
|
success = True
|
||||||
else:
|
else:
|
||||||
success = False
|
success = False
|
||||||
|
|
@ -671,21 +689,66 @@ def SettingsAjaxRouter(request):
|
||||||
group = AgencyGroup.objects.get(pk=request.GET['id'], agency=request.user.profile.agency)
|
group = AgencyGroup.objects.get(pk=request.GET['id'], agency=request.user.profile.agency)
|
||||||
data = {"groupname" : group.agencygroupname}
|
data = {"groupname" : group.agencygroupname}
|
||||||
success = True
|
success = True
|
||||||
|
# SAVE NEW GROUP ADD GROUP
|
||||||
elif request.method == 'GET' and request.GET['action'] == "add_group" :
|
elif request.method == 'GET' and request.GET['action'] == "add_group" :
|
||||||
if(checkForGroupName(request, request.GET['newvalue'])):
|
if(checkForGroupName(request, request.GET['newvalue'])):
|
||||||
tempgroup = Group(name=str(request.user.profile.agency.pk) + "_" + randomString(8))
|
tempgroup = Group(name=str(request.user.profile.agency.pk) + "_" + randomString(8))
|
||||||
tempgroup.save()
|
tempgroup.save()
|
||||||
tempgroup_ag = AgencyGroup(savefordel=False, group=tempgroup, agency=request.user.profile.agency, agencygroupname=request.GET['newvalue'])
|
tempgroup_ag = AgencyGroup(savefordel=False, group=tempgroup, agency=request.user.profile.agency, agencygroupname=request.GET['newvalue'])
|
||||||
tempgroup_ag.save()
|
|
||||||
success = True
|
success = True
|
||||||
data = {"group_id" : tempgroup_ag.pk, "group_name" : tempgroup_ag.agencygroupname}
|
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:
|
else:
|
||||||
success = False
|
success = False
|
||||||
|
# DELETE A GROUP
|
||||||
elif request.method == 'GET' and request.GET['action'] == "delete_group" :
|
elif request.method == 'GET' and request.GET['action'] == "delete_group" :
|
||||||
groupag = AgencyGroup.objects.get(pk=request.GET['id'], agency=request.user.profile.agency)
|
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 = groupag.group
|
||||||
group_to_del.delete()
|
group_to_del.delete()
|
||||||
success = True
|
success = True
|
||||||
|
|
||||||
# PERMISSIONS ON GROUP!
|
# PERMISSIONS ON GROUP!
|
||||||
elif request.method == 'GET' and request.GET['action'] == "change_perm_group" :
|
elif request.method == 'GET' and request.GET['action'] == "change_perm_group" :
|
||||||
success = True
|
success = True
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -31,8 +31,8 @@ SESSION_COOKIE_AGE = 100*60*60
|
||||||
#CHANNELS_PRESENCE_MAX_AGE = 30
|
#CHANNELS_PRESENCE_MAX_AGE = 30
|
||||||
|
|
||||||
# FOR SUMMERNOTE ORIGIN
|
# FOR SUMMERNOTE ORIGIN
|
||||||
X_FRAME_OPTIONS = 'SAMEORIGIN'
|
#X_FRAME_OPTIONS = 'SAMEORIGIN'
|
||||||
#X_FRAME_OPTIONS = 'ALLOWALL'
|
X_FRAME_OPTIONS = 'ALLOWALL'
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue