diff --git a/cloud/__pycache__/urls.cpython-38.pyc b/cloud/__pycache__/urls.cpython-38.pyc index cb7a74a..e61a2b1 100644 Binary files a/cloud/__pycache__/urls.cpython-38.pyc and b/cloud/__pycache__/urls.cpython-38.pyc differ diff --git a/cloud/__pycache__/views.cpython-38.pyc b/cloud/__pycache__/views.cpython-38.pyc index 948fdfb..f179322 100644 Binary files a/cloud/__pycache__/views.cpython-38.pyc and b/cloud/__pycache__/views.cpython-38.pyc differ diff --git a/cloud/templates/cloud/cloud_main.html b/cloud/templates/cloud/cloud_main.html index ac18deb..e49f215 100644 --- a/cloud/templates/cloud/cloud_main.html +++ b/cloud/templates/cloud/cloud_main.html @@ -1,23 +1,46 @@ {% extends "users/base.html" %} {% load crispy_forms_tags %} +{% load counter_tag %} {% block content %} +
-

Dateien

-
-

- Hier können Sie Dateien und Ordner für ihre Agentur verwalten. -

+

Dateien 

+
+ {% if user|usergperm:"filesmanager" %}
{% csrf_token %} + {{form.media}} {{form|crispy}}
+ Dateien werden immer in das aktuelle Verzeichnis hochgeladen.
-
-

- {% if files %} +{% endif %} +

+ @@ -29,29 +52,114 @@ - {% for dir in dirs_level %} + {% for dir in dirs %} - + + + + {% endfor %} - {% for ele in files %} - - - - - - - + {% for ele in files %} + + + + + + + {% endfor %}
{{dir}}{{dir|splitdirstyle}} + {% if user|usergperm:"filedirmanager" and user|usergperm:"filesviewer" %} + + + {% endif %} +
{{ele.file}}{{ele.owner.first_name}} {{ele.owner.last_name}}{{ele.date_created}}Optionen
{{ele.file|filename}}{{ele.owner.first_name}} {{ele.owner.last_name}}{{ele.date_created}} + {% if user|usergperm:"filesmanager" and user|usergperm:"filesviewer" %} + + + {% endif %} +
- {% else %} - - {% endif %} +

