From 73aa0750dbd19528765acc3bdacfa61701423f8e Mon Sep 17 00:00:00 2001
From: Stefano Alberto Russo <stefano.russo@gmail.com>
Date: Sun, 10 Apr 2022 17:31:40 +0200
Subject: [PATCH] Implemented the "browsable" storage logic.

---
 services/webapp/code/rosetta/core_app/api.py   |  2 +-
 .../migrations/0033_auto_20220410_1531.py      | 18 ++++++++++++++++++
 .../webapp/code/rosetta/core_app/models.py     |  2 +-
 3 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 services/webapp/code/rosetta/core_app/migrations/0033_auto_20220410_1531.py

diff --git a/services/webapp/code/rosetta/core_app/api.py b/services/webapp/code/rosetta/core_app/api.py
index 898e890..7490d02 100644
--- a/services/webapp/code/rosetta/core_app/api.py
+++ b/services/webapp/code/rosetta/core_app/api.py
@@ -840,7 +840,7 @@ class FileManagerAPI(PrivateGETAPI, PrivatePOSTAPI):
                 data = {'data':[]}
                 
                 # Get storages
-                storages = list(Storage.objects.filter(group=None)) + list(Storage.objects.filter(group__user=request.user))
+                storages = list(Storage.objects.filter(group=None,browsable=True)) + list(Storage.objects.filter(group__user=request.user,browsable=True))
                 
                 # Oder storages (re-orderded in the file manager anyway)
                 storages.sort(key=lambda storage: storage.id)
diff --git a/services/webapp/code/rosetta/core_app/migrations/0033_auto_20220410_1531.py b/services/webapp/code/rosetta/core_app/migrations/0033_auto_20220410_1531.py
new file mode 100644
index 0000000..c1f8ae6
--- /dev/null
+++ b/services/webapp/code/rosetta/core_app/migrations/0033_auto_20220410_1531.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.1 on 2022-04-10 15:31
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('core_app', '0032_auto_20220409_1813'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='storage',
+            name='browsable',
+            field=models.BooleanField(default=True, verbose_name='Browsable in the file manager?'),
+        ),
+    ]
diff --git a/services/webapp/code/rosetta/core_app/models.py b/services/webapp/code/rosetta/core_app/models.py
index 0b7b8c7..76389f1 100644
--- a/services/webapp/code/rosetta/core_app/models.py
+++ b/services/webapp/code/rosetta/core_app/models.py
@@ -394,7 +394,7 @@ class Storage(models.Model):
     conf = JSONField(blank=True, null=True)
  
     # Include as browsable in the file manager?
-    browsable = models.BooleanField('Browsable in the file manager?', default=False)
+    browsable = models.BooleanField('Browsable in the file manager?', default=True)
 
  
     class Meta:
-- 
GitLab