diff --git a/cloud/__pycache__/models.cpython-38.pyc b/cloud/__pycache__/models.cpython-38.pyc index 07c3bcd..e24ec80 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 e61a2b1..99d2da4 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 f179322..c0fadf0 100644 Binary files a/cloud/__pycache__/views.cpython-38.pyc and b/cloud/__pycache__/views.cpython-38.pyc differ diff --git a/cloud/models.py b/cloud/models.py index 668db3c..9ac20c6 100644 --- a/cloud/models.py +++ b/cloud/models.py @@ -1,6 +1,6 @@ from django.db import models from django.contrib.auth.models import User -from users.models import Agency +from users.models import Agency, AgencyGroup # Create your models here. from django.db import models from django.utils import timezone @@ -19,6 +19,36 @@ class Data(models.Model): owner = models.ForeignKey(User, on_delete=models.PROTECT) agency = models.ForeignKey(Agency, on_delete=models.CASCADE, default=None) - def __str__(self): - print(self.file.name) + def __str__(self): return str(self.file.name) + + + +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) + owner = models.ForeignKey(User, on_delete=models.PROTECT, blank=True, null=True) + agency = models.ForeignKey(Agency, on_delete=models.CASCADE) + parent = models.ForeignKey('DataDir', on_delete=models.CASCADE, blank=True, null=True, related_name='dir_in_dir') + + def __str__(self): + return str(self.name) + + +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) + 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') + + def __str__(self): + return str(self.name) + diff --git a/cloud/templates/cloud/cloud_main.html b/cloud/templates/cloud/cloud_main.html index e49f215..3833a89 100644 --- a/cloud/templates/cloud/cloud_main.html +++ b/cloud/templates/cloud/cloud_main.html @@ -2,6 +2,7 @@ {% load crispy_forms_tags %} {% load counter_tag %} {% block content %} +