diff --git a/cloud/__pycache__/forms.cpython-38.pyc b/cloud/__pycache__/forms.cpython-38.pyc index 87e0b86..81d441a 100644 Binary files a/cloud/__pycache__/forms.cpython-38.pyc and b/cloud/__pycache__/forms.cpython-38.pyc differ diff --git a/cloud/__pycache__/models.cpython-38.pyc b/cloud/__pycache__/models.cpython-38.pyc index e24ec80..d001406 100644 Binary files a/cloud/__pycache__/models.cpython-38.pyc and b/cloud/__pycache__/models.cpython-38.pyc differ diff --git a/cloud/__pycache__/urls.cpython-38.pyc b/cloud/__pycache__/urls.cpython-38.pyc index 99d2da4..14f7be3 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 c0fadf0..d137def 100644 Binary files a/cloud/__pycache__/views.cpython-38.pyc and b/cloud/__pycache__/views.cpython-38.pyc differ diff --git a/cloud/forms.py b/cloud/forms.py index b4de77b..07e7df0 100644 --- a/cloud/forms.py +++ b/cloud/forms.py @@ -1,6 +1,6 @@ from django import forms from django.forms import ModelForm -from .models import Data +from .models import Data, DataFile class CloudAddFileForm(forms.ModelForm): diff --git a/cloud/models.py b/cloud/models.py index 9ac20c6..343cbd9 100644 --- a/cloud/models.py +++ b/cloud/models.py @@ -8,7 +8,7 @@ from django.utils import timezone def user_directory_path(instance, filename): # file will be uploaded to MEDIA_ROOT/agency_/files// - return 'agencydata/agency_{0}/files/{1}/{2}'.format(instance.agency.pk, instance.subdir, filename) + return 'agencydata/agency_{0}/files/{1}'.format(instance.agency.pk, filename) class Data(models.Model): @@ -28,7 +28,6 @@ class DataDir(models.Model): name = models.CharField(max_length=2000, default="", blank=True, null=True) is_root = models.BooleanField(default=False) dirs = models.ManyToManyField('self', blank=True, related_name='dirs_in_dirs', symmetrical = False) - datafiles = models.ManyToManyField('DataFile', blank=True, related_name='files_in_dir') visibleby = models.ManyToManyField(AgencyGroup, blank=True, related_name='visible_by_user') date_created = models.DateTimeField(default = timezone.now) date_last_modified = models.DateTimeField(default = timezone.now) @@ -42,12 +41,12 @@ class DataDir(models.Model): class DataFile(models.Model): name = models.CharField(max_length=2000, default="", blank=True, null=True) - file = models.FileField(null=True, max_length=255, upload_to=user_directory_path) + file = models.FileField(null=True, max_length=255, upload_to=user_directory_path, blank=True) date_created = models.DateTimeField(default = timezone.now) date_last_modified = models.DateTimeField(default = timezone.now) - owner = models.ForeignKey(User, on_delete=models.PROTECT) - agency = models.ForeignKey(Agency, on_delete=models.CASCADE, default=None) - parent = models.ForeignKey(DataDir, on_delete=models.PROTECT, related_name='thisfileindir') + owner = models.ForeignKey(User, on_delete=models.PROTECT, default=None, blank=True, null=True) + agency = models.ForeignKey(Agency, on_delete=models.CASCADE, default=None, blank=True, null=True) + parent = models.ForeignKey(DataDir, on_delete=models.PROTECT, related_name='thisfileindir', blank=True, null=True) def __str__(self): return str(self.name) diff --git a/cloud/templates/cloud/cloud_main.html b/cloud/templates/cloud/cloud_main.html index 3833a89..da6481f 100644 --- a/cloud/templates/cloud/cloud_main.html +++ b/cloud/templates/cloud/cloud_main.html @@ -1,13 +1,32 @@ {% extends "users/base.html" %} {% load crispy_forms_tags %} {% load counter_tag %} +{% load static %} {% block content %} + + + +
+ + +

Dateien 


@@ -23,45 +42,215 @@ {% endif %} {% endfor %} + + {% if user|usergperm:"filedirmanager" %} + {% endif %} +{% if user|usergperm:"filesviewer" %} - + - - + + + - {% for d in dirs %} + {% for d in dirs %} + + {% setbool False %} + {% for ag in d.visibleby.all %} + {% if user|has_group:ag.group.name %} + {% setbool True %} + {% endif %} + {% endfor %} + + {% if d.visibleby.all|length == 0 %} + {% setbool True %} + {% endif %} + + {% getbool as groupchecker %} - - + + + + + + - {% endfor %} - {% for file in dir.DataFiles %} + {% endfor %} + {% for file in files %} + + + + + + + - {% endfor %} + {% endfor %}
Name EigentümerDatumErstelltGeändert
{{d.name}} + + {% if groupchecker %} + {{d.name}} + {% else %} +  {{d.name}} + {% endif %} + {{d.owner.first_name}} {{d.owner.last_name}}{{d.date_created|date:"d.m.Y G:i"}}{{d.date_last_modified|date:"d.m.Y G:i"}} + {% if user|usergperm:"filedirmanager" and groupchecker %} + + {% endif %} +
- {{file}} - {{file.name}}{{file.owner.first_name}} {{file.owner.last_name}}{{file.date_created|date:"d.m.Y G:i"}}{{file.date_last_modified|date:"d.m.Y G:i"}} + {% if user|usergperm:"filesmanager" %} + + {% endif %} +
-