+ + + + + + {% endblock content %} diff --git a/cloud/urls.py b/cloud/urls.py index 424fb0d..e42773c 100644 --- a/cloud/urls.py +++ b/cloud/urls.py @@ -1,6 +1,8 @@ from django.urls import path from .views import CloudMain +from . import views urlpatterns = [ path('/', CloudMain.as_view(template_name="cloud/cloud_main.html"), name='cloud-main'), + path('clajax/', views.adddirbyajax, name="cloud-ajax"), ] diff --git a/cloud/views.py b/cloud/views.py index dd5eab7..ebc8d65 100644 --- a/cloud/views.py +++ b/cloud/views.py @@ -10,80 +10,73 @@ from .forms import CloudAddFileForm from django.conf import settings from django.core.files.storage import default_storage from digitaleagentur.settings import BASE_DIR +from django.http import JsonResponse import os -''' -import os -def list_files(startpath): - for root, dirs, files in os.walk(startpath): - level = root.replace(startpath, '').count(os.sep) - indent = ' ' * 4 * (level) - print('{}{}/'.format(indent, os.path.basename(root))) - subindent = ' ' * 4 * (level + 1) - for f in files: - print('{}{}'.format(subindent, f)) -''' - -def list_files(startpath, deep): - for root, dirs, files in os.walk(startpath): - level = root.replace(startpath, '').count(os.sep) - if(level <= deep+1 and (deep != 0 and(level > 0))): - print(level) - print(os.path.basename(root)) - for f in files: - print(f) - class CloudMain(LoginRequiredMixin, FormView): form_class = CloudAddFileForm - success_url = '/cloud/0' - + success_url = '/cloud/home' def form_valid(self, form): form = CloudAddFileForm(self.request.POST, self.request.FILES['file']) - tempdata = Data(file=self.request.FILES['file'], subdir="", agency=self.request.user.profile.agency, owner=self.request.user) + tempdata = Data(file=self.request.FILES['file'], subdir="/"+self.request.POST.get("subdirinfo")+"/", agency=self.request.user.profile.agency, owner=self.request.user) tempdata.save() return super().form_valid(form) # Change context and return for template-data - def get_context_data(self, **kwargs): + def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) agency_id = self.request.user.profile.agency.pk - if(self.kwargs['level'] == "home"): - print(list_files(os.path.dirname(BASE_DIR+"/media/agencydata/agency_"+str(agency_id)+"/files/"), 0)) - else: - print(list_files(os.path.dirname(BASE_DIR+"/media/agencydata/agency_"+str(agency_id)+"/files/"+self.kwargs['level']),2)) - context.update({'active_link' : 'cloud', 'files': list_files("agencydata/agency_"+str(agency_id)+"/", 2)}) - return context + if self.request.is_ajax() == False: + agencyfiles = Data.objects.filter(agency__pk=agency_id) - - -''' -dirs_level = [] - files = "" - subdir = "" - files_correcteddirname = [] - agency_id = self.request.user.profile.agency.pk - if(self.kwargs["level"] == "home"): - files = Data.objects.filter(agency__pk=agency_id, subdir="") - - for f in files: - tempstr = str(f.file) - files_correcteddirname.append(tempstr.split("/")[3]) - - dirs = Data.objects.filter(agency__pk=agency_id).exclude(subdir="") + dirs = [] + files = [] - for d in dirs: - tempstr = str(d.file) - dirs_level.append(tempstr.split("/")[3]) - else: - subdir = self.kwargs["level"] - files = Data.objects.filter(agency__pk=agency_id, file__startswith="agencydata/agency_"+str(agency_id)+"/files/"+subdir) - dirs = Data.objects.filter(agency__pk=agency_id).exclude(subdir="") - for d in dirs: - tempstr = str(d.file) - dirs_level.append(tempstr.split("/")[4]) + dirs = os.listdir(BASE_DIR+"\\media\\agencydata\\agency_"+str(agency_id)+"\\files\\") + if(self.kwargs['level'] != "home"): + dirs = os.listdir(BASE_DIR+"\\media\\agencydata\\agency_"+str(agency_id)+"\\files\\"+self.kwargs['level']) + + # ALLOWED FILETYPES + filecheckarr = [".txt", ".pdf", ".TXT", ".PDF", ".jpg", ".JPG", ".png", ".PNG", ".jpeg", ".JPEG", ".docx", ".odt", ".odf"] + + for d in dirs: + for fa in filecheckarr: + if fa in d: + templevel = self.kwargs["level"].split("\\") + templevel_final = templevel[len(self.kwargs["level"].split("\\"))-1] + if(templevel_final == "home"): + templevel_final = "" + tempsearchname = templevel_final+"/"+d + fileob = list(Data.objects.filter(file__endswith=tempsearchname))[0] + files.append(fileob) + dirs.remove(d) + + if(self.kwargs['level'] != "home"): + i = 0 + for d in dirs: + dirs[i] = self.kwargs["level"] + "\\" + d + i += 1 + + crumplevel = self.kwargs["level"].split("\\") + + context.update({'active_link' : 'cloud', 'files': files, 'dirs' : dirs, 'agencyfiles' : agencyfiles, 'level' : self.kwargs["level"], 'crumplevel' : crumplevel}) + return context + else: + context.update({'active_link' : 'cloud'}) + adddirname = self.request.GET.get("adddirname") + newdirname = self.request.GET.get("newdirname") + + if(adddirname == "home"): + os.mkdir(BASE_DIR+"\\media\\agencydata\\agency_"+str(agency_id)+"\\files\\" + newdirname) + else: + os.mkdir(BASE_DIR+"\\media\\agencydata\\agency_"+str(agency_id)+"\\files\\" + adddirname + "\\" + newdirname) + + return {} - context.update({'active_link' : 'cloud', 'files': files, 'dirs_level' : dirs_level}) -''' \ No newline at end of file + + +def adddirbyajax(request): + return {"success" : success} diff --git a/quicklinks/templates/quicklinks/ql_management.html b/quicklinks/templates/quicklinks/ql_management.html index 8dac933..e23b351 100644 --- a/quicklinks/templates/quicklinks/ql_management.html +++ b/quicklinks/templates/quicklinks/ql_management.html @@ -3,15 +3,12 @@ {% block content %} {% if request.user.profile.agency.module_quicklinks %}
-

Quicklinks

+

Quicklinks 


-

- Quicklinks helfen zur schnellen Verlinkung von oft genutzten Diensten. -

{% if user|usergperm:"modulequicklinks" %} {% endif %} diff --git a/standards/templates/standards/standards_add.html b/standards/templates/standards/standards_add.html index 908c4fa..f1ea737 100644 --- a/standards/templates/standards/standards_add.html +++ b/standards/templates/standards/standards_add.html @@ -1,7 +1,7 @@ {% extends "users/base.html" %} {% load crispy_forms_tags %} {% block content %} -
+

Neuen Standard anlegen


diff --git a/standards/templates/standards/standards_management.html b/standards/templates/standards/standards_management.html index b058c8e..beaa4ff 100644 --- a/standards/templates/standards/standards_management.html +++ b/standards/templates/standards/standards_management.html @@ -3,15 +3,12 @@ {% block content %}
-

