diff --git a/dasettings/templates/dasettings/groups_content.html b/dasettings/templates/dasettings/groups_content.html
index cd24382..2b69b6c 100644
--- a/dasettings/templates/dasettings/groups_content.html
+++ b/dasettings/templates/dasettings/groups_content.html
@@ -102,9 +102,9 @@
{% endif %}
{% endfor %}
{% endfor %}
-
+
-
+
@@ -124,6 +124,7 @@
+
{% for aggroup in agencygroups %}
{% for p in aggroup.group.permissions.all %}
diff --git a/dasettings/templates/dasettings/moduls_content.html b/dasettings/templates/dasettings/moduls_content.html
index ecc9803..91df90a 100644
--- a/dasettings/templates/dasettings/moduls_content.html
+++ b/dasettings/templates/dasettings/moduls_content.html
@@ -1,6 +1,5 @@
{% load crispy_forms_tags %}
-
-
+
@@ -13,26 +12,27 @@
{% csrf_token %}
-{% for formfield in modulform %}
+ {% for formfield in modulform %}
{% if formfield.name == 'module_organigramm' or formfield.name == 'module_timemanagement' %}
-
- {{formfield.label_tag}}
-
- {% if formfield.name == 'module_organigramm' and user.profile.agency.module_organigramm %}
-
- {% elif formfield.name == 'module_timemanagement' and user.profile.agency.module_timemanagement %}
-
- {% endif %}
-
-
+
+ {{formfield.label_tag}}
+
+ {% if formfield.name == 'module_organigramm' and user.profile.agency.module_organigramm %}
+
+ {% elif formfield.name == 'module_timemanagement' and user.profile.agency.module_timemanagement %}
+
+ {% endif %}
+
+
{% endif %}
-{% endfor %}
+ {% endfor %}
+
-
-
+
{% for formfield in modulform %}
+
-
{% endfor %}
+
diff --git a/dasettings/templates/dasettings/moduls_content_SAVE.html b/dasettings/templates/dasettings/moduls_content_SAVE.html
index e016555..ca72b21 100644
--- a/dasettings/templates/dasettings/moduls_content_SAVE.html
+++ b/dasettings/templates/dasettings/moduls_content_SAVE.html
@@ -1,10 +1,10 @@
{% load crispy_forms_tags %}
-
+
+
Modul
- Aktiviert
Einstellungen
@@ -13,23 +13,24 @@
{% csrf_token %}
-{% for formfield in modulform %}
-
- {{formfield.label_tag}}
- {{formfield}}
-
- {% if formfield.name == 'module_organigramm' and user.profile.agency.module_organigramm %}
-
- {% elif formfield.name == 'module_timemanagement' and user.profile.agency.module_timemanagement %}
-
- {% endif %}
-
-
-{% endfor %}
+ {% for formfield in modulform %}
+ {% if formfield.name == 'module_organigramm' or formfield.name == 'module_timemanagement' %}
+
+ {{formfield.label_tag}}
+
+ {% if formfield.name == 'module_organigramm' and user.profile.agency.module_organigramm %}
+
+ {% elif formfield.name == 'module_timemanagement' and user.profile.agency.module_timemanagement %}
+
+ {% endif %}
+
+
+ {% endif %}
+ {% endfor %}
+
-
Moduleinstellungen aktualisieren
-
+
{% for formfield in modulform %}
@@ -79,4 +80,6 @@
+
+
{% endfor %}
diff --git a/dasettings/templates/dasettings/notifications_content.html b/dasettings/templates/dasettings/notifications_content.html
index 27542cb..dac3694 100644
--- a/dasettings/templates/dasettings/notifications_content.html
+++ b/dasettings/templates/dasettings/notifications_content.html
@@ -393,13 +393,13 @@
type: "GET",
url: "/dasettings/ajax",
data:{
- action : "update_notifications",
+ //action : "update_notifications",
+ action : "",
fieldname : ele,
new_stat : new_stat
},
success: function( data )
{
- console.log(data);
if(data['success']){
$('#notchange_done').toast('show');
}
diff --git a/dasettings/templates/dasettings/quota_content.html b/dasettings/templates/dasettings/quota_content.html
new file mode 100644
index 0000000..d006350
--- /dev/null
+++ b/dasettings/templates/dasettings/quota_content.html
@@ -0,0 +1,106 @@
+{% load counter_tag %}
+{% getAGGroupQuotaData request as agquota %}
+
+
+
+
+ {{agquota.1|filesizeformat}} / {{agquota.0|filesizeformat}}
+
+Sie können mehr Speicherplatz für die Agentur dazubuchen und anschließend jedem Mitarbeiter ein bestimmtes Speicherkontingent zuweisen. Der Speicherplatz wird dann vom Agenturspeicher abgezogen.
+
+
+
+
+ Vorname
+ Nachname
+ Speicherplatz
+ Kontingent in MB
+
+
+
+{% for item in usersofagency %}
+
+ {{item.first_name }}
+ {{ item.last_name }}
+
+ {% getUserQuotaData item as userquotadata %}
+
+
+
+ {{userquotadata.0|filesizeformat }} (davon {{userquotadata.1|filesizeformat }})
+
+
+
+ {% if request.user.profile.agency.agencypackage > 0 %}
+
+ {% endif %}
+
+
+ {% endfor %}
+
+
+
+
+
+ Speicherplatzverteilung speichern
+
+
+
+
diff --git a/dasettings/templates/dasettings/settings.html b/dasettings/templates/dasettings/settings.html
index 30852d9..ad65648 100644
--- a/dasettings/templates/dasettings/settings.html
+++ b/dasettings/templates/dasettings/settings.html
@@ -55,6 +55,11 @@
Abrechnung
{% endif %}
+ {% if user|usergperm:"agencyinfo" %}
+
+ Speicherplatz
+
+ {% endif %}
{% if user|usergperm:"agencynetwork" %}
Agenturverbund
@@ -77,7 +82,7 @@
{% endif %}
{% if user|usergperm:"modulesconfig" %}
- Module
+ Module
{% endif %}
@@ -93,6 +98,16 @@
endblock
-->
+
+ {% if user|usergperm:"modulesconfig" %}
+
+
Module{% if request.user.profile.showtooltips %} {% endif %}
+ {% block moduls_content %}
+ {% include "dasettings/moduls_content.html" %}
+ {% endblock %}
+
+ {% endif %}
+
Benachrichtigungen{% if request.user.profile.showtooltips %} {% endif %}
@@ -120,6 +135,15 @@
{% endblock %}
{% endif %}
+ {% if user|usergperm:"agencyinfo" %}
+
+
Speicherplatz{% if request.user.profile.showtooltips %} {% endif %}
+
+ {% block quota_content %}
+ {% include "dasettings/quota_content.html" %}
+ {% endblock %}
+
+ {% endif %}
{% if user|usergperm:"agencynetwork" %}
Agenturverbünde{% if request.user.profile.showtooltips %} {% endif %}
@@ -163,14 +187,6 @@
{% include "dasettings/groups_content.html" %}
{% endblock %}
- {% endif %}
- {% if user|usergperm:"modulesconfig" %}
-
-
Module{% if request.user.profile.showtooltips %} {% endif %}
- {% block moduls_content %}
- {% include "dasettings/moduls_content.html" %}
- {% endblock %}
-
{% endif %}
@@ -179,6 +195,7 @@
var defaultsettingsview = "notifications";
/* COOKIE FOR SAVING OPEN TAB */
$(document).ready(function(){
+ $(".toast").hide();
$(".toast").toast({
autohide: true,
diff --git a/dasettings/views.py b/dasettings/views.py
index 8987cb2..8b4924b 100644
--- a/dasettings/views.py
+++ b/dasettings/views.py
@@ -624,6 +624,75 @@ def SettingsAjaxRouter(request):
setattr(request.user.usernotifications, request.GET['fieldname'], False)
request.user.usernotifications.save()
success = True
+
+
+
+
+
+ # QUOTA
+ elif request.method == 'GET' and request.GET['action'] == "quotaag_update" :
+ success = False
+ quotavalues = request.GET['quotavalues']
+
+ quotavalues_array = quotavalues.split("_SEPERATOR_")
+
+ newsumquota = 0
+
+ for newquotavalue in quotavalues_array:
+ ele = newquotavalue.split("__")
+
+ if("user" in ele[0]):
+ newsumquota += int(ele[1])
+
+ # CONVERTING MAX MB TO BYTES
+ newsumquota = newsumquota*1024
+ newsumquota = newsumquota*1024
+
+ # GETTING POSSIBLE BYTES FROM AGENCY
+ r = requests.request("PROPFIND", settings.NEXTCLOUD_URL + "remote.php/dav/files/" + request.user.username + "/Agenturdaten", headers={'Content-Type' : 'text/xml', 'Authorization' : "Bearer " + request.user.profile.nc_sid})
+
+ split_response = r.text.split("")
+ inuse = split_response[1].split(" ")[0]
+
+ # QUOTA
+ split_response = r.text.split("")
+ quota = split_response[1].split(" ")[0]
+
+ # TODO: Hier wird ja jedesmal die Agenturquota reduziert, dass ist natürlich doof!
+
+ # Check if needed Quota is bigger than inuse
+ newagencyquota = int(quota) - int(newsumquota)
+ if( newagencyquota > int(inuse) ):
+ for newquotavalue in quotavalues_array:
+ ele = newquotavalue.split("__")
+ if("user" in ele[0]):
+ userid = ele[0].split("_")[1]
+ userquota = int(ele[1])*1024
+ userquota = userquota*1024
+ headers = {
+ 'Accept' : 'application/json',
+ 'Access-Control-Allow-Headers' : 'OCS-APIRequest',
+ 'OCS-APIRequest' : 'true'
+ }
+ data_nc = {
+ "key" : "quota",
+ "value" : userquota
+ }
+ r = requests.put(settings.NEXTCLOUD_URL + "/ocs/v1.php/cloud/users/" + User.objects.get(pk=userid).username,headers=headers, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API), data=data_nc)
+
+ # Updating the AgencyQuota
+ data = {
+ "quota" : newagencyquota,
+ "user" : request.user.username
+ }
+
+ r = requests.post(settings.NEXTCLOUD_URL + "ocs/v2.php/apps/da_agency/api/v1/updategfquota?format=json", auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API), data=data)
+
+ ag = request.user.profile.agency
+ ag.agencyquota = newagencyquota
+ ag.save()
+ success = True
+
# UPDATE TOOLTUP
elif request.method == 'GET' and request.GET['action'] == "change_showtooltips" :
newtooltipvalue = False
diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc
index c62ecaf..252a0f6 100644
Binary files a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc and b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc differ
diff --git a/standards/templatetags/counter_tag.py b/standards/templatetags/counter_tag.py
index 54ddcda..bb7ac13 100644
--- a/standards/templatetags/counter_tag.py
+++ b/standards/templatetags/counter_tag.py
@@ -1177,3 +1177,42 @@ def getNCDirInfosURL(request, ncid):
return ""
+# QUOTA
+@register.simple_tag
+def getAGGroupQuotaData(request):
+ r = requests.request("PROPFIND", settings.NEXTCLOUD_URL + "remote.php/dav/files/" + request.user.username + "/Agenturdaten", headers={'Content-Type' : 'text/xml', 'Authorization' : "Bearer " + request.user.profile.nc_sid})
+
+ # IN USE
+ split_response = r.text.split("")
+ inuse = split_response[1].split(" ")[0]
+
+ # QUOTA
+ split_response = r.text.split("")
+ quota = split_response[1].split(" ")[0]
+
+ # PERCENT VALUE
+ percent = (100 / int(quota))*int(inuse)
+
+ return [quota, inuse, str(round(percent, 0)).replace(",", ".")]
+
+# User QUOTA
+import re, math
+@register.simple_tag
+def getUserQuotaData(userdata):
+ r = requests.request("GET", settings.NEXTCLOUD_URL + "/ocs/v1.php/cloud/users/" + userdata.username, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API), headers={'Content-Type' : 'text/xml', 'OCS-APIRequest': "true"})
+
+ quotadata = [int(s) for s in re.findall('(.+?) ', r.text)]
+ inuse = [int(s) for s in re.findall('(.+?) ', r.text)]
+
+ i = int(math.floor(math.log(quotadata[0], 1024)))
+ p = math.pow(1024, i)
+ # s for textlabel
+ s = round(quotadata[0] / p, 2)
+
+ # PERCENT
+ percent = (100 / int(quotadata[0]))*int(inuse[0])
+
+ # TODO: Hier werden GB nicht korrekt umgerechnet in MB
+
+ return [quotadata[0], inuse[0], str(round(percent, 0)).replace(",", "."), str(s).split(".")[0]]
+
diff --git a/users/models.py b/users/models.py
index 5ee1d66..d608394 100644
--- a/users/models.py
+++ b/users/models.py
@@ -145,6 +145,11 @@ class Agency(models.Model):
# RECOVERDIR
module_recoverdir = models.BooleanField(default=False)
+ # QUOTA
+ agencyquota = models.BigIntegerField(default=2146274449)
+ agencypackage = models.IntegerField(default=0)
+
+
def __str__(self):
return f'{self.name}'
@@ -260,6 +265,8 @@ class Profile(models.Model):
user_messages_mail = models.BooleanField(default=True)
user_messages_push = models.BooleanField(default=True)
+ userquota = models.BigIntegerField(default=104857600)
+
# ONLINESTATUS
'''