Standards

+

Standards 

Sichtbar sind alle veröffentlichten und von {{ user.first_name }} {{ user.last_name}} erstellten Standards.
-

- Standards dokumentieren und erläutern verschiedenen Verfahren, strukturiert nach Bereichen und Aufgaben. -


diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc index 321d86b..071e4fc 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 f4884d3..58a0593 100644 --- a/standards/templatetags/counter_tag.py +++ b/standards/templatetags/counter_tag.py @@ -1,6 +1,7 @@ from django import template from django.contrib.auth.models import Group, User from users.models import AgencyGroup +import os register = template.Library() b = 0 @@ -50,6 +51,16 @@ def usergperm(user, perm): def is_member(id, groupname): usertocheck = User.objects.get(pk=id) return usertocheck.groups.filter(name=groupname).exists() + +# Return a Filename splitted to only see the LAST element! +@register.filter(name="splitdirstyle") +def split_dir_style(dirtosplit): + tempsplit = dirtosplit.split("\\") + return tempsplit[len(tempsplit)-1] + +@register.filter(name="filename") +def filename(value): + return os.path.basename(value.file.name) ''' class Counter: count = 0 diff --git a/users/__pycache__/models.cpython-38.pyc b/users/__pycache__/models.cpython-38.pyc index 623516e..821489b 100644 Binary files a/users/__pycache__/models.cpython-38.pyc and b/users/__pycache__/models.cpython-38.pyc differ diff --git a/users/__pycache__/signals.cpython-38.pyc b/users/__pycache__/signals.cpython-38.pyc index 025e517..3f7f6d7 100644 Binary files a/users/__pycache__/signals.cpython-38.pyc and b/users/__pycache__/signals.cpython-38.pyc differ diff --git a/users/__pycache__/views.cpython-38.pyc b/users/__pycache__/views.cpython-38.pyc index 253c642..1016e41 100644 Binary files a/users/__pycache__/views.cpython-38.pyc and b/users/__pycache__/views.cpython-38.pyc differ diff --git a/users/models.py b/users/models.py index 33a1be3..5d3190d 100644 --- a/users/models.py +++ b/users/models.py @@ -194,12 +194,14 @@ class AgencyGroup(models.Model): permissions = [ ('agencyinfo', 'Agenturinformationen verändern'), - ('usermanager', 'Benutzer bearbeiten'), + ('usermanager', 'Mitarbeiter bearbeiten'), ('groupmanager', 'Gruppen bearbeiten'), - ('areaconfig', 'Bereiche bearbeiten'), - ('activityconfig', 'Tätigkeiten bearbeiten'), + ('structuremanager', 'Struktur bearbeiten'), ('standardmanager', 'Standards bearbeiten und freischalten'), ('modulenews', 'News bearbeiten und veröffentlichen'), ('modulesconfig', 'Module verwalten'), - ('modulequicklinks', 'Quicklinks bearbeiten') + ('modulequicklinks', 'Quicklinks bearbeiten'), + ('filesmanager', 'Dateien bearbeiten'), + ('filedirmanager', 'Ordner bearbeiten'), + ('filesviewer', 'Dateien lesen') ] \ No newline at end of file diff --git a/users/signals.py b/users/signals.py index 5665687..79d8773 100644 --- a/users/signals.py +++ b/users/signals.py @@ -101,6 +101,7 @@ def adjust_group_notifications(instance, action, reverse, model, pk_set, using, @receiver(post_save, sender=News) def save_news(sender, instance, **kwargs): + GLOBALSENDMAILS = True if(kwargs["created"]): usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk) for user in usersofagency: @@ -126,7 +127,7 @@ def save_news(sender, instance, **kwargs): # SIGNALS FOR TASK @receiver(signal=m2m_changed, sender=Tasks.usersfield.through) -def adjust_group_notifications(instance, action, reverse, model, pk_set, using, *args, **kwargs): +def adjust_group_notifications_task(instance, action, reverse, model, pk_set, using, *args, **kwargs): # IF FALSE NO MAILS WILL BE SEND - IN PRODUCTIVITY CHANGE TO TRUE # GLOBALSENDMAILS = True diff --git a/users/templates/users/base.html b/users/templates/users/base.html index 522294c..9d2195c 100644 --- a/users/templates/users/base.html +++ b/users/templates/users/base.html @@ -1,4 +1,5 @@ {% load static %} +{% load counter_tag %} @@ -126,14 +127,14 @@ {% endif %} - {% if request.user.profile.agency.module_files %} + {% if request.user.profile.agency.module_files and request.user|usergperm:"filesviewer" %} {% if active_link == 'cloud' %}